1// 'getScript' loads scripts after the page has loaded so the page can render quicker 2function getScript(url, success) { 3 var script = document.createElement('script'); 4 script.type = "text/javascript"; 5 script.async = true; 6 script.src = url; 7 var head = document.getElementsByTagName('head')[0], 8 done = false; 9 script.onload = script.onreadystatechange = function () { 10 if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { 11 done = true; 12 if (typeof success != 'undefined') { success(); } 13 script.onload = script.onreadystatechange = null; 14 head.removeChild(script); 15 } 16 }; 17 head.appendChild(script); 18} 19 20// --------------- Query actions --------------- // 21getScript('https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js', function () { 22 // -------- MVC Client Side Validation ---------- // 23 getScript('https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js', function () { 24 getScript('https://ajax.aspnetcdn.com/ajax/mvc/4.0/jquery.validate.unobtrusive.min.js'); 25 }); 26 27 // Archive 28 if ($(".smartArchive").length > 0) { 29 $(".smartArchive a").on("click", function (e) { 30 var link = $(this); 31 var listItem = $(link.parent()); 32 var subList = listItem.children("ul"); 33 34 if (subList.length > 0) { 35 e.preventDefault(); 36 37 if (listItem.hasClass("open")) { 38 listItem.removeClass("open"); 39 subList.hide(); 40 } 41 else { 42 listItem.addClass("open"); 43 subList.show(); 44 } 45 } 46 }); 47 } 48 49 // Loads in the facebook api 50 getScript('https://connect.facebook.net/en_US/all.js', function () { 51 FB.init({ 52 appId: '374162762699021', // App ID from the app dashboard, make sure the app is live and your website domain has been set within it. 53 status: true, // Check Facebook Login status 54 xfbml: true, // Look for social plugins on the page 55 oauth: true 56 }); 57 58 // When the facebook button is clicked (if it exists), then login the user 59 if ($('#facebookButton').length > 0) { 60 $('#facebookButton').click(function (e) { 61 e.preventDefault(); 62 login(); 63 }); 64 } 65 66 // The login function to retrieve and set the user details into the form. 67 function login() { 68 FB.getLoginStatus(function (response) { 69 console.log('Welcome! Fetching your information.... '); 70 FB.api('/me', function (response) { 71 console.log('Good to see you, ' + response.name + '.'); 72 }); 73 74 if (response.status === 'connected') { 75 // User is already authorised and logged in 76 FB.api('me?fields=name,email,website', function (user) { 77 if (user != null) { 78 console.log("You've already provided authorisation to this website"); 79 $("#commentName").val(user.name); 80 $("#commentEmail").val(user.email); 81 $("#commentWebsite").val(user.website); 82 } 83 }); 84 } else if (response.status === 'not_authorized') { 85 // The user is logged in but has not authenticated the app 86 console.log("Looks like you've not provided access to this application") 87 } else { 88 // The user has not logged into facebook so ask them to 89 FB.login(function (response) { 90 if (response.authResponse) { 91 if (response.authResponse.accessToken) { 92 FB.api('me?fields=name,email,website', function (user) { 93 if (user != null) { 94 $("#commentName").val(user.name); 95 $("#commentEmail").val(user.email) 96 $("#commentWebsite").val(user.website); 97 } 98 }) 99 } 100 } 101 else { 102 alert("You need to log in and authorise this website before you can autofill the form."); 103 } 104 }, { scope: 'email,user_website' }); 105 } 106 }, true); 107 } 108 });
109 110 // Listen for search request 111 $('#smartBlogSearchForm').on('submit', function (e) { 112 e.preventDefault(); 113 114 doSmartBlogSearch(); 115 }); 116 117 // Perform search 118 function doSmartBlogSearch() { 119 var address = document.URL.split('?')[0]; 120 var query = $("#smartSearchInput").val(); 121 122 // If no search term has been requested then alert the user, 123 // else perform the search. 124 if (query != "") { 125 // If on a post, we need to redirect the user up a level too. 126 if ($('#postPageBody').length > 0) { 127 window.location = address.substr(0, address.lastIndexOf("/")) + "?q=" + query; 128 } 129 else { 130 window.location = address + "?q=" + query; 131 } 132 } 133 else { 134 alert("Please provide a search term.") 135 } 136 } 137}); 138 139// If any ajax call fails 140function OnErrorCall(response) { 141 alert(response.status + " " + response.statusText); 142 console.log(response) 143}
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.