Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
JavaScript
/*<![CDATA[*/
	if (typeof Date.now === 'undefined') { Date.now = function () { return +new Date(); } }
	$(document).ready(function(){		
		$("<a id="top" name="top"></a><a href="#top" id="gototop"></a>").prependTo("body");
		$("#gototop").click(function(){
			$(window).get(0).location.hash ="#"; 
		});
		window.pip = {};
		window.pip.c = true;
		window.pip.p = true;
		window.pip.j= 460;
		window.pip.k= 720;
		window.pip.cs= 465;
		window.pip.ce= 720;
		window.pip.t = parseInt(791);
		window.pip.l = parseInt(1461570100475);
		window.pip.cd = +Date.now();
		window.pip.d = window.pip.l - window.pip.cd;
		window.pip.cd = window.pip.cd + window.pip.d;
		try{
			window.pip.o = parseInt(25000);
			window.pip.co = parseInt(6000);
			window.pip.f = parseInt(1);
		}catch(err){}
		if(window.pip.f != 1){
			window.pip.c = false;
			window.pip.p = false;
		}
		if(window.pip.j != null && window.pip.k !=null){
			window.pip.j = parseInt(window.pip.j);
			window.pip.k = parseInt(window.pip.k);
			if(window.pip.t < window.pip.j || window.pip.t >= window.pip.k){
				window.pip.p = false;
			}
		}
		if(window.pip.cs != null && window.pip.ce !=null){
			window.pip.cs = parseInt(window.pip.cs);
			window.pip.ce = parseInt(window.pip.ce);
			if(window.pip.t < window.pip.cs || window.pip.t >= window.pip.ce){
				window.pip.c = false;
			}
		}
		if(!(window.pip.o != null && window.pip.o > 0)){
			window.pip.p = false;
		}
		if(!(window.pip.co != null && window.pip.co > 0)){
			window.pip.c = false;
		}
	$("#bkg_captcha").on("load",function(){
		window.pip.clt = +Date.now() + window.pip.d;
	});
	$('#addPassengerForm_errorloc').hide();
	$("#validate").click(function(event){
		var msgs = new Array();
		validatePassengerForm(event, msgs);
		if(msgs.length > 0){
			showErrorMessage(msgs, "addPassengerForm_errorloc");
			}else{
				if(!chkBedRollSrctzn()){
					return false;
				}
				if(_twoSSReleaseFlag==1 && _twoSSEligible && $("input[name='addPassengerForm:bookingCond']:checked").val() != 6){
				    $( '<div><p>'+validatorMsg["twoSSSplitCoachAlert"]+'</p></div>' ).dialog({
				        resizable: false,
				        dialogClass: "no-close",
				        modal: true,
				        width:600,
				        buttons: [
						  {
							  text:validatorMsg.yes,
				          	  click: function() {
					        	$("#addPassengerForm\\:twoSSSplitChochChoice").val(true);
					            $( this ).dialog( "close" );
					            procedeNow();
				          	  }
				          },
				          {
					          text:validatorMsg.no,
				              click: function() {
					        	$("#addPassengerForm\\:twoSSSplitChochChoice").val(false);
					            $( this ).dialog( "close" );
					            procedeNow();
					        }
				          }],
				          create: function (event, ui) {
				        	$(event.target).parent().css('position', 'fixed');
				          }
				      });						
				}else{
					procedeNow();
				}
			}
		});	
	});
	function procedeNow(){
		$(".psgn-nationality,.psgn-idcardtype,.psgn-gender,.psgn-disablePsgnType").removeAttr("readonly").attr("onfocus","loseFocus(this);").prop("disabled",false);
		document.getElementById('validate').disabled = true;
		document.getElementById('addPassengerForm:replan').disabled = true;
		window.pip.ow = +Date.now() + window.pip.d-bkgIntTm;
		window.pip.cow = +Date.now() + window.pip.d-window.pip.clt;
   		if(window.pip.p && window.pip.c && (window.pip.o - window.pip.ow) < (window.pip.co - window.pip.cow)) {
   			window.pip.c = true;
   			window.pip.p = false;
	   	} else if(window.pip.p && window.pip.c && (window.pip.o - window.pip.ow) > (window.pip.co - window.pip.cow)) {
	   		window.pip.c = false;
   			window.pip.p = true;
	   	}
   		if(window.pip.p && window.pip.ow < window.pip.o){
   			RichFaces.$('addPassengerForm:waitOnPPPopup').show();
   			setTimeout(function () {
   				RichFaces.$('addPassengerForm:waitOnPPPopup').hide();
   				$("#addPassengerForm\\:jpProceedBooking").click();
			}, window.pip.o - window.pip.ow);
			return true;
		}
   		window.pip.cow = +Date.now() + window.pip.d-window.pip.clt;
   		if(window.pip.c && window.pip.cow < window.pip.co){
   			RichFaces.$('addPassengerForm:waitOnPPPopup').show();
   			setTimeout(function () {
   				RichFaces.$('addPassengerForm:waitOnPPPopup').hide();
   				$("#addPassengerForm\\:jpProceedBooking").click();
			}, window.pip.co - window.pip.cow);
			return true;
		}
   		$("#addPassengerForm\\:jpProceedBooking").click();
		return true;
	}
	/**/


What I have tried:

kartik sir,
i not tried , plz convert jquery to javascript
Posted
Updated 21-May-16 5:37am
v2
Comments
CHill60 21-May-16 8:31am    
Who is Kartik?
This is a quick answers forum, not a conversion service
Dave Kreskowiak 21-May-16 9:08am    
Uhhhh... you have no idea what the relationship between jQuery and javascript is, do you?
Sergey Alexandrovich Kryukov 21-May-16 10:27am    
What have you tried so far?

Despite the absurd formulation (jQuery is already JavaScript), it's most likely that you wanted to write the code doing the same thing without using jQuery or other 3rd-party libraries, which may make perfect sense. But this is the site "for those who code"... :-)

—SA

Quote:
I want to convert below jquery function into javascript
you are lucky jquery is already Javascript. So it is already done :-o unless you want to rewrite jquery.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-May-16 10:29am    
You are right, of course, but the inquirer may mean writing the code doing the same without a 3rd-party library. This is not the reason to do the job for this inquirer though — please see my comment to the question.
—SA
Patrice T 21-May-16 11:20am    
In this case, Op should be careful with question formulation.
Sergey Alexandrovich Kryukov 21-May-16 11:26am    
Of course, that's important, but also: less lazy. Re-writing code without 3rd-party can be a pure routine work: learn what library function does and see a) how it can be implemented based on JavaScript (and JavaScript HTML DOM) documentation, b) how it is actually implemented in the library. That's all.
—SA
Patrice T 21-May-16 11:31am    
I agree that rewriting code to study how implantation is done is very interesting. But having code rewritten by others is not.
Sergey Alexandrovich Kryukov 21-May-16 11:39am    
You know what..? I guess this a good idea — please see Solution 2.
Your comment above is credited; it's very nice. :-)
—SA
Please see my comments to the Solution 1.

If your goal is to get rid of 3rd-party library like jQuery, you really need to write the alternative code by yourself. (This site is "for those who code".)

And it can be done via the some routine steps. First of all, jQuery, as well as all other JavaScript library, is always available in source code. So, these steps could be:
  1. Look at the code fragment and understand what the library does. For this purpose, address to the library documentation. In case of jQuery, the documentation is very detail and clear, readily available.
  2. In addition to the previous item, if something is not quite clear, create a single HTML+JavaScript project (just one file) to experiment with this part if API, to understand better what it does.
  3. Look at JavaScript documentation and, where required, to the HTML DOM documentation in part related to JavaScript access, and try to figure out how to implement the same functionality. My favorite source is documentation, very accurate and detailed, is MDN:
    JavaScript | MDN[^],
    JavaScript — Learning web development | MDN[^].
  4. As an alternative or in addition to the previous step: dig into the source code of the library and find out how the part of API in question is actually implemented.
  5. PROFIT! :-)


See also the last comment by ppolymorphe to his Solution 1.

Good luck.
—SA
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900