liquid_feedback_frontend
annotate static/js/xhr.js @ 1647:123eb46b4d3e
Fixed base url for fetch request
author | bsw |
---|---|
date | Wed Feb 10 00:30:53 2021 +0100 (2021-02-10) |
parents | 62856200414d |
children | 4188405c2425 |
rev | line source |
---|---|
bsw@1619 | 1 function toggleInterest(issueId) { |
bsw@1619 | 2 var linkEl = document.getElementById("issue_" + issueId + "_interest_link"); |
bsw@1619 | 3 var iconEl = document.getElementById("issue_" + issueId + "_interest_icon"); |
bsw@1618 | 4 var interested = iconEl.innerHTML == "star_outline"; |
bsw@1619 | 5 |
bsw@1619 | 6 if (interested) { |
bsw@1619 | 7 linkEl.classList.add("mdl-button--accent"); |
bsw@1619 | 8 linkEl.classList.add("mdl-button--feature-on"); |
bsw@1619 | 9 linkEl.classList.remove("mdl-button--feature-off"); |
bsw@1619 | 10 iconEl.innerHTML = "star"; |
bsw@1619 | 11 } else { |
bsw@1619 | 12 linkEl.classList.remove("mdl-button--accent"); |
bsw@1619 | 13 linkEl.classList.remove("mdl-button--feature-on"); |
bsw@1619 | 14 linkEl.classList.add("mdl-button--feature-off"); |
bsw@1619 | 15 iconEl.innerHTML = "star_outline"; |
bsw@1619 | 16 } |
bsw@1618 | 17 |
bsw@1618 | 18 var data = new FormData(); |
bsw@1619 | 19 data.append("issue_id", issueId); |
bsw@1618 | 20 data.append("interested", interested); |
bsw@1618 | 21 |
bsw@1647 | 22 fetch(baseURL + "/interest/xhr_update", { |
bsw@1618 | 23 method : "POST", |
bsw@1618 | 24 body: data |
bsw@1618 | 25 }).then( |
bsw@1618 | 26 response => { |
bsw@1619 | 27 if (response.status != 200) { |
bsw@1619 | 28 window.alert("Error during update"); |
bsw@1618 | 29 } |
bsw@1618 | 30 } |
bsw@1618 | 31 ); |
bsw@1618 | 32 |
bsw@1618 | 33 } |
bsw@1618 | 34 |