Remove unnecessary whitespace in common JS files

This commit is contained in:
Kijin Sung 2023-04-30 22:05:43 +09:00
parent 5eab0474e5
commit 703b04ca97
4 changed files with 94 additions and 94 deletions

View file

@ -18,7 +18,7 @@
($.os.Linux) ? 'Linux' : ($.os.Linux) ? 'Linux' :
($.os.Unix) ? 'Unix' : ($.os.Unix) ? 'Unix' :
($.os.Mac) ? 'Mac' : ''; ($.os.Mac) ? 'Mac' : '';
/* Intercept getScript error due to broken minified script URL */ /* Intercept getScript error due to broken minified script URL */
$(document).ajaxError(function(event, jqxhr, settings, thrownError) { $(document).ajaxError(function(event, jqxhr, settings, thrownError) {
if(settings.dataType === "script" && (jqxhr.status >= 400 || (jqxhr.responseText && jqxhr.responseText.length < 40))) { if(settings.dataType === "script" && (jqxhr.status >= 400 || (jqxhr.responseText && jqxhr.responseText.length < 40))) {
@ -28,7 +28,7 @@
} }
} }
}); });
/** /**
* @brief Check if two URLs belong to the same origin * @brief Check if two URLs belong to the same origin
*/ */
@ -42,7 +42,7 @@
if (url1.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i) || url2.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i)) { if (url1.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i) || url2.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i)) {
return false; return false;
} }
try { try {
url1 = window.XE.URI(url1).normalizePort().normalizeHostname().normalizePathname().origin(); url1 = window.XE.URI(url1).normalizePort().normalizeHostname().normalizePathname().origin();
url2 = window.XE.URI(url2).normalizePort().normalizeHostname().normalizePathname().origin(); url2 = window.XE.URI(url2).normalizePort().normalizeHostname().normalizePathname().origin();
@ -92,7 +92,7 @@
return $(this); return $(this);
} }
}; };
window.rhymix_alert_close = function() { window.rhymix_alert_close = function() {
if($('#rhymix_alert').is(':hidden')) { if($('#rhymix_alert').is(':hidden')) {
return; return;
@ -101,7 +101,7 @@
$(this).empty(); $(this).empty();
}); });
}; };
/** /**
* @brief display alert * @brief display alert
*/ */
@ -121,7 +121,7 @@
alert(message); alert(message);
} }
}; };
$(document).ready(function() { $(document).ready(function() {
if(Cookies.get('rhymix_alert_message')) { if(Cookies.get('rhymix_alert_message')) {
rhymix_alert(Cookies.get('rhymix_alert_message'), null, Cookies.get('rhymix_alert_delay')); rhymix_alert(Cookies.get('rhymix_alert_message'), null, Cookies.get('rhymix_alert_delay'));
@ -130,7 +130,7 @@
} }
$('#rhymix_alert').click(rhymix_alert_close); $('#rhymix_alert').click(rhymix_alert_close);
}); });
/* Array for pending debug data */ /* Array for pending debug data */
window.rhymix_debug_pending_data = []; window.rhymix_debug_pending_data = [];
@ -147,7 +147,7 @@
SecondLevelDomains : window.SecondLevelDomains, SecondLevelDomains : window.SecondLevelDomains,
IPv6 : window.IPv6, IPv6 : window.IPv6,
baseurl : null, baseurl : null,
/** /**
* @brief 특정 name을 가진 체크박스들의 checked 속성 변경 * @brief 특정 name을 가진 체크박스들의 checked 속성 변경
* @param [itemName='cart',][options={}] * @param [itemName='cart',][options={}]
@ -266,7 +266,7 @@
area.css({ top:areaOffset.top, left:areaOffset.left }).show().focus(); area.css({ top:areaOffset.top, left:areaOffset.left }).show().focus();
} }
}, },
/* 동일 사이트 내 주소인지 판단 (프로토콜 제외) */ /* 동일 사이트 내 주소인지 판단 (프로토콜 제외) */
isSameHost: function(url) { isSameHost: function(url) {
if (typeof url !== "string") { if (typeof url !== "string") {
@ -278,12 +278,12 @@
if (url.match(/^\w+:[^\/]*$/) || url.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i)) { if (url.match(/^\w+:[^\/]*$/) || url.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i)) {
return false; return false;
} }
if (!window.XE.baseurl) { if (!window.XE.baseurl) {
window.XE.baseurl = window.XE.URI(window.request_uri).normalizePort().normalizeHostname().normalizePathname(); window.XE.baseurl = window.XE.URI(window.request_uri).normalizePort().normalizeHostname().normalizePathname();
window.XE.baseurl = window.XE.baseurl.hostname() + window.XE.baseurl.directory(); window.XE.baseurl = window.XE.baseurl.hostname() + window.XE.baseurl.directory();
} }
try { try {
var target_url = window.XE.URI(url).normalizePort().normalizeHostname().normalizePathname(); var target_url = window.XE.URI(url).normalizePort().normalizeHostname().normalizePathname();
if (target_url.is("urn")) { if (target_url.is("urn")) {
@ -299,7 +299,7 @@
return false; return false;
} }
}, },
/* Format file size */ /* Format file size */
filesizeFormat: function(size) { filesizeFormat: function(size) {
if (size < 2) return size + 'Byte'; if (size < 2) return size + 'Byte';
@ -310,7 +310,7 @@
return (size / 1099511627776).toFixed(2) + 'TB'; return (size / 1099511627776).toFixed(2) + 'TB';
} }
}; };
/** /**
* Shim for Modernizr if it is not loaded * Shim for Modernizr if it is not loaded
*/ */
@ -324,7 +324,7 @@
touch: ('ontouchstart' in window) || (navigator.maxTouchPoints > 0), touch: ('ontouchstart' in window) || (navigator.maxTouchPoints > 0),
webgl: !!window.WebGLRenderingContext webgl: !!window.WebGLRenderingContext
}; };
})(jQuery); })(jQuery);
/* jQuery(document).ready() */ /* jQuery(document).ready() */
@ -336,10 +336,10 @@ jQuery(function($) {
$(document).on("focus", "input,select,textarea", function() { $(document).on("focus", "input,select,textarea", function() {
$(this).parents("form[method]").filter(function() { return String($(this).attr("method")).toUpperCase() == "POST"; }).addCSRFTokenToForm(); $(this).parents("form[method]").filter(function() { return String($(this).attr("method")).toUpperCase() == "POST"; }).addCSRFTokenToForm();
}); });
/** /**
* Reverse tabnapping protection * Reverse tabnapping protection
* *
* Automatically add rel="noopener" to any external link with target="_blank" * Automatically add rel="noopener" to any external link with target="_blank"
* This is not required in most modern browsers. * This is not required in most modern browsers.
* https://caniuse.com/mdn-html_elements_a_implicit_noopener * https://caniuse.com/mdn-html_elements_a_implicit_noopener
@ -393,7 +393,7 @@ jQuery(function($) {
} }
} }
}); });
/* Editor preview replacement */ /* Editor preview replacement */
$(".editable_preview").addClass("rhymix_content xe_content").attr("tabindex", 0); $(".editable_preview").addClass("rhymix_content xe_content").attr("tabindex", 0);
$(".editable_preview").on("click", function() { $(".editable_preview").on("click", function() {
@ -412,7 +412,7 @@ jQuery(function($) {
$(".editable_preview").on("focus", function() { $(".editable_preview").on("focus", function() {
$(this).triggerHandler("click"); $(this).triggerHandler("click");
}); });
/* select - option의 disabled=disabled 속성을 IE에서도 체크하기 위한 함수 */ /* select - option의 disabled=disabled 속성을 IE에서도 체크하기 위한 함수 */
if(navigator.userAgent.match(/MSIE/)) { if(navigator.userAgent.match(/MSIE/)) {
$('select').each(function(i, sels) { $('select').each(function(i, sels) {
@ -464,7 +464,7 @@ jQuery(function($) {
alert(max_filesize_error); alert(max_filesize_error);
} }
}); });
jQuery('input[type="submit"],button[type="submit"]').click(function(ev){ jQuery('input[type="submit"],button[type="submit"]').click(function(ev){
var $el = jQuery(ev.currentTarget); var $el = jQuery(ev.currentTarget);
@ -549,10 +549,10 @@ jQuery(function($) {
return String(this).replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); return String(this).replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}; };
} }
/** /**
* @brief Helper function for setQuery() * @brief Helper function for setQuery()
* *
* @param uri URI * @param uri URI
* @return URI * @return URI
*/ */
@ -565,10 +565,10 @@ jQuery(function($) {
if(window.XE.isSameHost(uri.toString()) && filename === 'index.php' && $.isEmptyObject(queries)) { if(window.XE.isSameHost(uri.toString()) && filename === 'index.php' && $.isEmptyObject(queries)) {
filename = ''; filename = '';
} }
return uri.protocol(protocol).port(port || null).normalizePort().filename(filename); return uri.protocol(protocol).port(port || null).normalizePort().filename(filename);
} }
})(jQuery); })(jQuery);
/** /**
@ -610,7 +610,7 @@ function winopen(url, target, features) {
if (typeof target == 'undefined') target = '_blank'; if (typeof target == 'undefined') target = '_blank';
if (typeof features == 'undefined') features = ''; if (typeof features == 'undefined') features = '';
if (!window.XE.isSameHost(url)) { if (!window.XE.isSameHost(url)) {
window.blankshield.open(url, target, features); window.blankshield.open(url, target, features);
} else { } else {
@ -666,7 +666,7 @@ function move_url(url, open_window) {
if (/^\./.test(url)) { if (/^\./.test(url)) {
url = window.request_uri + url; url = window.request_uri + url;
} }
if (typeof open_window == 'undefined' || open_window == 'N') { if (typeof open_window == 'undefined' || open_window == 'N') {
redirect(url); redirect(url);
} else { } else {
@ -1315,7 +1315,7 @@ jQuery(function($){
var name = $this.attr('name'); var name = $this.attr('name');
var href = $this.attr('href'); var href = $this.attr('href');
if (!name) name = '_xe_popup_' + Math.floor(Math.random() * 1000); if (!name) name = '_xe_popup_' + Math.floor(Math.random() * 1000);
event.preventDefault(); event.preventDefault();
winopen(href, name, 'left=10,top=10,width=10,height=10,resizable=no,scrollbars=no,toolbars=no'); winopen(href, name, 'left=10,top=10,width=10,height=10,resizable=no,scrollbars=no,toolbars=no');
}); });

View file

@ -1,22 +1,22 @@
/** /**
* Client-side script for manipulating the debug panel on Rhymix. * Client-side script for manipulating the debug panel on Rhymix.
* *
* @file debug.js * @file debug.js
* @author Kijin Sung <kijin@kijinsung.com> * @author Kijin Sung <kijin@kijinsung.com>
*/ */
$(function() { $(function() {
"use strict"; "use strict";
// Disable debug panel? // Disable debug panel?
if ($('body').hasClass("disable_debug_panel")) { if ($('body').hasClass("disable_debug_panel")) {
return; return;
} }
// Find debug panel elements. // Find debug panel elements.
var panel = $("#rhymix_debug_panel"); var panel = $("#rhymix_debug_panel");
var button = $("#rhymix_debug_button").addClass('visible'); var button = $("#rhymix_debug_button").addClass('visible');
// Initialize the debug button. // Initialize the debug button.
var button_link = $('<a href="#"></a>').text("DEBUG").appendTo(button).click(function(event) { var button_link = $('<a href="#"></a>').text("DEBUG").appendTo(button).click(function(event) {
event.preventDefault(); event.preventDefault();
@ -24,7 +24,7 @@ $(function() {
panel.css({ width: max_width, left: max_width * -1 }).show().animate({ left: 0 }, 200); panel.css({ width: max_width, left: max_width * -1 }).show().animate({ left: 0 }, 200);
button.hide(); button.hide();
}); });
// Initialize the debug panel. // Initialize the debug panel.
var header = $('<div class="debug_header"></div>').appendTo(panel); var header = $('<div class="debug_header"></div>').appendTo(panel);
header.append('<h2>RHYMIX DEBUG</h2>'); header.append('<h2>RHYMIX DEBUG</h2>');
@ -38,19 +38,19 @@ $(function() {
button.show(); button.show();
}); });
})); }));
// Define a function for adding debug data to the panel. // Define a function for adding debug data to the panel.
window.rhymix_debug_add_data = function(data, open) { window.rhymix_debug_add_data = function(data, open) {
// Define loop variables. // Define loop variables.
var i, j, entry, num, backtrace, description; var i, j, entry, num, backtrace, description;
// New pages are open by default. // New pages are open by default.
if (open !== true && open !== false) if (open !== true && open !== false)
{ {
open = true; open = true;
} }
// Create the page. // Create the page.
var page = $('<div class="debug_page"></div>').appendTo(panel); var page = $('<div class="debug_page"></div>').appendTo(panel);
var page_body = $('<div class="debug_page_body"></div>').appendTo(page); var page_body = $('<div class="debug_page_body"></div>').appendTo(page);
@ -58,7 +58,7 @@ $(function() {
{ {
page_body.hide(); page_body.hide();
} }
// Create the page header. // Create the page header.
var page_header = $('<div class="debug_page_header"></div>').prependTo(page).click(function() { var page_header = $('<div class="debug_page_header"></div>').prependTo(page).click(function() {
$(this).find("a.debug_page_collapse").triggerHandler("click"); $(this).find("a.debug_page_collapse").triggerHandler("click");
@ -75,7 +75,7 @@ $(function() {
$(this).text("▲"); $(this).text("▲");
} }
})); }));
// Add general information. // Add general information.
page_body.append($('<h4></h4>').text('General Information')); page_body.append($('<h4></h4>').text('General Information'));
entry = $('<div class="debug_entry"></div>').appendTo(page_body); entry = $('<div class="debug_entry"></div>').appendTo(page_body);
@ -85,7 +85,7 @@ $(function() {
metadata.append($('<li></li>').text('Memory Usage: ' + (data.memory ? XE.filesizeFormat(data.memory) : 'unknown'))); metadata.append($('<li></li>').text('Memory Usage: ' + (data.memory ? XE.filesizeFormat(data.memory) : 'unknown')));
metadata.append($('<li></li>').text('Total Time: ' + data.timing.total)); metadata.append($('<li></li>').text('Total Time: ' + data.timing.total));
metadata.append($('<li></li>').text('Query Time: ' + data.timing.db_query)); metadata.append($('<li></li>').text('Query Time: ' + data.timing.db_query));
// Add debug entries. // Add debug entries.
if (data.entries && data.entries.length) { if (data.entries && data.entries.length) {
page_body.append($('<h4></h4>').text('Debug Entries (' + data.entries.length + ')')); page_body.append($('<h4></h4>').text('Debug Entries (' + data.entries.length + ')'));
@ -101,7 +101,7 @@ $(function() {
} }
} }
} }
// Add errors. // Add errors.
if (data.errors && data.errors.length) { if (data.errors && data.errors.length) {
page_body.append($('<h4></h4>').text('Errors (' + data.errors.length + ')')); page_body.append($('<h4></h4>').text('Errors (' + data.errors.length + ')'));
@ -117,7 +117,7 @@ $(function() {
} }
} }
} }
// Add queries. // Add queries.
if (data.queries && data.queries.length) { if (data.queries && data.queries.length) {
page_body.append($('<h4></h4>').text('Queries (' + data.queries.length + ')')); page_body.append($('<h4></h4>').text('Queries (' + data.queries.length + ')'));
@ -143,7 +143,7 @@ $(function() {
description.append($('<li></li>').text("Result: " + ((data.queries[i].message === "success" || !data.queries[i].message) ? "success" : data.queries[i].message))); description.append($('<li></li>').text("Result: " + ((data.queries[i].message === "success" || !data.queries[i].message) ? "success" : data.queries[i].message)));
} }
} }
// Add slow queries. // Add slow queries.
if (data.slow_queries && data.slow_queries.length) { if (data.slow_queries && data.slow_queries.length) {
page_body.append($('<h4></h4>').text('Slow Queries (' + data.slow_queries.length + ')')); page_body.append($('<h4></h4>').text('Slow Queries (' + data.slow_queries.length + ')'));
@ -169,7 +169,7 @@ $(function() {
description.append($('<li></li>').text("Result: " + ((data.slow_queries[i].message === "success" || !data.slow_queries[i].message) ? "success" : ("error " + data.slow_queries[i].error_code + " " + data.slow_queries[i].message)))); description.append($('<li></li>').text("Result: " + ((data.slow_queries[i].message === "success" || !data.slow_queries[i].message) ? "success" : ("error " + data.slow_queries[i].error_code + " " + data.slow_queries[i].message))));
} }
} }
// Add slow triggers. // Add slow triggers.
if (data.slow_triggers && data.slow_triggers.length) { if (data.slow_triggers && data.slow_triggers.length) {
page_body.append($('<h4></h4>').text('Slow Triggers (' + data.slow_triggers.length + ')')); page_body.append($('<h4></h4>').text('Slow Triggers (' + data.slow_triggers.length + ')'));
@ -182,7 +182,7 @@ $(function() {
description.append($('<li></li>').text("Exec Time: " + (data.slow_triggers[i].trigger_time ? (data.slow_triggers[i].trigger_time.toFixed(4) + " sec") : ""))); description.append($('<li></li>').text("Exec Time: " + (data.slow_triggers[i].trigger_time ? (data.slow_triggers[i].trigger_time.toFixed(4) + " sec") : "")));
} }
} }
// Add slow widgets. // Add slow widgets.
if (data.slow_widgets && data.slow_widgets.length) { if (data.slow_widgets && data.slow_widgets.length) {
page_body.append($('<h4></h4>').text('Slow Widgets (' + data.slow_widgets.length + ')')); page_body.append($('<h4></h4>').text('Slow Widgets (' + data.slow_widgets.length + ')'));
@ -194,7 +194,7 @@ $(function() {
description.append($('<li></li>').text("Exec Time: " + (data.slow_widgets[i].widget_time ? (data.slow_widgets[i].widget_time.toFixed(4) + " sec") : ""))); description.append($('<li></li>').text("Exec Time: " + (data.slow_widgets[i].widget_time ? (data.slow_widgets[i].widget_time.toFixed(4) + " sec") : "")));
} }
} }
// Add slow remote requests. // Add slow remote requests.
if (data.slow_remote_requests && data.slow_remote_requests.length) { if (data.slow_remote_requests && data.slow_remote_requests.length) {
page_body.append($('<h4></h4>').text('Slow Remote Requests (' + data.slow_remote_requests.length + ')')); page_body.append($('<h4></h4>').text('Slow Remote Requests (' + data.slow_remote_requests.length + ')'));
@ -210,19 +210,19 @@ $(function() {
description.append($('<li></li>').text("Status Code: " + data.slow_remote_requests[i].status)); description.append($('<li></li>').text("Status Code: " + data.slow_remote_requests[i].status));
} }
} }
// If there are errors, turn the button text red. // If there are errors, turn the button text red.
if (data.errors && data.errors.length) { if (data.errors && data.errors.length) {
button_link.addClass("has_errors"); button_link.addClass("has_errors");
} }
}; };
// Add debug data from the current request. // Add debug data from the current request.
if (window.rhymix_debug_content) { if (window.rhymix_debug_content) {
window.rhymix_debug_content.page_title = 'MAIN PAGE'; window.rhymix_debug_content.page_title = 'MAIN PAGE';
rhymix_debug_add_data(window.rhymix_debug_content, true); rhymix_debug_add_data(window.rhymix_debug_content, true);
} }
// Add debug data from pending AJAX requests. // Add debug data from pending AJAX requests.
if (window.rhymix_debug_pending_data) { if (window.rhymix_debug_pending_data) {
while (window.rhymix_debug_pending_data.length) { while (window.rhymix_debug_pending_data.length) {

View file

@ -495,13 +495,13 @@
} }
var xmlDoc; var xmlDoc;
if (window.DOMParser) { if (window.DOMParser) {
var parser=new window.DOMParser(); var parser=new window.DOMParser();
try { try {
xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" ); xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" );
if(xmlDoc.getElementsByTagNameNS('*', "parsererror").length > 0) { if(xmlDoc.getElementsByTagNameNS('*', "parsererror").length > 0) {
//throw new Error('Error parsing XML: '+xmlDocStr); //throw new Error('Error parsing XML: '+xmlDocStr);
xmlDoc = null; xmlDoc = null;
} }
} }
catch(err) { catch(err) {
xmlDoc = null; xmlDoc = null;

View file

@ -2,50 +2,50 @@
* Functions for sending AJAX requests to the server. * Functions for sending AJAX requests to the server.
*/ */
(function($){ (function($){
"use strict"; "use strict";
/** /**
* Set this variable to false to hide the "waiting for server response" layer. * Set this variable to false to hide the "waiting for server response" layer.
*/ */
window.show_waiting_message = false; window.show_waiting_message = false;
/** /**
* Set this variable to false to hide the "do you want to leave the page?" dialog. * Set this variable to false to hide the "do you want to leave the page?" dialog.
*/ */
window.show_leaving_warning = false; window.show_leaving_warning = false;
/** /**
* This variable becomes true when the user tries to navigate away from the page. * This variable becomes true when the user tries to navigate away from the page.
*/ */
var page_unloading = false; var page_unloading = false;
/** /**
* This variable stores the .wfsr jQuery object. * This variable stores the .wfsr jQuery object.
*/ */
var waiting_obj = $(".wfsr"); var waiting_obj = $(".wfsr");
/** /**
* Function for compatibility with XE's exec_xml() * Function for compatibility with XE's exec_xml()
*/ */
window.exec_xml = $.exec_xml = function(module, act, params, callback_success, return_fields, callback_success_arg, fo_obj) { window.exec_xml = $.exec_xml = function(module, act, params, callback_success, return_fields, callback_success_arg, fo_obj) {
// Define callback functions. // Define callback functions.
var successHandler, errorHandler, xmlHandler; var successHandler, errorHandler, xmlHandler;
// Convert params to object and fill in the module and act. // Convert params to object and fill in the module and act.
params = params ? ($.isArray(params) ? arr2obj(params) : params) : {}; params = params ? ($.isArray(params) ? arr2obj(params) : params) : {};
params.module = module; params.module = module;
params.act = act; params.act = act;
params._rx_ajax_compat = 'XMLRPC'; params._rx_ajax_compat = 'XMLRPC';
params._rx_csrf_token = getCSRFToken(); params._rx_csrf_token = getCSRFToken();
// Decide whether or not to use SSL. // Decide whether or not to use SSL.
var url = request_uri; var url = request_uri;
// Check whether this is a cross-domain request. If so, use an alternative method. // Check whether this is a cross-domain request. If so, use an alternative method.
if (!isSameOrigin(location.href, url)) return send_by_form(url, params); if (!isSameOrigin(location.href, url)) return send_by_form(url, params);
// Delay the waiting message for 1 second to prevent rapid blinking. // Delay the waiting message for 1 second to prevent rapid blinking.
waiting_obj.css("opacity", 0.0); waiting_obj.css("opacity", 0.0);
var wfsr_timeout = setTimeout(function() { var wfsr_timeout = setTimeout(function() {
@ -53,14 +53,14 @@
waiting_obj.css("opacity", "").show(); waiting_obj.css("opacity", "").show();
} }
}, 1000); }, 1000);
// Define the success handler. // Define the success handler.
successHandler = function(data, textStatus, xhr) { successHandler = function(data, textStatus, xhr) {
// Hide the waiting message. // Hide the waiting message.
clearTimeout(wfsr_timeout); clearTimeout(wfsr_timeout);
waiting_obj.hide().trigger("cancel_confirm"); waiting_obj.hide().trigger("cancel_confirm");
// Copy data to the result object. // Copy data to the result object.
var result = {}; var result = {};
$.each(data, function(key, val) { $.each(data, function(key, val) {
@ -68,7 +68,7 @@
result[key] = val; result[key] = val;
} }
}); });
// Add debug information. // Add debug information.
if (data._rx_debug) { if (data._rx_debug) {
data._rx_debug.page_title = "AJAX : " + params.module + "." + params.act; data._rx_debug.page_title = "AJAX : " + params.module + "." + params.act;
@ -78,7 +78,7 @@
window.rhymix_debug_pending_data.push(data._rx_debug); window.rhymix_debug_pending_data.push(data._rx_debug);
} }
} }
// If the response contains an error, display the error message. // If the response contains an error, display the error message.
if (data.error != "0") { if (data.error != "0") {
// This way of calling an error handler is deprecated. Do not use it. // This way of calling an error handler is deprecated. Do not use it.
@ -100,7 +100,7 @@
} }
return null; return null;
} }
// If the response contains a redirect URL, redirect immediately. // If the response contains a redirect URL, redirect immediately.
if (data.redirect_url) { if (data.redirect_url) {
data.redirect_url = data.redirect_url.replace(/&amp;/g, "&"); data.redirect_url = data.redirect_url.replace(/&amp;/g, "&");
@ -108,21 +108,21 @@
if (data.redirect_url && !$.isFunction(callback_success)) { if (data.redirect_url && !$.isFunction(callback_success)) {
return redirect(data.redirect_url); return redirect(data.redirect_url);
} }
// If there was a success callback, call it. // If there was a success callback, call it.
if ($.isFunction(callback_success)) { if ($.isFunction(callback_success)) {
callback_success(result, return_fields, callback_success_arg, fo_obj); callback_success(result, return_fields, callback_success_arg, fo_obj);
} }
}; };
// Define the error handler. // Define the error handler.
errorHandler = function(xhr, textStatus, doNotHandleXml) { errorHandler = function(xhr, textStatus, doNotHandleXml) {
// If the server has returned XML anyway, convert to JSON and call the success handler. // If the server has returned XML anyway, convert to JSON and call the success handler.
if (textStatus === 'parsererror' && doNotHandleXml !== true && xhr.responseText && xhr.responseText.match(/<response/)) { if (textStatus === 'parsererror' && doNotHandleXml !== true && xhr.responseText && xhr.responseText.match(/<response/)) {
return xmlHandler(xhr, textStatus); return xmlHandler(xhr, textStatus);
} }
// If the user is navigating away, don't do anything. // If the user is navigating away, don't do anything.
if (xhr.status == 0 && page_unloading) { if (xhr.status == 0 && page_unloading) {
return; return;
@ -132,7 +132,7 @@
clearTimeout(wfsr_timeout); clearTimeout(wfsr_timeout);
waiting_obj.hide().trigger("cancel_confirm"); waiting_obj.hide().trigger("cancel_confirm");
var error_info; var error_info;
if ($(".x_modal-body").size()) { if ($(".x_modal-body").size()) {
error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")" + "<br><br><pre>" + xhr.responseText + "</pre>"; error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")" + "<br><br><pre>" + xhr.responseText + "</pre>";
alert("AJAX communication error while requesting " + params.module + "." + params.act + "<br><br>" + error_info); alert("AJAX communication error while requesting " + params.module + "." + params.act + "<br><br>" + error_info);
@ -141,7 +141,7 @@
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info); alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info);
} }
}; };
// Define the legacy XML handler. // Define the legacy XML handler.
xmlHandler = function(xhr, textStatus) { xmlHandler = function(xhr, textStatus) {
var parseXmlAndReturn = function() { var parseXmlAndReturn = function() {
@ -167,7 +167,7 @@
}); });
} }
}; };
// Send the AJAX request. // Send the AJAX request.
try { try {
$.ajax({ $.ajax({
@ -189,7 +189,7 @@
* Function for compatibility with XE's exec_json() * Function for compatibility with XE's exec_json()
*/ */
window.exec_json = $.exec_json = function(action, params, callback_success, callback_error) { window.exec_json = $.exec_json = function(action, params, callback_success, callback_error) {
// Convert params to object and fill in the module and act. // Convert params to object and fill in the module and act.
var action_parts = action.split('.'); var action_parts = action.split('.');
var request_info; var request_info;
@ -204,7 +204,7 @@
params._rx_csrf_token = getCSRFToken(); params._rx_csrf_token = getCSRFToken();
request_info = params.module + "." + params.act; request_info = params.module + "." + params.act;
} }
// Delay the waiting message for 1 second to prevent rapid blinking. // Delay the waiting message for 1 second to prevent rapid blinking.
waiting_obj.css("opacity", 0.0); waiting_obj.css("opacity", 0.0);
var wfsr_timeout = setTimeout(function() { var wfsr_timeout = setTimeout(function() {
@ -212,14 +212,14 @@
waiting_obj.css("opacity", "").show(); waiting_obj.css("opacity", "").show();
} }
}, 1000); }, 1000);
// Define the success handler. // Define the success handler.
var successHandler = function(data, textStatus, xhr) { var successHandler = function(data, textStatus, xhr) {
// Hide the waiting message. // Hide the waiting message.
clearTimeout(wfsr_timeout); clearTimeout(wfsr_timeout);
waiting_obj.hide().trigger("cancel_confirm"); waiting_obj.hide().trigger("cancel_confirm");
// Add debug information. // Add debug information.
if (data._rx_debug) { if (data._rx_debug) {
data._rx_debug.page_title = "AJAX : " + request_info; data._rx_debug.page_title = "AJAX : " + request_info;
@ -229,7 +229,7 @@
window.rhymix_debug_pending_data.push(data._rx_debug); window.rhymix_debug_pending_data.push(data._rx_debug);
} }
} }
// If the response contains an error, display the error message. // If the response contains an error, display the error message.
if(data.error != "0" && data.error > -1000) { if(data.error != "0" && data.error > -1000) {
// If this is a temporary CSRF error, retry with a new token. // If this is a temporary CSRF error, retry with a new token.
@ -261,7 +261,7 @@
return; return;
} }
} }
// If the response contains a redirect URL, redirect immediately. // If the response contains a redirect URL, redirect immediately.
if (data.redirect_url) { if (data.redirect_url) {
data.redirect_url = data.redirect_url.replace(/&amp;/g, "&"); data.redirect_url = data.redirect_url.replace(/&amp;/g, "&");
@ -269,13 +269,13 @@
if (data.redirect_url && !$.isFunction(callback_success)) { if (data.redirect_url && !$.isFunction(callback_success)) {
return redirect(data.redirect_url); return redirect(data.redirect_url);
} }
// If there was a success callback, call it. // If there was a success callback, call it.
if($.isFunction(callback_success)) { if($.isFunction(callback_success)) {
callback_success(data); callback_success(data);
} }
}; };
// Define the error handler. // Define the error handler.
var errorHandler = function(xhr, textStatus) { var errorHandler = function(xhr, textStatus) {
@ -283,12 +283,12 @@
if (xhr.status == 0 && page_unloading) { if (xhr.status == 0 && page_unloading) {
return; return;
} }
// Hide the waiting message and display an error notice. // Hide the waiting message and display an error notice.
clearTimeout(wfsr_timeout); clearTimeout(wfsr_timeout);
waiting_obj.hide().trigger("cancel_confirm"); waiting_obj.hide().trigger("cancel_confirm");
var error_info; var error_info;
if ($(".x_modal-body").size()) { if ($(".x_modal-body").size()) {
error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")" + "<br><br><pre>" + xhr.responseText + "</pre>"; error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")" + "<br><br><pre>" + xhr.responseText + "</pre>";
alert("AJAX communication error while requesting " + params.module + "." + params.act + "<br><br>" + error_info); alert("AJAX communication error while requesting " + params.module + "." + params.act + "<br><br>" + error_info);
@ -297,7 +297,7 @@
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info); alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info);
} }
}; };
// Send the AJAX request. // Send the AJAX request.
try { try {
$.ajax({ $.ajax({
@ -396,7 +396,7 @@
XE.ajaxForm(this); XE.ajaxForm(this);
} }
}); });
/** /**
* Empty placeholder for beforeUnload handler. * Empty placeholder for beforeUnload handler.
*/ */
@ -404,7 +404,7 @@
page_unloading = true; page_unloading = true;
return ""; return "";
}; };
/** /**
* Register the beforeUnload handler. * Register the beforeUnload handler.
*/ */
@ -431,18 +431,18 @@
* It was meant for cross-domain requests, but should be replaced with JSONP. * It was meant for cross-domain requests, but should be replaced with JSONP.
*/ */
function send_by_form(url, params) { function send_by_form(url, params) {
// This function is deprecated! // This function is deprecated!
if (typeof console == "object" && typeof console.log == "function") { if (typeof console == "object" && typeof console.log == "function") {
console.log("DEPRECATED : send_by_form() is deprecated in Rhymix."); console.log("DEPRECATED : send_by_form() is deprecated in Rhymix.");
} }
// Create the hidden iframe. // Create the hidden iframe.
var frame_id = "xeTmpIframe"; var frame_id = "xeTmpIframe";
if (!$("#" + frame_id).length) { if (!$("#" + frame_id).length) {
$('<iframe name="%id%" id="%id%" style="position:absolute;left:-1px;top:1px;width:1px;height:1px"></iframe>'.replace(/%id%/g, frame_id)).appendTo(document.body); $('<iframe name="%id%" id="%id%" style="position:absolute;left:-1px;top:1px;width:1px;height:1px"></iframe>'.replace(/%id%/g, frame_id)).appendTo(document.body);
} }
// Create the hidden form. // Create the hidden form.
var form_id = "xeVirtualForm"; var form_id = "xeVirtualForm";
$("#" + form_id).remove(); $("#" + form_id).remove();
@ -452,17 +452,17 @@ function send_by_form(url, params) {
"action" : url, "action" : url,
"target" : frame_id "target" : frame_id
}); });
// Add virtual XML parameters. // Add virtual XML parameters.
params.xeVirtualRequestMethod = "xml"; params.xeVirtualRequestMethod = "xml";
params.xeRequestURI = location.href.replace(/#(.*)$/i, ""); params.xeRequestURI = location.href.replace(/#(.*)$/i, "");
params.xeVirtualRequestUrl = request_uri; params.xeVirtualRequestUrl = request_uri;
// Add inputs to the form. // Add inputs to the form.
$.each(params, function(key, value){ $.each(params, function(key, value){
$('<input type="hidden">').attr("name", key).attr("value", value).appendTo(form); $('<input type="hidden">').attr("name", key).attr("value", value).appendTo(form);
}); });
// Submit the hidden form. // Submit the hidden form.
form.appendTo(document.body).submit(); form.appendTo(document.body).submit();
} }