D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
htdocs
/
spaw
/
js
/
common
/
Filename :
utils.js
back
Copy
// utility functions function SpawUtils() { } SpawUtils.ltrim = function(txt) { var spacers = " \t\r\n"; while (txt.length>0 && spacers.indexOf(txt.charAt(0)) != -1) { txt = txt.substr(1); } return(txt); } SpawUtils.rtrim = function(txt) { var spacers = " \t\r\n"; while (txt.length>0 && spacers.indexOf(txt.charAt(txt.length-1)) != -1) { txt = txt.substr(0,txt.length-1); } return(txt); } SpawUtils.trim = function(txt) { return(SpawUtils.ltrim(SpawUtils.rtrim(txt))); } SpawUtils.trimLineBreaks = function(txt) { var spacers = "\r\n"; while (txt.length>0 && spacers.indexOf(txt.charAt(txt.length-1)) != -1) { txt = txt.substr(0,txt.length-1); } while (txt.length>0 && spacers.indexOf(txt.charAt(0)) != -1) { txt = txt.substr(1); } return(txt); } SpawUtils.htmlEncode = function(txt) { return txt.replace(/&/gm,'&').replace(/</gm,'<').replace(/>/gm, '>').replace(/\u00A0/g, " "); } SpawUtils.getPageOffsetLeft = function(obj) { var elm = obj; x = obj.offsetLeft; while ((elm = elm.offsetParent) != null) { x += elm.offsetLeft; } return x; } SpawUtils.getPageOffsetTop = function(obj) { var elm = obj; y = obj.offsetTop; while ((elm = elm.offsetParent) != null) { y += elm.offsetTop; } return y; }