PK
Default page
- Your IP: 198.50.126.145
- Server IP: 198.50.126.145
- Server: Linux servidor.grupodeallus.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
- Server Software: Apache
- PHP Version: 8.2.29
-
Buat File |
Buat Folder
Edit File: alt-selector.js
';
}
tag.innerHTML = html;
}
return tag;
}(data['data']['domain'], data['data']['domains'], data['data']['uri']));
//Create path elem
dom['wsgi'] = (function(t){
var span = document.createElement('span');
span.appendChild(document.createTextNode(t));
return span;
}(data['data']['wsgi']||''));
//Create selector elem
dom['version'] = (function(v, a){
var s = document.createElement('select');
s.className = 'app-versionselector';
a.forEach(function(i){
var opt = document.createElement('option');
opt.appendChild(document.createTextNode(i));
if (i === v) opt.selected = true;
s.appendChild(opt);
});
return s;
}(data['data']['version'], data['data']['interpreters']));
//Create modules list
dom['modules'] = (function(obj){
var table = (function(){
var t = document.createElement('table');
t.style.borderCollapse = 'collapse';
return t
}()),
tbody = document.createElement('tbody'),
divs = [1, 2, 3, 4].map(function(v){
return document.createElement('div')
});
tbody.appendChild((function(data){
var dom = ['tr', 'td', 'td', 'input'].map(function(i){
return document.createElement(i)
});
dom[1].colSpan = '2';
dom[2].className = 'app-modadd';
dom[2].appendChild(document.createTextNode('Add'));
self._style(dom[2], {
textAlign: 'left',
padding: '.2em',
cursor: 'pointer',
textDecoration: 'underline'
});
dom[3].type = 'text';
dom[3].className = 'app-modaddfield';
dom[1].appendChild(dom[3]);
dom.slice(1,3).forEach(function(i){dom[0].appendChild(i)});
return dom[0];
}(data['data'])));
//Path and URI rows styling
[divs[0], divs[2]].forEach(function(i){
self._style(i, {
textAlign: 'left',
padding: '.2em',
cursor: 'pointer',
textDecoration: 'underline'
});
});
//Creating table rows for modules
for (var row in obj) {
if (!obj.hasOwnProperty(row)) continue;
tbody.appendChild((function(row, data){
var dom = ['tr', 'td', 'td', 'td'].map(function(i){
return document.createElement(i)
});
dom.slice(1,2).forEach(function(i){self._style(i, {
minWidth: '6em', padding: '.2em'
})});
dom[1].appendChild(document.createTextNode(row));
dom[2].appendChild(document.createTextNode(obj[row]));
self._style(dom[3], {
cursor: 'pointer', padding: '.2em', textAlign: 'right'
});
dom[3].className = 'app-modremove';
dom[3].appendChild(document.createTextNode('[x]'));
dom.slice(1).forEach(function(i){dom[0].appendChild(i)});
self._style(dom[0], {borderBottom:b_style});
dom[0].className = 'app-modentry';
return dom[0];
}(row, data['data'])));
}
table.appendChild(tbody);
divs[0].className = 'app-modexpand';
divs[0].appendChild(document.createTextNode('show'));
divs[1].appendChild(table);
divs[2].className = 'app-modcollapse';
divs[2].appendChild(document.createTextNode('hide'));
divs.slice(1,3).forEach(function(i){self._style(i, {display: 'none'})});
divs.slice(0,3).forEach(function(i){divs[3].appendChild(i)});
return divs.pop();
}(data['data']['modules']));
//Create execute
dom['execute'] = (function(){
var fragment = document.createDocumentFragment();
var input = document.createElement('input'); input.type = 'text';
input.setAttribute('class', 'app-executecmd form-control');
input.setAttribute('style', 'width: 50%; float:left;');
input.setAttribute('placeholder', '0-9a-zA-Z /_-.,"~>< symbols are allowed');
fragment.appendChild(input);
var button = document.createElement('button');
self._style(button, {minWidth: '5.2em'});
button.appendChild(document.createTextNode('Run'));
button.setAttribute('class', 'app-execute btn btn-default input-button');
fragment.appendChild(button);
return fragment;
}());
//Create show virtual environment activate command
dom['activate'] = (function(activate_cmd){
var activate_line = document.createElement('span');
activate_line.setAttribute('class', 'enter-virtualenv-cmd');
activate_line.appendChild(document.createTextNode(activate_cmd));
return activate_line;
}(data['data']['activate']));
//Creating app table rows
var titles = req['alt'] === 'python'
? ['path', 'uri', 'domains', 'wsgi', 'version', 'modules', 'execute', 'activate']
: ['path', 'uri', 'domains', 'version', 'modules', 'execute', 'activate'];
titles.forEach(function(i){
var cells = ['tr', 'td', 'td', 'td'].map(function(j){
return document.createElement(j)
});
cells[0].className = 'app-' + i + 'section';
self._style(cells[1], {
borderRight: b_style,
borderBottom: b_style,
width: '20%',
textAlign: 'right',
fontSize: '.92em',
padding: '.1em .6em',
height: '2em'
});
cells[1].appendChild(document.createTextNode(title_alias[i]));
self._style(cells[2], {
borderBottom: b_style,
width: '73%',
fontSize: '.92em',
padding: '.1em .6em',
height: '2em'
});
cells[2].appendChild(dom[i]);
if (i === 'version') {
cells[2].appendChild((function(v){
var el = document.createElement('span');
self._style(el, {display:'none'});
el.appendChild(document.createTextNode(v));
return el;
}(data['data']['version'])));
} else if (i === 'domains') {
cells[2].className = 'app-additionaldomains-list';
}
self._style(cells[3], {
borderBottom: b_style,
width: '7%',
fontSize: '.92em',
padding: '.1em .6em',
height: '2em'
});
if (i === 'path' || i === 'uri' || i === 'wsgi') {
cells[3].appendChild((function(t){
var el = document.createElement('span');
self._style(el, {cursor:'pointer', textDecoration:'underline'});
el.className = 'app-' + i + 'edit';
el.appendChild(document.createTextNode(t));
return el;
}('Edit')));
} else {
cells[3].appendChild(document.createTextNode('\u00A0'));
}
if (i === 'domains' && cells[2].getElementsByTagName("a").length == 0) {
cells[0].style.display = 'none';
}
cells.slice(1).forEach(function(j){cells[0].appendChild(j)});
dom['tbody'].appendChild(cells[0]);
});
self._style(dom['table'], {borderSpacing: '0', width: '100%'});
dom['table'].appendChild(dom['tbody']);
self._style(dom['info'], {margin: '.2em'});
dom['info'].appendChild(dom['table']);
self._style(dom['controls'], {height: '2.32em', paddingLeft: '1em'});
['update', 'reset', 'restart', 'remove'].forEach(function(i){
var b = 'b_'+i;
dom[b].className = 'app-'+ i + ' btn btn-default input-button';
dom[b].style.minWidth = '5.2em';
dom[b].appendChild(document.createTextNode(i.charAt(0).toUpperCase() + i.slice(1)));
if (i === 'remove')
self._style(dom[i], {marginLeft: '2em'});
else if (i === 'update' || i === 'reset')
dom[b].disabled = true;
dom[i].appendChild(dom[b]);
self._style(dom[i], {cssFloat: 'left', minWidth: '5.2em'});
dom['controls'].appendChild(dom[i]);
});
['info', 'controls'].forEach(function(i){
dom['container'].appendChild(dom[i])
});
self._style(dom['container'], {
border: b_style, borderRadius: '.2em', margin: '.4em 1em'
});
dom['container'].className = 'app-container';
dom['container'].id = self.id;
self.parent.appendChild(dom['container']);
self.add_hook();
var path_field = document.getElementById('project-path-field'),
uri_field = document.getElementById('project-uri-field');
if (path_field !== null) path_field.value = '';
if (uri_field !== null) uri_field.value = '';
var app_count = document.getElementById('app-count');
if (app_count) {
var counter = parseInt(app_count.firstChild.nodeValue);
if (isNaN(counter)) counter = 0;
app_count.firstChild.nodeValue = counter+1;
}
self._enable_controls();
};
//Batch style setter
this._style = function(o, s){
s = s || {};
for (var i in s) {
if (!s.hasOwnProperty(i)) continue;
o.style[i] = s[i];
}
};
this.empty = function(el){
while (el.firstChild)
el.removeChild(el.firstChild);
};
this.enable_buttons = function(){
var controls = document.getElementById(this.id).lastElementChild,
upd = controls.firstElementChild.firstElementChild,
rst = controls.firstElementChild.nextElementSibling.firstElementChild;
upd.disabled = false;
rst.disabled = false;
};
this.disable_buttons = function(){
var controls = document.getElementById(this.id).lastElementChild,
upd = controls.firstElementChild.firstElementChild,
rst = controls.firstElementChild.nextElementSibling.firstElementChild;
upd.disabled = true;
rst.disabled = true;
};
/**
* Display layout over the passed 'parent'element with message: Please wait... or another message
* @param parent:
* @param message
* @private
*/
this._disable_controls = function(parent, message){
if (parent === undefined)
parent = document.getElementById('project-control');
if (parent === null) return;
var div = document.createElement('div'),
span = document.createElement('span'),
top = (parent.offsetTop+2) + 'px',
left = (parent.offsetLeft+2) + 'px',
width = (parseInt(window.getComputedStyle(parent, null).width)-1) + 'px',
height = (parseInt(window.getComputedStyle(parent, null).height)-1) + 'px';
div.id = 'modal-layer';
div.setAttribute('class', 'modal-layer');
this._style(div, {
position: 'absolute',
top: top,
left: left,
width: width,
height: height,
zIndex: '9999',
backgroundColor: 'rgba(155,163,178,.3)',
color: '#000',
textAlign: 'center',
lineHeight: height
});
this._style(span, {fontSize: '4em', fontWeight: 'bold'});
span.appendChild(document.createTextNode(message || 'Please wait...'));
div.appendChild(span);
parent.appendChild(div);
};
this._enable_controls = function(parent){
var div;
if(parent){
div = parent.getElementsByClassName('modal-layer')[0] || null;
} else {
div = document.getElementById('modal-layer');
}
if (div === null) return;
div.parentNode.removeChild(div);
};
this.appendlist = function(list, el){
var popup = document.getElementById('listpopup'),
o = window.pageYOffset ? window.pageYOffset : 0,
r = el.getBoundingClientRect(),
maxlen = Math.max.apply(null, list.map(function(i){return i.length})),
self = this,
appDiv = document.getElementById(this.id);
this.empty(popup);
for (i in list) {
if (typeof list[i] === 'function') continue;
var item = document.createElement('div');
this._style(item, {height:'1.2em'});
item.className = 'app-modadditem';
item.onmouseover = function(e){self._style(e.target, {backgroundColor:'#DBDBDB'})};
item.onmouseout = function(e){self._style(e.target, {backgroundColor:'#FFF'})};
item.onclick = function(e){
var curr = el.value,
pos = curr.lastIndexOf(','),
extension = e.target.firstChild.nodeValue,
data = {};
self._disable_controls(appDiv);
data = { extension: extension, action: self.alt + 'modver' };
self._sync(data, self.getVersionList, false, { field: el }); // synchronous request
self._enable_controls();
if(popup.getAttribute('verCount')) {
return;
}
if (pos !== -1)
curr = curr.substring(0, pos);
else
curr = '';
el.value = (curr !== '' ? curr + ',' + extension : extension) + ',';
};
item.appendChild(document.createTextNode(list[i]));
popup.appendChild(item);
}
this._style(popup, {top:(Math.round(r.bottom)+o)+'px',left:Math.round(r.left)+'px',overflow:'auto', width:maxlen+'em', zIndex:'9000'});
popup.style.maxHeight = '11.2em';
popup.style.display = 'block';
};
this.add_hook = function(){
var self = this,
el = document.getElementById(self.id),
char_patt = /[a-zA-Z0-9\-_]/;
if (el === null) return;
var f = el.getElementsByClassName('app-modaddfield')[0];
if (!f) return;
f.addEventListener('keypress', function(evt){
var charCode = evt.which || evt.keyCode,
charTyped = String.fromCharCode(charCode),
tgt = evt.target,
pos = tgt.value.lastIndexOf(','),
found = false,
data,
list = [];
if (modlist.length === 0) return;
if (pos !== -1) {
data = tgt.value.substring(pos+1);
}
else {
data = tgt.value;
}
if (char_patt.test(charTyped)) {
data += charTyped;
}
else if (charCode === 8) {
data = data.substring(0,data.length-1);
if (data === '')
data = tgt.value.charAt(tgt.value.length-1) === ',' ? tgt.value.substring(0, tgt.value.length-1) : tgt.value;
}
for (var i in modlist) {
if (modlist[i].toString().toLowerCase().indexOf(data.toLowerCase()) !== 0) {
if (!found)
continue;
else
break;
}
else {
if (!found)
found = true;
list.push(modlist[i]);
}
}
if (list.length === 0) {
var popup = document.getElementById('listpopup');
self.empty(popup);
popup.style.display = 'none';
return;
}
self.appendlist(list, tgt);
}, false);
};
this.getVersionList = function(self, data, req, params) {
var popup = document.getElementById('listpopup'),
div, versions,
sLength = 0;
if(data.status != 'OK') return false;
for(key in data.data) {
versions = data.data[key].versions;
if(versions.length <= 1)
continue;
popup.innerHTML = '';
for(var i=0; i