Advertisement
Guest User

Untitled

a guest
Jan 8th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function initMspSettings() {
  2.     var n = {},
  3.         t = null,
  4.         r = function() {
  5.             return $("#webAPIRoot").text()
  6.         },
  7.         u = function() {
  8.             return parseInt($("#maxTimeSpanHours").text())
  9.         },
  10.         i = function() {
  11.             return $("#culture").text()
  12.         },
  13.         f = function() {
  14.             var n = i(),
  15.                 t = n.length > 1 ? n.slice(0, 2) : "en";
  16.             return t.toLowerCase()
  17.         },
  18.         e = function() {
  19.             return $("#webSyncServerUri").text()
  20.         },
  21.         o = function() {
  22.             return $("#webApplicationRoot").text()
  23.         },
  24.         s = function() {
  25.             var n = sessionStorage.accessToken || $("#tkn").text();
  26.             return n ? (sessionStorage.accessToken || (sessionStorage.accessToken = n), n) : null
  27.         },
  28.         h = function() {
  29.             var n = t || $("#tkn").text();
  30.             return n ? (t || (t = n), {
  31.                 Authorization: "Bearer " + n
  32.             }) : {}
  33.         },
  34.         c = function() {
  35.             var n = 0;
  36.             return $("#dealerInfoTabIsVisible").text().toLowerCase() == "true" && $("#dealerInfoTabIsDefault").text().toLowerCase() == "true" && (n = 5), n
  37.         };
  38.     n.getWebApiRoot = r;
  39.     n.getMaxTimeSpanHours = u;
  40.     n.getUserCulture = i;
  41.     n.getLanguage = f;
  42.     n.getWebSyncServerUri = e;
  43.     n.getWebApplicationRoot = o;
  44.     n.getSecurityHeaders = h;
  45.     n.getAccessToken = s;
  46.     n.getDefaultTabIndex = c;
  47.     n.DAY_MILLISEC = 864e5;
  48.     n.JSON_POST_LOCALTIMEFORMAT = "yyyy-MM-ddTHH:mm:ss";
  49.     n.QUERYSTRING_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
  50.     window.mspSettings = n
  51. }
  52.  
  53. function initUiUtil() {
  54.     function t(n, t) {
  55.         return (t -= n.toString().length, t > 0) ? new Array(t + (/\./.test(n) ? 2 : 1)).join("0") + n : n + ""
  56.     }
  57.     var n = {},
  58.         i = (new Date).getTimezoneOffset();
  59.     n.okDialogForShortMessage = function(n, t) {
  60.         var i = $("<div style='margin: 6px;'><p><\/p><p>" + t + "<\/p><br/><div style='text-align: center;'><button class='btnOk k-button'>" + lang.crudText().close + "<\/button><\/div><\/div>").kendoWindow({
  61.             title: n,
  62.             resizable: !1,
  63.             modal: !0
  64.         });
  65.         i.data("kendoWindow").center().open();
  66.         i.find(".btnOk").click(function() {
  67.             i.data("kendoWindow").close()
  68.         }).end()
  69.     };
  70.     n.isTripJournalRole = function() {
  71.         return $.inArray("TripJournalUser", window.mspRoles) > -1
  72.     };
  73.     n.isCompanyFleetsViewerRole = function() {
  74.         return $.inArray("CompanyFleetsViewer", window.mspRoles) > -1
  75.     };
  76.     n.isDriverBehaviorRole = function() {
  77.         return $.inArray("DriverBehavior", window.mspRoles) > -1
  78.     };
  79.     n.isDriverBehaviorRole_Fleets = function() {
  80.         return $.inArray("DriverBehavior_Fleets", window.mspRoles) > -1
  81.     };
  82.     n.isCompanyAdminRole = function() {
  83.         return $.inArray("CompanyAdmin", window.mspRoles) > -1
  84.     };
  85.     n.isRealtimeTrackingRole = function() {
  86.         return $.inArray("RealtimeTracking", window.mspRoles) > -1
  87.     };
  88.     n.isRealtimeTrackingRole_Fleets = function() {
  89.         return $.inArray("RealtimeTracking_Fleets", window.mspRoles) > -1
  90.     };
  91.     n.isViewPrivateTripsRole_Fleets = function() {
  92.         return $.inArray("ViewPrivateTrips_Fleets", window.mspRoles) > -1
  93.     };
  94.     n.toDateTimeWithSecondsString = function(n) {
  95.         return kendo.toString(n, kendo.culture().calendar.patterns.G)
  96.     };
  97.     n.toDateTimeString = function(n) {
  98.         return kendo.toString(n, kendo.culture().calendar.patterns.g)
  99.     };
  100.     n.toDateString = function(n) {
  101.         return kendo.toString(n, kendo.culture().calendar.patterns.d)
  102.     };
  103.     n.toTimeString = function(n) {
  104.         return kendo.toString(n, kendo.culture().calendar.patterns.t)
  105.     };
  106.     n.toDateTimeStringFromISO8601 = function(n) {
  107.         return n ? kendo.toString(new Date(Date.parseISO8601(n)), kendo.culture().calendar.patterns.g) : ""
  108.     };
  109.     n.toWeekdayDateTimeString = function(n) {
  110.         return n ? kendo.toString(new Date(Date.parseISO8601(n)), "ddd") + " " + kendo.toString(new Date(Date.parseISO8601(n)), kendo.culture().calendar.patterns.g) : ""
  111.     };
  112.     n.toWeekdayDateString = function(n) {
  113.         return n ? kendo.toString(new Date(Date.parseISO8601(n)), "ddd") + " " + kendo.toString(new Date(Date.parseISO8601(n)), kendo.culture().calendar.patterns.d) : ""
  114.     };
  115.     n.toDateStringFromISO8601 = function(n) {
  116.         return kendo.toString(new Date(Date.parseISO8601(n)), kendo.culture().calendar.patterns.d)
  117.     };
  118.     n.toTimeStringFromISO8601 = function(n) {
  119.         return kendo.toString(new Date(Date.parseISO8601(n)), kendo.culture().calendar.patterns.t)
  120.     };
  121.     n.parseDate = function(n) {
  122.         return kendo.parseDate(n, kendo.culture().calendar.patterns.d)
  123.     };
  124.     n.parseDateTime = function(n) {
  125.         return kendo.parseDate(n, kendo.culture().calendar.patterns.g)
  126.     };
  127.     n.parseDateFromISO8601 = function(n) {
  128.         return new Date(Date.parseISO8601(n)).clearTime()
  129.     };
  130.     n.parseDateTimeFromISO8601 = function(n) {
  131.         return new Date(Date.parseISO8601(n))
  132.     };
  133.     n.toBrowserLocalTimeFromUtcTime = function(n) {
  134.         var t = 0 - i;
  135.         return n.addMinutes(t)
  136.     };
  137.     n.toUTCTimeFromBrowserLocalTime = function(n) {
  138.         var t = i;
  139.         return n.addMinutes(t)
  140.     };
  141.     n.showTimeSpan = function(n) {
  142.         var i = new Date(n);
  143.         return t(Math.floor(n / 36e5), 2) + ":" + t(i.getMinutes(), 2) + ":" + t(i.getSeconds(), 2)
  144.     };
  145.     n.showTimeSpanMinutes = function(n) {
  146.         var i = new Date(n);
  147.         return t(Math.floor(n / 36e5), 2) + ":" + t(i.getMinutes(), 2)
  148.     };
  149.     n.getCurrentMonthTimespan = function() {
  150.         var n = Date.today(),
  151.             i = new Date(n.getFullYear(), n.getMonth(), 1),
  152.             t;
  153.         return n.addMonths(1), t = new Date(n.getFullYear(), n.getMonth(), 1).addDays(-1), {
  154.             begin: i,
  155.             end: t
  156.         }
  157.     };
  158.     n.getPrevMonthTimespan = function() {
  159.         var t = Date.today(),
  160.             n = new Date(t.getFullYear(), t.getMonth(), 1).addDays(-1),
  161.             i = new Date(n.getFullYear(), n.getMonth(), 1);
  162.         return {
  163.             begin: i,
  164.             end: n
  165.         }
  166.     };
  167.     n.getCurrentWeekTimespan = function() {
  168.         var t = Date.today(),
  169.             n = t.clone(),
  170.             i;
  171.         return t.getDay() !== kendo.culture().calendar.firstDay && n.moveToDayOfWeek(kendo.culture().calendar.firstDay, -1), i = n.clone(), {
  172.             begin: n,
  173.             end: i.addDays(6)
  174.         }
  175.     };
  176.     n.getPrevWeekTimespan = function() {
  177.         var t = Date.today(),
  178.             n = t.clone(),
  179.             i;
  180.         return n.moveToDayOfWeek(kendo.culture().calendar.firstDay, -1), t.getDay() > kendo.culture().calendar.firstDay && n.moveToDayOfWeek(kendo.culture().calendar.firstDay, -1), i = n.clone(), {
  181.             begin: n,
  182.             end: i.addDays(6)
  183.         }
  184.     };
  185.     n.getQueryParameterByName = function(n) {
  186.         n = n.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  187.         var i = new RegExp("[\\?&]" + n + "=([^&#]*)"),
  188.             t = i.exec(location.search);
  189.         return t == null ? "" : decodeURIComponent(t[1].replace(/\+/g, " "))
  190.     };
  191.     n.getArrowImageName = function(n) {
  192.         var t = "SmallBlueCircle.png";
  193.         switch (!0) {
  194.             case n > 337.5 || n <= 22.5:
  195.                 t = "Arrows/SmallBlueCircleNorth.png";
  196.                 break;
  197.             case n > 22.5 && n <= 67.5:
  198.                 t = "Arrows/SmallBlueCircleNorthEast.png";
  199.                 break;
  200.             case n > 67.5 && n <= 112.5:
  201.                 t = "Arrows/SmallBlueCircleEast.png";
  202.                 break;
  203.             case n > 112.5 && n <= 157.5:
  204.                 t = "Arrows/SmallBlueCircleSouthEast.png";
  205.                 break;
  206.             case n > 157.5 && n <= 202.5:
  207.                 t = "Arrows/SmallBlueCircleSouth.png";
  208.                 break;
  209.             case n > 202.5 && n <= 247.5:
  210.                 t = "Arrows/SmallBlueCircleSouthWest.png";
  211.                 break;
  212.             case n > 247.5 && n <= 292.5:
  213.                 t = "Arrows/SmallBlueCircleWest.png";
  214.                 break;
  215.             case n > 292.5 && n <= 337.5:
  216.                 t = "Arrows/SmallBlueCircleNorthWest.png";
  217.                 break;
  218.             default:
  219.                 t = "SmallBlueCircle.png"
  220.         }
  221.         return "Images/Map/" + t
  222.     };
  223.     n.showAjaxLoaderImage = function(n) {
  224.         var t = $("<div id='divAjaxLoaderImage' style='position:fixed; top:48%; left: 49%;z-index:999; width: 50px; height: 50px; ' class='k-loading-image'><\/div>");
  225.         n ? t.appendTo(n) : t.appendTo("body")
  226.     };
  227.     n.hideAjaxLoaderImage = function() {
  228.         $("#divAjaxLoaderImage").remove()
  229.     };
  230.     n.changePassword = function(n, t) {
  231.         function u(n, i) {
  232.             var r = {
  233.                 UserId: n.UserId,
  234.                 Password: i
  235.             };
  236.             uiUtil.easyroadAjaxPost({
  237.                 url: "/api/admin/setuserpassword?companyId=" + t,
  238.                 data: r,
  239.                 success: function() {}
  240.             })
  241.         }
  242.         var i = $("#changePasswordWindow").kendoWindow({
  243.                 title: lang.actionText().changePassword,
  244.                 modal: !0,
  245.                 visible: !1,
  246.                 resizable: !1,
  247.                 width: 450
  248.             }).data("kendoWindow"),
  249.             f = kendo.template($("#changePasswordTemplate").html()),
  250.             e = {
  251.                 usernameLbl: lang.labels().editPassword.userName,
  252.                 username: n.Username,
  253.                 newPasswordLbl: lang.labels().editPassword.newPassword1,
  254.                 newPasswordLbl2: lang.labels().editPassword.newPassword2,
  255.                 acceptBtnLbl: lang.crudText().accept,
  256.                 cancelBtnLbl: lang.crudText().cancel
  257.             },
  258.             r;
  259.         i.content(f(e));
  260.         i.center().open();
  261.         r = $("#changePassword-container").kendoValidator({
  262.             rules: {
  263.                 validPassword: function(n) {
  264.                     return (n.val() || "").length > 2
  265.                 },
  266.                 confirmPassword: function() {
  267.                     var n = $("#newPassword").val(),
  268.                         t = $("#newPassword2").val();
  269.                     return n === t
  270.                 }
  271.             },
  272.             messages: {
  273.                 validPassword: lang.validationMsg().password,
  274.                 confirmPassword: lang.validationMsg().passwordConfirm
  275.             },
  276.             validateOnBlur: !1
  277.         }).data("kendoValidator");
  278.         $("#btnAcceptNewPassword").click(function() {
  279.             if (r.validate()) {
  280.                 var t = $("#newPassword").val();
  281.                 u(n, t);
  282.                 i.close()
  283.             }
  284.         });
  285.         $("#btnCancelNewPassword").click(function() {
  286.             i.close()
  287.         })
  288.     };
  289.     n.easyroadAjaxGet = function(n) {
  290.         var t = n || {
  291.             url: "",
  292.             data: {},
  293.             success: function() {},
  294.             error: null,
  295.             async: !0
  296.         };
  297.         return $.ajax({
  298.             url: mspSettings.getWebApiRoot() + t.url,
  299.             headers: mspSettings.getSecurityHeaders(),
  300.             dataType: "json",
  301.             cache: !1,
  302.             async: t.async == undefined || !!t.async,
  303.             data: t.data || {},
  304.             success: t.success || null,
  305.             error: function(t, i, r) {
  306.                 t.status == 401 ? $("#signOutButton").get(0).click() : n.error && n.error.call(t, i, r)
  307.             }
  308.         })
  309.     };
  310.     n.easyroadAjaxPost = function(n) {
  311.         var t = n || {
  312.                 url: "",
  313.                 data: {},
  314.                 success: function() {},
  315.                 error: null
  316.             },
  317.             i = kendo.stringify(t.data || {});
  318.         return $.ajax({
  319.             url: mspSettings.getWebApiRoot() + t.url,
  320.             headers: mspSettings.getSecurityHeaders(),
  321.             dataType: "json",
  322.             type: "POST",
  323.             data: i,
  324.             cache: !1,
  325.             contentType: "application/json",
  326.             success: t.success || null,
  327.             error: function(t, i, r) {
  328.                 t.status === 401 ? $("#signOutButton").get(0).click() : n.error && n.error.call(t, i, r)
  329.             }
  330.         })
  331.     };
  332.     window.uiUtil = n
  333. }
  334.  
  335. function addDeviceCheckText(n) {
  336.     n.languages.en.deviceCheck = {
  337.         startDeviceSearchText: "Searching device...",
  338.         messagesTitleText: "Last message(s)",
  339.         cancelMessage: "Cancelling...",
  340.         pageTitleText: "Device check",
  341.         btnMessageCheckText: "Start",
  342.         btnCancelCheckText: "Cancel",
  343.         lblDeviceSerialNrText: "Give device serialnumber",
  344.         lblDeviceTypeText: "and device type",
  345.         deviceFoundText1: "Device",
  346.         deviceFoundText2: "found",
  347.         insertDeviceInstall: "Add device installation info",
  348.         serialNumber: "Serialnumber",
  349.         deviceType: "Device type",
  350.         customer: "Customer",
  351.         searchDevice: "Search device",
  352.         tabInstallationText: "Device installation info",
  353.         tabMessagesText: "Device messages",
  354.         frmLblInstallDate: "Install date",
  355.         frmLblInstallerName: "Installer name",
  356.         frmLblInstallerEmail: "Installer email",
  357.         frmLblVehiclePlateNr: "Vehicle plate nr.",
  358.         frmLblVehicleOdometerVal: "Vehicle odometer value",
  359.         frmLblNotes: "Notes"
  360.     };
  361.     n.languages.fi.deviceCheck = {
  362.         startDeviceSearchText: "Etsitään laitetta...",
  363.         messagesTitleText: "Viesti(t)",
  364.         cancelMessage: "Peruutetaan...",
  365.         pageTitleText: "Laitteen tarkistus",
  366.         btnMessageCheckText: "Aloita",
  367.         btnCancelCheckText: "Peruuta",
  368.         lblDeviceSerialNrText: "Anna laitteen sarjanumero",
  369.         lblDeviceTypeText: "sekä laitteen tyyppi",
  370.         deviceFoundText1: "Laite",
  371.         deviceFoundText2: "löytyi",
  372.         insertDeviceInstall: "Lisää laitteen asennustiedot",
  373.         serialNumber: "Sarjanumero",
  374.         deviceType: "Laitteen tyyppi",
  375.         customer: "Asiakas",
  376.         searchDevice: "Etsi laite",
  377.         tabInstallationText: "Laitteen asennustiedot",
  378.         tabMessagesText: "Laitteen viestitys",
  379.         frmLblInstallDate: "Asennuspäivä",
  380.         frmLblInstallerName: "Asentaja",
  381.         frmLblInstallerEmail: "Asentajan sposti",
  382.         frmLblVehiclePlateNr: "Ajoneuvon rek.nro",
  383.         frmLblVehicleOdometerVal: "Ajoneuvon mittarilukema",
  384.         frmLblNotes: "Muut tiedot"
  385.     };
  386.     n.languages.sv.deviceCheck = {
  387.         startDeviceSearchText: "Söker efter enhet...",
  388.         messagesTitleText: "Meddelande(n)",
  389.         cancelMessage: "Annuleras...",
  390.         pageTitleText: "Kontroll av enhet",
  391.         btnMessageCheckText: "Starta",
  392.         btnCancelCheckText: "Annulera",
  393.         lblDeviceSerialNrText: "Ge enhetens serienummer",
  394.         lblDeviceTypeText: "och typ av enhet",
  395.         deviceFoundText1: "Enhet",
  396.         deviceFoundText2: "hittades",
  397.         insertDeviceInstall: "Lägg till installations info",
  398.         serialNumber: "Serienummer",
  399.         deviceType: "Typ av enhet",
  400.         customer: "Kund",
  401.         searchDevice: "Sök enhet",
  402.         tabInstallationText: "Installations info",
  403.         tabMessagesText: "Test av enhet",
  404.         frmLblInstallDate: "Installationsdatum",
  405.         frmLblInstallerName: "Namn installatör",
  406.         frmLblInstallerEmail: "Epost installatör",
  407.         frmLblVehiclePlateNr: "Registreringsnummer",
  408.         frmLblVehicleOdometerVal: "Vägmätarställning",
  409.         frmLblNotes: "Anteckningar"
  410.     };
  411.     n.languages.fr.deviceCheck = {
  412.         startDeviceSearchText: "En recherchant l'appareil...",
  413.         messagesTitleText: "Les derniers messages",
  414.         cancelMessage: "En annulant...",
  415.         pageTitleText: "Vérifier l'appareil",
  416.         btnMessageCheckText: "Commencer",
  417.         btnCancelCheckText: "Annuler",
  418.         lblDeviceSerialNrText: "Taper le numéro de série d'appareil",
  419.         lblDeviceTypeText: "et modèle d'appareil",
  420.         deviceFoundText1: "Appareil",
  421.         deviceFoundText2: "trouvé",
  422.         insertDeviceInstall: "Ajouter les données de l'installation d'appareil",
  423.         serialNumber: "Numéro de série",
  424.         deviceType: "Modèle d'appareil",
  425.         customer: "Client",
  426.         searchDevice: "Rechercer l'appareil",
  427.         tabInstallationText: "Les données de l'installation d'appareil",
  428.         tabMessagesText: "Messages d'appareil",
  429.         frmLblInstallDate: "Date de l'installation",
  430.         frmLblInstallerName: "Nom de l'installateur",
  431.         frmLblInstallerEmail: "Adresse courriel de l'installateur",
  432.         frmLblVehiclePlateNr: "Le numéro d'immatriculation du véhicule",
  433.         frmLblVehicleOdometerVal: "La valeur d'odomètre du véhicule",
  434.         frmLblNotes: "Note"
  435.     };
  436.     n.deviceCheck = function() {
  437.         return n.languages.current.deviceCheck
  438.     }
  439. }
  440.  
  441. function initDeviceCheck() {
  442.     function yt() {
  443.         n = !1;
  444.         t = !1;
  445.         h = 0;
  446.         s = 0;
  447.         c = null;
  448.         r = null;
  449.         e = ""
  450.     }
  451.  
  452.     function pt() {
  453.         $("#divSearch").hide();
  454.         deviceCheckTabs.disable("#tabDeviceInstall")
  455.     }
  456.  
  457.     function wt() {
  458.         $("#divSearch").show();
  459.         deviceCheckTabs.enable("#tabDeviceInstall")
  460.     }
  461.  
  462.     function bt() {
  463.         var r = uiUtil.getQueryParameterByName("lang"),
  464.             n = "en-US",
  465.             t;
  466.         switch (r.toLocaleLowerCase()) {
  467.             case "fi":
  468.                 n = "fi-FI";
  469.                 break;
  470.             case "se":
  471.                 n = "sv-SE";
  472.                 break;
  473.             case "sv":
  474.                 n = "sv-SE";
  475.                 break;
  476.             case "fr":
  477.                 n = "fr-FR"
  478.         }
  479.         t = n.substr(0, 2);
  480.         kendo.culture(n);
  481.         lang.language(t);
  482.         addDeviceCheckText(window.lang);
  483.         ct.text(lang.deviceCheck().pageTitleText);
  484.         i.text(lang.deviceCheck().btnMessageCheckText);
  485.         st.text(lang.deviceCheck().lblDeviceSerialNrText);
  486.         ht.text(lang.deviceCheck().lblDeviceTypeText);
  487.         $("#btnSearchText").text(" " + lang.deviceCheck().searchDevice);
  488.         $("#btnAddText").text(" " + lang.deviceCheck().insertDeviceInstall);
  489.         $("#tabDeviceInstall a").text(lang.deviceCheck().tabInstallationText);
  490.         $("#tabDeviceMessageCheck a").text(lang.deviceCheck().tabMessagesText);
  491.         $("#formLblSerialnumber").text(lang.deviceCheck().serialNumber);
  492.         $("#formLblDeviceType").text(lang.deviceCheck().deviceType);
  493.         $("#formLblCustomer").text(lang.deviceCheck().customer);
  494.         $("#formLblInstallDate").text(lang.deviceCheck().frmLblInstallDate);
  495.         $("#formLblInstallerName").text(lang.deviceCheck().frmLblInstallerName);
  496.         $("#formLblInstallerEmail").text(lang.deviceCheck().frmLblInstallerEmail);
  497.         $("#formLblVehicleOdometerVal").text(lang.deviceCheck().frmLblVehicleOdometerVal);
  498.         $("#formLblVehiclePlateNr").text(lang.deviceCheck().frmLblVehiclePlateNr);
  499.         $("#formLblNotes").text(lang.deviceCheck().frmLblNotes);
  500.         deviceCheckTabs.disable("#tabDeviceInstall");
  501.         deviceCheckTabs.disable("#tabDeviceMessageCheck")
  502.     }
  503.  
  504.     function a() {
  505.         var n = window.location.href;
  506.         return n.indexOf("?") > -1 && (n = n.split("?")[0]), n
  507.     }
  508.  
  509.     function dt(n) {
  510.         var t = uiUtil.toBrowserLocalTimeFromUtcTime(uiUtil.parseDateTimeFromISO8601(n.DeviceTime)),
  511.             i = "<span>" + uiUtil.toDateTimeWithSecondsString(t) + "&nbsp;<\/span>",
  512.             r = n.Latitude && n.Longitude ? kendo.toString(n.Latitude, "n8") + " " + kendo.toString(n.Longitude, "n8") : "-",
  513.             u = "&nbsp;&nbsp;<span>GPS (" + r + ")<\/span>",
  514.             f = "&nbsp;&nbsp;<span>Status (" + n.Status + ")<\/span>";
  515.         return '<div class="message">' + i + f + u + "<\/div>"
  516.     }
  517.  
  518.     function gt(n) {
  519.         $("<li>" + dt(n) + "<\/li>").prependTo("#messageList").hide().slideDown();
  520.         for (var t = l.children("li").length; t > 9; t--) $(l.children("li")[t]).fadeOut("fast", function() {
  521.             $(l.children("li")[t]).remove()
  522.         })
  523.     }
  524.  
  525.     function ni() {
  526.         if (u.val().length < 1) {
  527.             uiUtil.okDialogForShortMessage("", lang.deviceCheck().lblDeviceSerialNrText + "!");
  528.             return
  529.         }
  530.         yt();
  531.         i.text(lang.deviceCheck().btnCancelCheckText);
  532.         u.attr("disabled", !0);
  533.         f.text(lang.deviceCheck().startDeviceSearchText);
  534.         pt();
  535.         nt()
  536.     }
  537.  
  538.     function w() {
  539.         n = !0;
  540.         t = !0;
  541.         e = "";
  542.         v.text("");
  543.         $("li", l).remove();
  544.         f.text(lang.deviceCheck().cancelMessage);
  545.         i.hide()
  546.     }
  547.  
  548.     function d() {
  549.         u.removeAttr("disabled");
  550.         n = !1;
  551.         t = !1;
  552.         f.text("");
  553.         i.text(lang.deviceCheck().btnMessageCheckText);
  554.         i.show();
  555.         wt()
  556.     }
  557.  
  558.     function ti() {
  559.         e.length > 15 ? e = "" : e += ".";
  560.         f.text(lang.deviceCheck().startDeviceSearchText + e)
  561.     }
  562.  
  563.     function ii() {
  564.         n = !0;
  565.         v.text(lang.deviceCheck().messagesTitleText);
  566.         r && tt(r.DeviceId)
  567.     }
  568.  
  569.     function g(n) {
  570.         if (n.Data[0].InstallDate) {
  571.             var t = uiUtil.parseDateFromISO8601(n.Data[0].InstallDate);
  572.             n.Data[0].InstallDate = t
  573.         } else n.Data[0].InstallDate = new Date;
  574.         y.devInst = n.Data[0];
  575.         kendo.bind(lt, y);
  576.         deviceCheckTabs.enable("#tabDeviceInstall");
  577.         deviceCheckTabs.enable("#tabDeviceMessageCheck");
  578.         deviceCheckTabs.select("#tabDeviceInstall")
  579.     }
  580.  
  581.     function ri() {
  582.         deviceCheckTabs.disable("#tabDeviceInstall");
  583.         deviceCheckTabs.disable("#tabDeviceMessageCheck");
  584.         $.ajax({
  585.             type: "GET",
  586.             async: !0,
  587.             url: mspSettings.getWebApiRoot() + "/api/devicecheck/GetDeviceInstall?noCache=_" + (new Date).getTime(),
  588.             success: function(n) {
  589.                 if (n.Data && n.Data.length > 0) {
  590.                     var t = n.Data[0];
  591.                     t.DeviceTypeId > 0 ? g(n) : (deviceCheckTabs.enable("#tabDeviceMessageCheck"), deviceCheckTabs.select("#tabDeviceMessageCheck"))
  592.                 }
  593.             },
  594.             data: {
  595.                 serialNumber: u.val(),
  596.                 deviceTypeId: b.val()
  597.             },
  598.             dataType: "json"
  599.         })
  600.     }
  601.  
  602.     function nt() {
  603.         $.ajax({
  604.             type: "GET",
  605.             async: !0,
  606.             url: mspSettings.getWebApiRoot() + "/api/devicecheck/GetDevice?noCache=_" + (new Date).getTime(),
  607.             success: function(t) {
  608.                 if (s++, s > et) {
  609.                     s = 0;
  610.                     w();
  611.                     return
  612.                 }
  613.                 if (t.Data && t.Data.length > 0) {
  614.                     var i = t.Data[0];
  615.                     if (i && i.DeviceId > 0) {
  616.                         f.text(lang.deviceCheck().deviceFoundText1 + " " + i.SerialNumber + " (v. " + i.VersionInfo + ") " + lang.deviceCheck().deviceFoundText2 + ".");
  617.                         r = i;
  618.                         n = !0;
  619.                         ii();
  620.                         return
  621.                     }
  622.                 }
  623.                 ti()
  624.             },
  625.             data: {
  626.                 deviceSerialNumber: u.val(),
  627.                 deviceTypeId: b.val()
  628.             },
  629.             error: function() {},
  630.             dataType: "json",
  631.             complete: function() {
  632.                 n ? t && d() : setTimeout(nt, ut)
  633.             }
  634.         })
  635.     }
  636.  
  637.     function tt() {
  638.         $.ajax({
  639.             type: "GET",
  640.             async: !0,
  641.             url: mspSettings.getWebApiRoot() + "/api/devicecheck/GetLastDeviceTracking?noCache=_" + (new Date).getTime(),
  642.             success: function(n) {
  643.                 var i = n.Data;
  644.                 if (i.length > 0) {
  645.                     if (h++, h > ot) {
  646.                         h = 0;
  647.                         w();
  648.                         return
  649.                     }
  650.                     if (c && c.DeviceTime == i[0].DeviceTime) return;
  651.                     c = i[0];
  652.                     t || gt({
  653.                         DeviceTime: i[0].DeviceTime,
  654.                         Status: i[0].Status,
  655.                         Latitude: i[0].Latitude,
  656.                         Longitude: i[0].Longitude
  657.                     })
  658.                 }
  659.             },
  660.             data: {
  661.                 deviceId: r.DeviceId
  662.             },
  663.             error: function() {},
  664.             dataType: "json",
  665.             complete: function() {
  666.                 t ? d() : setTimeout(tt, ft)
  667.             }
  668.         })
  669.     }
  670.  
  671.     function ui() {
  672.         it = $("#inputDeviceType").kendoDropDownList({
  673.             dataTextField: "Item2",
  674.             dataValueField: "Item1",
  675.             animation: !1,
  676.             dataSource: p
  677.         }).data("kendoDropDownList")
  678.     }
  679.  
  680.     function rt(n) {
  681.         return $.ajax({
  682.             url: mspSettings.getWebApiRoot() + "/api/DeviceCheck/UpsertDeviceInstall?noCache=_" + (new Date).getTime(),
  683.             dataType: "json",
  684.             type: "POST",
  685.             cache: !1,
  686.             data: kendo.stringify(n),
  687.             contentType: "application/json"
  688.         })
  689.     }
  690.  
  691.     function fi() {
  692.         function r(n, t) {
  693.             var i = {
  694.                 Id: 0,
  695.                 SerialNumber: n,
  696.                 DeviceTypeId: t
  697.             };
  698.             rt(i).done(function(n) {
  699.                 o.close();
  700.                 g(n)
  701.             })
  702.         }
  703.         var u = $("#dialogWindow"),
  704.             t, n, i;
  705.         o = u.kendoWindow({
  706.             title: lang.deviceCheck().insertDeviceInstall,
  707.             modal: !0,
  708.             visible: !1,
  709.             resizable: !1,
  710.             width: 450
  711.         }).data("kendoWindow");
  712.         t = kendo.template($("#insertInstallationTemplate").html());
  713.         n = {
  714.             serialNumber: $("#inputDeviceSerialNr").val(),
  715.             deviceTypeId: $("#inputDeviceType").val(),
  716.             lblSerialNr: lang.deviceCheck().serialNumber,
  717.             lblDeviceType: lang.deviceCheck().deviceType,
  718.             acceptBtnLbl: lang.crudText().accept,
  719.             cancelBtnLbl: lang.crudText().cancel
  720.         };
  721.         o.content(t(n));
  722.         o.center().open();
  723.         $("#ddlDeviceType").kendoDropDownList({
  724.             dataTextField: "Item2",
  725.             dataValueField: "Item1",
  726.             animation: !1,
  727.             dataSource: p
  728.         });
  729.         i = $("#installationInsert-container").kendoValidator({
  730.             rules: {
  731.                 validSerialNumber: function(n) {
  732.                     return n.is("[name=SerialNumber]") ? (n.val() || "").length > 0 : !0
  733.                 }
  734.             },
  735.             messages: {
  736.                 validSerialNumber: lang.validationMsg().required
  737.             }
  738.         }).data("kendoValidator");
  739.         kendo.bind("#dialogWindow", n);
  740.         $("#btnAccept").off("click");
  741.         $("#btnCancel").off("click");
  742.         $("#btnAccept").click(function() {
  743.             if (i.validate()) {
  744.                 var n = $("#inputDeviceSerialNr").val(),
  745.                     t = $("#inputDeviceType").val();
  746.                 r(n, t)
  747.             }
  748.         });
  749.         $("#btnCancel").click(function() {
  750.             o.close()
  751.         })
  752.     }
  753.     var n = !0,
  754.         t = !0,
  755.         s = 0,
  756.         h = 0,
  757.         c = null,
  758.         r = null,
  759.         ut = 5e3,
  760.         ft = 1e4,
  761.         et = 120,
  762.         ot = 60,
  763.         i = $("#btnCheckDevice"),
  764.         u = $("#inputDeviceSerialNr"),
  765.         b = $("#inputDeviceType"),
  766.         f = $("#checkDeviceResult"),
  767.         v = $("#checkMessageTitle"),
  768.         st = $("#lblDeviceSerialNr"),
  769.         ht = $("#lblDeviceType"),
  770.         ct = $("#pageTitle"),
  771.         l = $("#messageList"),
  772.         e = "",
  773.         lt = $("#divDeviceInstall"),
  774.         at = $("#btnSearchDevice"),
  775.         vt = $("#btnAddDeviceInstallation"),
  776.         it, o;
  777.     bt();
  778.     $("#imgEn").click(function() {
  779.         window.location = a() + "?lang=en"
  780.     });
  781.     $("#imgFi").click(function() {
  782.         window.location = a() + "?lang=fi"
  783.     });
  784.     $("#imgSe").click(function() {
  785.         window.location = a() + "?lang=sv"
  786.     });
  787.     $("#imgFr").click(function() {
  788.         window.location = a() + "?lang=fr"
  789.     });
  790.     var k = $("#divDeviceInstall").kendoValidator({
  791.             rules: {
  792.                 validSerialNumber: function(n) {
  793.                     return n.is("[name=SerialNumber]") ? (n.val() || "").length > 0 : !0
  794.                 },
  795.                 validOdometerValue: function(n) {
  796.                     if (n.is("[name=OdometerValue]")) {
  797.                         if ((n.val() || "").length > 0) {
  798.                             var t = kendo.parseFloat(n.val());
  799.                             return t > 0
  800.                         }
  801.                         return !0
  802.                     }
  803.                     return !0
  804.                 }
  805.             },
  806.             messages: {
  807.                 validSerialNumber: lang.validationMsg().required,
  808.                 validOdometerValue: lang.messages().odoMeterSync.mustBeNumber
  809.             }
  810.         }).data("kendoValidator"),
  811.         y = kendo.observable({
  812.             deviceTypesSource: null,
  813.             devInst: null,
  814.             hasChanges: !1,
  815.             save: function() {
  816.                 var n = this;
  817.                 k.validate() && rt(this.devInst).done(function() {
  818.                     n.set("hasChanges", !1);
  819.                     $("#btnSaveDeviceInstall").hide();
  820.                     uiUtil.okDialogForShortMessage("", "Ok");
  821.                     deviceCheckTabs.disable("#tabDeviceInstall");
  822.                     deviceCheckTabs.select("#tabDeviceMessageCheck")
  823.                 })
  824.             },
  825.             change: function() {
  826.                 this.set("hasChanges", !0);
  827.                 k.validate();
  828.                 $("#btnSaveDeviceInstall").show()
  829.             }
  830.         }),
  831.         p = null,
  832.         kt = new kendo.data.DataSource({
  833.             transport: {
  834.                 read: {
  835.                     url: function() {
  836.                         return mspSettings.getWebApiRoot() + "/api/devicecheck/devicetypes?noCache=_" + (new Date).getTime()
  837.                     },
  838.                     dataType: "json"
  839.                 }
  840.             },
  841.             requestEnd: function(n) {
  842.                 n.type === "read" && n.response.length > 0 && (p = n.response, ui(), y.deviceTypesSource = n.response)
  843.             }
  844.         });
  845.     kt.read();
  846.     u.change(function() {
  847.         n = !0;
  848.         t = !0;
  849.         f.text("");
  850.         v.text("");
  851.         r = null
  852.     });
  853.     i.click(function() {
  854.         i.text() == lang.deviceCheck().btnMessageCheckText ? ni() : w()
  855.     });
  856.     at.click(function() {
  857.         ri()
  858.     });
  859.     vt.click(function() {
  860.         fi()
  861.     });
  862.     it = null;
  863.     $("#btnSaveDeviceInstall").contents().last()[0].textContent = " " + lang.crudText().save;
  864.     o = null
  865. }
  866.  
  867. function initTabStrips() {
  868.     var n = $("#divResults").kendoTabStrip({}).data("kendoTabStrip");
  869.     window.deviceCheckTabs = n
  870. }(function(n, t) {
  871.     var i = n.parse,
  872.         r = [1, 4, 5, 6, 10, 11];
  873.     n.parseISO8601 = function(u) {
  874.         var e, f, o = 0,
  875.             s, h;
  876.         if (f = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/.exec(u)) {
  877.             for (s = 0; h = r[s]; ++s) f[h] = +f[h] || 0;
  878.             f[2] = (+f[2] || 1) - 1;
  879.             f[3] = +f[3] || 1;
  880.             f[7] = f[7] ? +(f[7] + "00").substr(0, 3) : 0;
  881.             f[8] === t && f[9] === t ? e = +new n(f[1], f[2], f[3], f[4], f[5], f[6], f[7]) : (f[8] !== "Z" && f[9] !== t && (o = f[10] * 60 + f[11], f[9] === "+" && (o = 0 - o)), e = n.UTC(f[1], f[2], f[3], f[4], f[5] + o, f[6], f[7]))
  882.         } else e = i ? i(u) : NaN;
  883.         return e
  884.     }
  885. })(Date);
  886. $(function() {
  887.     var n, t;
  888.     initMspSettings();
  889.     n = mspSettings.getUserCulture() || "en-US";
  890.     kendo.culture(n);
  891.     initUiUtil();
  892.     t = n.length > 1 ? n.substr(0, 2) : "en";
  893.     lang.language(t);
  894.     initTabStrips();
  895.     initDeviceCheck()
  896. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement