Просмотр файла servises/screen/class.js

Размер файла: 4.08Kb
/***
class Browser
***/

var Browser = {



getLocationSearch: function () {


var b = location.search.substring(1).length > 0 ? location.search.substring(1).split('&') : [], c = [], d = [], e;


for(e = 0; e < b.length; e++) {


c = b[e].split('=');


d[c[0]] = (isNaN(c[1]) || c[1] == '') ? (new String(c[1])).split('+').join('%20') : parseInt(c[1]);


}


return d;


},



getDateFromTimezone: function (date, timezone) {

return (new Date(date.getTime() + date.getTimezoneOffset() * 60000 + timezone * 3600000));

},



getCookie: function (name) {


var b = document.cookie.length > 0 ? document.cookie.split(';') : [], c = [], d = [], e;


for(e = 0; e < b.length; e++) {


c = b[e].split('=');

d[c[0]] = isNaN(c[1]) ? unescape(c[1]) : parseInt(c[1]);


}


return d[name];


},



setCookie: function (name, value, props) {


props = props||{};


var exp = props.expires;


if(typeof exp == "number" && exp) {


var d = new Date;


d.setTime(d.getTime() + exp*1000);


exp = props.expires = d;


}


if(exp && exp.toUTCString) {

props.expires = exp.toUTCString();

}


value = encodeURIComponent(value);


var updatedCookie = name + "=" + value;


for(var propName in props){


updatedCookie += "; " + propName;


var propValue = props[propName];


if(propValue !== true){

updatedCookie += "=" + propValue;


}

}


document.cookie = updatedCookie;


},



deleteCookie: function (name) {


Browser.setCookie(name, null, { expires: -1 });


}



}



/***
class Doc
***/

var Doc = {



include: function (src) {

document.write('<script src="' + src + '"></script>');

}



}



/***
class Arr
***/


var Arr = {


setIndex: function(arr, val, index) {

for(var i = 0; i < arr.length; i++) {

arr[i][index] = val[i];

}

return arr;

},


sortByIndex: function (arr, index) {

var newArr = [];

for(var i = 0, n = 0; i < arr.length; i++) {

if(arr[i][index] >= arr.length) arr[i][index] = arr.length - 1;


for(var j = 0; j < arr.length; j++) {

if(arr[j][index] == i) {

newArr[n] = arr[j];

n++;

}

}


}

return newArr;

}



}



/***
class Text
***/

var Text = {



decodeUTF: function(decodeString) {

var str = unescape((new String(decodeString))), win = '', ch;


for(var i = 0; i < str.length; i++) {

ch = str.charCodeAt(i);


if(ch != 208 && ch != 209) {

if((ch >127 && ch < 144 && ch != 129) || (ch == 129 && str.charCodeAt(i-1) == 209) || ch == 145) {


win += String.fromCharCode(ch + 960);


} else if(ch > 143 && ch < 192 || ch == 129) {


win += String.fromCharCode(ch + 896);


} else {


win += str.charAt(i);


}

}

}

return win;

},



parseBBCode: function (str) {

str = str.replace(new RegExp('\\[br/\\]', 'g'), '<br />');

str = str.replace(new RegExp('\\[color=(#?[\\d\\w]+)\\](.+)\\[/color\\]', 'g'), '<span style="color:$1;">$2</span>');

str = str.replace(new RegExp('\\[size=([\\d\\w]+%?)\\](.+)\\[/size\\]', 'g'), '<span style="font-size:$1;">$2</span>');

str = str.replace(new RegExp('http://([^\\s]+)', 'g'), '<a href="http://$1">http://$1</a>');

str = str.replace(new RegExp('\\[url=(.+)\\](.+)\\[/url\\]', 'g'), '<a href="http://$1">$2</a>');

return str;

},



parseSmileTags: function (str) {

return str.replace(new RegExp(':(\\w+):'), '<img src="http://' + location.host + '/smile/$1.png" alt=":$1:" />');

}



}



/***
class MySQL
***/

function MySQL(id) {



var x = {};


x.id = id;

x.string = '';

x.get = '';



x.header = function (name, dsString) {

this.get += '&' + name + '=' + encodeURIComponent(dsString);

};



x.query = function (name, queryString) {

this.string += encodeURIComponent(';' + name + '|' + queryString);

};



x.result = function () {


document.write('<script src="http://wapmyadmin.com/sdb/index.php?query=' + this.id + this.string + this.get + '"></script>');


this.string = '';

this.get = '';


};



return x;



}



//-->