Intuit Anywhere script reload jQuery

Our application downloads jQuery 1.10.2, and then downloads https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js from Intuit. Anywhere in the script, <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> is added to the head and reloaded jQuery

This wipes the namespace and destroys most of our code. Should the script see that jQuery is already loaded? How to prevent jquery reload?

Thanks Forrest

+2
source share
2 answers

EDIT:

The problem is that window.jQuery.fn.jquery < "1.4.2" returns false since '1.10.2' < '1.4.2' also returns false. This is because javascript will see it as 1.1.2 < 1.4.2 . Another option is to remove || window.jQuery.fn.jquery < "1.4.2" || window.jQuery.fn.jquery < "1.4.2"


If you are sure you include jQuery, just change the part of the code where it adds the script tag.

At the bottom of the script. The change

 // function that starts it all. timeout is 0 (function() { // these are the domains whose js files we're going to look at // intuit.ipp.ourDomain = /(.intuit.com).*?#(.*)/; intuit.ipp.ourDomain = /intuit.com$/; if(window.jQuery === undefined || window.jQuery.fn.jquery < "1.4.2") { // minimum version 1.4.2 var script_tag = document.createElement('script'); script_tag.setAttribute("type","text/javascript"); script_tag.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"); script_tag.onload = function () { if(window.jQuery) { intuit.ipp.jQuery = window.jQuery.noConflict(true); intuit.ipp.anywhere.windowLoad(); } }; script_tag.onreadystatechange = function () { // Same thing but for IE if (this.readyState == 'complete' || this.readyState == 'loaded') { script_tag.onload(); } }; // Try to find the head, otherwise default to the documentElement (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); } else { // we do have jquery intuit.ipp.jQuery = window.jQuery; intuit.ipp.anywhere.windowLoad(); } })(); 

For

 // function that starts it all. timeout is 0 (function () { // these are the domains whose js files we're going to look at // intuit.ipp.ourDomain = /(.intuit.com).*?#(.*)/; intuit.ipp.ourDomain = /intuit.com$/; // we do have jquery intuit.ipp.jQuery = window.jQuery; intuit.ipp.anywhere.windowLoad(); })(); 
+2
source

The decision given by Spocky is partially correct.

To serve the Anywhere script locally, you also need to make some changes to the code so that the domain can point to the Intuit site. Thus, CSS links and applications in the Blue Dot menu are redirected correctly to the Intuit domain.

(Note: Updating the intuit.ipp.ourDomain variable intuit.ipp.ourDomain not work as described above.)

Here is what I changed:

Lines 20-40 contain:

 windowLoad : function() { intuit.ipp.jQuery(document).ready(function () { intuit.ipp.jQuery('script').each(function (){ // check if this script file is from our domain if (!this.src) { return; } var jsSrc = this.src; var jsSrcParts = jsSrc.replace(/http[s]?:\/\//, '').split('/'); var qs = intuit.ipp.ourDomain.exec(jsSrcParts[0]); if(!qs) { qs = document.domain.match(intuit.ipp.ourDomain); } if (!qs || !jsSrcParts[jsSrcParts.length - 1].match('intuit.ipp.anywhere') || !jsSrc.match(/:\/\/(.[^/]+)/)) { return; } // get ipp domain intuit.ipp.anywhere.serviceHost = jsSrc.match(/:\/\/(.[^/]+)/)[1]; 

I replaced them:

 windowLoad : function() { intuit.ipp.jQuery(document).ready(function () { intuit.ipp.jQuery('script').each(function (){ // check if this script file is from our domain if (!this.src) { return; } var jsSrc = this.src; var jsSrcParts = jsSrc.replace(/http[s]?:\/\//, '').split('/'); var qs = intuit.ipp.ourDomain.exec(jsSrcParts[0]); // if(!qs) { // qs = document.domain.match(intuit.ipp.ourDomain); // } if (!jsSrcParts[jsSrcParts.length - 1].match('intuit.ipp.anywhere') || !jsSrc.match(/:\/\/(.[^/]+)/)) { return; } // get ipp domain //intuit.ipp.anywhere.serviceHost = jsSrc.match(/:\/\/(.[^/]+)/)[1]; intuit.ipp.anywhere.serviceHost = "appcenter.intuit.com"; 
+1
source

Source: https://habr.com/ru/post/1492360/


All Articles