From 3d1eadccf4964cf7c57272b4e55e918aa79e49dd Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Thu, 11 Jul 2013 08:29:33 -0400
Subject: [PATCH] - Fixed: distribution recognition of debian wheezy
---
interface/web/js/scrigo.js.php | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 202 insertions(+), 20 deletions(-)
diff --git a/interface/web/js/scrigo.js.php b/interface/web/js/scrigo.js.php
index 0e3fe68..c78406a 100644
--- a/interface/web/js/scrigo.js.php
+++ b/interface/web/js/scrigo.js.php
@@ -1,10 +1,23 @@
<?php
session_start();
include('../../lib/config.inc.php');
+ header('Content-Type: text/javascript; charset=utf-8'); // the config file sets the content type header so we have to override it here!
+ require_once('../../lib/app.inc.php');
$lang = (isset($_SESSION['s']['language']) && $_SESSION['s']['language'] != '')?$_SESSION['s']['language']:'en';
include_once(ISPC_ROOT_PATH.'/web/strengthmeter/lib/lang/'.$lang.'_strengthmeter.lng');
+
+ $app->uses('ini_parser,getconf');
+ $server_config_array = $app->getconf->get_global_config();
?>
-
+var pageFormChanged = false;
+var tabChangeWarningTxt = '';
+var tabChangeDiscardTxt = '';
+var tabChangeWarning = false;
+var tabChangeDiscard = false;
+var requestsRunning = 0;
+var indicatorPaddingH = -1;
+var indicatorPaddingW = -1;
+var indicatorCompleted = false;
redirect = '';
function reportError(request) {
@@ -15,6 +28,61 @@
/*alert(request);*/
}
+function resetFormChanged() {
+ pageFormChanged = false;
+}
+
+function showLoadIndicator() {
+ document.body.style.cursor = 'wait';
+
+<?php
+if($server_config_array['misc']['use_loadindicator'] == 'y'){
+?>
+ requestsRunning += 1;
+
+ if(requestsRunning < 2) {
+ var indicator = jQuery('#ajaxloader');
+ if(indicator.length < 1) {
+ indicator = jQuery('<div id="ajaxloader" style="display: none;"></div>');
+ indicator.appendTo('body');
+ }
+ var parent = jQuery('#content');
+ if(parent.length < 1) return;
+ indicatorCompleted = false;
+
+ var atx = parent.offset().left + 150; //((parent.outerWidth(true) - indicator.outerWidth(true)) / 2);
+ var aty = parent.offset().top + 150;
+ indicator.css( {'left': atx, 'top': aty } ).fadeIn('fast', function() {
+ // check if loader should be hidden immediately
+ indicatorCompleted = true;
+ if(requestsRunning < 1) $(this).fadeOut('fast', function() { $(this).hide();});
+ });
+ }
+<?php
+}
+?>
+}
+
+function hideLoadIndicator() {
+ document.body.style.cursor = '';
+
+ requestsRunning -= 1;
+ if(requestsRunning < 1) {
+ requestsRunning = 0; // just for the case...
+ if(indicatorCompleted == true) jQuery('#ajaxloader').fadeOut('fast', function() { jQuery('#ajaxloader').hide(); } );
+ }
+}
+
+function onAfterContentLoad() {
+<?php
+if($server_config_array['misc']['use_combobox'] == 'y'){
+?>
+ $('#pageContent').find("select").combobox();
+<?php
+}
+?>
+}
+
function loadContentRefresh(pagename) {
if(document.getElementById('refreshinterval').value > 0) {
@@ -22,12 +90,19 @@
url: pagename,
data: "refresh="+document.getElementById('refreshinterval').value,
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
+ hideLoadIndicator();
jQuery('#pageContent').html(jqXHR.responseText);
+ onAfterContentLoad();
+ pageFormChanged = false;
},
error: function() {
+ hideLoadIndicator();
reportError('Ajax Request was not successful.'+pagename);
- },
+ }
});
setTimeout( "loadContentRefresh('"+pagename+"&refresh="+document.getElementById('refreshinterval').value+"')", document.getElementById('refreshinterval').value*1000 );
}
@@ -38,6 +113,9 @@
url: "capp.php",
data: "mod="+module+((redirect != undefined) ? '&redirect='+redirect : ''),
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
if(jqXHR.responseText != '') {
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
@@ -51,10 +129,12 @@
}
}
loadMenus();
+ hideLoadIndicator();
},
error: function() {
+ hideLoadIndicator();
reportError('Ajax Request was not successful.'+module);
- },
+ }
});
}
@@ -70,11 +150,19 @@
if(passwordObj.value == ''){
passwordObj.focus();
return;
- }
+ }
+
+ $('#dummy_username').val(userNameObj.value);
+ $('#dummy_passwort').val(passwordObj.value);
+ $('#dummy_login_form').submit();
+
var submitFormObj = jQuery.ajax({ type: "POST",
url: "content.php",
data: jQuery('#'+formname).serialize(),
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
var parts = jqXHR.responseText.split(':');
@@ -87,12 +175,16 @@
document.location.href = 'index.php';
} else {
jQuery('#pageContent').html(jqXHR.responseText);
+ onAfterContentLoad();
+ pageFormChanged = false;
}
loadMenus();
+ hideLoadIndicator();
},
error: function() {
+ hideLoadIndicator();
reportError('Ajax Request was not successful.110');
- },
+ }
});
/*
if(redirect != '') {
@@ -109,6 +201,9 @@
url: target,
data: jQuery('#'+formname).serialize(),
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
var parts = jqXHR.responseText.split(':');
@@ -118,12 +213,16 @@
//window.setTimeout('loadContent(redirect)', 1000);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
+ onAfterContentLoad();
+ pageFormChanged = false;
}
+ hideLoadIndicator();
},
error: function(jqXHR, textStatus, errorThrown) {
+ hideLoadIndicator();
var parts = jqXHR.responseText.split(':');
reportError('Ajax Request was not successful. 111');
- },
+ }
});
/*
if(redirect != '') {
@@ -134,12 +233,17 @@
}
function submitFormConfirm(formname,target,confirmation) {
+ var successMessage = arguments[3];
if(window.confirm(confirmation)) {
var submitFormObj = jQuery.ajax({ type: "POST",
url: target,
data: jQuery('#'+formname).serialize(),
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
+ if(successMessage) alert(successMessage);
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
var parts = jqXHR.responseText.split(':');
//alert(parts[1]);
@@ -148,12 +252,16 @@
//window.setTimeout('loadContent(redirect)', 1000);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
+ onAfterContentLoad();
+ pageFormChanged = false;
}
+ hideLoadIndicator();
},
error: function(jqXHR, textStatus, errorThrown) {
+ hideLoadIndicator();
var parts = jqXHR.responseText.split(':');
reportError('Ajax Request was not successful. 111');
- },
+ }
});
}
}
@@ -200,11 +308,13 @@
}
function loadContent(pagename) {
+ var params = arguments[1];
var pageContentObject2 = jQuery.ajax({ type: "GET",
url: pagename,
+ data: (params ? params : null),
dataType: "html",
beforeSend: function() {
- jQuery('#pageContent').html('<div id="ajaxloader"><img src="themes/default/images/ajax-loader.gif" /></div>');
+ showLoadIndicator();
},
success: function(data, textStatus, jqXHR) {
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
@@ -220,11 +330,15 @@
//jQuery.each(reponseScript, function(idx, val) { eval(val.text); } );
jQuery('#pageContent').html(jqXHR.responseText);
+ onAfterContentLoad();
+ pageFormChanged = false;
}
+ hideLoadIndicator();
},
error: function() {
+ hideLoadIndicator();
reportError('Ajax Request was not successful. 113');
- },
+ }
});
}
@@ -234,17 +348,24 @@
url: "content.php",
data: "s_mod=login&s_pg=index",
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
var parts = jqXHR.responseText.split(":");
loadContent(parts[1]);
} else {
jQuery('#pageContent').html(jqXHR.responseText);
+ onAfterContentLoad();
+ pageFormChanged = false;
}
+ hideLoadIndicator();
},
error: function() {
+ hideLoadIndicator();
reportError('Ajax Request was not successful. 114');
- },
+ }
});
loadMenus();
@@ -255,7 +376,7 @@
function setFocus() {
try {
- document.pageForm.username.focus();
+ jQuery('form#pageForm').find('input[name="username"]').focus();
} catch (e) {
}
}
@@ -266,32 +387,66 @@
url: "nav.php",
data: "nav=side",
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
+ hideLoadIndicator();
jQuery('#sideNav').html(jqXHR.responseText);
},
error: function() {
+ hideLoadIndicator();
reportError('Ajax Request was not successful. 115');
- },
+ }
});
var topNavObject = jQuery.ajax({ type: "GET",
url: "nav.php",
data: "nav=top",
dataType: "html",
+ beforeSend: function() {
+ showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
+ hideLoadIndicator();
jQuery('#topNav').html(jqXHR.responseText);
},
error: function(o) {
+ hideLoadIndicator();
reportError('Ajax Request was not successful. 116');
- },
+ }
});
}
-function changeTab(tab,target) {
+function changeTab(tab,target,force) {
//document.forms[0].next_tab.value = tab;
document.pageForm.next_tab.value = tab;
- submitForm('pageForm',target);
+
+ var idel = jQuery('form#pageForm').find('[name="id"]');
+ var id = null;
+ if(idel.length > 0) id = idel.val();
+ if(tabChangeDiscard == 'y' && !force) {
+ if((idel.length < 1 || id) && (pageFormChanged == false || window.confirm(tabChangeDiscardTxt))) {
+ var next_tab = tab;
+ if(id) loadContent(target, {'next_tab': next_tab, 'id': id});
+ else loadContent(target, {'next_tab': next_tab});
+ } else {
+ return false;
+ }
+ } else {
+ if(id && tabChangeWarning == 'y' && pageFormChanged == true) {
+ if(window.confirm(tabChangeWarningTxt)) {
+ submitForm('pageForm', target);
+ } else {
+ var next_tab = tab;
+ if(id) loadContent(target, {'next_tab': next_tab, 'id': id});
+ else loadContent(target, {'next_tab': next_tab});
+ }
+ } else {
+ submitForm('pageForm',target);
+ }
+ }
}
function del_record(link,confirmation) {
@@ -310,12 +465,17 @@
var pageContentObject2 = jQuery.ajax({ type: "GET",
url: pagename,
dataType: "html",
+ beforeSend: function() {
+// showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
+// hideLoadIndicator();
jQuery('#'+elementid).html(jqXHR.responseText);
},
error: function() {
+// hideLoadIndicator();
reportError('Ajax Request was not successful. 118');
- },
+ }
});
}
@@ -323,7 +483,11 @@
var pageContentObject2 = jQuery.ajax({ type: "GET",
url: pagename,
dataType: "html",
+ beforeSend: function() {
+// showLoadIndicator();
+ },
success: function(data, textStatus, jqXHR) {
+// hideLoadIndicator();
var teste = jqXHR.responseText;
var elemente = teste.split('#');
el=document.getElementById(elementid);
@@ -337,8 +501,9 @@
}
},
error: function() {
+// hideLoadIndicator();
reportError('Ajax Request was not successful. 119');
- },
+ }
});
}
@@ -351,7 +516,7 @@
},
error: function() {
reportError('Session expired. Please login again.');
- },
+ }
});
//setTimeout( keepalive, 1000000 );
}
@@ -563,6 +728,8 @@
newPWField.attr('id', passwordFieldID).val(pword).trigger('keyup');
}
+var funcDisableClick = function(e) { e.preventDefault(); return false; };
+
function checkPassMatch(pwField1,pwField2){
var rpass = jQuery('#'+pwField2).val();
var npass = jQuery('#'+pwField1).val();
@@ -570,13 +737,22 @@
jQuery('#confirmpasswordOK').hide();
jQuery('#confirmpasswordError').show();
jQuery('button.positive').attr('disabled','disabled');
- jQuery('.tabbox_tabs ul li a').attr('onclick','return false;');
+ jQuery('.tabbox_tabs ul li a').each(function() {
+ var $this = $(this);
+ $this.data('saved_onclick', $this.attr('onclick'));
+ $this.removeAttr('onclick');
+ $this.click(funcDisableClick);
+ });
return false;
} else {
jQuery('#confirmpasswordError').hide();
jQuery('#confirmpasswordOK').show();
jQuery('button.positive').removeAttr('disabled');
- jQuery('.tabbox_tabs ul li a').removeAttr('onclick');
+ jQuery('.tabbox_tabs ul li a').each(function() {
+ var $this = $(this);
+ $this.unbind('click', funcDisableClick);
+ if($this.data('saved_onclick') && !$this.attr('onclick')) $this.attr('onclick', $this.data('saved_onclick'));
+ });
}
}
@@ -589,6 +765,12 @@
var template = jQuery(this).siblings(':input');
template.insertAtCaret(placeholderText);
});
+
+jQuery('.addPlaceholderContent').live("click", function(){
+ var placeholderContentText = jQuery(this).find('.addPlaceholderContent').text();
+ var template2 = jQuery(this).siblings(':input');
+ template2.insertAtCaret(placeholderContentText);
+});
jQuery.fn.extend({
insertAtCaret: function(myValue){
--
Gitblit v1.9.1