ftimme
2012-09-04 b889edb33e4a09cc1f65d2fb9ad9f9ea16b1eae9
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,8 +210,10 @@
}
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>');
@@ -220,11 +232,12 @@
                                       //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');
                                 },
                                 }
                           });
}
@@ -240,11 +253,12 @@
                                       loadContent(parts[1]);
                                    } else {
                                       jQuery('#pageContent').html(jqXHR.responseText);
                                                    pageFormChanged = false;
                                    }
                                 },
                                 error: function() {
                                    reportError('Ajax Request was not successful. 114');
                                 },
                                 }
                              });
  
  loadMenus();
@@ -255,7 +269,7 @@
function setFocus() {
   try {
      document.pageForm.username.focus();
      jQuery('form#pageForm').find('input[name="username"]').focus();
   } catch (e) {
   }
}
@@ -271,7 +285,7 @@
                                 },
                                 error: function() {
                                    reportError('Ajax Request was not successful. 115');
                                 },
                                 }
                           });
   
  var topNavObject = jQuery.ajax({         type: "GET", 
@@ -283,7 +297,7 @@
                                 },
                                 error: function(o) {
                                    reportError('Ajax Request was not successful. 116');
                                 },
                                 }
                        });
}
@@ -291,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) {
@@ -315,7 +353,7 @@
                                 },
                                 error: function() {
                                    reportError('Ajax Request was not successful. 118');
                                 },
                                 }
                              });
}
@@ -338,7 +376,7 @@
                                 },
                                 error: function() {
                                    reportError('Ajax Request was not successful. 119');
                                 },
                                 }
                              });
}
@@ -351,7 +389,7 @@
                                 },
                                 error: function() {
                                    reportError('Session expired. Please login again.');
                                 },
                                 }
                              });
     //setTimeout( keepalive, 1000000 );
}
@@ -553,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, false)).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();
@@ -568,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'));
        });
    }
}