diff --git a/core/src/main/resources/org/apache/struts2/interceptor/debugging/webconsole.js b/core/src/main/resources/org/apache/struts2/interceptor/debugging/webconsole.js index ee9e07e1f..2068e61cd 100644 --- a/core/src/main/resources/org/apache/struts2/interceptor/debugging/webconsole.js +++ b/core/src/main/resources/org/apache/struts2/interceptor/debugging/webconsole.js @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -19,57 +17,58 @@ * under the License. */ -function printResult(result_string) { - var result_div = document.getElementById('wc-result'); - var result_array = result_string.split('\n'); +function printResult(resultString) { + var resultDiv = document.getElementById('wc-result'); + var resultArray = resultString.split('\n'); - var new_command = document.getElementById('wc-command').value; - result_div.appendChild(document.createTextNode(new_command)); - result_div.appendChild(document.createElement('br')); + var newCommand = document.getElementById('wc-command').value; + resultDiv.appendChild(document.createTextNode(newCommand)); + resultDiv.appendChild(document.createElement('br')); - for (var line_index in result_array) { - var result_wrap = document.createElement('pre') - line = document.createTextNode(result_array[line_index]); - result_wrap.appendChild(line); - result_div.appendChild(result_wrap); - result_div.appendChild(document.createElement('br')); + for (var lineIndex in resultArray) { + if (resultArray.hasOwnProperty(lineIndex)) { + var resultWrap = document.createElement('pre'), + line = document.createTextNode(resultArray[lineIndex]); + resultWrap.appendChild(line); + resultDiv.appendChild(resultWrap); + resultDiv.appendChild(document.createElement('br')); + } + } + resultDiv.appendChild(document.createTextNode(':-> ')); - } - result_div.appendChild(document.createTextNode(':-> ')); - - result_div.scrollTop = result_div.scrollHeight; - document.getElementById('wc-command').value = ''; + resultDiv.scrollTop = resultDiv.scrollHeight; + document.getElementById('wc-command').value = ''; } function keyEvent(event, url) { - switch (event.keyCode) { - case 13: - var the_shell_command = document.getElementById('wc-command').value; - if (the_shell_command) { - commands_history[commands_history.length] = the_shell_command; - history_pointer = commands_history.length; - var the_url = url ? url : window.opener.location.pathname; - jQuery.post(the_url, jQuery("#wc-form").serialize(), function (data) { - printResult(data); - }); - } - break; - case 38: // this is the arrow up - if (history_pointer > 0) { - history_pointer--; - document.getElementById('wc-command').value = commands_history[history_pointer]; - } - break; - case 40: // this is the arrow down - if (history_pointer < commands_history.length - 1) { - history_pointer++; - document.getElementById('wc-command').value = commands_history[history_pointer]; - } - break; - default: - break; - } + switch (event.keyCode) { + case 13: + var theShellCommand = document.getElementById('wc-command').value; + if (theShellCommand) { + commandsHistory[commandsHistory.length] = theShellCommand; + historyPointer = commandsHistory.length; + var theUrl = url ? url : window.opener.location.pathname; + jQuery.post(theUrl, jQuery("#wc-form").serialize(), function (data) { + printResult(data); + }); + } + break; + case 38: // this is the arrow up + if (historyPointer > 0) { + historyPointer--; + document.getElementById('wc-command').value = commandsHistory[historyPointer]; + } + break; + case 40: // this is the arrow down + if (historyPointer < commandsHistory.length - 1) { + historyPointer++; + document.getElementById('wc-command').value = commandsHistory[historyPointer]; + } + break; + default: + break; + } } -var commands_history = []; -var history_pointer; +var commandsHistory = []; +var historyPointer; diff --git a/core/src/main/resources/org/apache/struts2/static/inputtransferselect.js b/core/src/main/resources/org/apache/struts2/static/inputtransferselect.js index bda929e8f..80e5a270f 100644 --- a/core/src/main/resources/org/apache/struts2/static/inputtransferselect.js +++ b/core/src/main/resources/org/apache/struts2/static/inputtransferselect.js @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -21,7 +19,7 @@ function addOption(objTextBox, objTargetElement) { var value = objTextBox.value; - if(value != null && value != '') { + if (value !== null && value !== '') { objTargetElement.options[objTargetElement.options.length] = new Option(value, value); objTextBox.value = ''; } @@ -29,7 +27,7 @@ function addOption(objTextBox, objTargetElement) { function removeOptions(objTargetElement) { var i = 0; - while(objTargetElement.options.length > i) { + while (objTargetElement.options.length > i) { if (objTargetElement.options[i].selected) { objTargetElement.options.remove(i); } else { @@ -39,7 +37,7 @@ function removeOptions(objTargetElement) { } function removeAllOptions(objTargetElement) { - while(objTargetElement.options.length != 0) { + while (objTargetElement.options.length !== 0) { objTargetElement.options[0] = null; } } @@ -48,85 +46,90 @@ function selectAllOptionsExceptSome(objTargetElement, type, ptn) { var test = compile(ptn); for (var i = 0; i < objTargetElement.length; i++) { var opt = objTargetElement.options[i]; - if ((type == 'key' && !test(opt.value)) || - (type == 'text' && !test(opt.text))) { + if ((type === 'key' && !test(opt.value)) || + (type === 'text' && !test(opt.text))) { opt.selected = true; } else { opt.selected = false; - } + } } return false; } function compile(ptn) { - if (ptn != undefined) { - if (ptn == '' || !window.RegExp) { - return function(val) { return val == ptn; } + if (ptn !== undefined) { + if (ptn === '' || !window.RegExp) { + return function (val) { + return val === ptn; + }; } else { var reg = new RegExp("^" + ptn + "$"); return function (val) { - if (val == '') { // ignore empty option added by template - return true; + if (val === '') { // ignore empty option added by template + return true; } - return reg.test(val); } + return reg.test(val); + }; } } - return function(val) { return false; } + return function (val) { + return false; + }; } function selectAllOptions(objTargetElement) { for (var i = 0; i < objTargetElement.length; i++) { - if (objTargetElement.options[i].value != '') { - objTargetElement.options[i].selected = true; - } + if (objTargetElement.options[i].value !== '') { + objTargetElement.options[i].selected = true; + } } return false; } function moveOptionUp(objTargetElement, type, ptn) { - var test = compile(ptn); - for (i=0; i= 0; i--) { - if (objTargetElement[i].selected) { - var v; - if ((i != (objTargetElement.length-1)) && !objTargetElement[i+1].selected) { - if (type == 'key') { - v = objTargetElement[i].value - } - else { - v = objTargetElement[i].text; - } - if (!test(v)) { - swapOptions(objTargetElement,i,i+1); - } - } - } - } + var test = compile(ptn); + for (i = (objTargetElement.length - 1); i >= 0; i--) { + if (objTargetElement[i].selected) { + var v; + if ((i !== (objTargetElement.length - 1)) && !objTargetElement[i + 1].selected) { + if (type === 'key') { + v = objTargetElement[i].value; + } + else { + v = objTargetElement[i].text; + } + if (!test(v)) { + swapOptions(objTargetElement, i, i + 1); + } + } + } + } } function swapOptions(objTargetElement, first, second) { - var opt = objTargetElement.options; - var temp = new Option(opt[first].text, opt[first].value, opt[first].defaultSelected, opt[first].selected); - var temp2= new Option(opt[second].text, opt[second].value, opt[second].defaultSelected, opt[second].selected); - opt[first] = temp2; - opt[second] = temp; + var opt = objTargetElement.options; + var temp = new Option(opt[first].text, opt[first].value, opt[first].defaultSelected, opt[first].selected); + var temp2 = new Option(opt[second].text, opt[second].value, opt[second].defaultSelected, opt[second].selected); + opt[first] = temp2; + opt[second] = temp; } diff --git a/core/src/main/resources/org/apache/struts2/static/optiontransferselect.js b/core/src/main/resources/org/apache/struts2/static/optiontransferselect.js index 105addf4d..681450b7b 100644 --- a/core/src/main/resources/org/apache/struts2/static/optiontransferselect.js +++ b/core/src/main/resources/org/apache/struts2/static/optiontransferselect.js @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -22,8 +20,8 @@ function moveSelectedOptions(objSourceElement, objTargetElement, toSort, notMove1, notMove2) { var test1 = compile(notMove1); var test2 = compile(notMove2); - moveOptions(objSourceElement, objTargetElement, toSort, - function(opt) { + moveOptions(objSourceElement, objTargetElement, toSort, + function (opt) { return (opt.selected && !test1(opt.value) && !test2(opt.value)); } ); @@ -32,28 +30,33 @@ function moveSelectedOptions(objSourceElement, objTargetElement, toSort, notMove function moveAllOptions(objSourceElement, objTargetElement, toSort, notMove1, notMove2) { var test1 = compile(notMove1); var test2 = compile(notMove2); - moveOptions(objSourceElement, objTargetElement, toSort, - function(opt) { + moveOptions(objSourceElement, objTargetElement, toSort, + function (opt) { return (!test1(opt.value) && !test2(opt.value)); } ); } function compile(ptn) { - if (ptn != undefined) { - if (ptn == '' || !window.RegExp) { - return function(val) { return val == ptn; } + if (ptn !== undefined) { + if (ptn === '' || !window.RegExp) { + return function (val) { + return val === ptn; + }; } else { var reg = new RegExp("^" + ptn + "$"); - return function (val) { - if (val == '') { // ignore empty option added by template - return true; + return function (val) { + if (val === '') { // ignore empty option added by template + return true; } - return reg.test(val); } + return reg.test(val); + }; } } - return function(val) { return false; } -} + return function (val) { + return false; + }; +} function moveOptions(objSourceElement, objTargetElement, toSort, chooseFunc) { var aryTempSourceOptions = []; @@ -65,8 +68,8 @@ function moveOptions(objSourceElement, objTargetElement, toSort, chooseFunc) { if (chooseFunc(objSourceElement.options[i])) { //need to move this option to target element var intTargetLen = objTargetElement.length++; - objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text; - objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value; + objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text; + objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value; } else { //storing options that stay to recreate select element @@ -79,36 +82,40 @@ function moveOptions(objSourceElement, objTargetElement, toSort, chooseFunc) { } //sorting and refilling target list - for (var i = 0; i < objTargetElement.length; i++) { - var objTempValues = {}; - objTempValues.text = objTargetElement.options[i].text; - objTempValues.value = objTargetElement.options[i].value; - aryTempTargetOptions[i] = objTempValues; + for (var j = 0; j < objTargetElement.length; j++) { + var oTempValues = {}; + oTempValues.text = objTargetElement.options[j].text; + oTempValues.value = objTargetElement.options[j].value; + aryTempTargetOptions[j] = oTempValues; } - + if (toSort) { aryTempTargetOptions.sort(sortByText); - } - - for (var i = 0; i < objTargetElement.length; i++) { - objTargetElement.options[i].text = aryTempTargetOptions[i].text; - objTargetElement.options[i].value = aryTempTargetOptions[i].value; - objTargetElement.options[i].selected = false; - } - + } + + for (var k = 0; k < objTargetElement.length; k++) { + objTargetElement.options[k].text = aryTempTargetOptions[k].text; + objTargetElement.options[k].value = aryTempTargetOptions[k].value; + objTargetElement.options[k].selected = false; + } + //resetting length of source objSourceElement.length = aryTempSourceOptions.length; //looping through temp array to recreate source select element - for (var i = 0; i < aryTempSourceOptions.length; i++) { - objSourceElement.options[i].text = aryTempSourceOptions[i].text; - objSourceElement.options[i].value = aryTempSourceOptions[i].value; - objSourceElement.options[i].selected = false; + for (var l = 0; l < aryTempSourceOptions.length; l++) { + objSourceElement.options[l].text = aryTempSourceOptions[l].text; + objSourceElement.options[l].value = aryTempSourceOptions[l].value; + objSourceElement.options[l].selected = false; } } function sortByText(a, b) { - if (a.text < b.text) {return -1} - if (a.text > b.text) {return 1} + if (a.text < b.text) { + return -1; + } + if (a.text > b.text) { + return 1; + } return 0; } @@ -116,69 +123,69 @@ function selectAllOptionsExceptSome(objTargetElement, type, ptn) { var test = compile(ptn); for (var i = 0; i < objTargetElement.length; i++) { var opt = objTargetElement.options[i]; - if ((type == 'key' && !test(opt.value)) || - (type == 'text' && !test(opt.text))) { + if ((type === 'key' && !test(opt.value)) || + (type === 'text' && !test(opt.text))) { opt.selected = true; } else { opt.selected = false; - } + } } return false; } function selectAllOptions(objTargetElement) { for (var i = 0; i < objTargetElement.length; i++) { - if (objTargetElement.options[i].value != '') { - objTargetElement.options[i].selected = true; - } + if (objTargetElement.options[i].value !== '') { + objTargetElement.options[i].selected = true; + } } return false; } function moveOptionUp(objTargetElement, type, ptn) { - var test = compile(ptn); - for (i=0; i= 0; i--) { - if (objTargetElement[i].selected) { - var v; - if ((i != (objTargetElement.length-1)) && !objTargetElement[i+1].selected) { - if (type == 'key') { - v = objTargetElement[i].value - } - else { - v = objTargetElement[i].text; - } - if (!test(v)) { - swapOptions(objTargetElement,i,i+1); - } - } - } - } + var test = compile(ptn); + for (i = (objTargetElement.length - 1); i >= 0; i--) { + if (objTargetElement[i].selected) { + var v; + if ((i !== (objTargetElement.length - 1)) && !objTargetElement[i + 1].selected) { + if (type === 'key') { + v = objTargetElement[i].value; + } + else { + v = objTargetElement[i].text; + } + if (!test(v)) { + swapOptions(objTargetElement, i, i + 1); + } + } + } + } } function swapOptions(objTargetElement, first, second) { - var opt = objTargetElement.options; - var temp = new Option(opt[first].text, opt[first].value, opt[first].defaultSelected, opt[first].selected); - var temp2 = new Option(opt[second].text, opt[second].value, opt[second].defaultSelected, opt[second].selected); - opt[first] = temp2; - opt[second] = temp; + var opt = objTargetElement.options; + var temp = new Option(opt[first].text, opt[first].value, opt[first].defaultSelected, opt[first].selected); + var temp2 = new Option(opt[second].text, opt[second].value, opt[second].defaultSelected, opt[second].selected); + opt[first] = temp2; + opt[second] = temp; } diff --git a/core/src/main/resources/org/apache/struts2/static/utils.js b/core/src/main/resources/org/apache/struts2/static/utils.js index 1779ce57a..bf745e788 100644 --- a/core/src/main/resources/org/apache/struts2/static/utils.js +++ b/core/src/main/resources/org/apache/struts2/static/utils.js @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -29,7 +27,7 @@ StrutsUtils.getValidationErrors = function(data) { } else { if (data.indexOf("/* {") === 0) { - return eval("( " + data.substring(2, data.length - 2) + " )"); + return JSON.parse( data.substring(2, data.length - 2) + " )"); } else { return null; } diff --git a/core/src/main/resources/template/css_xhtml/validation.js b/core/src/main/resources/template/css_xhtml/validation.js index 78b442ac5..2e10d229f 100644 --- a/core/src/main/resources/template/css_xhtml/validation.js +++ b/core/src/main/resources/template/css_xhtml/validation.js @@ -1,6 +1,4 @@ /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -158,9 +156,9 @@ function addError(e, errorText) { } //focus first element -var StrutsUtils_showValidationErrors = StrutsUtils.showValidationErrors; +var StrutsUtilsShowValidationErrors = StrutsUtils.showValidationErrors; StrutsUtils.showValidationErrors = function(form, errors) { - StrutsUtils_showValidationErrors(form, errors); + StrutsUtilsShowValidationErrors(form, errors); if (firstFieldErrorPosition !== null && form.elements[firstFieldErrorPosition].focus) { form.elements[firstFieldErrorPosition].focus(); }