|
| 1 | +/* See license.txt for terms of usage */ |
| 2 | + |
| 3 | +"use strict"; |
| 4 | + |
| 5 | +module.metadata = { |
| 6 | + "stability": "stable" |
| 7 | +}; |
| 8 | + |
| 9 | +/** |
| 10 | + * xxxHonza TODO docs |
| 11 | + */ |
| 12 | +const jQueryLintInjectorCode = "\ |
| 13 | +(function() {\ |
| 14 | + var el = document.createElement('div');\ |
| 15 | + var b = document.getElementsByTagName('body')[0];\ |
| 16 | + var otherlib = false;\ |
| 17 | + var msg = '';\ |
| 18 | + el.style.fontFamily = 'Arial, Verdana';\ |
| 19 | + el.style.position = 'fixed';\ |
| 20 | + el.style.padding = '5px 10px 5px 10px';\ |
| 21 | + el.style.margin = '0';\ |
| 22 | + el.style.zIndex = 1001;\ |
| 23 | + el.style.lineHeight = '46px';\ |
| 24 | + el.style.fontSize = '40px';\ |
| 25 | + el.style.fontWeight = 'bold';\ |
| 26 | + el.style.color = '#444';\ |
| 27 | + el.style.backgroundColor = '#FFFB00';\ |
| 28 | + el.style.MozBorderRadius = '8px';\ |
| 29 | + el.style.opacity = '0.8';\ |
| 30 | + el.style.textAlign = 'center';\ |
| 31 | + if (typeof jQuery == 'undefined') {\ |
| 32 | + msg = 'No jQuery detected!';\ |
| 33 | + return showMsg();\ |
| 34 | + }\ |
| 35 | + function getScript(url, success, failure) {\ |
| 36 | + var script = document.createElement('script');\ |
| 37 | + script.src = url;\ |
| 38 | + var head = document.getElementsByTagName('head')[0],\ |
| 39 | + done = false;\ |
| 40 | + var timeout = setTimeout(function() { failure(); }, {{jQueryLintURLTimeout}});\ |
| 41 | + script.onload = script.onreadystatechange = function() {\ |
| 42 | + if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {\ |
| 43 | + done = true;\ |
| 44 | + clearTimeout(timeout);\ |
| 45 | + success();\ |
| 46 | + }\ |
| 47 | + };\ |
| 48 | + head.appendChild(script);\ |
| 49 | + }\ |
| 50 | + getScript('{{jQueryLintURL}}', \ |
| 51 | + function() {\ |
| 52 | + if (!jQuery.LINT) {\ |
| 53 | + msg = 'Sorry, but jQuery Lint wasn\\'t able to load';\ |
| 54 | + return showMsg(true);\ |
| 55 | + }\ |
| 56 | + }, function() {\ |
| 57 | + msg = 'Unable to load jQuery Lint from:<br/>{{jQueryLintURL}}';\ |
| 58 | + return showMsg(true);\ |
| 59 | + });\ |
| 60 | + function showMsg(isError) {\ |
| 61 | + el.innerHTML = msg;\ |
| 62 | + if (isError) el.style.backgroundColor = '#FF4444';\ |
| 63 | + b.appendChild(el);\ |
| 64 | + el.style.left = Math.floor((window.innerWidth - el.clientWidth) / 2) + 'px';\ |
| 65 | + el.style.top = Math.floor((window.innerHeight - el.clientHeight) / 2) + 'px';\ |
| 66 | + window.setTimeout(function() {\ |
| 67 | + if (typeof jQuery == 'undefined') {\ |
| 68 | + b.removeChild(el);\ |
| 69 | + } else {\ |
| 70 | + b.removeChild(el);\ |
| 71 | + if (otherlib) {\ |
| 72 | + $jq = jQuery.noConflict();\ |
| 73 | + }\ |
| 74 | + }\ |
| 75 | + },\ |
| 76 | + 2500);\ |
| 77 | + }\ |
| 78 | +})();\ |
| 79 | +"; |
| 80 | + |
| 81 | +// Exports from this module |
| 82 | +exports.jQueryLintInjectorCode = jQueryLintInjectorCode; |
0 commit comments