PageSourceSearch

https://www.icruise.com/common_library/js/g_javascript_functions.js

js icruise.com collected 2026-10-02 05:00:43 UTC 21,607 bytes, 371 lines download raw bytes

1function gAddFavItin(Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType,initArraySrcCID){
2
3    var g_imagePath = "https://d23n7ahjfnjotp.cloudfront.net";
4    var currentdate = new Date();
5    var datetime =  currentdate.getDate() + "/"
6    + (currentdate.getMonth()+1)  + "/"
7    + currentdate.getFullYear() + " "
8    + currentdate.getHours() + ":"
9    + currentdate.getMinutes() + ":"
10    + currentdate.getSeconds();
11
12    Email = Email.replace(/\+/g, '%2B'); //to replace + with asccii veriosn, so we can pass it.
13
14    FirstName = typeof FirstName !== 'undefined' ? FirstName : '';
15    LastName = typeof LastName !== 'undefined' ? LastName : '';   
16    EmailOffers = typeof EmailOffers !== 'undefined' ? EmailOffers : 0;
17    FromSailPlan = typeof FromSailPlan !== 'undefined' ? FromSailPlan : 1;
18    FormLocation = typeof FormLocation !== 'undefined' ? FormLocation : 2; // 2 Sail plan Desk   
19    srcGetValue2 = typeof srcGetValue2 !== 'undefined' ? srcGetValue2 : '';
20    SRC_CODE  = typeof SRC_CODE  !== 'undefined' ? SRC_CODE  : ''; 
21    originPage  = typeof originPage  !== 'undefined' ? originPage  : ''; 
22    fromPageSrcType  = typeof fromPageSrcType  !== 'undefined' ? fromPageSrcType  : ''; 
23    initArraySrcCID  = typeof initArraySrcCID  !== 'undefined' ? initArraySrcCID  : '';
24    var tealium_event=$("#tealium_event").val();
25
26    let tealium_utag = new Object();
27    tealium_utag.email = Email;
28    tealium_utag.tealium_event = tealium_event;
29    
30    if(originPage=="src"){
31        //$(".srcfavid_"+CruiseItineraryID + " .srcloading").show();
32        $(".srcfavid_"+CruiseItineraryID + " .srcloading").css("opacity","1");
33    }
34
35    if(originPage=="srcoverlay"){
36        $('#bootstrapContainer .modal-body').html('<img src="' + g_imagePath + '/imgs/loading.gif" alt="Currently Loading" class="currentLoading">');
37    }
38
39    if ($( "#requestQuoteModal" ).length) {
40        $('#popup-quote-confirm-wrapper,#popup-quote-options-wrapper').hide();
41        $('#requestQuoteloading').show();
42    }
43
44    if($(".fav-subscribe-" + CruiseItineraryID).length){$(".fav-subscribe-" + CruiseItineraryID).css("display","none");}
45    if($(".fav-unsubscribe-" + CruiseItineraryID).length){$(".fav-unsubscribe-" + CruiseItineraryID).css("display","none");}
46    if($(".favs-loading-" + CruiseItineraryID).length){$(".favs-loading-" + CruiseItineraryID).css("display","flex");}
47
48    $.ajax({ 
49        url: '/c/tracker-favorites-save-NewForProfile.php',
50        type: 'POST', 
51        data: 'FirstName='+FirstName+'&LastName='+LastName+'&Email='+Email+'&CID=' + CruiseItineraryID +'&ms='+datetime+'&EmailOffers='+EmailOffers+'&FromSailPlan='+FromSailPlan+'&FormLocation='+FormLocation+'&src='+SRC_CODE+'&originPage='+originPage+'&fromPageSrcType='+fromPageSrcType,
52        success: function(data){
53            utag_tealium(tealium_utag);
54            data = data.split("|");
55            
56            var TrackingCount = data[1];
57            var TotalUserCruiseTracking = parseInt(data[2]);  
58            //console.log(data);
59
60            if(TotalUserCruiseTracking>0){
61                $('.FavCountSpanNonIndex').html("( "+$.trim(TotalUserCruiseTracking)+" )");
62                $('.FavCountSpanNonIndexTopMenu').html("( "+$.trim(TotalUserCruiseTracking)+" )");
63            }else{
64                $('.FavCountSpanNonIndex').html("");  
65                $('.FavCountSpanNonIndexTopMenu').html("");  
66            }
67            if ($( "#requestQuoteModal" ).length) {
68                $('#requestQuoteloading').hide();
69            }
70            switch(originPage){
71                case "sailplan":
72                    updateSailplan(true,TrackingCount,Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType);
73                break;
74                case "sailplaniFrame":
75                    updateSailplaniFrame(true,TrackingCount,Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage, $.trim(TotalUserCruiseTracking), fromPageSrcType);
76                case "src":
77                    updateSRCFavorites(true,TrackingCount,Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType);
78                break;
79                case "srcoverlay":
80                    updateSRCOverlayFavs(true,TrackingCount,Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, initArraySrcCID, originPage, fromPageSrcType);
81                break;
82                case "search":
83                    if($(".favs-loading-" + CruiseItineraryID).length){$(".favs-loading-" + CruiseItineraryID).css("display","none");}
84                    if($(".fav-subscribe-" + CruiseItineraryID).length){$(".fav-subscribe-" + CruiseItineraryID).css("display","none");}
85                    if($(".fav-subscribe-" + CruiseItineraryID).length){$(".fav-unsubscribe-" + CruiseItineraryID).css("display","flex");}
86                break;
87                default:
88            }
89        } 
90    });   
91}
92    
93function gUnSubFavItin(Reason, Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType){
94
95    Reason = typeof Reason !== 'undefined' ? Reason : '5';
96    Email = typeof Email !== 'undefined' ? Email : '';
97
98    var currentdate = new Date();
99    var datetime =  currentdate.getDate() + "/"
100    + (currentdate.getMonth()+1)  + "/"
101    + currentdate.getFullYear() + " "
102    + currentdate.getHours() + ":"
103    + currentdate.getMinutes() + ":"
104    + currentdate.getSeconds();
105
106    FirstName = typeof FirstName !== 'undefined' ? FirstName : '';
107    LastName = typeof LastName !== 'undefined' ? LastName : '';   
108    EmailOffers = typeof EmailOffers !== 'undefined' ? EmailOffers : 0;
109    FromSailPlan = typeof FromSailPlan !== 'undefined' ? FromSailPlan : 1;
110    FormLocation = typeof FormLocation !== 'undefined' ? FormLocation : 2; // 2 Sail plan Desk   
111    srcGetValue2 = typeof srcGetValue2 !== 'undefined' ? srcGetValue2 : '';
112    SRC_CODE  = typeof SRC_CODE  !== 'undefined' ? SRC_CODE  : ''; 
113    originPage  = typeof originPage  !== 'undefined' ? originPage  : ''; 
114    fromPageSrcType  = typeof fromPageSrcType  !== 'undefined' ? fromPageSrcType  : ''; 
115    
116    if(originPage=="src"){
117        //$(".srcfavid_"+CruiseItineraryID + " .srcloading").show();
118        $(".srcfavid_"+CruiseItineraryID + " .srcloading").css("opacity","1");
119    }
120
121    if($(".fav-subscribe-" + CruiseItineraryID).length){$(".fav-subscribe-" + CruiseItineraryID).css("display","none");}
122    if($(".fav-unsubscribe-" + CruiseItineraryID).length){$(".fav-unsubscribe-" + CruiseItineraryID).css("display","none");}
123    if($(".favs-loading-" + CruiseItineraryID).length){$(".favs-loading-" + CruiseItineraryID).css("display","flex");}
124
125    $.ajax({ 
126        url: '/c/RemoveFavItin.php',
127        type: 'POST', 
128        data: 'CID='+CruiseItineraryID+'&Reason='+Reason+'&ms='+datetime,
129        success: function(data){ 
130
131            data = data.split("|");
132            var TrackingCount = data[1];
133            var TotalUserCruiseTracking = parseInt(data[2]);  
134            //console.log(data);
135            if(TotalUserCruiseTracking>0){
136                $('.FavCountSpanNonIndex').html("( "+$.trim(TotalUserCruiseTracking)+" )");
137                $('.FavCountSpanNonIndexTopMenu').html("( "+$.trim(TotalUserCruiseTracking)+" )");
138            }else{
139                $('.FavCountSpanNonIndex').html("");  
140                $('.FavCountSpanNonIndexTopMenu').html("");  
141            }
142            switch(originPage){
143                case "sailplan":
144                    updateSailplan(false, TrackingCount, Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType);
145                break;
146                case "sailplaniFrame":
147                    updateSailplaniFrame(false, TrackingCount,Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType);
148                case "src":
149                    updateSRCFavorites(false,TrackingCount,Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType);
150                break;
151                case "search":
152                    if($(".favs-loading-" + CruiseItineraryID).length){$(".fav
152s-loading-" + CruiseItineraryID).css("display","none");}
153                    if($(".fav-subscribe-" + CruiseItineraryID).length){$(".fav-subscribe-" + CruiseItineraryID).css("display","flex");}
154                    if($(".fav-unsubscribe-" + CruiseItineraryID).length){$(".fav-unsubscribe-" + CruiseItineraryID).css("display","none");}
155                break;
156                default:
157            }
158        }
159    }); 
160}
161
162function updateSailplan(action, TrackingCount, Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType){
163
164    var getModalAttr = $(".track-cruisenumber .tracking-wrapper").attr("data-toggle");
165    var JSFunctionAddFav = "javascript:gAddFavItin('" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + ");ga('send','event','Sailplan | Mobile','Sailplan Conversion','Get Price Alert - Link');";
166    var JSFunctionUnFav = "javascript:gUnSubFavItin('','" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + ");";
167    
168    if(action){
169        if(getModalAttr){
170            $("#ShowTrackThisItinDiv.tracking-wrapper").removeAttr("data-toggle"); 
171            $(".saveTrackText").removeAttr("data-toggle");   
172            $("#ShowTrackThisItinDiv.tracking-wrapper").attr("onclick", JSFunctionAddFav); 
173        }  
174        var Text = gTrackingText(TrackingCount, 'Y');
175            
176        $(".saveTrackText").attr("onclick",JSFunctionUnFav); 
177        $(".saveText").hide();
178        $(".savedText").show();  
179            
180        $('#ShowTrackThisItinDiv').hide();
181        $('#ShowAlreadyTrackedThisItinDiv').show();
182        $('#ShowAlreadyTrackedThisItinDivText').html(Text);
183    }else{
184         var Text = gTrackingText(TrackingCount, 'N');
185         
186         $(".saveTrackText").attr("onclick",JSFunctionAddFav); 
187         $(".saveText").show();
188         $(".savedText").hide();
189        
190         $('#ShowTrackThisItinDiv').show();
191         $('#ShowAlreadyTrackedThisItinDiv').hide();
192         $('#ShowTrackThisItinDivText').html(Text);
193        
194    }
195}
196
197function updateSailplaniFrame(action, TrackingCount, Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,TotalUserCruiseTracking,fromPageSrcType){
198       var getParent = window.parent;
199       getParent.$('.FavCountSpanNonIndex').html("( "+TotalUserCruiseTracking+" )");
200       getParent.$('.FavCountSpanNonIndexTopMenu').html("( "+TotalUserCruiseTracking+" )");
201
202       /*** Update ***/
203       originPage="sailplan";
204       /*** Update***/
205       var getModalAttr = getParent.$(".track-cruisenumber .tracking-wrapper").attr("data-toggle");
206       var JSFunctionAddFav = "javascript:gAddFavItin('" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + ");ga('send','event','Sailplan | Mobile','Sailplan Conversion','Get Price Alert - Link');";
207       var JSFunctionUnFav = "javascript:gUnSubFavItin('','" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + " );";
208
209    if(action){
210        if(getModalAttr){
211            getParent.$("#ShowTrackThisItinDiv.tracking-wrapper").removeAttr("data-toggle"); 
212            getParent.$(".saveTrackText").removeAttr("data-toggle");   
213            getParent.$("#ShowTrackThisItinDiv.tracking-wrapper").attr("onclick", JSFunctionAddFav); 
214        }  
215        var Text = gTrackingText(TrackingCount, 'Y');
216            
217        getParent.$(".saveTrackText").attr("onclick",JSFunctionUnFav); 
218        getParent.$(".saveText").hide();
219        getParent.$(".savedText").show();  
220            
221        getParent.$('#ShowTrackThisItinDiv').hide();
222        getParent.$('#ShowAlreadyTrackedThisItinDiv').show();
223        getParent.$('#ShowAlreadyTrackedThisItinDivText').html(Text);
224
225        if ( $( ".favs-init" ).length) {
226            $(".favs-init").hide();
227            $(".favs-container").show();
228            $("#requestQuoteModal .close").click();
229        }
230        if ($( "#requestQuoteModal" ).length) {
231            $("#requestQuoteModal .close").click();
232            $("#requestQuoteModal").modal('toggle');
233        }
234    }else{
235         var Text = gTrackingText(TrackingCount, 'N');
236         
237         getParent.$(".saveTrackText").attr("onclick",JSFunctionAddFav); 
238         getParent.$(".saveText").show();
239         getParent.$(".savedText").hide();
240        
241         getParent.$('#ShowTrackThisItinDiv').show();
242         getParent.$('#ShowAlreadyTrackedThisItinDiv').hide();
243         getParent.$('#ShowTrackThisItinDivText').html(Text);
244        
245    }
246}
247
248
249function updateSRCOverlayFavs(action, TrackingCount, Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, initArraySrcCID, originPage, fromPageSrcType){
250       var getModalAttr = $("#results_table .celldata .src_favs").attr("data-toggle"); 
251       var g_imagePath = "https://d23n7ahjfnjotp.cloudfront.net";  
252       
253var JSFunctionAddFav = "javascript:gAddFavItin('" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + ");ga('send','event','Sailplan | Mobile','Sailplan Conversion','Get Price Alert - Link');";
254
255var JSFunctionUnFav = "javascript:gUnSubFavItin('','" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + ");";
256    
257       var getSailDate = $(".srcfavid_" + CruiseItineraryID).attr("data-startdate");
258       var getShipName = $(".srcfavid_" + CruiseItineraryID).attr("data-shipname");
259       
260       var confirm2 = $(".confirmation").html();
261       confirm2 = confirm2.replace("@@CruiseItineraryID@@",CruiseItineraryID);
262       confirm2 = confirm2.replace("@@SailDate@@",getSailDate);
263       confirm2 = confirm2.replace("@@ShipName@@",getShipName);
264
265       $('.bootstrap_genclass .modal-body').html('<img src="' + g_imagePath + '/imgs/loading.gif" alt="Currently Loading" class="currentLoading">');
266       $("#bootstrapContainer .modal-body").html("<div class=\"loading-txt\">Loading...</div><div class=\"loading\"></div>");
267       
268       var getSrcCIDArray = initArraySrcCID;
269       var getFavedArray;
270       $.ajax({ 
271            url: '/c/getUserfavorites.php',
272            type: 'POST', 
273            data: 'WMPHLoginUserID='+Email+'&CruiseItineraryID='+CruiseItineraryID,
274            success: function(data){ 
275
276                var getFavedArray = JSON.parse(data);
277                for(var n=0;n < getSrcCIDArray.length; n++){
278                    updateSRCFavorites(false,TrackingCount,Email, FirstName, LastName, getSrcCIDArray[n], EmailOffers, FromSailPlan, FormLocation, srcGetValue2,SRC_CODE,'src','');
279                }
280                for(var x=0;x < getFavedArray.length; x++){
281                    if(getSrcCIDArray.includes(getFavedArray[x])){
282                       updateSRCFavorites(true,TrackingCount,Email, FirstName, LastName, getFavedArray[x], EmailOffers, FromSailPlan, FormLocation, srcGetValue2,SRC_CODE,'src','');
283                    } 
284                }
285
286               /* for(var n=0;n < getSrcCIDArray.length; n++){
287                    for(var x=0;x < getFavedArray.length; x++){
288                        if(getSrcCIDArray[n] == getFavedArray[x]){
289                            updateSRCFavorites(true,TrackingCount,Email, FirstName, LastName, getSrcCIDArray[n], EmailOffers, FromSailPlan, FormLocation, srcGetValue2,SRC_CODE,'src','');
290                            
291                        }else if(getSrcCIDArray[n] != getFavedArray[x]){
292                            updateSRCFavorites(false,TrackingCount,Email, FirstName, LastName, getSrcCIDArray[n], EmailOffers, FromSailPlan, FormLocation, srcGetValue2,SRC_CODE,'src','');  
293                        }
294                    }  
295                }*/
296            }
297       }); 
298
299       $('.bootstrap_genclass .modal-body').html(confirm2);
300       if(action){
301        if(getModalAttr){
302            $("#results_table .celldata .src_favs").removeAttr("data-toggle");   
303        } 
304       } 
305       
306       for(var x=0;x<initArraySrcCID.length;x++){
307            //console.log(initArraySrcCID);
308       }  
309       $(".close").click(function(){
310          //location.reload(); 
311       });  
312       $(".btn.btn-default").click(function(){
313          //location.reload(); 
314       });  
315       $("#bootstrapContainer").click(function(){
316          //location.reload(); 
317       });     
318}    
319
320
321function updateSRCFavorites(action, TrackingCount, Email, FirstName, LastName, CruiseItineraryID, EmailOffers, FromSailPlan, FormLocation, srcGetValue2, SRC_CODE, originPage,fromPageSrcType){
322
323    var getModalAttr = $("#results_table .celldata .src_favs").attr("data-toggle");
324    
325    var JSFunctionAddFav = "javascript:gAddFavItin('" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + ");ga('send','event','Sailplan | Mobile','Sailplan Conversion','Get Price Alert - Link');";
326    
327    var JSFunctionUnFav = "javascript:gUnSubFavItin('','" + Email + "','" + FirstName + "','" + LastName + "'," + CruiseItineraryID + ",'" + EmailOffers + "','" + FromSailPlan + "','" + FormLocation + "','" + srcGetValue2 + "','" + SRC_CODE + "','" + originPage + "'," + fromPageSrcType + ");";
328    var g_imagePath = "https://d23n7ahjfnjotp.cloudfront.net";
329    var imgFaved = "/imgs/mobile/80x80-favorite-selected.png";
330    var imgUnFaved = "/imgs/mobile/80x80-favorite.png";
331    //$(".srcloading").hide();
332    $(".srcloading").css("opacity","0");
333
334    if(action==true){
335        if(getModalAttr){
336            $("#results_table .celldata .src_favs").removeAttr("data-toggle");   
337        }  
338        var Text = gTrackingText(TrackingCount, 'Y'); 
339        $("#results_table .celldata.save .srcfavid_" + CruiseItineraryID).attr("onclick", JSFunctionUnFav); 
340        $("#results_table .celldata.save .srcfavid_" + CruiseItineraryID + " .favimg").attr("src", g_imagePath + imgFaved); 
341        $("#results_table .celldata.save .srcfavid_" + CruiseItineraryID + " .favlabel").html("Saved");      
342    }else if(action==false){    
343        $("#results_table .celldata.save .srcfavid_" + CruiseItineraryID).attr("onclick", JSFunctionAddFav); 
344        $("#results_table .celldata.save .srcfavid_" + CruiseItineraryID + " .favimg").attr("src", g_imagePath + imgUnFaved); 
345        $("#results_table .celldata.save .srcfavid_" + CruiseItineraryID + " .favlabel").html("Add to Favorites");  
346    }
347}
348
349function gTrackingText(count, ThisUserTrackingThisCruise){
350            var MSG='';
351        if (ThisUserTrackingThisCruise == 'Y'){
352            if (count == 1){
353                MSG='You are tracking this cruise.';    
354            }else if(count == 2){
355                MSG=' <span class=\'TotalTrackerCount\'> 2 </span> You and one other person is tracking this cruise.'; 
356            }else if(count > 2){
357                var NewCount = count-1;
358                MSG='<span class=\'TotalTrackerCount\'> '+count+' </span> You and '+NewCount+' people are tracking this cruise and getting price alerts.'; 
359            }
360        }else{
361            if (count < 1){
362                MSG='Favorite this Cruise and receive Price Alerts when the rates go up or down.';
363            }if (count == 1){
364                MSG='<span class=\'TotalTrackerCount\'> '+count+' </span> Person is tracking this cruise and getting price alerts.';
365            }else if(count > 1){
366                MSG='<span class=\'TotalTrackerCount\'> '+count+' </span> People are tracking this cruise and getting price alerts.';
367            }
368        }
369
370        return MSG;    
371}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.