· 5 years ago · Sep 16, 2020, 04:44 PM
1var svc1_assignmentLogId = 0;
2/// <reference file="jquery-1.6.4-vsdoc.js" />
3/// <reference file="main.js" />
4function LoadLoginForm(absolute) {
5 // $("#title").html("I-Viewer Mobile - Login");
6 /* $("#MissedQASummary").hide();
7 $("#menu_back").hide();
8 $("#Menu_AssignmentResource").hide();
9 $("#menu_CancelSession").hide();
10 $("#menu_logout").hide();
11 $("#menu_testfinish").hide();
12 $("#menu_loadtest").hide(); speedtest();
13 curform = 0;
14 */
15
16
17
18 $("#title").html("Login");
19 $("#MissedQASummary").hide();
20 $("#menu_back").hide();
21 $("#menu_logout").hide();
22 $("#menu_testfinish").hide();
23 $("#Menu_AssignmentResource").hide();
24 $("#menu_CancelSession").hide();
25 $("#menu_loadtest").hide();
26
27 // Start - GreatWest-Phase 2-Rollout
28
29 $("#menu_home").hide();
30 $("#menu_controlpanel").hide();
31 $("#menu_faq").hide();
32
33
34
35 // $("#gwHeaderImage").hide();
36 // End - GreatWest-Phase 2-Rollout
37
38
39
40
41 if (typeof $.mobile !== 'undefined') {
42 $("#Menu_AssignmentResource").addClass('ui-corner-right')
43 $("#menu_CancelSession").addClass('ui-corner-right')
44 $("#menu_CancelSession").addClass('ui-corner-left')
45
46 $("#menu_testfinish").addClass('ui-corner-right')
47 $("#menu_testfinish").addClass('ui-corner-left')
48 $("#menu_loadtest").addClass('ui-corner-left')
49 }
50 var svcpath = "IMobieService.svc/GetLoginPage";
51
52 if (isdesktop == "3")
53 svcpath = "IMobieService.svc/GetLoginPage2";
54
55 $.ajax({
56 url: url + svcpath,
57 dataType: "jsonp",
58 success: function (data) {
59
60 var d2;
61
62
63 if (isdesktop == "3") {
64 $("#Page").html(data.GetLoginFormHTML2Result.formtext);
65 salt = data.GetLoginFormHTML2Result.salt;
66 d2 = new Date(data.GetLoginFormHTML2Result.servertime);
67 sessionid = data.GetLoginFormHTML2Result.sessionid;
68 } else {
69 $("#Page").html(data.GetLoginFormHTMLResult.formtext);
70 salt = data.GetLoginFormHTMLResult.salt;
71 d2 = new Date(data.GetLoginFormHTMLResult.servertime);
72 sessionid = data.GetLoginFormHTMLResult.sessionid;
73 }
74
75 var d1 = new Date(); //"now"
76
77 _serverTimestampDiff = d1 - d2;
78
79 var cert1 = GetQueryStringParms('cert1');
80 var cert2 = GetQueryStringParms('cert2');
81 var cert3 = GetQueryStringParms('cert3');
82 var userIdPreAuth = GetQueryStringParms('u');
83
84
85
86
87 if (typeof cert1 != 'undefined' && typeof cert2 != 'undefined' && typeof cert3 != 'undefined') {
88 LogGeneral('Login Started', "");
89 SubmitAuto(cert1, cert2, cert3);
90
91 }
92
93 if (typeof userIdPreAuth != 'undefined' && typeof absolute == 'undefined') {
94 LogGeneral('Login Started', "");
95 SubmitAutoUserID(userIdPreAuth);
96
97 }
98
99 if (isdesktop == "3" || typeof $.mobile !== 'undefined') {
100 $("#Page").find('[data-role="fieldcontain"]').fieldcontain();
101 $("#Page").find('input,textarea').textinput();
102 $("#Page").find('[data-role="button"]').button();
103
104 }
105 $("#UserName").focus();
106 },
107 beforeSend: function () {
108 if (typeof $.mobile !== 'undefined')
109 $.mobile.showPageLoadingMsg();
110 },
111 complete: function () {
112 if (typeof $.mobile !== 'undefined')
113 $.mobile.hidePageLoadingMsg();
114
115
116 },
117 error: function (a) {
118 alert("Error Loading Login Form.");
119 }
120 });
121}
122
123var isCtrl = false;
124
125function keyEvent(e) {
126
127 if (e.keyCode == 17) isCtrl = true;
128
129 //var a = "";
130
131 if (e.keyCode == 119 && isCtrl == true) //ctrl+f8 Displays Bandwidth Test info
132 {
133 var msg = 'VIDEO BANDWIDTH DETAIL\n' +
134 'Video Bitrate File: ' + downloadspeed.mp4suffix + '\n' +
135 'SpeedBps: ' + downloadspeed.speedBps + '\n' +
136 'SpeedKbps: ' + downloadspeed.speedKbps + '\n' +
137 'SpeedMbps: ' + downloadspeed.speedMbps + '\n';
138 alert(msg);
139 }
140
141
142}
143
144function keyUpEvent(e) {
145
146 //alert(e.keyCode);
147 if (e.keyCode == 17) {
148 isCtrl = false;
149 //alert('here');
150 }
151
152 if (e.keyCode == 13 && curform == 0 && $("#btnChangePassword").length == 0) {
153 validateAndSubmitForm();
154 }
155 //else
156}
157
158function LoadMenu_Click(userclss) {
159
160 var LinkTextName = $("#Menu_AssignmentResource").text();
161 if (userclss.isLendingLibrary == "1" || LinkTextName == 'Assignment') {
162
163 if (userclss.isLendingLibrary == "1") {
164 $("#Menu_AssignmentResource").hide();
165 } else if (isdesktop == "1" || isdesktop == "2")
166 $("#Menu_AssignmentResource").html('Resource');
167 else
168 $("#Menu_AssignmentResource .ui-btn-text").html('Resource');
169
170 resourceToggle = 0;
171 } else {
172 if (isdesktop == "1" || isdesktop == "2")
173 $("#Menu_AssignmentResource").html('Assignment');
174 else
175 $("#Menu_AssignmentResource .ui-btn-text").html('Assignment');
176
177 resourceToggle = 1;
178 }
179 LoadMenu(userclss);
180}
181
182function statusWait(hide) {
183
184 if (isdesktop == "3" || isdesktop == "0") {
185
186 if (hide == '1')
187 $.mobile.hidePageLoadingMsg();
188 else
189 $.mobile.showPageLoadingMsg();
190
191
192 } else {
193 if (hide == '1' && isdesktop >= '1') {
194 $('#loading_image').hide().fadeOut(1000);
195 } else if (isdesktop >= '1')
196 $('#loading_image').hide().fadeIn(1000);
197 }
198}
199
200
201
202function checkParamExist(parName) {
203
204 var ret = false;
205
206 var parExist = GetQueryStringParms(parName);
207 if (typeof parExist != 'undefined')
208 ret = true;
209
210 return ret;
211
212
213}
214
215function getParamExistValue(parName) {
216
217 var ret = '';
218
219 var parExist = GetQueryStringParms(parName);
220 if (typeof parExist != 'undefined') {
221 ret = parExist;
222 }
223 return ret;
224
225
226}
227
228
229function handleCustomLogoutButton() {
230
231 if (checkParamExist('loredir'))
232 $("#menu_logout").show();
233
234}
235
236function handleCustomMenuBackButton() {
237
238
239 if (checkParamExist('loredir') && isdesktop == "1" && curform == "3")
240 $("#menu_back").hide();
241 else
242 $("#menu_back").show();
243
244
245}
246
247function LoadMenu(userclss) {
248
249
250 if (typeof userclss.default_assignmentid != 'undefined') {
251 if (userclss.default_assignmentid != '') //SHA login
252 return;
253 }
254 // if (userclss.Key > ' ') //SHA login
255 // return;
256
257 if (isdesktop == "3")
258 $('#Page').html('<div id="image-loading"> <img src="img/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
259 else
260 $('#Page').html('<div id="image-loading"> <img src="Images/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
261
262
263 var isdesktopMobile = "3";
264
265 isdesktopMobile = isdesktop;
266
267 var concatenateDevice = "";
268 if (isdesktopMobile == "3") {
269 concatenateDevice = "2";
270 } else {
271 $("#headerimage").show();
272 }
273 $("#docframe").html("");
274
275 //Start -GWCC lending Library login change [#46690]
276
277 if (userclss.CompanyID == 1037) {
278
279 /* Start - GreatWest-Phase 3-Rollout */
280
281 $("#title").css("background-color", "black");
282
283 /* Start - GreatWest-Phase 5-Rollout */
284 // $("#title").css("margin-top","0");
285 $("#bodydiv").css("border", "3px solid black");
286 $("#bodydiv").css("padding-top", "3px");
287 $("#bodydiv").css("padding-left", "3px");
288 $("#bodydiv").css("padding-right", "3px");
289
290 /* End - GreatWest-Phase 5-Rollout */
291
292 $("#headerimage").css("background-color", "rgb(0, 57, 125)");
293
294 /* End - GreatWest-Phase 3-Rollout */
295
296 /* Start - GreatWest-Phase 2-Rollout */
297
298 //$("#headerimage").css("background-color", "#00467f");
299 // $("#gwHeaderImage").show();
300 // $("#gwHeaderImage").html("<img src='images/GWheader.jpg' width='100%" + "'/>");
301 $("#menu_home").show();
302 $("#menu_controlpanel").show();
303 $("#menu_faq").show();
304 $("#menu_logout").hide();
305
306
307
308 /* End - GreatWest-Phase 2-Rollout */
309
310 } else {
311 // $("#gwHeaderImage").hide();
312 $("#menu_home").hide();
313 $("#menu_controlpanel").hide();
314 $("#menu_faq").hide();
315
316
317 }
318 //End - GWCC lending Library login change [#46690]
319
320 //statusWait();
321
322
323
324 var LinkTextName = $("#Menu_AssignmentResource").text();
325 var URLPath;
326 var URLPathFull;
327
328 if (userclss.isLendingLibrary == '1' || LinkTextName == 'Assignment') {
329
330 URLPath = "IMobieService.svc/GetMenuResource/";
331 URLPathFull = url + URLPath + encodeURIComponent(userclss.UserAccount) + "/" + encodeURIComponent(userclss.Key) + "/" + isdesktopMobile + "/" + userclss.isLendingLibrary;
332
333 /* Start - GreatWest-Phase 2-Rollout */
334 if (userclss.CompanyID == 1037) {
335 $("#title").html('');
336 } else {
337 if (userclss.isLendingLibrary == '1')
338 $("#title").html('Learning Library');
339 //$("#Menu_AssignmentResource").hide();
340 else
341 $("#title").html('Resources');
342 }
343 // $("#Menu_AssignmentResource").html('Resource');
344
345 /* End - GreatWest-Phase 2-Rollout */
346 } else {
347
348 URLPath = "IMobieService.svc/getmenu/";
349 $("#title").html('Assignments');
350 URLPathFull = url + URLPath + encodeURIComponent(userclss.UserAccount) + "/" + encodeURIComponent(userclss.Key) + "/" + isdesktopMobile;
351
352 // $("#Menu_AssignmentResource").html('Assignment');
353 }
354
355 $.ajax({
356 url: URLPathFull,
357 async: false,
358 dataType: "jsonp",
359 success: function (menuxml) {
360 if (menuxml.JSONDataResult == 'Invalid Key') {
361 LoadLoginForm();
362 return;
363
364 }
365
366 if (isdesktop == '2')
367 $("#bodydiv").css('background-color', '#CCFFFF');
368 else
369 $("#bodydiv").css('background-color', userclss.BackGroundColor);
370
371
372 if (URLPath == "IMobieService.svc/getmenu/")
373 $('#Page').html(menuxml.JSONDataResult);
374 else
375 $('#Page').html(menuxml.GetResourceMenuResult);
376
377
378
379 $("#menu_back").show();
380 $("#menu_back").removeAttr('disabled');
381 $("#Menu_AssignmentResource").css({
382 'visibility': 'visible',
383 'display': 'inline-block'
384 });
385
386 handleCustomLogoutButton();
387
388 /*Start - GreatWest-Phase 2-Rollout */
389
390
391 if (userclss.CompanyID == 1037) {
392
393
394 $('#GreatWestWelMsg').html('Welcome to the <p>CLASSROOM');
395 $('#GreatWestInfo').html('Click on the + sign to expand each category');
396
397 $("#Page .treeview").css('border', '#FFFFFF');
398 $("#menu_logout").hide();
399
400 } else {
401 /* Start - GreatWest-Phase 5-Rollout */
402
403 $('#GreatWestWelMsg').hide();
404 $('#GreatWestInfo').hide();
405 }
406 /* End - GreatWest-Phase 5-Rollout */
407 /* End - GreatWest-Phase 2-Rollout */
408
409 if (isdesktop == '1') {
410 //rhua 4/28/2013
411 ddtreemenu.createTree("root_0", true, 5);
412 ddtreemenu.flatten("root_0", 'contact');
413 if (userclss.isLendingLibrary == '1') {
414 $(".treeview li ul li ul li span").hover(
415 function () {
416 toolid = $(this).attr("toolid")
417 leftpos = $(".maintreeview").offset().left + $(".maintreeview")[0].scrollWidth + 15
418 // leftpos = $(".maintreeview")[0].left + $(".maintreeview")[0].scrollWidth + 15
419 loadtooldesc(toolid, leftpos)
420 }
421 );
422
423 $(".treeview li ul li ul li span").mouseout(
424 function () {
425
426 loadtooldesc('', -1000)
427 }
428 );
429
430
431 $("#Menu_AssignmentResource").hide();
432 }
433 } else if (isdesktop == '2') {
434 $("#VerColMenu ul ").hide();
435 // $("#VerColMenu > li > span").not(":first").find("+ ul").slideUp(1);
436
437 var submenuclicked = false;
438 $("#VerColMenu>li").click(
439 function () {
440 if (submenuclicked == true) {
441 submenuclicked = false;
442 return;
443 }
444 if ($('>ul', this).is(':hidden')) {
445 $('>ul', this).slideToggle("fast");
446 } else {
447 $('ul', this).slideUp(1);
448 }
449 }
450 );
451
452 $("#VerColMenu>li>ul>li").click(
453 function () {
454 submenuclicked = true;
455 if ($('ul', this).is(':hidden')) {
456 $('ul', this).slideToggle("fast");
457 } else {
458 $('ul', this).slideUp(1);
459 }
460 });
461
462
463 if (userclss.isLendingLibrary == '1') {
464 $("#Menu_AssignmentResource").css({
465 'visibility': 'hidden',
466 'display': 'inline-block'
467 });
468 $("#lendingpopup").html('').css('visibility', 'hidden');
469 }
470 } else {
471 $('#header').find('[data-role="button"]').button();
472 if (userclss.isLendingLibrary == '1')
473 $("#Menu_AssignmentResource").hide();
474 }
475
476 curform = 3;
477 handleCustomMenuBackButton();
478 },
479 beforeSend: function () {
480 //if (isdesktop == "3" || typeof $.mobile !== 'undefined')
481 //$.mobile.showPageLoadingMsg();
482 },
483 complete: function () {
484 if (isdesktop == "3" || typeof $.mobile !== 'undefined') {
485 //$.mobile.hidePageLoadingMsg();
486 $('#Page').find('[data-role="listview"]').listview();
487 $('.menucls').hide();
488 $('#root_0').show();
489 }
490 },
491 error: function (a) {
492 alert("You have no assignments.");
493 }
494 });
495}
496
497
498function afterLogin() {
499
500 if (isdesktop <= '1') {
501
502
503 getMP4SuffixInitial();
504
505 // loadLoginConfirmation(userclss);
506 } else if (userclss.MP4Format > '' && userclss.isMP4Only == 'True') {
507
508 downloadspeed.mp4suffix = userclss.MP4Format;
509 speedtest();
510 //loadLoginConfirmation(userclss);
511 } else {
512 speedtest();
513 }
514
515}
516
517function ChangePassword() {
518
519 var a = "";
520
521 $("#lblPasswordMessage").text('');
522 if ($("#NewPassword").val().length == 0) {
523 $("#lblPasswordMessage").text('You must enter a password.');
524 $("#NewPassword").focus();
525 return;
526 } else if ($("#PasswordConfirm").val().length == 0) {
527 $("#lblPasswordMessage").text('You must re-type password to confirm.');
528 $("#PasswordConfirm").focus();
529 return;
530 } else if ($("#PasswordConfirm").val() != $("#NewPassword").val()) {
531 $("#lblPasswordMessage").text('Your passwords do not match. Please reconfirm your passwords.');
532 $("#PasswordConfirm").focus();
533 return;
534 }
535
536 var newPassword = $("#NewPassword").val();
537 var newPasswordSalt = CryptoJS.MD5($("#NewPassword").val().toLowerCase() + salt);
538 if (newPasswordSalt == _password) {
539 $("#lblPasswordMessage").text('You must choose a new password. You cannot reuse the current password.');
540 $("#NewPassword").focus();
541 return;
542 }
543
544
545 _password = '';
546
547 //AJAX goes here
548 $.ajax({
549 url: url + "IMobieService.svc/ChangePassword/" + userclss.ID + "/" + newPassword,
550 dataType: "jsonp",
551 success: function (data) {
552
553 if (isdesktop == "3")
554 $('#Page').html('<div id="image-loading"> <img src="img/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
555 else
556 $('#Page').html('<div id="image-loading"> <img src="Images/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
557 statusWait();
558
559 afterLogin();
560
561 },
562 beforeSend: function () {
563 if (typeof $.mobile !== 'undefined')
564 $.mobile.showPageLoadingMsg();
565 },
566 complete: function () {
567
568
569
570 },
571 error: function (a) {
572 alert("Error Loading Login Form.");
573 }
574 });
575
576
577
578
579}
580
581function validateAndSubmitForm() {
582
583 //validate
584 var a = "";
585 $("#menu_home").hide();
586
587 $("#title").html("Login Confirmation");
588 if ($("#UserName").val().length == 0) {
589 $("#lblLoginText").focus();
590 return;
591 } else if ($("#Password").val().length == 0) {
592 $("#Password").focus();
593 return;
594 }
595 var username = encodeURIComponent($("#UserName").val());
596 var usernameLog = $("#UserName").val();
597 var password = encodeURIComponent(CryptoJS.MD5($("#Password").val().toLowerCase() + salt));
598 var referer = '0';
599
600
601 if (document.referrer != '')
602 referer = encodeURI(document.referrer.split('/')[2].split(':')[0]);
603
604
605 var ref1 = GetQueryStringParms('ref1');
606 if (typeof ref1 != 'undefined')
607 referer = encodeURI(ref1);
608 // referrer = 'teresa.infinit-i.net';
609 //$('#Page').html('<div id="image-loading"> <img src="Images/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
610
611 var loginHtml = $('#Page').html();
612
613 if (isdesktop == "3")
614 $('#Page').html('<div id="image-loading"> <img src="img/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
615 else
616 $('#Page').html('<div id="image-loading"> <img src="Images/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
617
618 statusWait();
619
620 $.ajax({
621 url: url + "IMobieService.svc/GetUserInfo/" + username + "/" + password + "/" + referer,
622 dataType: "jsonp",
623 success: function (data) {
624 userclss = data.GetUserClssResult;
625
626
627 // if (userclss.BackGroundColor.length > 0) {
628 // $(".container").css('background-color', userclss.BackGroundColor);
629
630 // }
631 if (typeof (userclss) != 'undefined' && userclss.Key == null) { //alert('Login failed, please try again');
632 // alert("invalid login");
633 statusWait('1');
634 $('#Page').html(loginHtml)
635 var txmsg = "<b>Login failed</b> - Enter your user name and password above";
636 $("#lblLoginText").html(txmsg).css("color", "red");
637 LogGeneral('Login Invalid - ' + usernameLog + "-" + password, "");
638 return;
639 }
640 LogGeneral('Login Sucessfull - ' + usernameLog + "-" + password, userclss.ID);
641
642 if (userclss.isPasswordChangeRequired == 'True') {
643 _password = password;
644 $("#bodydiv").css('background-color', 'white');
645 $("#Page").html(displayChangePassword(userclss));
646
647 $("#NewPassword").focus();
648 } else
649 afterLogin();
650
651 // $("#Page").html(displayloginconfirmation(userclss));
652 // $("#Page").find('[data-role="fieldcontain"]').fieldcontain();
653 // $("#Page").find('input,textarea').checkboxradio();
654 // $("#Page").find('[data-role="button"]').button();
655 // $("#menu_back").show();
656 // curform++
657 },
658 beforeSend: function () {
659 // if (typeof $.mobile !== 'undefined')
660 // $.mobile.showPageLoadingMsg();
661 },
662 complete: function () {
663 if (typeof $.mobile !== 'undefined')
664 $.mobile.hidePageLoadingMsg();
665 },
666 error: function (a) {
667 statusWait('1');
668 $('#Page').html(loginHtml)
669 alert("Error Loading Page");
670 $("#Page").find('[data-role="button"]').button();
671 }
672 });
673}
674
675
676
677
678function SubmitAuto(cert1, cert2, cert3) {
679 //auto login from api
680 var a = "";
681 var loginHtml = $('#Page').html();
682 // if (document.referrer == '')
683 // return;
684
685 /* Start - SSO decoding parameters */
686 var cert1Decoded = decodeURIComponent(cert1);
687 var cert2Decoded = decodeURIComponent(cert2);
688 var cert3Decoded = decodeURIComponent(cert3);
689 var cert1Coded = encodeURIComponent(cert1Decoded);
690 var cert2Coded = encodeURIComponent(cert2Decoded);
691 var cert3Coded = encodeURIComponent(cert3Decoded);
692
693 /* End - SSO decoding parameters */
694
695
696 var ref1 = GetQueryStringParms('ref1');
697 if (typeof ref1 != 'undefined')
698 referer = encodeURI(ref1);
699
700 if (isdesktop == "3")
701 $('#Page').html('<div id="image-loading"> <img src="img/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
702 else
703 $('#Page').html('<div id="image-loading"> <img src="Images/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
704
705 statusWait();
706
707 referer = encodeURI(document.referrer.split('/')[2].split(':')[0]);
708 /* Start - SSO decoding parameters */
709 refererDecoded = decodeURI(referer)
710 //$.ajax({ url: url + "IMobieService.svc/GetUserInfo2/" + cert1 + "/" + cert2 + "/" + cert3 + "/" + referer,
711 $.ajax({
712 url: url + "IMobieService.svc/GetUserInfo2/" + cert1Coded + "/" + cert2Coded + "/" + cert3Coded + "/" + referer,
713 /* End - SSO decoding parameters */
714
715 dataType: "jsonp",
716 success: function (data) {
717 userclss = data.GetUserClss2Result;
718 if (typeof (userclss) != 'undefined' && userclss.Key == null) { //alert('Login failed, please try again');
719 // alert("invalid login");
720 statusWait('1');
721 $('#Page').html(loginHtml)
722 var txmsg = "<b>Login failed</b> - Enter your user name and password above";
723 $("#lblLoginText").html(txmsg).css("color", "red");
724 /* Start - SSO decoding parameters */
725 //LogGeneral('Login Invalid - ' + cert1 + "-" + cert2 + "-" + cert3 + "-" + referer, "");
726 LogGeneral('Login Invalid - ' + cert1Decoded + "-" + cert2Decoded + "-" + cert3Decoded + "-" + refererDecoded, "");
727 /* End - SSO decoding parameters */
728
729 return;
730 }
731 /* Start - SSO decoding parameters */
732 //LogGeneral('Login Sucessfull - ' + cert1 + "-" + cert2 + "-" + cert3 + "-" + referer, userclss.ID);
733 LogGeneral('Login Sucessfull - ' + cert1Decoded + "-" + cert2Decoded + "-" + cert3Decoded + "-" + refererDecoded, userclss.ID);
734 /* End - SSO decoding parameters */
735
736
737
738 if (userclss.isPasswordChangeRequired == 'True') {
739 _password = password;
740 $("#bodydiv").css('background-color', 'white');
741 $("#Page").html(displayChangePassword(userclss));
742 $("#NewPassword").focus();
743 } else
744 afterLogin();
745
746 // $("#Page").html(displayloginconfirmation(userclss));
747 // $("#Page").find('[data-role="fieldcontain"]').fieldcontain();
748 // $("#Page").find('input,textarea').checkboxradio();
749 // $("#Page").find('[data-role="button"]').button();
750 // $("#menu_back").show();
751 // curform++
752 },
753 beforeSend: function () {
754 if (typeof $.mobile !== 'undefined')
755 $.mobile.showPageLoadingMsg();
756 },
757 complete: function () {
758 if (typeof $.mobile !== 'undefined')
759 $.mobile.hidePageLoadingMsg();
760 },
761 error: function (a) {
762 alert("Error Loading Page");
763 if (typeof $.mobile !== 'undefined')
764 $("#Page").find('[data-role="button"]').button();
765 }
766 });
767}
768
769
770
771
772function SubmitAutoUserID(useridField) {
773 var a = ""
774 //auto login from control panel
775 if (useridField.indexOf("i22011i2") < 0)
776 return;
777
778 var userid = useridField.replace("i22011i2", "");
779
780 if (isdesktop == "3")
781 $('#Page').html('<div id="image-loading"> <img src="img/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
782 else
783 $('#Page').html('<div id="image-loading"> <img src="Images/layer_loading.gif" style="display: none;" id="loading_image" class="image-loading"></div>');
784
785 statusWait();
786
787 $.ajax({
788 url: url + "IMobieService.svc/GetUserInfo3/" + userid,
789 dataType: "jsonp",
790 success: function (data) {
791 userclss = data.GetUserClss3Result;
792 if (typeof (userclss) != 'undefined' && userclss.Key == null) { //alert('Login failed, please try again');
793 // alert("invalid login");
794 var txmsg = "<b>Login failed</b> - Enter your user name and password above";
795 $("#lblLoginText").html(txmsg).css("color", "red");
796 LogGeneral('Login Invalid - ' + userid, "");
797 LoadLoginForm(true);
798 return;
799 }
800 LogGeneral('Login Sucessfull - ' + userid, userclss.ID);
801
802 if (userclss.isPasswordChangeRequired == 'True') {
803 _password = password;
804 $("#bodydiv").css('background-color', 'white');
805 $("#Page").html(displayChangePassword(userclss));
806 $("#NewPassword").focus();
807 } else
808 afterLogin();
809
810 // $("#Page").html(displayloginconfirmation(userclss));
811 // $("#Page").find('[data-role="fieldcontain"]').fieldcontain();
812 // $("#Page").find('input,textarea').checkboxradio();
813 // $("#Page").find('[data-role="button"]').button();
814 // $("#menu_back").show();
815 // curform++
816 },
817 beforeSend: function () {
818 if (typeof $.mobile !== 'undefined')
819 $.mobile.showPageLoadingMsg();
820 },
821 complete: function () {
822 if (typeof $.mobile !== 'undefined')
823 $.mobile.hidePageLoadingMsg();
824 },
825 error: function (a) {
826 alert("Error Loading Page");
827 if (typeof $.mobile !== 'undefined')
828 $("#Page").find('[data-role="button"]').button();
829 }
830 });
831}
832
833
834
835function SubmitAutoUserIDBySHAKey(SHAKey) {
836
837 $.ajax({
838 url: url + "IMobieService.svc/GetLoginPage",
839 dataType: "jsonp",
840 success: function (data) {
841 salt = data.GetLoginFormHTMLResult.salt;
842 sessionid = data.GetLoginFormHTMLResult.sessionid;
843
844 var d1 = new Date(); //"now"
845 var d2 = new Date(data.GetLoginFormHTMLResult.servertime);
846 _serverTimestampDiff = d1 - d2;
847 GetUserClssBySHA(SHAKey);
848 },
849 error: function (a) {
850 alert("Error Loading Login Form.");
851 }
852 });
853
854}
855
856
857function SubmitAutoUserIDBySession(sessionKey) {
858
859 $.ajax({
860 url: url + "IMobieService.svc/GetLoginPage",
861 dataType: "jsonp",
862 success: function (data) {
863 salt = data.GetLoginFormHTMLResult.salt;
864 sessionid = data.GetLoginFormHTMLResult.sessionid;
865
866 var d1 = new Date(); //"now"
867 var d2 = new Date(data.GetLoginFormHTMLResult.servertime);
868 _serverTimestampDiff = d1 - d2;
869 GetUserClssBySession(sessionKey);
870 },
871 error: function (a) {
872 alert("Error Loading Login Form.");
873 }
874 });
875
876}
877
878
879//Start - GWCC lending Library login change [#46690]
880function SubmitAutoUserIDBySessionGreatWest(sessionKey) {
881
882 $.ajax({
883 url: url + "IMobieService.svc/GetLoginPage",
884 dataType: "jsonp",
885 success: function (data) {
886 salt = data.GetLoginFormHTMLResult.salt;
887 sessionid = data.GetLoginFormHTMLResult.sessionid;
888
889 var d1 = new Date(); //"now"
890 var d2 = new Date(data.GetLoginFormHTMLResult.servertime);
891 _serverTimestampDiff = d1 - d2;
892 GetUserClssBySessionGreatWest(sessionKey);
893 },
894 // Start- GreatWest-Phase-3-RollOut
895 beforeSend: function () {
896 // if (typeof $.mobile !== 'undefined')
897 // $.mobile.showPageLoadingMsg();
898 },
899 // End- GreatWest-Phase-3-RollOut
900 error: function (a) {
901 alert("Error Loading Login Form.");
902 }
903 });
904
905}
906
907
908//End-GWCC lending Library login change [#46690]
909
910function GetUserClssBySHA(SHAKey) {
911 $("#MissedQASummary").hide();
912 $("#menu_back").hide();
913 $("#menu_logout").hide();
914 $("#menu_testfinish").hide();
915 $("#Menu_AssignmentResource").hide();
916 $("#menu_CancelSession").hide();
917 $("#menu_loadtest").hide();
918
919 /* Start - GreatWest-Phase 5-Rollout */
920 $("#menu_home").hide();
921 $("#menu_controlpanel").hide();
922 $("#menu_faq").hide();
923 /* End - GreatWest-Phase 5-Rollout */
924
925
926
927 $.ajax({
928 url: url + "IMobieService.svc/GetUserClssBySHA/" + SHAKey,
929 dataType: "jsonp",
930 success: function (data) {
931 userclss = data.GetUserClssBySHAResult;
932 if (typeof (userclss) != 'undefined' && userclss.Key == null) { //alert('Login failed, please try again');
933 // alert("invalid login");
934 var txmsg = "<b>Login failed</b> - Enter your user name and password above";
935 $("#lblLoginText").html(txmsg).css("color", "red");
936 LogGeneral('Login Invalid - ' + userclss.ID, "");
937 // LoadLoginForm(true);
938
939 return;
940 }
941 LogGeneral('Login Sucessfull - ' + userclss.ID, userclss.ID);
942 // LoadMenu_Click(userclss);
943
944 if (userclss.default_completedtool == '') {
945 loadtool("a" + userclss.default_assignmentid + "-m" + userclss.default_moduleid + "-t" + userclss.default_toolid);
946 }
947 },
948 beforeSend: function () {
949 if (typeof $.mobile !== 'undefined')
950 $.mobile.showPageLoadingMsg();
951 },
952 complete: function () {
953 if (typeof $.mobile !== 'undefined')
954 $.mobile.hidePageLoadingMsg();
955 },
956 error: function (a) {
957 alert("Error Loading Page");
958 if (typeof $.mobile !== 'undefined')
959 $("#Page").find('[data-role="button"]').button();
960 }
961 });
962
963
964}
965
966
967
968function GetUserClssBySession(sessionKey) {
969 $("#MissedQASummary").hide();
970 $("#menu_back").hide();
971 $("#menu_logout").hide();
972 $("#menu_testfinish").hide();
973 $("#Menu_AssignmentResource").hide();
974 $("#menu_CancelSession").hide();
975 $("#menu_loadtest").hide();
976 $.ajax({
977 url: url + "IMobieService.svc/GetSessionUID/" + sessionKey,
978 dataType: "jsonp",
979 success: function (data) {
980 userclss = data.GetUIDSessionWResult;
981
982 SubmitAutoUserIDBySHAKey
983
984 if (typeof (userclss) != 'undefined' && userclss.Key == null) { //alert('Login failed, please try again');
985 // alert("invalid login");
986 var txmsg = "<b>Login failed</b> - Enter your user name and password above";
987 $("#lblLoginText").html(txmsg).css("color", "red");
988 LogGeneral('Login Invalid - ' + "Landing Page Login", "0");
989 LoadLoginForm(true);
990 return;
991 }
992 LogGeneral('Login Sucessfull - ' + "", userclss.ID);
993
994 if (userclss.isPasswordChangeRequired == 'True') {
995 //_password = password;
996 $("#bodydiv").css('background-color', 'white');
997 $("#Page").html(displayChangePassword(userclss));
998 $("#NewPassword").focus();
999 } else
1000 afterLogin();
1001 },
1002 beforeSend: function () {
1003 if (typeof $.mobile !== 'undefined')
1004 $.mobile.showPageLoadingMsg();
1005 },
1006 complete: function () {
1007 if (typeof $.mobile !== 'undefined')
1008 $.mobile.hidePageLoadingMsg();
1009 },
1010 error: function (a) {
1011 alert("Error Loading Page");
1012 if (typeof $.mobile !== 'undefined')
1013 $("#Page").find('[data-role="button"]').button();
1014 }
1015 });
1016
1017
1018}
1019
1020
1021//GWCC lending Library login change [#46690]
1022
1023function GetUserClssBySessionGreatWest(sessionKey) {
1024 $("#MissedQASummary").hide();
1025 $("#menu_back").hide();
1026 $("#menu_logout").hide();
1027 $("#menu_testfinish").hide();
1028 $("#Menu_AssignmentResource").hide();
1029 $("#menu_CancelSession").hide();
1030 $("#menu_loadtest").hide();
1031 $.ajax({
1032 url: url + "IMobieService.svc/GetSessionUID/" + sessionKey,
1033 dataType: "jsonp",
1034 success: function (data) {
1035 userclss = data.GetUIDSessionWResult;
1036
1037 SubmitAutoUserIDBySHAKey
1038
1039 if (typeof (userclss) != 'undefined' && userclss.Key == null) { //alert('Login failed, please try again');
1040 // alert("invalid login");
1041 var txmsg = "<b>Login failed</b> - Enter your user name and password above";
1042 $("#lblLoginText").html(txmsg).css("color", "red");
1043 LogGeneral('Login Invalid - ' + "Landing Page Login", "0");
1044 LoadLoginForm(true);
1045 return;
1046 }
1047 LogGeneral('Login Sucessfull - ' + "", userclss.ID);
1048
1049 afterLogin();
1050 },
1051 beforeSend: function () {
1052 if (typeof $.mobile !== 'undefined')
1053 $.mobile.showPageLoadingMsg();
1054 },
1055 complete: function () {
1056 if (typeof $.mobile !== 'undefined')
1057 $.mobile.hidePageLoadingMsg();
1058 },
1059 error: function (a) {
1060 alert("Error Loading Page");
1061 if (typeof $.mobile !== 'undefined')
1062 $("#Page").find('[data-role="button"]').button();
1063 }
1064 });
1065
1066
1067}
1068
1069
1070
1071
1072function loadLoginConfirmation(userclss) {
1073
1074 //turn off status
1075 statusWait('1');
1076
1077 //Start - GWCC lending Library login change [#46690]
1078
1079 if (userclss.CompanyID == 1037) {
1080 curform = 2;
1081 $("#menu_back").hide();
1082 $("#Page").html("");
1083 $("#bodydiv").css('background-color', 'white');
1084 if (typeof $.mobile !== 'undefined')
1085 $("#Page").find('[data-role="button"]').button();
1086 else
1087 $("#headerimage").html("<img src='" + userclss.LogoPath + "'/>");
1088
1089
1090 LoadMenu(userclss)
1091 return;
1092 }
1093
1094 //End - GWCC lending Library login change [#46690]
1095
1096 if (userclss.EnableUserCertification != "True") {
1097 $("#menu_logout").show()
1098 $("#title").html("Main");
1099 loaduserCertificationContinue();
1100 return;
1101 }
1102
1103 $("#bodydiv").css('background-color', 'white');
1104
1105 if (isdesktop == "3")
1106 $("#Page").html(displayloginconfirmation2(userclss));
1107 else
1108 $("#Page").html(displayloginconfirmation(userclss));
1109
1110 if (isdesktop == "3" || typeof $.mobile !== 'undefined') {
1111 $("#Page").find('[data-role="fieldcontain"]').fieldcontain();
1112 //$("#Page").find('input,textarea').checkboxradio();
1113 $("#Page").find('input[type="checkbox"]');
1114 $("#Page").find('[data-role="button"]').button();
1115 }
1116 // $("#menu_back").show();
1117 curform = 1;
1118}
1119
1120
1121function userCertificationContinue(checkboxname) {
1122 $("#menu_logout").show()
1123 $("#title").html("Main");
1124
1125 if ($('#' + checkboxname).attr('checked')) {
1126 loaduserCertificationContinue();
1127 return;
1128 // $("#Page").html("");
1129 // $("#Page").html(displayloginMessage(userclss));
1130 // curform++
1131 // $("#Page").find('[data-role="button"]').button();
1132 } else {
1133 $("#chklbl").css("color", "red");
1134 return;
1135
1136 }
1137
1138}
1139
1140function loaduserCertificationContinue() {
1141 // $("#Page").html("");
1142
1143 curform = 2;
1144 $("#menu_back").hide();
1145 $("#Page").html("");
1146 $("#bodydiv").css('background-color', 'white');
1147 // $("#Page").html(displayloginMessage(userclss));
1148 $("#Page").append(displayloginMessage(userclss));
1149
1150 if (typeof $.mobile !== 'undefined')
1151 $("#Page").find('[data-role="button"]').button();
1152 else
1153 $("#headerimage").html("<img src='" + userclss.LogoPath + "'/>");
1154 return;
1155}
1156
1157function loadtool(toolid, testid) {
1158 if (typeof (testid) == 'undefined') a = '0';
1159
1160 $("#Menu_AssignmentResource").hide();
1161 redirectNow = false;
1162
1163 curform = 4;
1164
1165 handleCustomMenuBackButton();
1166
1167 curToolInfo = null;
1168 assignlogobj = {
1169 input_tool_ids: '0',
1170 useraccount: '0',
1171 testinfoids: '0',
1172 totalclick: '0',
1173 totaltestclick: '0',
1174 iscorrect: '0',
1175 viewbegdate: '0',
1176 viewenddate: '0',
1177 toolviewbegdate: '0',
1178 toolviewenddate: '0',
1179 testviewbegdate: '0',
1180 testviewenddate: '0',
1181 assignedactivity: '0',
1182 grade: '0',
1183 passfail: '0',
1184 passpercentage: '0',
1185 assignAct: 'STARTED',
1186 status: '0',
1187 session: '0',
1188 questioncounts: '0',
1189 questionsmissed: '0'
1190 };
1191 autoFail = {
1192 videoLength: $('.vjs-duration-display').html(),
1193 startViewTime: '0',
1194 endViewTime: '0',
1195 videoLength: '0',
1196 assignState: 'FAST FORWARD FAIL',
1197 timeFormat: function (vid) {
1198 //Check for string will tell use the video type. String is jwplayer, int is flash video
1199 if (typeof vid == "string") {
1200 var pieces = vid.split(":");
1201 var result = (Number(pieces[0]) * 60) + Number(pieces[1]);
1202 return (result.toFixed(0));
1203 } else {
1204 // keep as number for comparison
1205 return vid;
1206 }
1207
1208 },
1209 //214319 214350
1210 timeFunc: function (startTime, endTime, vidLength) {
1211 // alert("Entered time checking function\n start time:" + startTime + "\nend time:" + endTime + "\nvideo length:" + vidLength);
1212 try {
1213 if (startTime && endTime && vidLength) {
1214 var diff = Math.abs(startTime - endTime);
1215 var start = moment(startTime, "HH:mm:ss");
1216 var end = moment(endTime, "HH:mm:ss");
1217 var diff = moment.duration(end.diff(start));
1218 //Add 10 seconds of cushion to insure no false positives.
1219 var diffHour = diff._data.hour ? diff._data.hour * 3600 : 0;
1220 var diffMin = diff._data.minutes * 60;
1221 var diffSeconds = diff._data.seconds + diffMin + diffHour + 10;
1222 var secs = parseInt(autoFail.timeFormat(vidLength));
1223 // alert("Moment.js Times. \nstart time:" + start + "\nend:" + end + "\ndiff:" + diff + "\nvideo length in seconds:" + secs);
1224 if (diffSeconds) {
1225 if (diffSeconds < secs) {
1226 $("#dialog").show();
1227 setTimeout(function () {
1228 $("#dialog").hide();
1229 }, 10000);
1230 assignlogobj.assignAct = "FAST FORWARD FAIL";
1231 autoFail.sendGrade = 0;
1232 autoFail.LoadQuestion = false;
1233 if ($("#my_video_1_html5_api")[0] != undefined) {
1234 $("#my_video_1_html5_api")[0].webkitExitFullScreen();
1235 }
1236 // $("#my_popup").css("visibility", "visible");
1237 // alert("Fast Forwarding is not allowed, please re-watch video.");
1238 // $.mobile.hidePageLoadingMsg();
1239 return;
1240
1241 } else if (diffSeconds > secs) {
1242 $("#my_popup").css("visibility", "hidden");
1243 assignlogobj.assignAct = 'COMPLETED TOOL VIEW';
1244 autoFail.LoadQuestion = true
1245 if (typeof $.mobile !== 'undefined'){
1246 $.mobile.hidePageLoadingMsg();
1247 }
1248 return;
1249 } else {
1250 assignlogobj.assignAct = 'COMPLETED TOOL VIEW';
1251 assignlogobj.toolviewenddate = getDtNow();
1252 assignlogobj.viewenddate = getDtNow();
1253 if (typeof $.mobile !== 'undefined'){
1254 $.mobile.hidePageLoadingMsg();
1255 }
1256 return;
1257 }
1258 }
1259 } else {
1260 console.log(startTime, endTime, vidLength + "One or more objects returned null/0 meaning time comparison couldn't happen for unwarranted FF. Please contact Vertical Alliance team");
1261 return;
1262 }
1263 } catch (e) {
1264 alert("This error occured in Time Function. Please report this error to Vertical Alliance team: " + e);
1265 }
1266 },
1267 sendGrade: '',
1268 LoadQuestion: true
1269 }
1270
1271
1272 assignlogobj.input_tool_ids = toolid;
1273 LogAssignment("LoadTool", assignlogobj);
1274 $.ajax({
1275 url: url + "IMobieService.svc/GeToolInfo/" + toolid + "/" + userclss.CompanyID + "/" + userclss.ID,
1276 async: false,
1277 dataType: "jsonp",
1278 success: function (tool) {
1279 curToolInfo = tool.GetToolResult;
1280 $("#bodydiv").css('background-color', 'white');
1281
1282 LogAssignment("StartToolView", assignlogobj);
1283
1284 /* Start - GreatWest-Phase 5-Rollout */
1285
1286 $('#GreatWestWelMsg').hide();
1287 $('#GreatWestInfo').hide();
1288
1289 /* End - GreatWest-Phase 5-Rollout */
1290
1291
1292
1293 if (curToolInfo.tooltype == 'VIDO' || curToolInfo.tooltype == 'VIDS') {
1294 LoadVideo(curToolInfo.locationurl, curToolInfo.toolname);
1295 } else if (curToolInfo.tooltype != null) //(curToolInfo.tooltype == 'PDFS')
1296 {
1297
1298 if ((userclss.isLendingLibrary == "1" || testid == '0') && curToolInfo.tooltype != "EXTOLE") {
1299
1300 /* Start - GreatWest-Phase 2-Rollout */
1301 if (userclss.CompanyID == 1037)
1302 $("#headerimage").show();
1303 else
1304 $("#headerimage").hide();
1305 /* End - GreatWest-Phase 2-Rollout */
1306
1307 LogAssignment("EndToolView", assignlogobj);
1308 //TESTTEST
1309 LogAssignment("COMPLETED TOOL", assignlogobj);
1310 $("#menu_loadtest").hide();
1311 } else if (resourceToggle == 0) {
1312 if (curToolInfo.testid != 0) {
1313 $("#menu_loadtest").show();
1314 }
1315 } else {
1316 $("#menu_loadtest").hide();
1317 }
1318
1319
1320 if (curToolInfo.tooltype == "EXTOLE") {
1321
1322 //UNCOMMENT IN PROD
1323 $("#menu_loadtest").hide();
1324 LoadIFrameExternal(curToolInfo);
1325 } else if (curToolInfo.tooltype == "LINKNT") {
1326
1327 //UNCOMMENT IN PROD
1328 $("#menu_loadtest").hide();
1329 LoadIFrame(curToolInfo.locationurl, curToolInfo.toolname);
1330 } else
1331 LoadIFrame(curToolInfo.locationurl, curToolInfo.toolname);
1332 } else {
1333
1334 if (userclss.isLendingLibrary == "1") {
1335 $("#Menu_AssignmentResource").hide();
1336 } else
1337 $("#Menu_AssignmentResource").show();
1338 }
1339 },
1340 error: function (a) {
1341 alert("Error loading file from server!");
1342 }
1343 });
1344
1345
1346}
1347
1348
1349
1350function LoadIFrame(URL, toolname) {
1351 $("#Page").hide();
1352
1353 /* Start - GreatWest-Phase 2-Rollout */
1354 if (userclss.CompanyID == 1037)
1355 $("#headerimage").show();
1356 else
1357 $("#headerimage").hide();
1358 /* End - GreatWest-Phase 2-Rollout */
1359
1360 $("#title").html(toolname);
1361 $("#docframe").show();
1362
1363 var height = '650px';
1364 if (curToolInfo.tooltype == "EXTOLE") {
1365 height = '800px';
1366 }
1367 //create jquery window to replace iframe
1368 $('#myIframe').ready(function() {
1369 var externalHtml = '<p>Infinit-i</p>';
1370 $('#myIframe').contents().find('body')
1371 .html('<div id="iframeContent" style="display:none;min-width:' + $('body').width() + 'px">' +
1372 externalHtml +
1373 '</div>'
1374 );
1375 // Let the CSS load before getting height
1376 setTimeout(function() {
1377 $('#myIframe').css('height',
1378 height
1379 );
1380 }, 50);
1381 });
1382 var baseUrl = "/js/pdf.js/web/viewer.html?file=/PDFSpike/StreamPdf.aspx?Url%3D";
1383 var pdfUrl = encodeURI(curToolInfo.locationurl);
1384 if (pdfUrl.substring(pdfUrl.length - 3, pdfUrl.length).toUpperCase() == "PDF")
1385 $("#docframe").html("<iframe id='myIframe' width='100%' height='650px' src='" + baseUrl + pdfUrl + "'></iframe>");
1386 else
1387 $("#docframe").html("<iframe id='myIframe' width='100%' height='650px' src='" + curToolInfo.locationurl + "'></iframe>");
1388}
1389
1390function LoadIFrameExternal(CurToolInfo) {
1391 $("#Page").hide();
1392 $("#headerimage").hide()
1393 $("#title").html(CurToolInfo.toolname);
1394 $("#docframe").show();
1395 var toolinfo;
1396 toolinfo = "a" + CurToolInfo.assignmentid + "-c" + userclss.CompanyID + "-u" + userclss.ID + "-m" + CurToolInfo.moduleid + "-t" + CurToolInfo.toolid;
1397
1398 var height = '650px';
1399
1400 if (curToolInfo.tooltype == "EXTOLE") {
1401
1402 height = '800px';
1403 }
1404
1405 //create jquery window to replace iframe
1406 $('#myIframe').ready(function() {
1407
1408 var externalHtml = '<p>Infinit-i</p>';
1409 //alert('here');
1410 // Find the body of the iframe and set its HTML
1411 // Add a wrapping div for height hack
1412 // Set min-width on wrapping div in order to get real height afterwords
1413 $('#myIframe').contents().find('body')
1414 .html('<div id="iframeContent" style="display:none;min-width:' + $('body').width() + 'px">' +
1415 externalHtml +
1416 '</div>'
1417 );
1418
1419 // Let the CSS load before getting height
1420 setTimeout(function() {
1421 // Set the height of the iframe to the height of the content
1422 // $('#myIframe').css('height',
1423 // $('#myIframe').contents().find('#iframeContent').height() + 'px'
1424 // );
1425 $('#myIframe').css('height',
1426 height
1427 );
1428
1429
1430 }, 50);
1431 });
1432
1433
1434
1435 // if (isdesktop >= '1') {
1436
1437 //$("#docframe").html("<iframe width='100%' height='650px' src='" + "ViewDocWS.aspx?fn=" + userclss.FirstName + " " + userclss.LastName + "&cn=" + userclss.CompanyName + "&cc=" + CurToolInfo.toolCode + "&tk=" + CurToolInfo.SessionSHA + "&ui=" + toolinfo + "'></iframe>");
1438 $("#docframe").html("<iframe id='myIframe' width='100%' height='650px' src='" + "ViewDocWS.aspx?fn=" + userclss.FirstName + " " + userclss.LastName + "&cn=" + userclss.CompanyName + "&cc=" + CurToolInfo.toolCode + "&tk=" + CurToolInfo.SessionSHA + "&ui=" + toolinfo + "'></iframe>");
1439 // } //if PDF
1440 //else if (URL.toLowerCase().indexOf('.pdf', URL.length - 5) > 0) {}
1441 // else {
1442
1443 // if (device == 'ipad')
1444 // $("#docframe").html("<iframe width='100%' height='650px' src='" + curToolInfo.locationurl.replace("viewdoc.aspx", "viewdocm2.aspx") + "'></iframe>");
1445 // else
1446 // $("#docframe").html("<iframe width='100%' height='650px' src='" + curToolInfo.locationurl.replace("viewdoc.aspx", "viewdocm.aspx") + "'></iframe>");
1447 // }
1448}
1449
1450
1451function LoadTest(manual) {
1452
1453 if (isdesktop >= "1")
1454 $("#bit_rate_list").hide();
1455
1456 if (manual == 'true')
1457 LogAssignment("EndToolView", assignlogobj);
1458
1459 var isRandom = '0';
1460
1461 if (curToolInfo.isRandom == 'True')
1462 isRandom = '1';
1463
1464
1465 curToolTestInf = null;
1466 $.ajax({
1467 url: url + "IMobieService.svc/GetTestQA/" + curToolInfo.toolid + "/" + isdesktop + "/" + isRandom,
1468 // url: url + "IMobieService.svc/GetTestQA/" + 20959 + "/" + isdesktop,
1469 async: false,
1470 dataType: "jsonp",
1471 success: function (tool) {
1472 curToolInfo.curTestinfo = tool.GetTestQAResult;
1473 if (curToolInfo.curTestinfo.QAHTML == "" || resourceToggle == 1) {
1474 if (resourceToggle == 0 && curToolInfo.tooltype == "EXTOLE") {
1475 LogAssignment("COMPLETED TOOL", assignlogobj);
1476 }
1477 unloadVideo();
1478 } else {
1479
1480 if (userclss.isLendingLibrary != "1") {
1481 unloadVideo();
1482 if (autoFail.LoadQuestion == true) {
1483 loadquestions();
1484 }
1485
1486 }
1487 }
1488
1489
1490
1491 },
1492 error: function (a) {
1493 alert("Error loading file from server!");
1494 }
1495 });
1496
1497}
1498
1499
1500
1501function loadquestions() {
1502 // curToolInfo.curTestinfo = tool.GetTestQAResult;
1503 //curToolTestInf = tool.GetTestQAResult;
1504 assignlogobj.totaltestclick = 0;
1505 assignlogobj.totalclick = 0;
1506 missedQA = '';
1507 answeraccumulator = '';
1508
1509 $("#Page").hide();
1510
1511 //$("#tv_frame").hide();
1512 // $("#tv_frame").css({ 'width': '0px', 'height': '0px' });
1513 // $("#mediaplayer").css({ 'width': '0px', 'height': '0px' });
1514 // $("#my_video_1").css({ 'width': '0px', 'height': '0px' });
1515 // $("#flash_fallback_1").css({ 'width': '0px', 'height': '0px' });
1516 $("#tv_frame").css({
1517 'position': 'absolute',
1518 'margin-top': '-2000px'
1519 });
1520
1521 // $("#bodydiv").css('background-color', 'white');
1522 $("#MissedQASummary").hide();
1523 $("#docframe").hide();
1524
1525 $("#Page2").html(curToolInfo.curTestinfo.QAHTML);
1526 if (userclss.TextColor > ' ')
1527 $("#Page2").css("color", userclss.TextColor);
1528 $("#question1").css('background-color', userclss.BackGroundColor);
1529 $("#Page2").show();
1530 if ($("#question2").length > 0)
1531 $("#question2").css('background-color', userclss.BackGroundColor);
1532
1533 $(".hidequestions").hide();
1534 $("#question1").show();
1535 assignlogobj.testinfoids = $("#question1").attr("qid")
1536 LogAssignment("LoadQuestion", assignlogobj)
1537
1538 $("#menu_back").hide();
1539
1540 $("#menu_testfinish").hide();
1541 $("#menu_loadtest").hide();
1542 $("#menu_CancelSession").show();
1543 // if (userclss.Key > ' ') {
1544
1545 // $("#menu_CancelSession").hide();
1546 // }
1547
1548
1549 if (typeof userclss.default_assignmentid != 'undefined') {
1550 if (userclss.default_assignmentid != '') //SHA login
1551 $("#menu_CancelSession").hide();
1552 }
1553
1554
1555
1556 $("#button1").attr("disabled", "disabled");
1557 $("#title").html('Test Questions: ' + curToolInfo.toolname);
1558
1559 if (isdesktop == "0")
1560 $("#Page2").find('[data-role="button"]').button();
1561
1562}
1563
1564
1565
1566
1567////// function unloadVideo() {
1568
1569////// assignlogobj.totaltestclick = 0;
1570////// assignlogobj.totalclick = 0;
1571////// missedQA = '';
1572
1573////// $("#Page").show();
1574
1575////// $("#tv_frame").css({ 'position': 'absolute', 'margin-top': '-2000px' });
1576////// $("#MissedQASummary").hide();
1577////// $("#docframe").hide();
1578////// LoadMenu(userclss);
1579////// // $("#menu_back").show();
1580////// // $("#menu_testfinish").hide();
1581////// // $("#menu_loadtest").hide();
1582////// // $("#menu_CancelSession").show();
1583////// // $("#button1").attr("disabled", "disabled");
1584////// // $("#title").html('Test Questions: ' + curToolInfo.toolname);
1585////// }
1586
1587function unloadVideo() {
1588
1589
1590 assignlogobj.totaltestclick = 0;
1591 assignlogobj.totalclick = 0;
1592 missedQA = '';
1593 vidStop();
1594 vidSetSource('');
1595
1596 if (isdesktop >= "1")
1597 $("#bit_rate_list").hide();
1598
1599
1600
1601 $("#Page").show();
1602
1603 // $("#tv_frame").hide();
1604
1605 if (BrowserDetect.browser == "Explorer")
1606 $("#tv_frame").css({
1607 'position': 'absolute',
1608 'margin-top': '-2000px'
1609 });
1610 else if ((BrowserDetect.browser == "Chrome" || BrowserDetect.browser == "Safari" || BrowserDetect.browser == 'Firefox') && (device != "iphone" && device != "ipad"))
1611 $("#tv_frame").hide();
1612 else if (device != "iphone" || device != "ipad")
1613 $("#tv_frame").css({
1614 'position': 'absolute',
1615 'margin-top': '-2000px'
1616 });
1617
1618 $("#MissedQASummary").hide();
1619 $("#docframe").hide();
1620 LoadMenu(userclss);
1621 // $("#menu_back").show();
1622 // $("#menu_testfinish").hide();
1623 // $("#menu_loadtest").hide();
1624 // $("#menu_CancelSession").show();
1625 // $("#button1").attr("disabled", "disabled");
1626 // $("#title").html('Test Questions: ' + curToolInfo.toolname);
1627}
1628
1629function NextQAClick(testids, questionnum, questiontotal) {
1630 $('#wrong_answer').html('');
1631
1632 if ($("input:radio[name=" + testids + "]:checked").val() == 'undefined')
1633 var ansid
1634 ansid = $("input:radio[name=" + testids + "]:checked").val();
1635 if (!isca(ansid) || waf == 1) {
1636 ++assignlogobj.questionsmissed;
1637
1638
1639 if (isdesktop == "1")
1640 missedQA = missedQA + "<p><div class='qes'>" + $("#button" + questionnum).parent('div').find('p').text();
1641 else
1642 missedQA = missedQA + "<p><div class='qes'>" + $("#button" + questionnum).parent('div').find('.questiontext').text();
1643
1644
1645 $("#button" + questionnum).parent('div').find('label').each(function (index) {
1646 var a = this.innerText;
1647 //var ca = isca(this.htmlFor.replace('radio', '')) ? " - <div class='cans'>(Correct Answer)</div>" : "";
1648 //var ca = " - <div class='cans'>(Correct Answer)</div>";
1649 var ca = " - <label class='cans'>(Correct Answer)</label>";
1650 if (isca(this.htmlFor.replace('radio', '')) == true) {
1651 missedQA = missedQA + "<div class='ans'>" + this.innerText + ca + "</div>";
1652 }
1653
1654 // var b = isca(this.htmlFor.replace('radio', ''));
1655
1656
1657 });
1658 missedQA = missedQA + "</div>";
1659
1660 // assignlogobj.questionmissed = assignlogobj.questionmissed + '[' + buttonid + ']'
1661 // }
1662 assignlogobj.iscorrect = 0;
1663 } else {
1664
1665 assignlogobj.iscorrect = 1;
1666 }
1667
1668
1669 if (parseInt(questionnum) < parseInt(questiontotal)) {
1670 $(".hidequestions").hide();
1671
1672
1673 $("#question" + ++questionnum).show();
1674 assignlogobj.testinfoids = $("input:radio[name=" + testids + "]:checked").val();
1675 LogAssignment("ContinuedQuestion", assignlogobj);
1676
1677 $("#button" + questionnum).attr("disabled", "disabled");
1678 $("#question" + ++questionnum).css('background-color', userclss.BackGroundColor);
1679 } else {
1680 //REMOVE IF ERROR
1681 assignlogobj.testinfoids = $("input:radio[name=" + testids + "]:checked").val();
1682 LogAssignment("ContinuedQuestion", assignlogobj);
1683
1684
1685 EndTestSession();
1686 }
1687 assignlogobj.totaltestclick = 0;
1688 waf = 0;
1689}
1690
1691function isca(ansid) {
1692 var a = curToolTestInf;
1693
1694
1695 for (var i = 0; i < curToolInfo.curTestinfo.qaval.length; i++) {
1696 if (curToolInfo.curTestinfo.qaval[i] == ansid)
1697 return true;
1698 }
1699 return false;
1700
1701}
1702
1703
1704function getca(qids) {
1705 for (var i = 0; i < curToolInfo.curTestinfo.qaval.length; i++) {
1706 if (curToolInfo.curTestinfo.qaval[i].substring(0, qids.length) == qids) {
1707 return curToolInfo.curTestinfo.qavala[i];
1708 break;
1709 }
1710
1711 }
1712 // return false;
1713
1714}
1715
1716
1717function CancelTestSession() {
1718 // if (userclss.Key > ' ') //SHA login
1719 // return;
1720
1721
1722
1723 if (typeof userclss.default_assignmentid != 'undefined') {
1724 if (userclss.default_assignmentid != '') //SHA login
1725 return;
1726 }
1727
1728
1729 $("#menu_back").show();
1730 $("#menu_testfinish").hide();
1731 $("#menu_CancelSession").hide();
1732
1733 if (curToolInfo.tooltype == 'VIDO' || curToolInfo.tooltype == 'VIDS')
1734 vidStop();
1735
1736 $("#menu_loadtest").hide();
1737 LogAssignment("TOOL CANCELED", assignlogobj);
1738 $("#Page2").html('');
1739 $("#Page2").hide();
1740 $("#MissedQASummary").html('');
1741 $("#MissedQASummary").hide();
1742 $("#Page").show();
1743
1744 handleCustomMenuBackButton();
1745
1746}
1747
1748function FinishTestSession() {
1749
1750 // if (userclss.Key > ' ') //SHA login
1751 // return;
1752
1753 if (typeof userclss.default_assignmentid != 'undefined') {
1754 if (userclss.default_assignmentid != '') //SHA login
1755 return;
1756 }
1757
1758 $("#menu_back").show();
1759 $("#menu_testfinish").hide();
1760 $("#menu_CancelSession").hide();
1761 $("#menu_loadtest").hide();
1762
1763 $("#Page2").html('');
1764 $("#Page2").hide();
1765 $("#MissedQASummary").html('');
1766 $("#MissedQASummary").hide();
1767 $("#Page").show();
1768 LoadMenu(userclss);
1769
1770
1771}
1772
1773
1774function EndTestSession() {
1775
1776 var numquestions = curToolInfo.curTestinfo.qaval.length;
1777 var missquestions = assignlogobj.questionsmissed;
1778 var PassPercentage = curToolInfo.PassPercentage;
1779
1780
1781 var grade = parseInt(((parseInt(numquestions) - parseInt(missquestions)) / parseInt(numquestions)) * 100);
1782 assignlogobj.grade = grade;
1783 //Auto Fail check for 0
1784 // if (autoFail.sendGrade == 0) {
1785 // assignlogobj.grade = 0;
1786 // }
1787 var passing = false;
1788
1789 if (parseInt(grade) >= parseInt(PassPercentage))
1790 passing = true;
1791 else
1792 passing = false;
1793 var testresult
1794
1795 testresult = "<div class='heading'>";
1796 assignlogobj.passfail = "F";
1797
1798 var testPassed = false;
1799 if (curToolInfo.isPassFail == 'True') {
1800 if (passing == true) {
1801 testPassed = true;
1802 }
1803 } else {
1804
1805 assignlogobj.passfail = "P";
1806 testPassed = true;
1807 assignlogobj.grade = 100;
1808 }
1809
1810 if (testPassed == true)
1811 testresult = testresult + "<span class='Grade'>Passed, this tool has been marked as completed</span>";
1812
1813 if (curToolInfo.isPassFail == 'True') {
1814 testresult = testresult + "<span class='Grade'>Test Grade: " + assignlogobj.grade + "</span>";
1815 }
1816
1817
1818 if (curToolInfo.EmailRetakeonFail == 'True' && curToolInfo.isPassFail == 'True' && testPassed == false)
1819
1820 testresult = testresult + "<span class='Retake'>A grade of " + assignlogobj.grade + " does not meet the established requirements. Please retake the test as soon as possible.</span>"
1821
1822 if (missedQA.length > 1 && curToolInfo.ShowIncorrectAnswerSummary == 'True')
1823 testresult = testresult + "<span class='IncorrectAnswer'>The following questions were answered incorrectly</span>"
1824 testresult = testresult + "</div>"
1825 // assignlogobj.passfail = parseInt(grade) >= parseInt(PassPercentage);
1826 assignlogobj.passpercentage = PassPercentage;
1827
1828
1829
1830 LogAssignment("COMPLETED TEST", assignlogobj);
1831
1832
1833 if (userclss.default_redirectURL != null && testPassed == true) {
1834 redirectNow = true;
1835 if (curToolInfo.tooltype == 'VIDO' || curToolInfo.tooltype == 'VIDS')
1836 vidStop();
1837 }
1838
1839
1840 if (testPassed == true) {
1841 LogAssignment("COMPLETED TOOL", assignlogobj);
1842 } else {
1843 LogAssignment("COMPLETED TOOL NO PASS", assignlogobj);
1844 }
1845
1846 // AGB Added to support cases where users must not be allowed to continue without passing
1847 var redirectText = "<p><span class='Retake'>You did not meet the required score to complete this training, you will be redirected to the beginning of the video for another attempt....</span></p>"
1848
1849 var showIncorrectAnswers = curToolInfo.ShowIncorrectAnswerSummary;
1850 var isPassFail = curToolInfo.isPassFail;
1851
1852
1853 if (curToolInfo.ShowIncorrectAnswerSummary == 'True') {
1854
1855 $("#Page2").html('');
1856 $("#Page2").hide();
1857 $("#MissedQASummary").html(testresult + missedQA);
1858 $("#MissedQASummary").show();
1859
1860 // AGB: If we failed, show user appended text stating so, and in 10 seconds redirect them and do not record as passed
1861 if (testPassed != true && userclss.default_redirectURL != null) {
1862 $("#MissedQASummary").append(redirectText);
1863
1864 setTimeout(delayRedirect, 10000);
1865
1866 function delayRedirect() {
1867 if (curToolInfo.tooltype == 'VIDO' || curToolInfo.tooltype == 'VIDS')
1868 vidStop();
1869 SubmitAutoUserIDBySHAKey(ref7);
1870 };
1871 }
1872 } else {
1873 $("#Page2").html('');
1874 $("#Page2").hide();
1875 $("#MissedQASummary").html(testresult);
1876 $("#MissedQASummary").show();
1877
1878 if (testPassed != true && userclss.default_redirectURL != null) {
1879 $("#MissedQASummary").append(redirectText);
1880
1881 setTimeout(delayRedirect, 10000);
1882
1883 function delayRedirect() {
1884 if (curToolInfo.tooltype == 'VIDO' || curToolInfo.tooltype == 'VIDS')
1885 vidStop();
1886 SubmitAutoUserIDBySHAKey(ref7);
1887 };
1888 }
1889 }
1890
1891
1892 $("#menu_testfinish").show();
1893 $("#menu_back").hide();
1894 $("#menu_CancelSession").hide();
1895
1896 //alert('Tool has been completed.');
1897 // $("#Page2").html('');
1898 // $("#MissedQASummary").html('');
1899 // $("#Page").show();
1900
1901 // var a = curToolInfo.curTestinfo;
1902 // var b = assignlogobj.testinfoids;
1903 // $("#menu_back").show();
1904 // $("#menu_CancelSession").hide();
1905 // $("#menu_testfinish").hide();
1906 //
1907 // $("#Page2").html('');
1908 // $("#Page").show();
1909
1910} /// <reference path="http://localhost:50477/Classes/tools/" />
1911
1912
1913
1914function integrationRedirect() {
1915
1916
1917 if (userclss.default_redirectURL != null) {
1918
1919 var redirect;
1920 if (userclss.default_redirectURL.indexOf("?") != -1) {
1921
1922 redirect = userclss.default_redirectURL + "&token=" + ref7;
1923 } else {
1924
1925 redirect = userclss.default_redirectURL + "?token=" + ref7;
1926 }
1927
1928 window.location = redirect;
1929
1930 }
1931}
1932
1933
1934function EnableNext(buttonid) {
1935 var ansid
1936 // alert($("#question1").find("label:for=radioo20959-t20959-q33053-a66043").val());
1937
1938 ansid = $("#" + buttonid).parent('div').find("input:radio:checked").val();
1939
1940
1941 if (answeraccumulator.indexOf(ansid) == -1) {
1942 answeraccumulator = answeraccumulator + '|' + ansid;
1943 ++assignlogobj.totalclick;
1944 ++assignlogobj.totaltestclick;
1945 }
1946
1947 if (!isca(ansid)) {
1948 if (curToolInfo.isPassFail == 'False') {
1949 waf = 1;
1950 $('#wrong_answer').html('Incorrect - Please select another answer');
1951 $("#" + buttonid).attr("disabled", "disabled");
1952 return;
1953 }
1954 assignlogobj.testinfoid
1955 }
1956 if (curToolInfo.isPassFail == 'False')
1957 $('#wrong_answer').html('<font color="green">Correct</font>');
1958 else
1959 $('#wrong_answer').html('');
1960
1961 $("#" + buttonid).removeAttr("disabled");
1962
1963}
1964
1965function getDtNow() {
1966
1967 var d_now = new Date();
1968 var d = new Date(d_now.getTime() - _serverTimestampDiff);
1969
1970 yy = d.getFullYear();
1971 mm = parseInt(d.getMonth()) + 1;
1972 mm = ((parseInt(mm) < 10) ? '0' + String(mm) : String(mm));
1973 dd = d.getDate();
1974 dd = ((parseInt(dd) < 10) ? '0' + String(dd) : String(dd));
1975 hh = d.getHours();
1976 hh = ((parseInt(hh) < 10) ? '0' + String(hh) : String(hh));
1977 mi = d.getMinutes();
1978 mi = ((parseInt(mi) < 10) ? '0' + String(mi) : String(mi));
1979 ss = d.getSeconds();
1980 ss = ((parseInt(ss) < 10) ? '0' + String(ss) : String(ss));
1981 return String(mm) + String(dd) + String(yy) + String(hh) + String(mi) + String(ss);
1982}
1983
1984function specialgGetDtNow() {
1985
1986 var d_now = new Date();
1987 var d = new Date(d_now.getTime() - _serverTimestampDiff);
1988
1989 // yy = d.getFullYear();
1990 // mm = parseInt(d.getMonth()) + 1;
1991 // mm = ((parseInt(mm) < 10) ? '0' + String(mm) : String(mm));
1992 // dd = d.getDate();
1993 // dd = ((parseInt(dd) < 10) ? '0' + String(dd) : String(dd));
1994 hh = d.getHours();
1995 hh = ((parseInt(hh) < 10) ? '0' + String(hh) : String(hh));
1996 mi = d.getMinutes();
1997 mi = ((parseInt(mi) < 10) ? '0' + String(mi) : String(mi));
1998 ss = d.getSeconds();
1999 ss = ((parseInt(ss) < 10) ? '0' + String(ss) : String(ss));
2000 return String(hh) + String(mi) + String(ss);
2001}
2002
2003// assignmentlog.input_tool_ids = toolid;
2004// logevents("LoadTool", assignmentlog);
2005
2006function LogAssignment(EventDesc, assignlogobj) {
2007 // return;
2008
2009 //var myVideoPlayer = $('my_video_1_html5_api');
2010 //if (myVideoPlayer) {
2011 // myVideoPlayer.addEventListener('loadedmetadata', function () {
2012 // var duration = myVideoPlayer.duration;
2013 // });
2014 //}
2015 var appleProductChk = navigator.userAgent || navigator.vendor || window.opera;
2016
2017 if (typeof (userclss.UserAccount) != 'undefined') {
2018
2019 assignlogobj.useraccount = userclss.UserAccount;
2020
2021 }
2022 var resourceText = 'RESOURCE ';
2023
2024
2025 if (typeof (userclss.isLendingLibrary) != 'undefined') {
2026 if (userclss.isLendingLibrary == "1") {
2027 resourceText = "Learning Library ";
2028 } else if (resourceToggle == 0) {
2029 resourceText = '';
2030 }
2031 }
2032 /*
2033 log device
2034 1=desktop
2035 2=iphone
2036 3=ipad
2037 4=android
2038 5=creationdeck
2039 7=Any Pre-Field Changes (was null)
2040 */
2041
2042 var app = "1";
2043 if (device != "") {
2044 if (device == "iphone")
2045 app = "2";
2046 else if (device == "ipad")
2047 app = "3";
2048 else if (device == "android")
2049 app = "4";
2050 else
2051 app = "0";
2052
2053 }
2054
2055
2056 var urlparms;
2057 switch (EventDesc) {
2058 case 'LoadTool':
2059 {
2060 // loaded in load tool AssignlogObj.input_tool_ids
2061 assignlogobj.viewbegdate = getDtNow();
2062 assignlogobj.totalclick = 0;
2063 assignlogobj.assignAct = 'STARTED';
2064 assignlogobj.status = '0';
2065 assignlogobj.grade = '0';
2066 assignlogobj.passpercentage = '0';
2067
2068
2069 break;
2070 }
2071 case 'StartToolView':
2072 {
2073 autoFail.startViewTime = specialgGetDtNow();
2074 assignlogobj.assignAct = 'STARTED ' + resourceText + 'TOOL VIEW';
2075 assignlogobj.toolviewbegdate = getDtNow();
2076 break;
2077 }
2078 case 'EndToolView':
2079 {
2080 if (iOS() && userclss.MediaView !== "full") {
2081 if (userclss.MediaView || userclss.MediaView != undefined) {
2082 ffCheck(userclss, autoFail, assignlogobj);
2083 } else {
2084 console.log("No userclass.MediaView came across meaning no video setting was made on admin side");
2085 break;
2086 }
2087 } else {
2088 assignlogobj.assignAct = 'COMPLETED ' + resourceText + 'TOOL VIEW';
2089 assignlogobj.toolviewenddate = getDtNow();
2090 assignlogobj.viewenddate = getDtNow();
2091 break;
2092 }
2093 }
2094 case 'LoadQuestion':
2095 {
2096 $("#my_popup").css("visibility", "hidden");
2097 assignlogobj.assignAct = 'TEST LOADED';
2098 assignlogobj.testviewbegdate = getDtNow();
2099 break;
2100 }
2101 case 'ContinuedQuestion':
2102 {
2103 assignlogobj.assignAct = 'CONTINUED TEST';
2104 break;
2105 }
2106 case 'COMPLETED TEST':
2107 {
2108 assignlogobj.assignAct = 'COMPLETED TEST';
2109 assignlogobj.testviewenddate = getDtNow();
2110 break;
2111 }
2112 case 'TOOL CANCELED':
2113 {
2114 assignlogobj.assignAct = resourceText + 'TOOL CANCELED';
2115 assignlogobj.toolviewenddate = getDtNow();
2116 assignlogobj.viewenddate = getDtNow();
2117 break;
2118 }
2119 case 'COMPLETED TOOL':
2120 {
2121 assignlogobj.assignAct = 'COMPLETED TOOL';
2122 assignlogobj.toolviewenddate = getDtNow();
2123 assignlogobj.viewenddate = getDtNow();
2124 break;
2125 }
2126 case 'COMPLETED TOOL NO PASS':
2127 {
2128 assignlogobj.assignAct = 'COMPLETED TOOL NO PASS';
2129 assignlogobj.toolviewenddate = getDtNow();
2130 assignlogobj.viewenddate = getDtNow();
2131 break;
2132 }
2133 }
2134 var others;
2135 others = 'ac' + assignlogobj.assignAct + '-gr' + assignlogobj.grade + '-pp' + assignlogobj.passpercentage + '-pf' + assignlogobj.passfail + '-st' + assignlogobj.status + '-tc' + assignlogobj.totalclick + '-qc' + assignlogobj.totaltestclick + '-ic' + assignlogobj.iscorrect;
2136
2137
2138 urlparms = assignlogobj.useraccount + '/' + assignlogobj.input_tool_ids + '/' + assignlogobj.testinfoids + '/' +
2139 assignlogobj.viewbegdate + '-' + assignlogobj.viewenddate + '/' +
2140 assignlogobj.toolviewbegdate + '-' + assignlogobj.toolviewenddate + '/' +
2141 assignlogobj.testviewbegdate + '-' + assignlogobj.testviewenddate + '/' + others + "/0/" + app + '/' + svc1_assignmentLogId;
2142
2143 $.ajax({
2144 url: url + "IMobieService.svc/LogAssignment/" + sessionid + "/" + urlparms,
2145 dataType: "jsonp",
2146 success: function (data) {
2147 if (assignlogobj.assignAct == 'STARTED TOOL VIEW') {
2148 if (data.LogAssignmentResult != "0") {
2149 svc1_assignmentLogId = data.LogAssignmentResult;
2150 }
2151 } else if (assignlogobj.assignAct == 'COMPLETED TOOL' || assignlogobj.assignAct == 'COMPLETED TOOL NO PASS') {
2152 svc1_assignmentLogId = 0;
2153 }
2154 if (logresult > ' ') {
2155 // alert("invalid login");
2156 alert("Error on LogAssignment!");
2157 // $("#Page").html("Error on LogAssignment!");
2158
2159 return;
2160 }
2161
2162 //Start - 10th street - titan transfer issue
2163 if (redirectNow == true && EventDesc == 'COMPLETED TOOL') {
2164 redirectNow = false;
2165 //TODO: Notify user that test must be taken again to pass. Pass token to integraionRedirect. From there call SubmitAutoUserIDBySHAKey(SHAKey)
2166 //Did we pass the test?
2167 integrationRedirect(ref7);
2168 }
2169 //End - 10th street - titan transfer issue
2170 },
2171 beforeSend: function () {
2172 //if (typeof $.mobile !== 'undefined')
2173 //$.mobile.showPageLoadingMsg();
2174 },
2175 complete: function () {
2176 //if (typeof $.mobile !== 'undefined')
2177 //$.mobile.hidePageLoadingMsg();
2178 },
2179 error: function (a) {
2180 alert("Please call Customer Service and report this error.");
2181 $("#Page").html("Error on LogAssignment!");
2182 }
2183 });
2184}
2185
2186function ffCheck(userclss, autoFail, assignlogobj) {
2187 if (userclss.MediaView !== "full") {
2188 //Auto Fail Time Comparison Logic, Returned assignlogobj.assignAct = "FAST FORWARD FAIL" if user fast forwards.
2189 autoFail.endViewTime = specialgGetDtNow();
2190 autoFail.videoLength = $('.vjs-duration-display').html() ? $('.vjs-duration-display').html() : Math.round($("#my_video_1")[0].duration);
2191 if (curToolInfo.tooltype == "VIDO") {
2192 autoFail.funcResults = autoFail.timeFunc(autoFail.startViewTime, autoFail.endViewTime, autoFail.videoLength);
2193 }
2194 assignlogobj.toolviewenddate = getDtNow();
2195 assignlogobj.viewenddate = getDtNow();
2196 } else if (userclss.MediaView === "full") {
2197 assignlogobj.assignAct = 'COMPLETED ' + resourceText + 'TOOL VIEW';
2198 assignlogobj.toolviewenddate = getDtNow();
2199 assignlogobj.viewenddate = getDtNow();
2200 } else {
2201 console.log("We are in ffCheck function, nothing was logged because something was wrong with mediaView var.");
2202 }
2203 return userclss, autoFail, assignlogobj
2204}
2205
2206function iOSversion() {
2207 if (/iP(hone|od|ad)/.test(navigator.platform)) {
2208 // supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
2209 var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
2210 return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
2211 }
2212}
2213
2214
2215function getIOSversion() {
2216
2217 ver = iOSversion();
2218
2219 // if (ver[0] >= 5) {
2220 // alert('This is running iOS 5 or later.');
2221 // }
2222
2223 return ver[0];
2224
2225}
2226
2227
2228function LogGeneral(EventDesc, userid) {
2229 var acct = '0-0-0';
2230 if (typeof (userclss) != 'undefined') {
2231
2232 if (userclss.UserAccount == 'null')
2233 acct = assignlogobj.useraccount = userclss.UserAccount;
2234 // if (userid == null||userid=="")
2235 // userid = "0";
2236
2237 }
2238
2239 if (userid == null || userid == "")
2240 userid = "0";
2241
2242
2243 $.ajax({
2244 url: url + "IMobieService.svc/LogGeneral/" + sessionid + "/" + acct + "/" + encodeURI(EventDesc) + "/" + userid,
2245 dataType: "jsonp",
2246 success: function (data) {
2247 logresult = data.LogGeneralResult;
2248 if (logresult > ' ') {
2249 // alert("invalid login");
2250 alert("Error on LogAssignment!");
2251 // $("#Page").html("Error on Log!");
2252
2253 return;
2254 }
2255
2256 },
2257 beforeSend: function () {
2258 // if (typeof $.mobile !== 'undefined')
2259 // $.mobile.showPageLoadingMsg();
2260 },
2261 complete: function () {
2262 if (typeof $.mobile !== 'undefined')
2263 $.mobile.hidePageLoadingMsg();
2264 },
2265 error: function (a) {
2266
2267 var msg = a.responseText;
2268 $("#Page").html("Error on Logging!" + msg);
2269
2270 // $("#Page").html("Error on Logging!");
2271 }
2272 });
2273}
2274
2275
2276// function speedtest() {
2277// // alert($('#myImage').prop('complete'));
2278// // var img1 = new Image();
2279// // $('#myImage').attr('src', 'http://c765480.r80.cf2.rackcdn.com/testdownload.jpg?' + (new Date()).getTime());
2280// startTime = (new Date()).getTime();
2281// $('#TestDownloadImage').attr('src', 'http://c765480.r80.cf2.rackcdn.com/testdownload2.jpg?' + (new Date()).getTime()).load(function () {
2282// // alert('Image Loaded');
2283// endTime = (new Date()).getTime();
2284// showResults()
2285// });
2286//// var myImage = $(document.createElement('img'));
2287//// myImage.addEvent('load', function (e) { alert('Image is done loading!'); });
2288//// myImage.src = 'http://c765480.r80.cf2.rackcdn.com/testdownload.tif?' + new (new Date()).getTime();
2289
2290// }
2291
2292
2293
2294function speedtest() {
2295
2296 if (downloadspeed.mp4suffix.indexOf('_220') != -1 || downloadspeed.mp4suffix.indexOf('_128') != -1) {
2297 showResults();
2298 return;
2299 }
2300
2301
2302
2303 if (isdesktop != "1") {
2304 endTime = (new Date()).getTime();
2305 showResults();
2306 return;
2307 }
2308
2309
2310 var download = new Image();
2311 download.onload = function () {
2312 endTime = (new Date()).getTime();
2313 showResults();
2314 }
2315
2316
2317
2318
2319 startTime = (new Date()).getTime();
2320 //download.src = 'http://c765480.r80.cf2.rackcdn.com/testdownload2.jpg?' + (new Date()).getTime()
2321 //download.src = 'https://e987e050533c7864f337-bc2b59f4f47baec65ec3c19464229c59.ssl.cf2.rackcdn.com/testdownload2.jpg?' + (new Date()).getTime()
2322 download.src = 'https://c12448673.ssl.cf2.rackcdn.com/testdownload2.jpg?' + (new Date()).getTime()
2323
2324}
2325
2326function showResults() {
2327 var duration = Math.round((endTime - startTime) / 1000);
2328
2329 if (duration > 0) {
2330 var bitsLoaded = downloadSize * 8;
2331 downloadspeed.speedBps = Math.round(bitsLoaded / duration);
2332 downloadspeed.speedKbps = (downloadspeed.speedBps / 1024).toFixed(0);
2333 downloadspeed.speedMbps = (downloadspeed.speedKbps / 1024).toFixed(0);
2334
2335 $.ajax({
2336 url: url + "IMobieService.svc/GetMP4Suffix/" + userclss.CompanyID + "/" + downloadspeed.speedKbps,
2337 dataType: "jsonp",
2338 success: function (data) {
2339 downloadspeed.mp4suffix = data.GetMP4SuffixResult;
2340 },
2341 beforeSend: function () {
2342 if (typeof $.mobile !== 'undefined')
2343 $.mobile.showPageLoadingMsg();
2344 },
2345 complete: function () {
2346 if (typeof $.mobile !== 'undefined')
2347 $.mobile.hidePageLoadingMsg();
2348 },
2349 error: function (a) {
2350 $("#Page").html("Error on peformning download speed test");
2351 }
2352 });
2353 // alert("Your connection speed is: \n" +
2354 //// downloadspeed.speedBps + " bps\n" +
2355 // downloadspeed.speedKbps + " kbps\n" +
2356 // downloadspeed.speedMbps + " Mbps\n");
2357 }
2358 loadLoginConfirmation(userclss);
2359}
2360
2361
2362function getMP4SuffixInitial() {
2363
2364
2365 $.ajax({
2366 url: url + "IMobieService.svc/GetMP4Suffix/" + userclss.CompanyID + "/" + "-1",
2367 dataType: "jsonp",
2368 success: function (data) {
2369 downloadspeed.mp4suffix = data.GetMP4SuffixResult;
2370 speedtest();
2371 },
2372 beforeSend: function () {
2373 if (typeof $.mobile !== 'undefined')
2374 $.mobile.showPageLoadingMsg();
2375 },
2376 complete: function () {
2377 if (typeof $.mobile !== 'undefined')
2378 $.mobile.hidePageLoadingMsg();
2379 },
2380 error: function (a) {
2381 $("#Page").html("Error on peformning download speed test");
2382 speedtest();
2383 }
2384 });
2385 // alert("Your connection speed is: \n" +
2386 //// downloadspeed.speedBps + " bps\n" +
2387 // downloadspeed.speedKbps + " kbps\n" +
2388 // downloadspeed.speedMbps + " Mbps\n");
2389
2390
2391}
2392
2393
2394function logout() {
2395 //Check for IE in compatability mode
2396 var uagent = navigator.userAgent.toLowerCase();
2397 var userDevice = "";
2398 if (uagent.search("msie 7.0") > -1)
2399 userDevice = "ie";
2400 else if (uagent.search("trident/7.0") > -1)
2401 userDevice = "ie";
2402 else if (uagent.search("trident/6.0") > -1)
2403 userDevice = "ie";
2404 else if (uagent.search("trident/5.0") > -1)
2405 userDevice = "ie";
2406 else if (uagent.search("trident/4.0") > -1)
2407 userDevice = "ie";
2408 else if (uagent.search("iemobile") > -1)
2409 userDevice = "iemob";
2410
2411
2412
2413 var referer = '0';
2414
2415
2416 if (document.referrer != '')
2417 referer = encodeURI(document.referrer.split('/')[2].split(':')[0]);
2418
2419
2420 var ref1 = GetQueryStringParms('ref1');
2421 if (typeof ref1 != 'undefined')
2422 referer = encodeURI(ref1);
2423
2424 var locDeviceType = 0;
2425 if (typeof deviceType != 'undefined')
2426 locDeviceType = deviceType;
2427
2428
2429 var customLogout = getParamExistValue('loredir');
2430 if (customLogout != '') {
2431
2432 window.location.href = customLogout;
2433 return;
2434 }
2435
2436
2437 if (locDeviceType == 1)
2438 window.location.href = "https://drivertech.infinit-i.net/drivertech.htm?referer=" + referer;
2439 else if (userDevice == "ie") {
2440 window.location.href = "https://classroom.infinit-i.net/desktop.htm";
2441 } else if (userDevice == "iemob") {
2442 window.location.href = "https://classroom.infinit-i.net/imobile.htm";
2443 } else {
2444 //if (isdesktop=="0")
2445 //window.location.href = "https://mobile.infinit-i.net/?referer=" + referer;
2446 //else
2447 window.location.href = "https://classroom.infinit-i.net/?referer=" + referer;
2448
2449
2450 }
2451
2452
2453}
2454
2455function loadtooldesc(toolid, leftpos) {
2456
2457
2458 $("#lendingpopup").offset({
2459 left: leftpos
2460 });
2461 if (toolid == '') {
2462 $("#lendingpopup").html('').css('visibility', 'hidden');
2463
2464 } else {
2465 $("#lendingpopup").html('');
2466 $.ajax({
2467 url: url + "IMobieService.svc/GeToolDesc/" + toolid,
2468 dataType: "jsonp",
2469 success: function (data) {
2470 $("#lendingpopup").html(data.GetToolDescResult.toolDesc).css('visibility', 'visible');
2471
2472 },
2473 beforeSend: function () {
2474 $("#lendingpopup").html('').css('visibility', 'hidden');
2475 },
2476 complete: function () {
2477
2478 },
2479 error: function (a) {
2480 $("#lendingpopup").html('').css('visibility', 'hidden');
2481 }
2482 });
2483 }
2484
2485
2486}
2487
2488function iOS() {
2489
2490 var iDevices = [
2491 'iPad Simulator',
2492 'iPhone Simulator',
2493 'iPod Simulator',
2494 'iPad',
2495 'iPhone',
2496 'iPod'
2497 ];
2498
2499 if (!!navigator.platform) {
2500 while (iDevices.length) {
2501 if (navigator.platform === iDevices.pop()) {
2502 return true;
2503 }
2504 }
2505 }
2506
2507 return false;
2508}