From b889edb33e4a09cc1f65d2fb9ad9f9ea16b1eae9 Mon Sep 17 00:00:00 2001 From: ftimme <ft@falkotimme.com> Date: Tue, 04 Sep 2012 11:42:42 -0400 Subject: [PATCH] - Ported changes from Apache plugin to nginx plugin. - Fixed errors in system.inc.php- --- interface/web/js/scrigo.js.php | 127 +++++++++++++++++++++++++++++++++++------ 1 files changed, 107 insertions(+), 20 deletions(-) diff --git a/interface/web/js/scrigo.js.php b/interface/web/js/scrigo.js.php index 7e01c7d..e550b47 100644 --- a/interface/web/js/scrigo.js.php +++ b/interface/web/js/scrigo.js.php @@ -4,7 +4,11 @@ $lang = (isset($_SESSION['s']['language']) && $_SESSION['s']['language'] != '')?$_SESSION['s']['language']:'en'; include_once(ISPC_ROOT_PATH.'/web/strengthmeter/lib/lang/'.$lang.'_strengthmeter.lng'); ?> - +var pageFormChanged = false; +var tabChangeWarningTxt = ''; +var tabChangeDiscardTxt = ''; +var tabChangeWarning = false; +var tabChangeDiscard = false; redirect = ''; function reportError(request) { @@ -24,10 +28,11 @@ dataType: "html", success: function(data, textStatus, jqXHR) { jQuery('#pageContent').html(jqXHR.responseText); + pageFormChanged = false; }, error: function() { reportError('Ajax Request was not successful.'+pagename); - }, + } }); setTimeout( "loadContentRefresh('"+pagename+"&refresh="+document.getElementById('refreshinterval').value+"')", document.getElementById('refreshinterval').value*1000 ); } @@ -54,7 +59,7 @@ }, error: function() { reportError('Ajax Request was not successful.'+module); - }, + } }); } @@ -87,12 +92,13 @@ document.location.href = 'index.php'; } else { jQuery('#pageContent').html(jqXHR.responseText); + pageFormChanged = false; } loadMenus(); }, error: function() { reportError('Ajax Request was not successful.110'); - }, + } }); /* if(redirect != '') { @@ -118,12 +124,13 @@ //window.setTimeout('loadContent(redirect)', 1000); } else { jQuery('#pageContent').html(jqXHR.responseText); + pageFormChanged = false; } }, error: function(jqXHR, textStatus, errorThrown) { var parts = jqXHR.responseText.split(':'); reportError('Ajax Request was not successful. 111'); - }, + } }); /* if(redirect != '') { @@ -134,12 +141,14 @@ } 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", 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 +157,13 @@ //window.setTimeout('loadContent(redirect)', 1000); } else { jQuery('#pageContent').html(jqXHR.responseText); + pageFormChanged = false; } }, error: function(jqXHR, textStatus, errorThrown) { var parts = jqXHR.responseText.split(':'); reportError('Ajax Request was not successful. 111'); - }, + } }); } } @@ -200,9 +210,14 @@ } 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>'); + }, success: function(data, textStatus, jqXHR) { if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { var parts = jqXHR.responseText.split(':'); @@ -215,13 +230,14 @@ //var reponse = jQuery(jqXHR.responseText); //var reponseScript = reponse.filter("script"); //jQuery.each(reponseScript, function(idx, val) { eval(val.text); } ); + jQuery('#pageContent').html(jqXHR.responseText); + pageFormChanged = false; } - }, error: function() { reportError('Ajax Request was not successful. 113'); - }, + } }); } @@ -237,11 +253,12 @@ loadContent(parts[1]); } else { jQuery('#pageContent').html(jqXHR.responseText); + pageFormChanged = false; } }, error: function() { reportError('Ajax Request was not successful. 114'); - }, + } }); loadMenus(); @@ -252,7 +269,7 @@ function setFocus() { try { - document.pageForm.username.focus(); + jQuery('form#pageForm').find('input[name="username"]').focus(); } catch (e) { } } @@ -268,7 +285,7 @@ }, error: function() { reportError('Ajax Request was not successful. 115'); - }, + } }); var topNavObject = jQuery.ajax({ type: "GET", @@ -280,7 +297,7 @@ }, error: function(o) { reportError('Ajax Request was not successful. 116'); - }, + } }); } @@ -288,7 +305,31 @@ function changeTab(tab,target) { //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') { + 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) { @@ -312,7 +353,7 @@ }, error: function() { reportError('Ajax Request was not successful. 118'); - }, + } }); } @@ -335,7 +376,7 @@ }, error: function() { reportError('Ajax Request was not successful. 119'); - }, + } }); } @@ -348,7 +389,7 @@ }, error: function() { reportError('Session expired. Please login again.'); - }, + } }); //setTimeout( keepalive, 1000000 ); } @@ -550,13 +591,17 @@ return password; } -function generatePassword(passwordFieldID){ +function generatePassword(passwordFieldID, repeatPasswordFieldID){ var oldPWField = jQuery('#'+passwordFieldID); var newPWField = oldPWField.clone(); newPWField.attr('type', 'text').attr('id', 'tmp'+passwordFieldID).insertBefore(oldPWField); oldPWField.remove(); - newPWField.attr('id', passwordFieldID).val(password(10, true)).trigger('keyup'); + var pword = password(10, false); + jQuery('#'+repeatPasswordFieldID).val(pword); + 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(); @@ -565,13 +610,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')); + }); } } @@ -579,3 +633,36 @@ return Math.floor(Math.random() * (max - min + 1)) + min; } +jQuery('.addPlaceholder').live("click", function(){ + var placeholderText = jQuery(this).text(); + var template = jQuery(this).siblings(':input'); + template.insertAtCaret(placeholderText); +}); + +jQuery.fn.extend({ + insertAtCaret: function(myValue){ + return this.each(function(i) { + if (document.selection) { + //For browsers like Internet Explorer + this.focus(); + sel = document.selection.createRange(); + sel.text = myValue; + this.focus(); + } else if (this.selectionStart || this.selectionStart == '0') { + //For browsers like Firefox and Webkit based + var startPos = this.selectionStart; + var endPos = this.selectionEnd; + var scrollTop = this.scrollTop; + this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length); + this.focus(); + this.selectionStart = startPos + myValue.length; + this.selectionEnd = startPos + myValue.length; + this.scrollTop = scrollTop; + } else { + this.value += myValue; + this.focus(); + } + }) + } +}); + -- Gitblit v1.9.1