vote_chart: Remove hash part of the URL
Now that the truths have anchor links, a user could select one and send the link directly to the truth, or refresh the page to there. However, the local part of the URL would be used by the script to fetch the voting data, which fail as it isn't expected by the server and is, anyway, malformed. Remove the local hash from the URL before requesting the voting data.
This commit is contained in:
parent
19898e1b09
commit
24ab2fc5f2
1 changed files with 3 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
|||
const limit_ratio = 1.3
|
||||
const colors = ['#b6b8fc', '#b6f4fc', '#fcb6cc', '#e0fcb6', '#fcdcb6', '#b6fcc8', '#f0b6fc']
|
||||
async function main() {
|
||||
const vote_response = await fetch(document.URL+"/votes");
|
||||
let current_url = new URL(document.URL)
|
||||
current_url.hash = '' // Strip the local part of the URL, for example if we select a Truth
|
||||
const vote_response = await fetch(current_url.toString()+"/votes");
|
||||
if (!vote_response.ok) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue