From d9bcf68e395d6156645a7974b1a992aa6e6c00aa Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Mon, 14 Oct 2013 08:57:25 -0400
Subject: [PATCH] Added missing empty directories from svn import

---
 interface/web/js/scrigo.js.php |  166 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 110 insertions(+), 56 deletions(-)

diff --git a/interface/web/js/scrigo.js.php b/interface/web/js/scrigo.js.php
index b3029f3..418b26b 100644
--- a/interface/web/js/scrigo.js.php
+++ b/interface/web/js/scrigo.js.php
@@ -1,8 +1,13 @@
 <?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 = '';
@@ -12,6 +17,7 @@
 var requestsRunning = 0;
 var indicatorPaddingH = -1;
 var indicatorPaddingW = -1;
+var indicatorCompleted = false;
 redirect = '';
 
 function reportError(request) {
@@ -22,41 +28,59 @@
 	/*alert(request);*/
 }
 
+function resetFormChanged() {
+    pageFormChanged = false;
+}
+
 function showLoadIndicator() {
+    document.body.style.cursor = 'wait';
+
+<?php
+if($server_config_array['misc']['use_loadindicator'] == 'y'){
+?>
     requestsRunning += 1;
     
-    var indicator = jQuery('#ajaxloader');
-    if(indicator.length < 1) {
-        indicator = jQuery('<div id="ajaxloader" style="display: none;"></div>');
-        indicator.appendTo('body');
+    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();});
+        });
     }
-    var parent = jQuery('#content');
-    if(parent.length < 1) return;
-    
-    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');
-    
-    /*var atx = parent.offset().left;
-    var aty = parent.offset().top;
-    if(indicatorPaddingW == -1) indicatorPaddingW = parseInt(indicator.css('padding-left')) + parseInt(indicator.css('padding-right'));
-    if(indicatorPaddingH == -1) indicatorPaddingH = parseInt(indicator.css('padding-top')) + parseInt(indicator.css('padding-bottom'));
-    var atw = parent.outerWidth() - indicatorPaddingW;
-    var ath = parent.outerHeight() - indicatorPaddingH;
-    
-    indicator.css( {'left': atx, 'top': aty, 'width': atw, 'height': ath } ).fadeIn('fast');*/
+<?php
+}
+?>
 }
 
 function hideLoadIndicator() {
+    document.body.style.cursor = '';
+
     requestsRunning -= 1;
     if(requestsRunning < 1) {
-        jQuery('#ajaxloader').fadeOut('fast', function() { jQuery('#ajaxloader').hide(); } );
         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) {
@@ -93,7 +117,6 @@
 												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
 												if(jqXHR.responseText != '') {
 													if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
 														var parts = jqXHR.responseText.split(':');
@@ -106,6 +129,7 @@
 													}
 												}
 												loadMenus();
+                                                hideLoadIndicator();
 											},
 											error: function() {
                                                 hideLoadIndicator();
@@ -126,7 +150,12 @@
     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(),
@@ -135,7 +164,6 @@
 												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
 												if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
 													var parts = jqXHR.responseText.split(':');
 													//alert(parts[1]);
@@ -151,6 +179,7 @@
                                                     pageFormChanged = false;
 												}
 												loadMenus();
+                                                hideLoadIndicator();
 											},
 											error: function() {
                                                 hideLoadIndicator();
@@ -176,7 +205,6 @@
 												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
 												if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
 													var parts = jqXHR.responseText.split(':');
 													//alert(parts[1]);
@@ -188,6 +216,7 @@
                                                     onAfterContentLoad();
                                                     pageFormChanged = false;
 												}
+                                                hideLoadIndicator();
 											},
 											error: function(jqXHR, textStatus, errorThrown) {
                                                 hideLoadIndicator();
@@ -214,7 +243,6 @@
 												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
 												if(successMessage) alert(successMessage);
 												if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
 													var parts = jqXHR.responseText.split(':');
@@ -227,6 +255,7 @@
                                                     onAfterContentLoad();
                                                     pageFormChanged = false;
 												}
+                                                hideLoadIndicator();
 											},
 											error: function(jqXHR, textStatus, errorThrown) {
                                                 hideLoadIndicator();
@@ -288,7 +317,6 @@
 												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
 												if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
 													var parts = jqXHR.responseText.split(':');
 													loadContent(parts[1]);
@@ -305,6 +333,7 @@
                                                     onAfterContentLoad();
                                                     pageFormChanged = false;
 												}
+                                                hideLoadIndicator();
 											},
 											error: function() {
                                                 hideLoadIndicator();
@@ -323,7 +352,6 @@
 												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
 												if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
 													var parts = jqXHR.responseText.split(":");
 													loadContent(parts[1]);
@@ -332,6 +360,7 @@
                                                     onAfterContentLoad();
                                                     pageFormChanged = false;
 												}
+                                                hideLoadIndicator();
 											},
 											error: function() {
                                                 hideLoadIndicator();
@@ -437,14 +466,14 @@
 											url: pagename,
 											dataType: "html",
 											beforeSend: function() {
-												showLoadIndicator();
+//												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
+//                                                hideLoadIndicator();
 												jQuery('#'+elementid).html(jqXHR.responseText);
 											},
 											error: function() {
-                                                hideLoadIndicator();
+//                                                hideLoadIndicator();
 												reportError('Ajax Request was not successful. 118');
 											}
 										});
@@ -455,10 +484,10 @@
 											url: pagename,
 											dataType: "html",
 											beforeSend: function() {
-												showLoadIndicator();
+//												showLoadIndicator();
 											},
 											success: function(data, textStatus, jqXHR) {
-                                                hideLoadIndicator();
+//                                                hideLoadIndicator();
 												var teste = jqXHR.responseText;
 												var elemente = teste.split('#');
 												el=document.getElementById(elementid);
@@ -472,7 +501,7 @@
 												}
 											},
 											error: function() {
-                                                hideLoadIndicator();
+//                                                hideLoadIndicator();
 												reportError('Ajax Request was not successful. 119');
 											}
 										});
@@ -613,40 +642,65 @@
 	return false;
 }
 
+var new_tpl_add_id = 0;
 function addAdditionalTemplate(){
-	var tpl_add = document.getElementById('template_additional').value;
-	
-	  var tpl_list = document.getElementById('template_additional_list').innerHTML;
-	  var addTemplate = document.getElementById('tpl_add_select').value.split('|',2);
-	  var addTplId = addTemplate[0];
-	  var addTplText = addTemplate[1];
+    var tpl_add = jQuery('#template_additional').val();
+    var addTemplate = jQuery('#tpl_add_select').val().split('|',2);
+	var addTplId = addTemplate[0];
+	var addTplText = addTemplate[1];
 	if(addTplId > 0) {
-	  var newVal = tpl_add + '/' + addTplId + '/';
-	  newVal = newVal.replace('//', '/');
-	  var newList = tpl_list + '<br>' + addTplText;
-	  newList = newList.replace('<br><br>', '<br>');
-	  document.getElementById('template_additional').value = newVal;
-	  document.getElementById('template_additional_list').innerHTML = newList;
-	  alert('additional template ' + addTplText + ' added to customer');
+        var newVal = tpl_add.split('/');
+        new_tpl_add_id += 1;
+        var delbtn = jQuery('<a href="#"></a>').attr('class', 'button icons16 icoDelete').click(function(e) {
+            e.preventDefault();
+            delAdditionalTemplate($(this).parent().attr('rel'));
+        });
+        newVal[newVal.length] = 'n' + new_tpl_add_id + ':' + addTplId;
+	    jQuery('<li>' + addTplText + '</li>').attr('rel', 'n' + new_tpl_add_id).append(delbtn).appendTo('#template_additional_list ul');
+	    jQuery('#template_additional').val(newVal.join('/'));
+	    alert('additional template ' + addTplText + ' added to customer');
 	} else {
-	  alert('no additional template selcted');
+	    alert('no additional template selcted');
 	}
 }
 
-function delAdditionalTemplate(){
-	var tpl_add = document.getElementById('template_additional').value;
-	if(tpl_add != '') {
-		var tpl_list = document.getElementById('template_additional_list').innerHTML;
+function delAdditionalTemplate(tpl_id){
+    var tpl_add = jQuery('#template_additional').val();
+	if(tpl_id) {
+        // new style
+		var $el = jQuery('#template_additional_list ul').find('li[rel="' + tpl_id + '"]').eq(0); // only the first
+        var addTplText = $el.text();
+        $el.remove();
+        
+		var oldVal = tpl_add.split('/');
+		var newVal = new Array();
+        for(var i = 0; i < oldVal.length; i++) {
+            var tmp = oldVal[i].split(':', 2);
+            if(tmp.length == 2 && tmp[0] == tpl_id) continue;
+            newVal[newVal.length] = oldVal[i];
+        }
+        jQuery('#template_additional').val(newVal.join('/'));
+		alert('additional template ' + addTplText + ' deleted from customer');
+    } else if(tpl_add != '') {
+        // old style
 		var addTemplate = document.getElementById('tpl_add_select').value.split('|',2);
 		var addTplId = addTemplate[0];
 		var addTplText = addTemplate[1];
+
+		jQuery('#template_additional_list ul').find('li:not([rel])').each(function() {
+            var text = jQuery(this).text();
+            if(text == addTplText) {
+                jQuery(this).remove();
+                return false;
+            }
+            return this;
+        });
+        
 		var newVal = tpl_add;
-		newVal = newVal.replace(addTplId, '');
+        var repl = new RegExp('(^|\/)' + addTplId + '(\/|$)');
+		newVal = newVal.replace(repl, '');
 		newVal = newVal.replace('//', '/');
-		var newList = tpl_list.replace(addTplText, '');
-		newList = newList.replace('<br><br>', '<br>');
-		document.getElementById('template_additional').value = newVal;
-		document.getElementById('template_additional_list').innerHTML = newList;
+		jQuery('#template_additional').val(newVal);
 		alert('additional template ' + addTplText + ' deleted from customer');
   } else {
   	alert('no additional template selcted');

--
Gitblit v1.9.1