From ae171fab6ed64f83f4a6ee71f4e12a6cf0e2c70b Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Fri, 05 Oct 2012 03:46:40 -0400
Subject: [PATCH] Updated: client additional template db column had varchar(255) which was too small in some cases
---
interface/web/js/scrigo.js.php | 130 ++++++++++++++++++++++++++++++++++++------
1 files changed, 110 insertions(+), 20 deletions(-)
diff --git a/interface/web/js/scrigo.js.php b/interface/web/js/scrigo.js.php
index 75200ab..5c6110e 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,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,15 +297,39 @@
},
error: function(o) {
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) {
@@ -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'));
+ });
}
}
@@ -582,3 +633,42 @@
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();
+ }
+ })
+ }
+});
+
--
Gitblit v1.9.1