// чистка вредных обработчиков javascript:(function(w){ var arr = ['contextmenu','copy','cut','paste','mousedown','mouseup','beforeunload','beforeprint']; for(var i = 0, x; x = arr[i]; i++) { if(w['on' + x])w['on' + x] = null; w.addEventListener(x, function(e){e.stopPropagation()}, true); }; for(var j = 0, f; f = w.frames[j]; j++) {try{arguments.callee(f)}catch(e){}} })(window); // Gets the selected text on the page and input fields; author: Lex1 var getSel = function(fConvertName, w /*window or frame*/) { var s = ''; if (arguments.length < 2) w = window; var d = w.document; if (d.selection) { var r = d.selection.createRange(); s = r ? r.text : ''; } else { s = d.getSelection().toString(); if (!s) { var e; var t = d.getElementsByTagName('textarea'); var u = d.getElementsByTagName('input'); var i = t.length; while (e = (i > 0) ? t[--i] : u[-i--]) { try { if (e.offsetHeight > 0 && (s = e.value.substring(e.selectionStart, e.selectionEnd))) break; } catch(x) {} } } } if (!s) { for (var j = 0, f; f = window.frames[j]; j++) { try { if (s = getSel(fConvertName, f)) break; } catch(x) {} } } if (fConvertName) { s = eval(fConvertName + '(' + JSON.stringify(s) + ')'); } return s; }; // escape function with the Russian characters function escapeRu(str) { var trans = []; for (var i = 0x410; i <= 0x44F; i++) trans[i] = i - 0x350; trans[0x401] = 0xA8; trans[0x451] = 0xB8; var ret = []; for (var i = 0; i < str.length; i++) { var n = str.charCodeAt(i); if (typeof trans[n] != 'undefined') n = trans[n]; if (n <= 0xFF) ret.push(n); } return escape(String.fromCharCode.apply(null, ret)); } // Items, opened url var openUrl = function(url, sel, bFullScreen) { if (sel) { var params = ''; if (bFullScreen) params = 'fullscreen=yes,scrollbars=yes,location=yes'; else params = 'width=946,height=576,left=100,top=100,scrollbars=yes,location=no'; window.open(url.replace('#SEL#', sel), '', params); } }; // in small screen var openUrlS = function(url, fcn) { openUrl(url, getSel(fcn), 0); }; // in full screen var openUrlF = function(url, fcn) { openUrl(url, getSel(fcn), 1); }; // Insert tags around selected text var insertTags = function(tagOpen, tagClose) { var ta = window.document.getElementsByTagName('textarea'); if (ta.length) { var le = ta.length - 1; var t = ta[le]; for (var i = le - 1; i >= 0; i--) { if (ta[i].rows >= 5 && ta[i].offsetHeight) { t = ta[i]; break; } } var val = tagOpen + getSel('') + tagClose; var cpos = t.selectionStart; t.value = t.value.substr(0, cpos) + val + t.value.substr(t.selectionEnd); cpos += val.length; t.setSelectionRange(cpos, cpos); t.focus(); } }; |