Select Git revision
vcs.git.class.php
-
Hahn Axel (hahn) authoredHahn Axel (hahn) authored
functions.js 2.58 KiB
var sSELECTEDSERVER='';
var sACTIVESERVERTAB='cronlogs';
/**
* get query parameters from url as object
* @returns {object}
*/
function getQueryParams() {
qs = document.location.search.split('+').join(' ');
var params = {},
tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
return params;
}
/**
* make an ajax-request and put response content into given div id
* @param {string} id id of the div to be filled
* @returns {undefined}
*/
function getPageItem(id, sData) {
// $('#'+id).html('reading ...');
if(!$('#'+id).hasClass('active')){
$('#errorlog').html('#'+id+' is not active') ;
return false;
}
var phpscript='get.php';
$('#'+id).css('opacity', '0.2');
if(!sData){
sData='item='+id+'&server='+sSELECTEDSERVER;
}
jQuery.ajax({
url: phpscript,
data: sData,
type: "GET",
success:function(data){
$('#'+id).css('opacity', '1');
$('#'+id).html(data);
},
error:function(){
$('#'+id).css('opacity', false);
$('#'+id).html('Failed :-/');
$('#errorlog').html(
$('#errorlog').html('AJAX error: <a href="'+phpscript+'?' + sData+'">'+phpscript+'?' + sData+'</a>')
);
}
});
}
/**
* set server (show its navigation)
* tghis action is used after clicking a servername in the navigation
*
* @param {string} sServer
* @returns {undefined}
*/
function setServer(sServer){
if(!sServer){
return false;
}
sSELECTEDSERVER=sServer;
$('#lblServername').html('<i class="far fa-hdd"></i> '+sSELECTEDSERVER);
getPageItem(sACTIVESERVERTAB);
}
/**
* onclick callback for tabs crontable, crontabs, graph
* @param {object} oLink clicked link
* @returns {undefined}
*/
function setTab(oLink){
sTabid=$(oLink).attr('href').replace(/^#/, '');
sACTIVESERVERTAB=sTabid;
$('nav.tabs a').each(function(){
$(this).removeClass('active');
});
$(oLink).addClass('active');
$('#tabcontent div').each(function(){
$(this).removeClass('active');
});
$('#'+sTabid).addClass('active');
setServer(sSELECTEDSERVER);
}
function showFile(sLogfile){
getPageItem(sACTIVESERVERTAB, 'item=showlog&logfile='+sLogfile);
}
function showFileBack(){
getPageItem(sACTIVESERVERTAB);
}