var sktcgc_jQuery = ''; /* * Example: * versionCompare('1.1', '1.2') => -1 * versionCompare('1.1', '1.1') => 0 * versionCompare('1.2', '1.1') => 1 * versionCompare('2.23.3', '2.22.3') => 1 * * Returns: * -1 = left is LOWER than right * 0 = they are equal * 1 = left is GREATER = right is LOWER * And FALSE if one of input versions are not valid */ function sktgc_versionCompare(left, right) { if (typeof left + typeof right != 'stringstring') return false; var a = left.split('.') , b = right.split('.') , i = 0, len = Math.max(a.length, b.length); for (; i < len; i++) { if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) { return 1; } else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) { return -1; } } return 0; } (function(){ var loadScript = function(url, callback){ var script = document.createElement("script"); script.type = "text/javascript"; // If the browser is Internet Explorer. if (script.readyState){ script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; // For any other browser. } else { script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; /* This is my app's JavaScript */ var myAppJavaScript = function($){ $.get( 'https://branded-gift-cards.shopkeepertools.com/ajax/getcontent/135/skt_gc_page_check', { url: window.location.href }, function(data) { if(data.success && 135 != 156){ sktcgc_jQuery = $; $("body").on('change', '#sktcgc_msg', function(e){ var str = $(this).val(); str = str.replace(/(?:\r\n|\r|\n)/g, '**newline**'); $("#sktcgc_msgprop").val(str); }); } //end if }); //end $.get }; //end myAppJavaScript if ((typeof jQuery === 'undefined') || ( sktgc_versionCompare(jQuery.fn.jquery, '1.10') != 1 ) ) { loadScript('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', function(){ jQuery110 = jQuery.noConflict(true); myAppJavaScript(jQuery110); }); } else { myAppJavaScript(jQuery); } })();