Skip to content

Commit

Permalink
improve the URL searchparams parse function
Browse files Browse the repository at this point in the history
  • Loading branch information
lixuanxian committed May 22, 2021
1 parent 9d72d4a commit 6b724a8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@
<iframe id="injection-graphXR-iframe-id" origin="*" > </iframe>

<script id="script" type="text/javascript">
let getQueryString = function (name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
let r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}

let URLSearch = new URLSearchParams(window.location.search.replace(/^\?/ig,''));
let defaultEmbedGraphURL = 'https://graphxr.kineviz.com/share/5fad3be86fd8dd0068f8c833/Russian%20Troll%20Tweets%20/5fad3cc86fd8dd0068f8c8d4/Russian-troll-tweets'
let iframe = document.getElementById('injection-graphXR-iframe-id');
iframe.setAttribute('src', getQueryString('embedGraphURL') || getQueryString('url') || iframe.getAttribute('src') || defaultEmbedGraphURL);
iframe.setAttribute('src', URLSearch.get('embedGraphURL') || URLSearch.get('url') || iframe.getAttribute('src') || defaultEmbedGraphURL);
</script>

<script id="script" type="text/javascript">
Expand Down

0 comments on commit 6b724a8

Please sign in to comment.