diff options
author | Tom Zakrajsek <tomz@codeaurora.org> | 2014-04-17 22:05:50 -0700 |
---|---|---|
committer | WebTech Code Review <code-review@localhost> | 2014-04-22 14:56:03 -0700 |
commit | bb6f89428a2cba323c7d223fbed40e648f66e4c8 (patch) | |
tree | acfedce92afad400031a6fbc45f2b673abff2187 | |
parent | fd75eaee2bd20e2af99c7e8093f38d9f9b970a54 (diff) | |
download | android_packages_apps_Gello-bb6f89428a2cba323c7d223fbed40e648f66e4c8.tar.gz android_packages_apps_Gello-bb6f89428a2cba323c7d223fbed40e648f66e4c8.tar.bz2 android_packages_apps_Gello-bb6f89428a2cba323c7d223fbed40e648f66e4c8.zip |
Ensure URL query string information is applied to anchor/go elements
CRs-Fixed: 648697
Issues-fixed: SWE-1848, CHNAPSS-1926
Change-Id: I53c9d9d378f974186bb3695d4fc8ed135d25dcad
-rwxr-xr-x | assets/wml/swe_wml.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/assets/wml/swe_wml.js b/assets/wml/swe_wml.js index 92fa6ee4..5e98452a 100755 --- a/assets/wml/swe_wml.js +++ b/assets/wml/swe_wml.js @@ -516,6 +516,39 @@ function internal_executeOnpickTask(option) } //<go> +function addQueryStringKeyValuePairsToForm(form) +{ + var href = form.dataset.wml_href; + var query; + + // Seperate the query string from the href + var queryFragments = href.split("?"); + if (queryFragments.length === 2) { + query = queryFragments[1]; + } else { + queryFragments.shift(); + query = queryFragments.join("?"); + } + + // Parse the query string for key/value pairs. Add them to the form + // as hidden input elements. + // E.g., http://myserver/test.wml?p1=foo&p2=bar + // would add the following to the form: + // <input type="hidden" name="p1" value="foo"> + // <input type="hidden" name="p2" value="bar"> + query.replace( + new RegExp( "([^?=&]+)(?:=([^&]*))?", "g" ), + function(match, name, value) { + var param = document.createElement("input"); + param.setAttribute("type","hidden") + param.setAttribute("name", name) + param.setAttribute("value",value) + form.appendChild(param) + } + ); + return true; +} + function internal_executeGoTask(form) { var href = form.dataset.wml_href; @@ -528,6 +561,7 @@ function internal_executeGoTask(form) } // Substitute variables in <postfield> 'value' attributes before form submission. updateVariableInPostfields(); + addQueryStringKeyValuePairsToForm(form); form.submit(); return false; } |