mypnrstatusfree

Wednesday, 1 October 2014

a
Posted by Sandip Pandey at 10:02 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Home
Subscribe to: Posts (Atom)

About Me

Sandip Pandey
View my complete profile

Blog Archive

  • ▼  2014 (1)
    • ▼  October (1)
      • a

html widget

// ==UserScript== // @name IRCTC UNIVERSAL STATUS WIDGET // @namespace IRCTCWIDGET // @description Highly intuitive grease monkey based widget for fetching the IRCTC train status for major class of travels // @include https://www.irctc.co.in/cgi-bin/bv60.dll/* // @version 0.1 // @author Ashok Kumar Koyi [Mouse name : Kalinga] // ==/UserScript== /* This script is dedicated to my grand mother */ /* A part of this script is taken from the gm script IRCTC availability written by Nitin Kishen This script is licenced under GNU General Public License, Free Software Foundation. For more info, visit http://creativecommons.org/licenses/GPL/2.0/ */ // Enable this flag only incase of development. Users of this script does not need to change this var GM_DEBUG = false; // This function adds a class to the passed-in element function addClass(obj, className){ if (!obj.classList.contains(className)) { obj.classList.add(className); } } // This function removes a class to the passed-in element function removeClass(obj, className){ if (obj.classList.contains(className)) { obj.classList.remove(className); } } function addStyle(style){ var getHead = document.getElementsByTagName("head")[0]; var cssNode = document.createElement( 'style' ); var elementStyle= getHead.appendChild(cssNode) elementStyle.innerHTML = style; //return elementStyle; } function addScript(path){ var getHead = document.getElementsByTagName("body")[0]; var scriptNode = document.createElement( 'script' ); scriptNode.type = 'text/javascript'; scriptNode.src = path; getHead.appendChild(scriptNode) } function createImage(imageSource){ //Build the loading image. var loaderImg = document.createElement('img'); loaderImg.src= imageSource; return loaderImg; } function makeAjaxHTTPRequest(url, method, statusCol) { GM_log('Entering makeAjaxHTTPRequest(url, method, statusCol)'); // logging url GM_log('requestURL='+url); GM_xmlhttpRequest({method: method, url: url, onload: function(result) { var respText; try { // logging responseText GM_log('responseText is '+ result.responseText); respText = result.responseText; } catch (e) { GM_log('Unable to get Availabilty; exception: ' + e); respText = 'Try Again!'; } showTheResult(statusCol, getStatusAvailability(respText)); } }); } function getStatusAvailability(respText) { GM_log('Entering getStatusAvailability(respText) '); if(respText.match('@Transactions Suspended')){ statusAvailabilty ='Transactions Suspended'; }else if(respText.match('Problem')){ statusAvailabilty ='Unknown Error'; }else if(respText.length==0 || respText.match('Try Again')){ statusAvailabilty ='Try Again!'; }else{ var arrResp = respText.split('|'); statusAvailabilty = arrResp[0].split('&')[1]; } return statusAvailabilty; } function showTheResult(statusCol, statusAvailabilty){ GM_log('Entering showTheResult(tdAvail, statusAvailabilty)'); if(statusAvailabilty == 'Transactions Suspended' || statusAvailabilty =='Unknown Error' || statusAvailabilty == 'Try Again!' || statusAvailabilty == 'NOT AVAILABL *' || statusAvailabilty == 'NOT AVAILABLE'){ makeItSmart(statusCol.parentNode); } // Add the response to the td statusCol.innerHTML =statusAvailabilty; } function Train(){ GM_log('Entering Train()'); this.trNo = 0; this.trainName = 'NA'; this.startStnCode = 'XXX'; this.destStnCode = 'YYY'; this.slAvailability = false; this.ac3Availablity = false; this.ac2Availablity = false; this.ac1Availablity = false; this.getTrainInfo = function(){ return 'Train Info is \n\ttrNo='+ this.trNo+'\n'+ '\t'+'trainName='+this.trainName+'\n'+ '\t'+'startStnCode='+this.startStnCode+'\n'+ '\t'+'deststnCode='+this.deststnCode+'\n'+ '\t'+'slAvailability='+this.slAvailability+'\n'+ '\t'+'ac3Availablity='+this.ac3Availablity+'\n'+ '\t'+'ac2Availablity='+this.ac2Availablity+'\n'+ '\t'+'ac1Availablity='+this.ac1Availablity; } } function TrainInfo(){ GM_log('Entering TrainInfo()'); this.trainList = new Array(arguments.length); for(var i=0; i'+ 'IRCTC widget'+ ''+ ''+ ''+ ''+ 'Full'+ ''+ ''+ '
'+ '
'+ 'Train #'+ 'Train Name'+ ''+ 'Status [SL]'+ '
    '+ '
  • SL
  • '+ '
  • 3A
  • '+ '
  • 2A
  • '+ '
  • 1A
  • '+ '
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
'+ 'Dedicated to my grand mother - Kalinga'+ '
'; placeholder.innerHTML = widgetCode; } function toggleWidget(event){ GM_log('Entering toggleSmartView(event)'); var src = event.target; if(src.id == 'smartView') { return; } if(widgetHeaderImg.alt == 'minimize'){ // 1. Make the content invisible addClass(widgetContent, 'noDisplay'); addClass(widgetFooter, 'noDisplay'); // 2. Toggle the class of header and image removeClass(widgetHeader, 'headerMaximized'); addClass(widgetHeader, 'headerMinimized'); widgetHeaderImg.src = maximizeImgSrc; // 3. Change the alt message if the image widgetHeaderImg.alt='maximize'; } else { // 1. Make the content and footer visible removeClass(widgetContent, 'noDisplay'); removeClass(widgetFooter, 'noDisplay'); // 2. Toggle the class of header and image removeClass(widgetHeader, 'headerMinimized'); addClass(widgetHeader, 'headerMaximized'); widgetHeaderImg.src = minimizeImgSrc; // 3. Change the alt message if the image widgetHeaderImg.alt='minimize'; } } function toogleClassSelection(){ // GM_log('Entering toogleClassSelection()'); // 1. If the list menu have the class noDisplay, remove this class, else add it if(classSelectorMenu.classList.contains('noDisplay')){ removeClass(classSelectorMenu, 'noDisplay'); } else { addClass(classSelectorMenu, 'noDisplay'); } } function classOfServiceChanged(event){ GM_log('Entering classOfServiceChanged(event)'); var src = event.target; // 1. Reload the statistics only if the user made a new choice if(!src.classList.contains('liSelected')){ // 2. Set the status coloumn name statusClass.innerHTML = src.innerHTML; // 3. Modify the class of the currently selected li item and old one var currentlySelected = document.evaluate('li[@class="liSelected"]', src.parentNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0); removeClass(currentlySelected, 'liSelected'); addClass(src, 'liSelected'); // 3. Recalculate the avaiability recalculateAvaiability(src.innerHTML); } } function recalculateAvaiability(selectedClassOfService){ GM_log('Entering recalculateAvaiability() :'+selectedClassOfService); // Reset the train rows which have the seatNA class set resetTrainRows(); var trainList = trainInfo.trainList; for(var i=0; i0){ removeClass(seatNAList[0], 'noDisplay'); removeClass(seatNAList[0], 'seatNA'); } GM_log('Leaving resetTrainRows()'); } /* This method replaces the contents of the status cloumn td with the loading image */ function resetStatusCol(train, selectedClassOfService, classAvailability){ GM_log('Entering resetStatusCol(train, selectedClassOfService, classAvailability)'); // 1. Veirfy the specified class of service exists before adding a loading image var statusCol = document.getElementById('train'+train.trNo+'Status'); if(classAvailability){ statusCol.removeChild(statusCol.firstChild); statusCol.appendChild(createImage(loaderImgSrc)); } else { document.getElementById('train'+train.trNo+'Status').innerHTML = 'Service N/A'; } GM_log('Leaving resetStatusCol(train, selectedClassOfService, classAvailability)'); } function populateTrains(trainList, classOfTravel){ GM_log('Entering populateTrains()'); var widgetContentBody = document.getElementById('widgetContentBody'); for(var i=0; i'+matches[2]+' '+matches[3]+']'; var tickingSpan = anchorHoldingTime.getElementsByTagName('span')[0]; window.updateTime = function updateTime(){ millisSince1Jan1970 += 1000; tickingSpan.innerHTML = new Date(millisSince1Jan1970).toLocaleTimeString(); } setInterval("updateTime()",1000); GM_log('Now the digital clock should tick'); }
Check your PNR Status Now
Enter a valid PNR No

Enter the 10-digit PNR number below

Simple theme. Powered by Blogger.