Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $( document ).ready(function() {
- var donecheck = 'false';
- if(donecheck == 'false'){
- // get variables from URL
- var href = document.URL ? document.URL : window.location.href;
- var res = href.split("?");
- var vars = res[1];
- var tokens = [];
- var values = [];
- // get all combinations
- var combos = vars.split("&");
- // parse combinations and get values and tokens
- for (var i = 0, len = combos.length; i < len; i++) {
- var item = combos[i];
- var res = item.split("=");
- tokens.push(res[0]);
- values.push(res[1]);
- }
- // get old content
- var oldcontent = $("#pageLayoutContent").html();
- // do replacements
- for (var i = 0, len = tokens.length; i < len; i++) {
- console.log('####'+len);
- var token = tokens[i];
- var value = values[i];
- // split value and fallback
- var res = value.split("#");
- // if value exists use it, if not display teh fallback
- if(res[0] != ''){
- var value = res[0];
- } else {
- var value = res[1];
- }
- // suppress "undefined"
- if (typeof value !== 'undefined') {
- // There is a value set
- } else {
- // no value set, so set "undefined" to blank
- var value = '';
- }
- // URL decode
- var value = decodeURIComponent(value);
- var oldcontent = oldcontent.replace('[['+token+']]',value);
- }
- // display new content
- $("#pageLayoutContent").html(oldcontent);
- donecheck = 'true';
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement