2016-12-06 16:48:39 +03:00
|
|
|
window.htmlspecialchars = function(text)
|
|
|
|
{
|
|
|
|
return (''+text).replace(/&/g, '&')
|
|
|
|
.replace(/'/g, ''') // '
|
|
|
|
.replace(/"/g, '"') // "
|
|
|
|
.replace(/</g, '<')
|
|
|
|
.replace(/>/g, '>');
|
|
|
|
};
|
|
|
|
|
2015-03-13 16:32:48 +03:00
|
|
|
window.addListener = (function() {
|
|
|
|
return window.addEventListener
|
|
|
|
? function(el, type, fn) { el.addEventListener(type, fn, false); }
|
|
|
|
: function(el, type, fn) { el.attachEvent('on'+type, fn); };
|
|
|
|
})();
|
|
|
|
|
|
|
|
window.removeListener = (function() {
|
|
|
|
return window.removeEventListener
|
|
|
|
? function(el, type, fn) { el.removeEventListener(type, fn, false); }
|
|
|
|
: function(el, type, fn) { el.detachEvent('on'+type, fn); };
|
|
|
|
})();
|
|
|
|
|
2016-03-10 14:26:55 +03:00
|
|
|
window.getEventCoord = function(e)
|
|
|
|
{
|
|
|
|
if (!e)
|
|
|
|
e = window.event;
|
|
|
|
if (e && e.pageX == null && e.clientX != null)
|
|
|
|
{
|
|
|
|
var html = document.documentElement;
|
|
|
|
var body = document.body;
|
|
|
|
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
|
|
|
|
e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0);
|
|
|
|
}
|
|
|
|
if (e && !e.which && e.button)
|
|
|
|
{
|
|
|
|
if (e.button & 1) e.which = 1;
|
|
|
|
else if (e.button & 4) e.which = 2;
|
|
|
|
else if (e.button & 2) e.which = 3;
|
|
|
|
}
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
2016-02-20 13:31:29 +03:00
|
|
|
window.curStyle = function(e)
|
|
|
|
{
|
|
|
|
return window.getComputedStyle ? getComputedStyle(e) : e.currentStyle;
|
|
|
|
};
|