/**
* Common JavaScript functions for AJAX requests (they are general purpose).
* --------------------------------------------------------------------
- * $Revision:: $
- * $Date:: $
- * $Tag:: 0.2.1-FINAL $
- * $Author:: $
- * --------------------------------------------------------------------
* Copyright (c) 2003 - 2009 by Roland Haeder
- * Copyright (c) 2009 - 2013 by Mailer Developer Team
+ * Copyright (c) 2009 - 2016 by Mailer Developer Team
* For more information visit: http://mxchange.org
*
* This program is free software; you can redistribute it and/or modify
// Checks whether a given element is visible by checking 'display: none'
function isElementVisible (prefix, element) {
+ //* DEBUG: */ alert('isElementVisible(' + prefix + ',' + element + ') Called!');
+
// Get element
var el = document.getElementById(prefix + '_' + element);
+ //* DEBUG: */ alert('isElementVisible(): el=' + el);
// Is element set?
if ((el === null) || (el == undefined)) {
- throw new '"' + prefix + '_' + element + '" does not exist.';
+ throw new ('prefix=' + prefix + ',element=' + element + ' does not exist.');
} else if ((el.style.display == undefined) || (el.style.display == '')) {
- throw new '"' + prefix + '_' + element + '" has no style.display element.';
+ throw new ('prefix=' + prefix + ',element=' + element + ' has no style.display element.');
}
// Default is visible
// Is it defined?
if (data['ajax_content'] == undefined) {
// Not set
- throw new 'ajax_content requested but not set.';
+ throw new('ajax_content requested but not set.');
} // END - if
// Return it
// Is ajax_content set?
if (ajax_content.reply_content == undefined) {
// This shall not happen
- throw new 'ajax_content.reply_content not returned from ajax.php, please fix your scripts. (1)';
+ throw new('ajax_content.reply_content not returned from ajax.php, please fix your scripts. (1)');
} else if (ajax_content.reply_content === null) {
// This shall not happen, too
- throw new 'ajax_content.reply_content=null from ajax.php, please fix your scripts. (2)';
+ throw new('ajax_content.reply_content=null from ajax.php, please fix your scripts. (2)');
}
// Set AJAX reply
// Mark it as success
setAjaxSuccess(true);
+
+ // Was there a redirect?
+ if ((ajax_content.redirect != undefined) && (ajax_content.redirect != null)) {
+ // Redirect URL detected
+ // @TODO Need this be secured?
+ document.location.href = ajax_content.redirect;
+ } // END - if
},
// Called in case of an error (e.g. HTTP response status not '200 OK')
// Is 'reply_content' set?
if (obj.reply_content == undefined) {
// This shall not happen
- throw new 'obj.reply_content not returned from ajax.php, please fix your scripts. (3)';
+ throw new('obj.reply_content not returned from ajax.php, please fix your scripts. (3)');
} // END - if
// Set it
return false;
} else {
// This shall not happen
- throw new 'ajax_content.reply_content not returned from ajax.php, please fix your scripts. (4)';
+ throw new('ajax_content.reply_content not returned from ajax.php, please fix your scripts. (4)');
}
} else if (ajax_content.reply_content === null) {
// This shall not happen, too
- throw new 'ajax_content.reply_content=null from ajax.php, please fix your scripts. (5)';
+ throw new('ajax_content.reply_content=null from ajax.php, please fix your scripts. (5)');
}
// Set AJAX reply
setAjaxReply(ajax_content.reply_content, isJson);
+
+ // Was there a redirect?
+ if ((ajax_content.redirect != undefined) && (ajax_content.redirect != null)) {
+ // Redirect URL detected
+ // @TODO Need this be secured?
+ document.location.href = ajax_content.redirect;
+ } // END - if
}
});
closeAllWindows(prefix);
// Abort here if warningDisplayed is still true
+ //* DEBUG: */ alert('displayChangedWarningWindow(): Calling isElementVisible(' + prefix + ', warning)');
if (isElementVisible(prefix, 'warning')) {
// Make sure this doesn't happen
+ //* DEBUG: */ alert('displayChangedWarningWindow(): isElementVisible(' + prefix + ', warning)=true');
return;
} // END - if
// Request it from the AJAX backend
+ //* DEBUG: */ alert('displayChangedWarningWindow(): Calling sendAjaxRequest(' + prefix + ', button=' + button + ',changedElements()=' + changedElements.join(':') + ')');
if (sendAjaxRequest(prefix, 'change_warning', '&button=' + button + '&elements=' + changedElements.join(':')) === true) {
// Transfer the returned content to the prefix_warning_content id
setWarningContent(prefix, getAjaxContent());
// Close all windows
function closeAllWindows (prefix) {
+ //* DEBUG: */ alert('closeAllWindows(): Calling closeWarningWindow(' + prefix + ', true, false)');
closeWarningWindow(prefix, true, false);
+ //* DEBUG: */ alert('closeAllWindows(): Calling closeErrorWindow(' + prefix + ', true, false)');
closeErrorWindow(prefix, true, false);
+ //* DEBUG: */ alert('closeAllWindows(): Calling closeProgressWindow(' + prefix + ', true, false)');
closeProgressWindow(prefix, true, false);
+ //* DEBUG: */ alert('closeAllWindows(): Calling closeSuccessWindow(' + prefix + ', true, false)');
closeSuccessWindow(prefix, true, false);
+ //* DEBUG: */ alert('closeAllWindows(): EXIT!');
}
// Waits until the window has been closed
// Closes an success window
function closeSuccessWindow (prefix, waitClose, resetCurrentTabId) {
// Is the success displayed?
+ //* DEBUG: */ alert('closeSuccessWindow(): prefix=' + prefix + ',waitClose=' + waitClose + ',resetCurrentTabId=' + resetCurrentTabId + ' - ENTERED!');
if (isElementVisible(prefix, 'success')) {
// Shall we wait ("sync") until the animation has completed?
if (waitClose === true) {
closeSuccessLocked(prefix);
} // END - if
} // END - if
+ //* DEBUG: */ alert('closeSuccessWindow(): prefix=' + prefix + ',waitClose=' + waitClose + ',resetCurrentTabId=' + resetCurrentTabId + ' - EXIT!');
}
// Waits until the window has been closed
saveChanges(prefix);
// Close the window
- //* DEBUG: */ alert('doSaveChangesPage(): prefix=' + prefix + ',htmlId=' + htmlId + ',tab=' + tab + ' - calling closeWarningWindow()');
+ //* DEBUG: */ alert('doSaveChangesContinue(): prefix=' + prefix + ',htmlId=' + htmlId + ',tab=' + tab + ' - calling closeWarningWindow()');
closeWarningWindow(prefix, true, false);
// Load requested content