function addNotification() { var emailFieldElement = document.getElementById('notification_email_field'); var buttonElement = document.getElementById('notification_button'); if (emailFieldElement) { var email = emailFieldElement.value; //Check e-mail if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) { //looks like a valid e-mail //disable the text field na mark the button as working emailFieldElement.disabled = true; buttonElement.className = "feedback_vote_button_voting_in_progress"; buttonElement.innerHTML = "Subscribing..."; buttonElement.onmousedown = function() { }; //do nothing var httpRequest = new XMLHttpRequest(); url = "https://www.lostminds.com/lib/feedback/feedback_add_notification.php" var params = "email="+email; httpRequest.open("POST", url, true); httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //Call this code when the state of the request changes. httpRequest.onreadystatechange = function() { if(httpRequest.readyState == 4 && httpRequest.status == 200) { //alert("submit vote response: "+httpRequest.responseText); //change the vote button if (buttonElement) { buttonElement.className = "feedback_vote_button_has_voted"; buttonElement.innerHTML = "Subscribed"; } //container.className = "entry_line_container"; //change to proper line if needed } } //Send the request! httpRequest.send(params); } else { alert("Please enter a valid e-mail address."); } } else { alert("addNotification error, no emailFieldElement found"); } } function removeNotification() { var emailElement = document.getElementById('notification_email'); var buttonElement = document.getElementById('notification_button'); var messageElement = document.getElementById('notification_message'); if (emailElement) { email = emailElement.innerHTML; //disable the text field na mark the button as working buttonElement.className = "feedback_vote_button_voting_in_progress"; buttonElement.innerHTML = "Working..."; buttonElement.onmousedown = function() { }; //do nothing var httpRequest = new XMLHttpRequest(); url = "https://www.lostminds.com/lib/feedback/feedback_remove_notification.php" var params = "email="+email; httpRequest.open("POST", url, true); httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //Call this code when the state of the request changes. httpRequest.onreadystatechange = function() { if(httpRequest.readyState == 4 && httpRequest.status == 200) { //change the vote button if (buttonElement) { buttonElement.className = "feedback_vote_button_has_voted"; buttonElement.innerHTML = "Unsubscribed"; buttonElement.style.display = 'none'; } if (messageElement) { messageElement.innerHTML = "You will not be notified if a feature you voted for is implemented. Reload the page if you want to subscribe again."; } //container.className = "entry_line_container"; //change to proper line if needed } } //Send the request! httpRequest.send(params); } else { alert("Error: no e-mail element found."); } } function submitVote(feature_id) { var httpRequest = new XMLHttpRequest(); //var url = "feedback_add_vote.php"; url = "https://www.lostminds.com/lib/feedback/feedback_add_vote.php" var params = "feature_id="+feature_id; httpRequest.open("POST", url, true); //Send the proper header information along with the request httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); var vote_button_element = document.getElementById('feedback_vote_button_'+feature_id); var vote_count_element = document.getElementById('feedback_feature_votes_'+feature_id); //mark in progress vote_button_element.className = "feedback_vote_button_voting_in_progress"; vote_button_element.innerHTML = "Voting..."; vote_button_element.onmousedown = function() { //do nothing }; //Call this code when the state of the request changes. httpRequest.onreadystatechange = function() { if(httpRequest.readyState == 4 && httpRequest.status == 200) { //alert("submit vote response: "+httpRequest.responseText); //change the vote button if (vote_button_element) { vote_button_element.className = "feedback_vote_button_has_voted"; vote_button_element.innerHTML = "Voted"; } //increate the vote count if (vote_count_element) { vote_count_element.innerHTML = String(parseInt(vote_count_element.innerHTML) + 1); } //container.className = "entry_line_container"; //change to proper line if needed } } //Send the request! httpRequest.send(params); }