Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. $( document ).ready(function() {
  3.     var donecheck = 'false';
  4.     if(donecheck == 'false'){
  5.  
  6.         // get variables from URL
  7.         var href = document.URL ? document.URL : window.location.href;
  8.         var res = href.split("?");
  9.         var vars = res[1];
  10.  
  11.         var tokens = [];
  12.         var values = [];
  13.  
  14.         // get all combinations
  15.         var combos = vars.split("&");
  16.  
  17.         // parse combinations and get values and tokens
  18.         for (var i = 0, len = combos.length; i < len; i++) {
  19.         var item = combos[i];
  20.         var res = item.split("=");
  21.         tokens.push(res[0]);
  22.         values.push(res[1]);
  23.         }
  24.  
  25.         // get old content
  26.         var oldcontent = $("#pageLayoutContent").html();
  27.  
  28.         // do replacements
  29.         for (var i = 0, len = tokens.length; i < len; i++) {
  30.  
  31.         console.log('####'+len);
  32.         var token = tokens[i];
  33.         var value = values[i];
  34.  
  35.         // split value and fallback
  36.         var res = value.split("#");
  37.  
  38.         // if value exists use it, if not display teh fallback
  39.         if(res[0] != ''){
  40.         var value = res[0];
  41.         } else {
  42.         var value = res[1];
  43.         }
  44.  
  45.         // suppress "undefined"
  46.         if (typeof value !== 'undefined') {
  47.         // There is a value set
  48.         } else {
  49.         // no value set, so set "undefined" to blank
  50.         var value = '';
  51.         }
  52.  
  53.         // URL decode
  54.         var value = decodeURIComponent(value);
  55.  
  56.         var oldcontent = oldcontent.replace('[['+token+']]',value);
  57.         }
  58.  
  59.         // display new content
  60.         $("#pageLayoutContent").html(oldcontent);
  61.  
  62.         donecheck = 'true';
  63.     }
  64. });
  65. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement