pastebin

loaderRTFetch
  1. "use strict";
  2.  
  3. // Container for loading prep.
  4. var loader = {};
  5. loader.auth = {};
  6.  
  7.  
  8. //IE polyfill
  9. if (!String.prototype.startsWith) {
  10.     String.prototype.startsWith = function (searchString, position) {
  11.         position = position || 0;
  12.         return this.indexOf(searchString, position) === position;
  13.     };
  14. }
  15.  
  16. //IE polyfill
  17. if (!String.prototype.includes) {
  18.     String.prototype.includes = function (search, start) {
  19.         if (typeof start !== 'number') {
  20.             start = 0;
  21.         }
  22.  
  23.         if (start + search.length > this.length) {
  24.             return false;
  25.         } else {
  26.             return this.indexOf(search, start) !== -1;
  27.         }
  28.     };
  29. }
  30.  
  31. function isIE() {
  32.     var ua = window.navigator.userAgent;
  33.     var msie = ua.indexOf('MSIE ');
  34.     var trident = ua.indexOf('Trident/');
  35.     var edge = ua.indexOf('Edge/');
  36.     if (msie > 0) {
  37.         // IE 10 or older
  38.         return true;
  39.     }
  40.     else if (trident > 0) {
  41.         // IE 11
  42.         return true;
  43.     }
  44.     else if (edge > 0) {
  45.         // Edge
  46.         return false;
  47.     }
  48.     else {
  49.         // other browser
  50.         return false;
  51.     }
  52. }
  53.  
  54. // Reads the settings from the given source element.
  55. function readSettingsFrom(sourceElementId) {
  56.     // Gather and validate settings.
  57.     loader.loadTag = document.getElementById(sourceElementId);
  58.     if (typeof loader.loadTag === "undefined") { console.log("Failed to find loader script."); }
  59.  
  60.     loader.whichPage = loader.loadTag.getAttribute("data-which-page");
  61.     loader.rootUrl = loader.loadTag.getAttribute("data-root-url");
  62.     loader.controllerPath = loader.loadTag.getAttribute("data-controller-path");
  63.     loader.controllerName = loader.loadTag.getAttribute("data-controller-name");
  64.     loader.controller = loader.loadTag.getAttribute("data-controller");
  65.     if (typeof loader.whichPage === "undefined") { console.log("Failed to find which page."); }
  66.     if (typeof loader.rootUrl === "undefined") { console.log("Failed to find root URL."); }
  67.  
  68.     loader.localization = [
  69.         "common",
  70.         "bing",
  71.         "concernRoot",
  72.         "onlineSafety",
  73.         "privacy",
  74.         "countries",
  75.         "dmca",
  76.         "healthVault",
  77.         "partnerEscalation",
  78.         "reinstateContent",
  79.         "officeViolation",
  80.         "scam"
  81.     ];
  82.  
  83.     if (loader.loadTag.getAttribute("data-localization")) {
  84.         loader.localization = loader.loadTag.getAttribute("data-localization").split(" ");
  85.     }
  86.  
  87.     loader.requireAuth = loader.loadTag.getAttribute("data-require-auth");
  88.     loader.hasAuth = loader.loadTag.getAttribute("data-hasAuth");
  89.     loader.auth.redirectUrl = loader.loadTag.getAttribute("data-auth-redirect-url") || window.location;
  90. }
  91.  
  92. // Configures RequireJS based on the current settings.
  93. function configureRequireJs() {
  94.     let urlArgs = "";
  95.  
  96.     if (isIE()) {
  97.         urlArgs = "iecachebust=" + (new Date()).getTime();
  98.     }
  99.  
  100.     let scriptRoot = loader.rootUrl + "/Scripts/app/";
  101.  
  102.     define("jquery", function () { return $; });
  103.  
  104.     requirejs.config({
  105.         baseUrl: scriptRoot,
  106.         urlArgs: urlArgs,
  107.         map: { "*": { "spin.js": "spin" } },
  108.         paths: {
  109.             "spin": "https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min",
  110.             knockout: "https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min",
  111.             "knockout.validation": "https://cdnjs.cloudflare.com/ajax/libs/knockout-validation/2.0.3/knockout.validation.min",
  112.             moment: "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min",
  113.             api: "../api",
  114.             "i18next": 'https://cdnjs.cloudflare.com/ajax/libs/i18next/4.1.1/i18next.min',
  115.             "i18next-xhr-backend": loader.rootUrl + '/Scripts/packages/i18nextXHRBackend.min',
  116.             "fingerprintjs2": loader.rootUrl + '/Scripts/packages/getPrint',
  117.             "bluebird": "https://cdn.jsdelivr.net/npm/bluebird@3.5.3/js/browser/bluebird.min",
  118.             "better-dom-datepicker": loader.rootUrl + '/Scripts/packages/betterDOMDatepicker',
  119.             "URLSearchParams": 'https://cdnjs.cloudflare.com/ajax/libs/url-search-params/1.1.0/url-search-params'
  120.         }
  121.     });
  122. }
  123.  
  124. function actuallyStart() {
  125.     // run configuration
  126.     readSettingsFrom("loader-script");
  127.     configureRequireJs();
  128.  
  129.     var loaderWithBluebirdRequire = document.createElement('script');
  130.     loaderWithBluebirdRequire.src = loader.rootUrl + '/Scripts/loaderRT.js';
  131.     loaderWithBluebirdRequire.type = 'text/javascript';
  132.     document.body.appendChild(loaderWithBluebirdRequire);
  133. }
  134.  
  135. // The actual initialization.
  136. document.addEventListener("DOMContentLoaded", function (event) {
  137.     actuallyStart();
  138. });
Parsed in 0.037 seconds