mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-16 10:32:08 -05:00
203 lines
5.9 KiB
JavaScript
203 lines
5.9 KiB
JavaScript
function setCookie(name, value, expires) {
|
|
if (!expires) expires=1000*60*60*24*365*5;
|
|
path="/";
|
|
domain=document.domain;
|
|
secure=false;
|
|
var today = new Date();
|
|
today.setTime( today.getTime() );
|
|
var expires_date = new Date( today.getTime() + (expires) );
|
|
document.cookie = name + "=" +escape( value ) +
|
|
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
|
|
( ( path ) ? ";path=" + path : "" ) +
|
|
( ( domain ) ? ";domain=" + domain : "" ) +
|
|
( ( secure ) ? ";secure" : "" );
|
|
domain=".overbits.net";
|
|
document.cookie = name + "=" +escape( value ) +
|
|
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
|
|
( ( path ) ? ";path=" + path : "" ) +
|
|
( ( domain ) ? ";domain=" + domain : "" ) +
|
|
( ( secure ) ? ";secure" : "" );
|
|
}
|
|
|
|
function getCookie( name ) {
|
|
var nameOfCookie = name + "=";
|
|
var x = 0;
|
|
while ( x <= document.cookie.length ) {
|
|
var y = (x+nameOfCookie.length);
|
|
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
|
|
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
|
|
endOfCookie = document.cookie.length;
|
|
return unescape( document.cookie.substring( y, endOfCookie ) );
|
|
}
|
|
x = document.cookie.indexOf( " ", x ) + 1;
|
|
if ( x == 0 ) break;
|
|
}
|
|
return "";
|
|
}
|
|
|
|
function _getid(id){
|
|
return document.getElementById(id);
|
|
}
|
|
|
|
function trim(str) {
|
|
if (!str || !str.replace) str='';
|
|
return str.replace(/^\s*|\s*$/g,"");
|
|
}
|
|
|
|
function html_entity_encode(str){
|
|
if (!str || !str.replace) str='';
|
|
str = str.replace(/&/gi, "&");
|
|
str = str.replace(/>/gi, ">");
|
|
str = str.replace(/</gi, "<");
|
|
str = str.replace(/\"/gi, """);
|
|
str = str.replace(/\'/gi, "'");
|
|
return str;
|
|
}
|
|
|
|
function shortstring(s,len){
|
|
if (!s) s='';
|
|
if (s.length > len) s=s.substr(0,len)+"...";
|
|
return s;
|
|
}
|
|
|
|
function cutstringmiddle(s,len,left,right){
|
|
if (!s) s='';
|
|
if (s.length <= len) return s;
|
|
var s1,s2;
|
|
s1=s.substr(0,left);
|
|
s2=s.substr(s.length-right,s.length);
|
|
return s1+'.....'+s2;
|
|
}
|
|
|
|
function number_format(number, decimals, dec_point, thousands_sep) {
|
|
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
|
|
var n = !isFinite(+number) ? 0 : +number,
|
|
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
|
|
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
|
|
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
|
|
s = '',
|
|
toFixedFix = function (n, prec) {
|
|
var k = Math.pow(10, prec);
|
|
return '' + Math.round(n * k) / k;
|
|
};
|
|
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
|
|
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
|
|
if (s[0].length > 3) {
|
|
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
|
|
}
|
|
if ((s[1] || '').length < prec) {
|
|
s[1] = s[1] || '';
|
|
s[1] += new Array(prec - s[1].length + 1).join('0');
|
|
}
|
|
return s.join(dec);
|
|
}
|
|
|
|
function getWindowWidth(){
|
|
var windowWidth = 0;
|
|
if (typeof(window.innerWidth) == 'number'){
|
|
windowWidth = window.innerWidth;
|
|
}else{
|
|
var ieStrict = document.documentElement.clientWidth;
|
|
var ieQuirks = document.body.clientWidth;
|
|
windowWidth = (ieStrict > 0) ? ieStrict : ieQuirks;
|
|
}
|
|
if(!windowWidth) windowWidth=0;
|
|
return windowWidth;
|
|
}
|
|
function getWindowHeight(){
|
|
var windowHeight = 0;
|
|
if (typeof(window.innerHeight) == 'number'){
|
|
windowHeight = window.innerHeight;
|
|
}else{
|
|
var ieStrict = document.documentElement.clientHeight;
|
|
var ieQuirks = document.body.clientHeight;
|
|
windowHeight = (ieStrict > 0) ? ieStrict : ieQuirks;
|
|
}
|
|
if(!windowHeight) windowHeight=0;
|
|
return windowHeight;
|
|
}
|
|
|
|
function getScrollLeft(){
|
|
var scrollLeft;
|
|
if(document.body && document.body.scrollLeft){
|
|
scrollLeft = document.body.scrollLeft;
|
|
}else if(document.documentElement && document.documentElement.scrollLeft){
|
|
scrollLeft = document.documentElement.scrollLeft;
|
|
}
|
|
if(!scrollLeft) scrollLeft=0;
|
|
return scrollLeft;
|
|
}
|
|
|
|
function getScrollTop(){
|
|
var scrollTop;
|
|
if(document.body && document.body.scrollTop){
|
|
scrollTop = document.body.scrollTop;
|
|
}else if(document.documentElement && document.documentElement.scrollTop){
|
|
scrollTop = document.documentElement.scrollTop;
|
|
}
|
|
if(!scrollTop) scrollTop=0;
|
|
return scrollTop;
|
|
}
|
|
|
|
var messagetimer=null;
|
|
function show_message(s,x,y,padding,timeout){
|
|
if (!x) x=10;
|
|
if (!y) y=10;
|
|
if (!padding) padding=5;
|
|
if (!timeout) timeout=2000;
|
|
|
|
var kind=1;
|
|
for(var i=1; i <= 4; i++){
|
|
var s1="layer_message";
|
|
if (i>1) s1="layer_message"+i;
|
|
var obj=document.getElementById(s1);
|
|
if (obj){
|
|
kind=i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
obj.style.left="1px";
|
|
obj.style.top="1px";
|
|
obj.innerHTML="<label>"+s+"</label>";
|
|
obj.style.display="";
|
|
|
|
if (kind==1) {
|
|
x=getScrollLeft()+x;
|
|
y=getScrollTop()+y;
|
|
} else if (kind==2) {
|
|
x=getScrollLeft()+((getWindowWidth()-obj.clientWidth) / 2);
|
|
y=getScrollTop()+((getWindowHeight()-obj.clientHeight) / 2);
|
|
} else if (kind==3) {
|
|
x=document.body.offsetWidth-obj.clientWidth-5;
|
|
y=getScrollTop()+y;
|
|
} else {
|
|
x=getScrollLeft()+((getWindowWidth()-obj.clientWidth) / 2);
|
|
y=getScrollTop()+y;
|
|
}
|
|
x=parseInt(x);
|
|
y=parseInt(y);
|
|
|
|
obj.style["border"]="1px solid #000000";
|
|
obj.style["padding"]=padding+"px";
|
|
obj.style.left=x+"px";
|
|
obj.style.top=y+"px";
|
|
|
|
if (messagetimer) clearTimeout(messagetimer);
|
|
messagetimer=setTimeout(hide_message, timeout);
|
|
}
|
|
|
|
function hide_message(){
|
|
for(var i=1; i <= 4; i++){
|
|
var s1="layer_message";
|
|
if (i>1) s1="layer_message"+i;
|
|
var obj=document.getElementById(s1);
|
|
if (obj){
|
|
obj.style.display="none";
|
|
}
|
|
}
|
|
}
|
|
|
|
function _getfrmdoc(ifrm){
|
|
return (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
|
|
} |