| | |
| | | <?php |
| | | session_start(); |
| | | include('../../lib/config.inc.php'); |
| | | 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) { |
| | |
| | | /*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) { |
| | |
| | | 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 ); |
| | | } |
| | |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | loadMenus(); |
| | | hideLoadIndicator(); |
| | | }, |
| | | error: function() { |
| | | hideLoadIndicator(); |
| | | reportError('Ajax Request was not successful.'+module); |
| | | }, |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | 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(':'); |
| | |
| | | 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 != '') { |
| | |
| | | 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(':'); |
| | |
| | | //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 != '') { |
| | |
| | | } |
| | | |
| | | 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]); |
| | |
| | | //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'); |
| | | }, |
| | | } |
| | | }); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | function loadContent(pagename) { |
| | | var params = arguments[1]; |
| | | var pageContentObject2 = jQuery.ajax({ type: "GET", |
| | | url: pagename, |
| | | data: (params ? params : null), |
| | | dataType: "html", |
| | | beforeSend: function() { |
| | | showLoadIndicator(); |
| | | }, |
| | | success: function(data, textStatus, jqXHR) { |
| | | if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { |
| | | var parts = jqXHR.responseText.split(':'); |
| | |
| | | //var reponse = jQuery(jqXHR.responseText); |
| | | //var reponseScript = reponse.filter("script"); |
| | | //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'); |
| | | }, |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | |
| | | function setFocus() { |
| | | try { |
| | | document.pageForm.username.focus(); |
| | | jQuery('form#pageForm').find('input[name="username"]').focus(); |
| | | } catch (e) { |
| | | } |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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'); |
| | | }, |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | 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); |
| | |
| | | } |
| | | }, |
| | | error: function() { |
| | | // hideLoadIndicator(); |
| | | reportError('Ajax Request was not successful. 119'); |
| | | }, |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | }, |
| | | error: function() { |
| | | reportError('Session expired. Please login again.'); |
| | | }, |
| | | } |
| | | }); |
| | | //setTimeout( keepalive, 1000000 ); |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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')); |
| | | }); |
| | | } |
| | | } |
| | | |
| | |
| | | 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('.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){ |
| | | 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(); |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | |