diff options
author | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-28 08:02:17 +0000 |
---|---|---|
committer | cweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2009-10-28 08:02:17 +0000 |
commit | a3ba58dfc048c948230317191c67101c4aa80bfb (patch) | |
tree | 75dc0309ac92381e3df31820894aa79f320b9e1f /www/jsScuttle.php | |
parent | a63765a4ad05b83f4c4ffcb7790b528f09f20a43 (diff) | |
download | semanticscuttle-a3ba58dfc048c948230317191c67101c4aa80bfb.tar.gz semanticscuttle-a3ba58dfc048c948230317191c67101c4aa80bfb.tar.bz2 |
basic ajax voting support. has a bad counting bug somewhere
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@445 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'www/jsScuttle.php')
-rw-r--r-- | www/jsScuttle.php | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/www/jsScuttle.php b/www/jsScuttle.php index 6aba422..6807e4a 100644 --- a/www/jsScuttle.php +++ b/www/jsScuttle.php @@ -42,7 +42,7 @@ function deleteConfirmed(ele, input, response) { post.style.display = 'none'; deleted = false; } else { - loadXMLDoc('<?php echo ROOT; ?>ajaxDelete.php?id=' + input); + loadXMLDocProc('<?php echo ROOT; ?>ajaxDelete.php?id=' + input); post.style.display = 'none'; } } @@ -97,7 +97,7 @@ function getTitle(input, response){ title.style.backgroundImage = 'none'; title.value = response; } else if (input.indexOf('http') > -1) { - loadXMLDoc('<?php echo ROOT; ?>ajaxGetTitle.php?url=' + input); + loadXMLDocProc('<?php echo ROOT; ?>ajaxGetTitle.php?url=' + input); } else { return false; } @@ -105,11 +105,25 @@ function getTitle(input, response){ } var xmlhttp; -function loadXMLDoc(url) { +function loadXMLDocProc(url) { + loadXMLDoc(url, processStateChange); +} +function vote(bookmark, vote) { + if (vote == 1) { + vote = 'for'; + } else { + vote = 'against'; + } + loadXMLDoc( + '<?php echo ROOT; ?>ajaxVote.php/' + vote + '/' + bookmark, + processVotingResult + ); +} +function loadXMLDoc(url, callback) { // Native if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); - xmlhttp.onreadystatechange = processStateChange; + xmlhttp.onreadystatechange = callback; xmlhttp.open("GET", url, true); xmlhttp.send(null); // ActiveX @@ -131,6 +145,20 @@ function processStateChange() { eval(method + '(\'\', result)'); } } +function processVotingResult() { + if (xmlhttp.readyState != 4 || xmlhttp.status != 200) { + return; + } + var response = xmlhttp.responseXML.documentElement; + var bookmark = response.getElementsByTagName('bookmark')[0] + .firstChild.nodeValue; + var bmnode = document.getElementById('bmv-'+bookmark); + + bmnode.parentNode.replaceChild( + response.getElementsByTagName('html')[0].firstChild, + bmnode + ); +} function playerLoad() { var anchors = document.getElementsByTagName('a'); |