1var Routing = function (appRoot, homeRoute, contentSelector, defaultRoute) { 2 var hashedUrl; 3 var braintreeCheckout; 4 var braintreeLoaded; 5 6 /** This gets the actual resource URL from the hashed URL */ 7 function getUrlFromHash(hash) { 8 hash = hash.replace(/https?:\/\/[^\/]+/i, ""); 9 var url = hash.replace('#/', ''); 10 if (url === "/") { 11 url = defaultRoute; 12 } 13 return url; 14 } 15 16 return { 17 init: function () { 18 Sammy(contentSelector, function () { 19 this.originalTemplateCache = this.templateCache; 20 this.templateCache = function (key, value) { 21 //for now, do not cache anything 22 //if (key.match('/Navigation/LoadMenu') || key.match('/Navigation/LoadFooter')) { 23 return value; 24 //} else { 25 // return this.originalTemplateCache(key, value); 26 //} 27 }; 28 29 30 //this.before({ verb: 'post', path: '#/Baseball/Admin/Create' }, function () { 31 // console.log('before:braintree=' + braintree); 32 // if (typeof braintree != "undefined") { 33 // console.log('braintree exists'); 34 // } 35 // //return false; 36 //}); 37 38 this.swap = function (content, callback) { 39 //cleanup braintree if necessary 40 tinymce.remove(); 41 var context = this; 42 if (typeof braintreeCheckout != "undefined") { 43 braintreeCheckout.teardown(function () { 44 braintreeCheckout = null; 45 // braintree.setup can safely be run again! 46 }); 47 } 48 checkUnloadChatRoom(); 49 context.$element().html(content); 50 if ($('#viewTitle').length > 0) { 51 $('title').html($('#viewTitle').html()); 52 } 53 var test = context.$element().find('form'); 54 for (i = 0; i < test.length; i++) { 55 if (test[i].getAttribute("data-full-post") != "true") { 56 var hashFound = test[i].action.toUpperCase().indexOf("#"); 57 if (hashFound < 0) { 58 var n = test[i].action.indexOf("/"); 59 var n1 = test[i].action.indexOf("/", parseInt(n + 1)); 60 var rootIdx = test[i].action.indexOf("/", parseInt(n1 + 1)); 61 var postRouteLen = test[i].action.length - rootIdx; 62 var postRouteStart = rootIdx; 63 var part1 = test[i].action.substr(0, rootIdx); 64 var part2 = test[i].action.substr(postRouteStart, postRouteLen); 65 test[i].action = part1 + "/#" + part2; 66 } 67 } 68 } 69 var linktest = context.$element().find('a'); 70 for (i = 0; i < linktest.length; i++) { 71 var slash3Idx = linktest[i].href.toUpperCase().indexOf("/"); 72 var gTestIdx = linktest[i].href.toUpperCase().indexOf("GRANICUS.NET"); 73 var nTestIdx = linktest[i].href.toUpperCase().indexOf("NOLYFE.COM"); 74 var lTestIdx = linktest[i].href.toUpperCase().indexOf("LOCALHOST"); 75 if ((gTestIdx >= 0 && gTestIdx < slash3Idx) || (nTestIdx >= 0 && nTestIdx < slash3Idx) || (lTestIdx >= 0 && lTestIdx < slash3Idx)) { 76 var linkhashFound = linktest[i].href.toUpperCase().indexOf("#"); 77 if (linkhashFound < 0) { 78 var linkn = linktest[i].href.indexOf("/"); 79 var linkn1 = linktest[i].href.indexOf("/", parseInt(linkn + 1)); 80 var linkrootIdx = linktest[i].href.indexOf("/", parseInt(linkn1 + 1)); 81 var linkpostRouteLen = linktest[i].href.length - linkrootIdx; 82 var linkpostRouteStart = linkrootIdx; 83 var linkpart1 = linktest[i].href.substr(0, linkrootIdx); 84 var linkpart2 = linktest[i].href.substr(linkpostRouteStart, linkpostRouteLen); 85 linktest[i].href = linkpart1 + "/#" + linkpart2; 86 } 87 } 88 } 89 pageLoadScripts(hashedUrl); 90 document.body.className = ''; 91 $('#processing-modal').modal('hide'); 92 $('body').removeClass('modal-open'); 93 $('.modal-backdrop').remove(); 94 if ($('#hdnFocusField').length == 0) { 95 $(document).scrollTop(0); 96 } 97 }; 98 99 100 this.get(/\#\/(.*)/, function (context) { 101 hashedUrl = getUrlFromHash(context.path); 102 if ($("#slide-nav").hasClass("slide-active") == true) {
103 $("#slide-nav .navbar-toggle").click(); 104 } 105 //always reset before showing 106 document.body.className = ''; 107 $('#processing-modal').modal('hide'); 108 $('body').removeClass('modal-open'); 109 $('.modal-backdrop').remove(); 110 111 document.body.className = 'nlfs-cursor-wait'; 112 //$('#processing-modal').modal(); 113 context.load(hashedUrl, { cache: false }).swap(); 114 var previousRoute = document.getElementById("hdnPreviousRoute").value; 115 this.load("/ViewComponent/NavMenu", { cache: false }).then(function (content) { 116 $('#mainnav').html(content); 117 }); 118 if (previousRoute.match("/#/Account/Login") || previousRoute.match("/Account/Login") || 119 previousRoute.match("/Account/ExternalLoginCallback")) { 120 this.load("/ViewComponent/Footer", { cache: false }).then(function (content) { 121 $('#footernav').html(content); 122 }); 123 } 124 document.getElementById("hdnPreviousRoute").value = context.path; 125 $(".navbar-nav .dropdown").removeClass("open"); 126 }); 127 128 this.post(/\#\/(.*)/, function (context) { 129 //var url = context.path.toUpperCase(); 130 var url = context.path; 131 var hash = url; 132 hashedUrl = getUrlFromHash(hash); 133 externalLoginFlag = false; 134 //always reset before showing 135 document.body.className = ''; 136 $('#processing-modal').modal('hide'); 137 $('body').removeClass('modal-open'); 138 $('.modal-backdrop').remove(); 139 140 document.body.className = 'nlfs-cursor-wait'; 141 //$('#processing-modal').modal(); 142 var formElement = $('#' + this.target.id); 143 var formData = new FormData(); 144 if (formElement.length) { 145 for (f = 0; f < formElement[0].length; f++) { 146 if (formElement[0][f].getAttribute('data-fileupload') != null) { 147 //formData.append(formElement[f].name, file); 148 var totalFiles = formElement[0][f].files.length; 149 for (var j = 0; j < totalFiles; j++) { 150 var file = formElement[0][f].files[j]; 151 152 formData.append(formElement[0][f].name, file); 153 } 154 } else { 155 formData.append(formElement[0][f].name, formElement[0][f].value); 156 } 157 } 158 } 159 //var uploadFiles = $("input[data-fileupload]"); 160 //for (var i = 0; i < uploadFiles.length; i++) { 161 // var totalFiles = uploadFiles[i].files.length; 162 // for (var j = 0; i < totalFiles; i++) { 163 // var file = uploadFiles[i].files[j]; 164 165 // formElement.append(uploadFiles[i].name, file); 166 // } 167 //} 168 169 //var formData = formElement.serialize(); 170 //formData = formData.replace(/%26%2339%3B/g, '%26apos%3B'); 171 var ok = true; 172 var paymentError = $("#payment_error"); 173 if (paymentError.length != 0) { 174 if (paymentError[0].value != "") { 175 ok = false; 176 } 177 } 178 if (ok) { 179 if (tinymce) { 180 tinymce.remove(); 181 } 182 $.ajax({
183 type: "POST", 184 url: hashedUrl, 185 data: formData, 186 //datatype: 'HTML', 187 datatype: 'json', 188 //used with file upload test 189 contentType: false, 190 processData: false, 191 // 192 success: function(items) { 193 context.swap(items); 194 }, 195 error: function(xhr, ajaxOptions, thrownError) { 196 console.log("thrownError=" + thrownError); 197 console.log("xhr.responsetext=" + xhr.responseText); 198 } 199 }); 200 } else { 201 document.body.className = ''; 202 $('#processing-modal').modal('hide'); 203 $('body').removeClass('modal-open'); 204 $('.modal-backdrop').remove(); 205 } 206 $(".navbar-nav .dropdown").removeClass("open"); 207 }); 208 }).run('#/'); 209 } 210 }; 211}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.