1window.SharedUtil = class SharedUtil { 2 static isMobile() { 3 return Modernizr.touchevents && navigator.appVersion.indexOf("Win") === -1; 4 } 5 6 static useNativeDateInput() { 7 SharedUtil.isMobile() && Modernizr.inputtypes.date; 8 } 9 10 static ajaxScript(url, method, data, successCallback, errorCallback) { 11 let form = $(`<form action=${url} data-remote=true method='post'></form>`) 12 form.html($(`<input type="hidden" name="_method" value="${method}">`)); 13 14 for (let key in data) { 15 let value = data[key]; 16 form.append(`<input type="hidden" name="${key}" value="${value}">`) 17 } 18 19 $('body').append(form); 20 21 if (successCallback) { 22 form.on("ajax:success", (event) => { 23 // detail[0] -> data 24 // detail[1] -> status 25 // detail[2] -> xhr 26 successCallback(event.detail[0], event.detail[2]); 27 }); 28 29 } 30 31 if (errorCallback) { 32 form.on("ajax:error", (event) => { 33 errorCallback(event.detail[0], event.detail[2]); 34 }); 35 } 36 37 form.on("ajax:complete", () => { 38 form.remove(); 39 }); 40 41 Rails.fire(form[0], "submit"); 42 } 43 44 static isMSEdge() { 45 return /Edge\/\d./i.test(navigator.userAgent) 46 } 47};
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.