Mini Shell
/**
* Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
*
* Licensed under CLOUD LINUX LICENSE AGREEMENT
* http://cloudlinux.com/docs/LICENSE.TXT
*/
function removeElem(){
var elid = document.getElementById('popup');
if (elid) {
elid.parentNode.removeChild(elid);
}
}
function fadeOutPopup(){
var timeout = 32,
opacity = 9,
popup = document.getElementById('popup'),
fading = window.setInterval(countDown, timeout);
function countDown(){
if ( popup ) {
popup.style.opacity = '0.' + opacity;
opacity--;
if ( opacity < 0 ) {
window.clearInterval(fading);
removeElem();
}
}
}
}
function findLeftOffset(obj){
var curleft = 0;
if(obj.offsetParent) {
while (1) {
curleft += obj.offsetLeft;
if ( !obj.offsetParent )
break;
obj = obj.offsetParent;
}
}
else if(obj.x) {
curleft += obj.x;
}
return curleft;
}
function findTopOffset(obj){
var curtop = 0;
if(obj.offsetParent) {
while (1) {
curtop += obj.offsetTop;
if ( !obj.offsetParent )
break;
obj = obj.offsetParent;
}
}
else if (obj.y) {
curtop += obj.y;
}
return curtop;
}
function encodeFormData(data){
if (!data) return "";
var pairs = [];
for ( var name in data ) {
if ( !data.hasOwnProperty(name) ) continue;
if ( typeof data[name] === "function" ) continue;
var value = data[name].toString();
name = encodeURIComponent( name );
value = encodeURIComponent( value );
pairs.push( name + "=" + value );
}
return pairs.join('&');
}
if ( ! window.getComputedStyle ) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
}
return this;
}
}
function displayIt(type, msg){
if (msg === 'alt-php packages not found') {
msg = 'PHPselector requires additional packages to be installed in order to work properly. \nPlease contact the server administrators, so they could proceed with the installation. \nHere is the guide: <a href="https://docs.cloudlinux.com/index.html?php_selector_installation.html">https://docs.cloudlinux.com/index.html?php_selector_installation.html</a>';
}
var body = document.getElementsByTagName('body')[0],
msgbox = document.createElement('div'),
msgelem = document.createTextNode(msg),
leftOffset = findLeftOffset(message_box),
topOffset = findTopOffset(message_box),
scrollOffset = (window.pageYOffset ? window.pageYOffset : 0),
pageWidth = (ie ? window.getComputedStyle(message_box).getPropertyValue('width') : message_box.offsetWidth+'px'),
maxLen = 0;
pageWidth = (pageWidth == 'auto' ? 751 : parseInt(pageWidth));
if ( Object.prototype.toString.call( msg ) === '[object Array]') {
msg_array = msg;
}
else {
msg_array = msg.replace(/[\t\r]/g, '').split('\n').map(
function(x){return x.replace(/(?:ERROR|WARN):/g,"");}
);
}
removeElem();
msgbox.setAttribute('id','popup');
msgbox.style.fontWeight = "bold";
msgbox.style.fontFamily = "trebuchet ms,arial,helvetica,sans-serif";
msgbox.style.fontSize = "13px";
msgbox.style.position = "absolute";
msgbox.style.boxShadow = "0 3px 6px #3F3F3F";
msgbox.style.top = (topOffset + scrollOffset + 32) + 'px';
msgbox.style.height = (1.5 * msg_array.length + 1.5) + 'em';
msgbox.style.overflowY = 'scroll';
msgbox.style.zIndex = 99999;
if ( type == 'error' ) {
msgbox.style.color = "#F00";
msgbox.style.backgroundColor = "#FFEFEF";
msgbox.style.border = "1px solid #F00";
}
else if ( type == 'warn' ) {
msgbox.style.color = "#FF8002";
msgbox.style.backgroundColor = "#FFF7EF";
msgbox.style.border = "1px solid #FF8002";
}
else if ( type == 'info' ) {
msgbox.style.color = "#1E7F2B";
msgbox.style.backgroundColor = "#F1FFEF";
msgbox.style.border = "1px solid #1E7F2B";
} else {
msgbox.style.color = "#FF8002";
msgbox.style.backgroundColor = "#FFF7EF";
msgbox.style.border = "1px solid #FF8002";
}
for ( var i in msg_array ) {
if ( typeof(msg_array[i]) != 'string' )
continue;
var content = msg_array[i], d = document.createElement('div'),
hasLink = /<a\s+.*?>(.*)<\/a>/.test(content), link = null;
if ( hasLink ) {
content = content.replace(/<a\s+.*?>(.*)<\/a>/, '');
link = document.createElement('a');
var linkContent = (msg_array[i].match(/<\s*?a\b[^>]*>(.*?)<\/a\b[^>]*>/) || ["", ""])[1];
link.href = linkContent;
link.innerText = linkContent;
}
if ( content.length > maxLen )
maxLen = content.length;
var ds = document.createTextNode(content);
d.appendChild(ds);
if ( hasLink ) {
d.appendChild(link);
}
d.style.margin = '.28em 0 0 2em';
msgbox.appendChild(d);
}
var stringLen = Math.ceil(maxLen * 8) + 64,
boxOffset = (pageWidth - stringLen) / 2;
msgbox.style.left = (leftOffset + boxOffset) + 'px';
msgbox.style.width = stringLen + 'px';
message_box.appendChild(msgbox);
setTimeout(fadeOutPopup, 4000);
}
function encodeUnicode(string){
var utfdata = "";
string = string.replace(/\r\n/g,"\n");
for (var n=0; n<string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utfdata += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utfdata += String.fromCharCode((c >> 6) | 192);
utfdata += String.fromCharCode((c & 63) | 128);
}
else {
utfdata += String.fromCharCode((c >> 12) | 224);
utfdata += String.fromCharCode(((c >> 6) & 63) | 128);
utfdata += String.fromCharCode((c & 63) | 128);
}
}
return utfdata;
}
function encodeBase64(input) {
var output = "",
i = 0,
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
input = encodeUnicode(input);
while (i<input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
}
else if (isNaN(chr3)) {
enc4 = 64;
}
output = output
+ keyStr.charAt(enc1)
+ keyStr.charAt(enc2)
+ keyStr.charAt(enc3)
+ keyStr.charAt(enc4);
}
return output;
}
function stripVersion(data) {
if (data.indexOf('(') != -1)
return data.substring(0, data.indexOf('(')-1);
return data;
}
Zerion Mini Shell 1.0