mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
feature: allow users to manage ssh keys
This commit is contained in:
@@ -1,57 +1,15 @@
|
||||
// Core javascript helper functions
|
||||
|
||||
// basic browser identification & version
|
||||
var isOpera = (navigator.userAgent.indexOf("Opera") >= 0) && parseFloat(navigator.appVersion);
|
||||
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
|
||||
|
||||
// Cross-browser event handlers.
|
||||
function addEvent(obj, evType, fn) {
|
||||
'use strict';
|
||||
if (obj.addEventListener) {
|
||||
obj.addEventListener(evType, fn, false);
|
||||
return true;
|
||||
} else if (obj.attachEvent) {
|
||||
var r = obj.attachEvent("on" + evType, fn);
|
||||
return r;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function removeEvent(obj, evType, fn) {
|
||||
'use strict';
|
||||
if (obj.removeEventListener) {
|
||||
obj.removeEventListener(evType, fn, false);
|
||||
return true;
|
||||
} else if (obj.detachEvent) {
|
||||
obj.detachEvent("on" + evType, fn);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function cancelEventPropagation(e) {
|
||||
'use strict';
|
||||
if (!e) {
|
||||
e = window.event;
|
||||
}
|
||||
e.cancelBubble = true;
|
||||
if (e.stopPropagation) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
'use strict';
|
||||
|
||||
// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
|
||||
function quickElement() {
|
||||
'use strict';
|
||||
var obj = document.createElement(arguments[0]);
|
||||
const obj = document.createElement(arguments[0]);
|
||||
if (arguments[2]) {
|
||||
var textNode = document.createTextNode(arguments[2]);
|
||||
const textNode = document.createTextNode(arguments[2]);
|
||||
obj.appendChild(textNode);
|
||||
}
|
||||
var len = arguments.length;
|
||||
for (var i = 3; i < len; i += 2) {
|
||||
const len = arguments.length;
|
||||
for (let i = 3; i < len; i += 2) {
|
||||
obj.setAttribute(arguments[i], arguments[i + 1]);
|
||||
}
|
||||
arguments[1].appendChild(obj);
|
||||
@@ -60,7 +18,6 @@ function quickElement() {
|
||||
|
||||
// "a" is reference to an object
|
||||
function removeChildren(a) {
|
||||
'use strict';
|
||||
while (a.hasChildNodes()) {
|
||||
a.removeChild(a.lastChild);
|
||||
}
|
||||
@@ -68,19 +25,14 @@ function removeChildren(a) {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Find-position functions by PPK
|
||||
// See http://www.quirksmode.org/js/findpos.html
|
||||
// See https://www.quirksmode.org/js/findpos.html
|
||||
// ----------------------------------------------------------------------------
|
||||
function findPosX(obj) {
|
||||
'use strict';
|
||||
var curleft = 0;
|
||||
let curleft = 0;
|
||||
if (obj.offsetParent) {
|
||||
while (obj.offsetParent) {
|
||||
curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
// IE offsetParent does not include the top-level
|
||||
if (isIE && obj.parentElement) {
|
||||
curleft += obj.offsetLeft - obj.scrollLeft;
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
} else if (obj.x) {
|
||||
curleft += obj.x;
|
||||
@@ -89,16 +41,11 @@ function findPosX(obj) {
|
||||
}
|
||||
|
||||
function findPosY(obj) {
|
||||
'use strict';
|
||||
var curtop = 0;
|
||||
let curtop = 0;
|
||||
if (obj.offsetParent) {
|
||||
while (obj.offsetParent) {
|
||||
curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
// IE offsetParent does not include the top-level
|
||||
if (isIE && obj.parentElement) {
|
||||
curtop += obj.offsetTop - obj.scrollTop;
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
} else if (obj.y) {
|
||||
curtop += obj.y;
|
||||
@@ -109,16 +56,9 @@ function findPosY(obj) {
|
||||
//-----------------------------------------------------------------------------
|
||||
// Date object extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
(function() {
|
||||
'use strict';
|
||||
{
|
||||
Date.prototype.getTwelveHours = function() {
|
||||
var hours = this.getHours();
|
||||
if (hours === 0) {
|
||||
return 12;
|
||||
}
|
||||
else {
|
||||
return hours <= 12 ? hours : hours - 12;
|
||||
}
|
||||
return this.getHours() % 12 || 12;
|
||||
};
|
||||
|
||||
Date.prototype.getTwoDigitMonth = function() {
|
||||
@@ -145,14 +85,6 @@ function findPosY(obj) {
|
||||
return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
|
||||
};
|
||||
|
||||
Date.prototype.getHourMinute = function() {
|
||||
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
|
||||
};
|
||||
|
||||
Date.prototype.getHourMinuteSecond = function() {
|
||||
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
|
||||
};
|
||||
|
||||
Date.prototype.getFullMonthName = function() {
|
||||
return typeof window.CalendarNamespace === "undefined"
|
||||
? this.getTwoDigitMonth()
|
||||
@@ -160,7 +92,7 @@ function findPosY(obj) {
|
||||
};
|
||||
|
||||
Date.prototype.strftime = function(format) {
|
||||
var fields = {
|
||||
const fields = {
|
||||
B: this.getFullMonthName(),
|
||||
c: this.toString(),
|
||||
d: this.getTwoDigitDate(),
|
||||
@@ -177,7 +109,7 @@ function findPosY(obj) {
|
||||
Y: '' + this.getFullYear(),
|
||||
'%': '%'
|
||||
};
|
||||
var result = '', i = 0;
|
||||
let result = '', i = 0;
|
||||
while (i < format.length) {
|
||||
if (format.charAt(i) === '%') {
|
||||
result = result + fields[format.charAt(i + 1)];
|
||||
@@ -191,36 +123,35 @@ function findPosY(obj) {
|
||||
return result;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// String object extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
String.prototype.pad_left = function(pad_length, pad_string) {
|
||||
var new_string = this;
|
||||
for (var i = 0; new_string.length < pad_length; i++) {
|
||||
new_string = pad_string + new_string;
|
||||
}
|
||||
return new_string;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// String object extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
String.prototype.strptime = function(format) {
|
||||
var split_format = format.split(/[.\-/]/);
|
||||
var date = this.split(/[.\-/]/);
|
||||
var i = 0;
|
||||
var day, month, year;
|
||||
const split_format = format.split(/[.\-/]/);
|
||||
const date = this.split(/[.\-/]/);
|
||||
let i = 0;
|
||||
let day, month, year;
|
||||
while (i < split_format.length) {
|
||||
switch (split_format[i]) {
|
||||
case "%d":
|
||||
day = date[i];
|
||||
break;
|
||||
case "%m":
|
||||
month = date[i] - 1;
|
||||
break;
|
||||
case "%Y":
|
||||
case "%d":
|
||||
day = date[i];
|
||||
break;
|
||||
case "%m":
|
||||
month = date[i] - 1;
|
||||
break;
|
||||
case "%Y":
|
||||
year = date[i];
|
||||
break;
|
||||
case "%y":
|
||||
// A %y value in the range of [00, 68] is in the current
|
||||
// century, while [69, 99] is in the previous century,
|
||||
// according to the Open Group Specification.
|
||||
if (parseInt(date[i], 10) >= 69) {
|
||||
year = date[i];
|
||||
break;
|
||||
case "%y":
|
||||
year = date[i];
|
||||
break;
|
||||
} else {
|
||||
year = (new Date(Date.UTC(date[i], 0))).getUTCFullYear() + 100;
|
||||
}
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
@@ -229,22 +160,4 @@ function findPosY(obj) {
|
||||
// date extraction.
|
||||
return new Date(Date.UTC(year, month, day));
|
||||
};
|
||||
|
||||
})();
|
||||
// ----------------------------------------------------------------------------
|
||||
// Get the computed style for and element
|
||||
// ----------------------------------------------------------------------------
|
||||
function getStyle(oElm, strCssRule) {
|
||||
'use strict';
|
||||
var strValue = "";
|
||||
if(document.defaultView && document.defaultView.getComputedStyle) {
|
||||
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
|
||||
}
|
||||
else if(oElm.currentStyle) {
|
||||
strCssRule = strCssRule.replace(/\-(\w)/g, function(strMatch, p1) {
|
||||
return p1.toUpperCase();
|
||||
});
|
||||
strValue = oElm.currentStyle[strCssRule];
|
||||
}
|
||||
return strValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user