From 703b04ca97516568fab831ca60f13e8735da5274 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 30 Apr 2023 22:05:43 +0900 Subject: [PATCH] Remove unnecessary whitespace in common JS files --- common/js/common.js | 52 ++++++++++++------------ common/js/debug.js | 44 ++++++++++---------- common/js/xml2json.js | 4 +- common/js/xml_handler.js | 88 ++++++++++++++++++++-------------------- 4 files changed, 94 insertions(+), 94 deletions(-) diff --git a/common/js/common.js b/common/js/common.js index 62ecace97..ff50bf93f 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -18,7 +18,7 @@ ($.os.Linux) ? 'Linux' : ($.os.Unix) ? 'Unix' : ($.os.Mac) ? 'Mac' : ''; - + /* Intercept getScript error due to broken minified script URL */ $(document).ajaxError(function(event, jqxhr, settings, thrownError) { 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 */ @@ -42,7 +42,7 @@ if (url1.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i) || url2.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i)) { return false; } - + try { url1 = window.XE.URI(url1).normalizePort().normalizeHostname().normalizePathname().origin(); url2 = window.XE.URI(url2).normalizePort().normalizeHostname().normalizePathname().origin(); @@ -92,7 +92,7 @@ return $(this); } }; - + window.rhymix_alert_close = function() { if($('#rhymix_alert').is(':hidden')) { return; @@ -101,7 +101,7 @@ $(this).empty(); }); }; - + /** * @brief display alert */ @@ -121,7 +121,7 @@ alert(message); } }; - + $(document).ready(function() { if(Cookies.get('rhymix_alert_message')) { rhymix_alert(Cookies.get('rhymix_alert_message'), null, Cookies.get('rhymix_alert_delay')); @@ -130,7 +130,7 @@ } $('#rhymix_alert').click(rhymix_alert_close); }); - + /* Array for pending debug data */ window.rhymix_debug_pending_data = []; @@ -147,7 +147,7 @@ SecondLevelDomains : window.SecondLevelDomains, IPv6 : window.IPv6, baseurl : null, - + /** * @brief 특정 name을 가진 체크박스들의 checked 속성 변경 * @param [itemName='cart',][options={}] @@ -266,7 +266,7 @@ area.css({ top:areaOffset.top, left:areaOffset.left }).show().focus(); } }, - + /* 동일 사이트 내 주소인지 판단 (프로토콜 제외) */ isSameHost: function(url) { if (typeof url !== "string") { @@ -278,12 +278,12 @@ if (url.match(/^\w+:[^\/]*$/) || url.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i)) { return false; } - + if (!window.XE.baseurl) { window.XE.baseurl = window.XE.URI(window.request_uri).normalizePort().normalizeHostname().normalizePathname(); window.XE.baseurl = window.XE.baseurl.hostname() + window.XE.baseurl.directory(); } - + try { var target_url = window.XE.URI(url).normalizePort().normalizeHostname().normalizePathname(); if (target_url.is("urn")) { @@ -299,7 +299,7 @@ return false; } }, - + /* Format file size */ filesizeFormat: function(size) { if (size < 2) return size + 'Byte'; @@ -310,7 +310,7 @@ return (size / 1099511627776).toFixed(2) + 'TB'; } }; - + /** * Shim for Modernizr if it is not loaded */ @@ -324,7 +324,7 @@ touch: ('ontouchstart' in window) || (navigator.maxTouchPoints > 0), webgl: !!window.WebGLRenderingContext }; - + })(jQuery); /* jQuery(document).ready() */ @@ -336,10 +336,10 @@ jQuery(function($) { $(document).on("focus", "input,select,textarea", function() { $(this).parents("form[method]").filter(function() { return String($(this).attr("method")).toUpperCase() == "POST"; }).addCSRFTokenToForm(); }); - + /** * Reverse tabnapping protection - * + * * Automatically add rel="noopener" to any external link with target="_blank" * This is not required in most modern browsers. * https://caniuse.com/mdn-html_elements_a_implicit_noopener @@ -393,7 +393,7 @@ jQuery(function($) { } } }); - + /* Editor preview replacement */ $(".editable_preview").addClass("rhymix_content xe_content").attr("tabindex", 0); $(".editable_preview").on("click", function() { @@ -412,7 +412,7 @@ jQuery(function($) { $(".editable_preview").on("focus", function() { $(this).triggerHandler("click"); }); - + /* select - option의 disabled=disabled 속성을 IE에서도 체크하기 위한 함수 */ if(navigator.userAgent.match(/MSIE/)) { $('select').each(function(i, sels) { @@ -464,7 +464,7 @@ jQuery(function($) { alert(max_filesize_error); } }); - + jQuery('input[type="submit"],button[type="submit"]').click(function(ev){ var $el = jQuery(ev.currentTarget); @@ -549,10 +549,10 @@ jQuery(function($) { return String(this).replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }; } - + /** * @brief Helper function for setQuery() - * + * * @param uri URI * @return URI */ @@ -565,10 +565,10 @@ jQuery(function($) { if(window.XE.isSameHost(uri.toString()) && filename === 'index.php' && $.isEmptyObject(queries)) { filename = ''; } - + return uri.protocol(protocol).port(port || null).normalizePort().filename(filename); } - + })(jQuery); /** @@ -610,7 +610,7 @@ function winopen(url, target, features) { if (typeof target == 'undefined') target = '_blank'; if (typeof features == 'undefined') features = ''; - + if (!window.XE.isSameHost(url)) { window.blankshield.open(url, target, features); } else { @@ -666,7 +666,7 @@ function move_url(url, open_window) { if (/^\./.test(url)) { url = window.request_uri + url; } - + if (typeof open_window == 'undefined' || open_window == 'N') { redirect(url); } else { @@ -1315,7 +1315,7 @@ jQuery(function($){ var name = $this.attr('name'); var href = $this.attr('href'); if (!name) name = '_xe_popup_' + Math.floor(Math.random() * 1000); - + event.preventDefault(); winopen(href, name, 'left=10,top=10,width=10,height=10,resizable=no,scrollbars=no,toolbars=no'); }); diff --git a/common/js/debug.js b/common/js/debug.js index 34123b5a2..46190415d 100644 --- a/common/js/debug.js +++ b/common/js/debug.js @@ -1,22 +1,22 @@ /** * Client-side script for manipulating the debug panel on Rhymix. - * + * * @file debug.js * @author Kijin Sung */ $(function() { - + "use strict"; - + // Disable debug panel? if ($('body').hasClass("disable_debug_panel")) { return; } - + // Find debug panel elements. var panel = $("#rhymix_debug_panel"); var button = $("#rhymix_debug_button").addClass('visible'); - + // Initialize the debug button. var button_link = $('').text("DEBUG").appendTo(button).click(function(event) { event.preventDefault(); @@ -24,7 +24,7 @@ $(function() { panel.css({ width: max_width, left: max_width * -1 }).show().animate({ left: 0 }, 200); button.hide(); }); - + // Initialize the debug panel. var header = $('
').appendTo(panel); header.append('

RHYMIX DEBUG

'); @@ -38,19 +38,19 @@ $(function() { button.show(); }); })); - + // Define a function for adding debug data to the panel. window.rhymix_debug_add_data = function(data, open) { - + // Define loop variables. var i, j, entry, num, backtrace, description; - + // New pages are open by default. if (open !== true && open !== false) { open = true; } - + // Create the page. var page = $('
').appendTo(panel); var page_body = $('
').appendTo(page); @@ -58,7 +58,7 @@ $(function() { { page_body.hide(); } - + // Create the page header. var page_header = $('
').prependTo(page).click(function() { $(this).find("a.debug_page_collapse").triggerHandler("click"); @@ -75,7 +75,7 @@ $(function() { $(this).text("▲"); } })); - + // Add general information. page_body.append($('

').text('General Information')); entry = $('
').appendTo(page_body); @@ -85,7 +85,7 @@ $(function() { metadata.append($('
  • ').text('Memory Usage: ' + (data.memory ? XE.filesizeFormat(data.memory) : 'unknown'))); metadata.append($('
  • ').text('Total Time: ' + data.timing.total)); metadata.append($('
  • ').text('Query Time: ' + data.timing.db_query)); - + // Add debug entries. if (data.entries && data.entries.length) { page_body.append($('

    ').text('Debug Entries (' + data.entries.length + ')')); @@ -101,7 +101,7 @@ $(function() { } } } - + // Add errors. if (data.errors && data.errors.length) { page_body.append($('

    ').text('Errors (' + data.errors.length + ')')); @@ -117,7 +117,7 @@ $(function() { } } } - + // Add queries. if (data.queries && data.queries.length) { page_body.append($('

    ').text('Queries (' + data.queries.length + ')')); @@ -143,7 +143,7 @@ $(function() { description.append($('
  • ').text("Result: " + ((data.queries[i].message === "success" || !data.queries[i].message) ? "success" : data.queries[i].message))); } } - + // Add slow queries. if (data.slow_queries && data.slow_queries.length) { page_body.append($('

    ').text('Slow Queries (' + data.slow_queries.length + ')')); @@ -169,7 +169,7 @@ $(function() { description.append($('
  • ').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. if (data.slow_triggers && data.slow_triggers.length) { page_body.append($('

    ').text('Slow Triggers (' + data.slow_triggers.length + ')')); @@ -182,7 +182,7 @@ $(function() { description.append($('
  • ').text("Exec Time: " + (data.slow_triggers[i].trigger_time ? (data.slow_triggers[i].trigger_time.toFixed(4) + " sec") : ""))); } } - + // Add slow widgets. if (data.slow_widgets && data.slow_widgets.length) { page_body.append($('

    ').text('Slow Widgets (' + data.slow_widgets.length + ')')); @@ -194,7 +194,7 @@ $(function() { description.append($('
  • ').text("Exec Time: " + (data.slow_widgets[i].widget_time ? (data.slow_widgets[i].widget_time.toFixed(4) + " sec") : ""))); } } - + // Add slow remote requests. if (data.slow_remote_requests && data.slow_remote_requests.length) { page_body.append($('

    ').text('Slow Remote Requests (' + data.slow_remote_requests.length + ')')); @@ -210,19 +210,19 @@ $(function() { description.append($('
  • ').text("Status Code: " + data.slow_remote_requests[i].status)); } } - + // If there are errors, turn the button text red. if (data.errors && data.errors.length) { button_link.addClass("has_errors"); } }; - + // Add debug data from the current request. if (window.rhymix_debug_content) { window.rhymix_debug_content.page_title = 'MAIN PAGE'; rhymix_debug_add_data(window.rhymix_debug_content, true); } - + // Add debug data from pending AJAX requests. if (window.rhymix_debug_pending_data) { while (window.rhymix_debug_pending_data.length) { diff --git a/common/js/xml2json.js b/common/js/xml2json.js index bf8c61843..46b3ef57b 100644 --- a/common/js/xml2json.js +++ b/common/js/xml2json.js @@ -495,13 +495,13 @@ } var xmlDoc; if (window.DOMParser) { - var parser=new window.DOMParser(); + var parser=new window.DOMParser(); try { xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" ); if(xmlDoc.getElementsByTagNameNS('*', "parsererror").length > 0) { //throw new Error('Error parsing XML: '+xmlDocStr); xmlDoc = null; - } + } } catch(err) { xmlDoc = null; diff --git a/common/js/xml_handler.js b/common/js/xml_handler.js index a39f2e229..63f170979 100644 --- a/common/js/xml_handler.js +++ b/common/js/xml_handler.js @@ -2,50 +2,50 @@ * Functions for sending AJAX requests to the server. */ (function($){ - + "use strict"; - + /** * Set this variable to false to hide the "waiting for server response" layer. */ window.show_waiting_message = false; - + /** * Set this variable to false to hide the "do you want to leave the page?" dialog. */ window.show_leaving_warning = false; - + /** * This variable becomes true when the user tries to navigate away from the page. */ var page_unloading = false; - + /** * This variable stores the .wfsr jQuery object. */ var waiting_obj = $(".wfsr"); - + /** * 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) { - + // Define callback functions. var successHandler, errorHandler, xmlHandler; - + // Convert params to object and fill in the module and act. params = params ? ($.isArray(params) ? arr2obj(params) : params) : {}; params.module = module; params.act = act; params._rx_ajax_compat = 'XMLRPC'; params._rx_csrf_token = getCSRFToken(); - + // Decide whether or not to use SSL. var url = request_uri; - + // 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); - + // Delay the waiting message for 1 second to prevent rapid blinking. waiting_obj.css("opacity", 0.0); var wfsr_timeout = setTimeout(function() { @@ -53,14 +53,14 @@ waiting_obj.css("opacity", "").show(); } }, 1000); - + // Define the success handler. successHandler = function(data, textStatus, xhr) { - + // Hide the waiting message. clearTimeout(wfsr_timeout); waiting_obj.hide().trigger("cancel_confirm"); - + // Copy data to the result object. var result = {}; $.each(data, function(key, val) { @@ -68,7 +68,7 @@ result[key] = val; } }); - + // Add debug information. if (data._rx_debug) { data._rx_debug.page_title = "AJAX : " + params.module + "." + params.act; @@ -78,7 +78,7 @@ window.rhymix_debug_pending_data.push(data._rx_debug); } } - + // If the response contains an error, display the error message. if (data.error != "0") { // This way of calling an error handler is deprecated. Do not use it. @@ -100,7 +100,7 @@ } return null; } - + // If the response contains a redirect URL, redirect immediately. if (data.redirect_url) { data.redirect_url = data.redirect_url.replace(/&/g, "&"); @@ -108,21 +108,21 @@ if (data.redirect_url && !$.isFunction(callback_success)) { return redirect(data.redirect_url); } - + // If there was a success callback, call it. if ($.isFunction(callback_success)) { callback_success(result, return_fields, callback_success_arg, fo_obj); } }; - + // Define the error handler. errorHandler = function(xhr, textStatus, doNotHandleXml) { - + // 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(/
    " + xhr.responseText + "
    "; alert("AJAX communication error while requesting " + params.module + "." + params.act + "

    " + error_info); @@ -141,7 +141,7 @@ alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info); } }; - + // Define the legacy XML handler. xmlHandler = function(xhr, textStatus) { var parseXmlAndReturn = function() { @@ -167,7 +167,7 @@ }); } }; - + // Send the AJAX request. try { $.ajax({ @@ -189,7 +189,7 @@ * Function for compatibility with XE's exec_json() */ window.exec_json = $.exec_json = function(action, params, callback_success, callback_error) { - + // Convert params to object and fill in the module and act. var action_parts = action.split('.'); var request_info; @@ -204,7 +204,7 @@ params._rx_csrf_token = getCSRFToken(); request_info = params.module + "." + params.act; } - + // Delay the waiting message for 1 second to prevent rapid blinking. waiting_obj.css("opacity", 0.0); var wfsr_timeout = setTimeout(function() { @@ -212,14 +212,14 @@ waiting_obj.css("opacity", "").show(); } }, 1000); - + // Define the success handler. var successHandler = function(data, textStatus, xhr) { - + // Hide the waiting message. clearTimeout(wfsr_timeout); waiting_obj.hide().trigger("cancel_confirm"); - + // Add debug information. if (data._rx_debug) { data._rx_debug.page_title = "AJAX : " + request_info; @@ -229,7 +229,7 @@ window.rhymix_debug_pending_data.push(data._rx_debug); } } - + // If the response contains an error, display the error message. if(data.error != "0" && data.error > -1000) { // If this is a temporary CSRF error, retry with a new token. @@ -261,7 +261,7 @@ return; } } - + // If the response contains a redirect URL, redirect immediately. if (data.redirect_url) { data.redirect_url = data.redirect_url.replace(/&/g, "&"); @@ -269,13 +269,13 @@ if (data.redirect_url && !$.isFunction(callback_success)) { return redirect(data.redirect_url); } - + // If there was a success callback, call it. if($.isFunction(callback_success)) { callback_success(data); } }; - + // Define the error handler. var errorHandler = function(xhr, textStatus) { @@ -283,12 +283,12 @@ if (xhr.status == 0 && page_unloading) { return; } - + // Hide the waiting message and display an error notice. clearTimeout(wfsr_timeout); waiting_obj.hide().trigger("cancel_confirm"); var error_info; - + if ($(".x_modal-body").size()) { error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")" + "

    " + xhr.responseText + "
    "; alert("AJAX communication error while requesting " + params.module + "." + params.act + "

    " + error_info); @@ -297,7 +297,7 @@ alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info); } }; - + // Send the AJAX request. try { $.ajax({ @@ -396,7 +396,7 @@ XE.ajaxForm(this); } }); - + /** * Empty placeholder for beforeUnload handler. */ @@ -404,7 +404,7 @@ page_unloading = true; return ""; }; - + /** * Register the beforeUnload handler. */ @@ -431,18 +431,18 @@ * It was meant for cross-domain requests, but should be replaced with JSONP. */ function send_by_form(url, params) { - + // This function is deprecated! if (typeof console == "object" && typeof console.log == "function") { console.log("DEPRECATED : send_by_form() is deprecated in Rhymix."); } - + // Create the hidden iframe. var frame_id = "xeTmpIframe"; if (!$("#" + frame_id).length) { $(''.replace(/%id%/g, frame_id)).appendTo(document.body); } - + // Create the hidden form. var form_id = "xeVirtualForm"; $("#" + form_id).remove(); @@ -452,17 +452,17 @@ function send_by_form(url, params) { "action" : url, "target" : frame_id }); - + // Add virtual XML parameters. params.xeVirtualRequestMethod = "xml"; params.xeRequestURI = location.href.replace(/#(.*)$/i, ""); params.xeVirtualRequestUrl = request_uri; - + // Add inputs to the form. $.each(params, function(key, value){ $('').attr("name", key).attr("value", value).appendTo(form); }); - + // Submit the hidden form. form.appendTo(document.body).submit(); }