From d582054c77b22daeb08d2bff17794b9a69a20dd4 Mon Sep 17 00:00:00 2001 From: mensonge Date: Wed, 12 Dec 2007 16:29:16 +0000 Subject: import of scuttle 0.7.2 git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@1 b3834d28-1941-0410-a4f8-b48e95affb8f --- jsScuttle.php | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 jsScuttle.php (limited to 'jsScuttle.php') diff --git a/jsScuttle.php b/jsScuttle.php new file mode 100644 index 0000000..fbe1e20 --- /dev/null +++ b/jsScuttle.php @@ -0,0 +1,141 @@ + + +function _playerAdd(anchor) { + var url = anchor.href; + var code = ''; + var code = code + ''; + var code = code + ''; + anchor.parentNode.innerHTML = code +' '+ anchor.parentNode.innerHTML; +} + +String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, ''); +}; + +var deleted = false; +function deleteBookmark(ele, input){ + var confirmDelete = " - "; + ele.style.display = 'none'; + ele.parentNode.innerHTML = ele.parentNode.innerHTML + confirmDelete; +} + +function deleteCancelled(ele) { + var del = previousElement(ele.parentNode); + del.style.display = 'inline'; + ele.parentNode.parentNode.removeChild(ele.parentNode); + return false; +} + +function deleteConfirmed(ele, input, response) { + if (deleted == false) { + deleted = ele.parentNode.parentNode.parentNode; + } + var post = deleted; + post.className = 'xfolkentry deleted'; + if (response != '') { + post.style.display = 'none'; + deleted = false; + } else { + loadXMLDoc('ajaxDelete.php?id=' + input); + } +} + +function previousElement(ele) { + ele = ele.previousSibling; + while (ele.nodeType != 1) { + ele = ele.previousSibling; + } + return ele; +} + +function isAvailable(input, response){ + var usernameField = document.getElementById("username"); + var username = usernameField.value; + username = username.toLowerCase(); + username = username.trim(); + var availability = document.getElementById("availability"); + if (username != '') { + usernameField.style.backgroundImage = 'url(loading.gif)'; + if (response != '') { + usernameField.style.backgroundImage = 'none'; + if (response == 'true') { + availability.className = 'available'; + availability.innerHTML = ''; + } else { + availability.className = 'not-available'; + availability.innerHTML = ''; + } + } else { + loadXMLDoc('ajaxIsAvailable.php?username=' + username); + } + } +} + +function useAddress(ele) { + var address = ele.value; + if (address != '') { + if (address.indexOf(':') < 0) { + address = 'http:\/\/' + address; + } + getTitle(address, null); + ele.value = address; + } +} + +function getTitle(input, response){ + var title = document.getElementById('titleField'); + if (title.value == '') { + title.style.backgroundImage = 'url(loading.gif)'; + if (response != null) { + title.style.backgroundImage = 'none'; + title.value = response; + } else if (input.indexOf('http') > -1) { + loadXMLDoc('ajaxGetTitle.php?url=' + input); + } else { + return false; + } + } +} + +var xmlhttp; +function loadXMLDoc(url) { + // Native + if (window.XMLHttpRequest) { + xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = processStateChange; + xmlhttp.open("GET", url, true); + xmlhttp.send(null); + // ActiveX + } else if (window.ActiveXObject) { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + if (xmlhttp) { + xmlhttp.onreadystatechange = processStateChange; + xmlhttp.open("GET", url, true); + xmlhttp.send(); + } + } +} + +function processStateChange() { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { + response = xmlhttp.responseXML.documentElement; + method = response.getElementsByTagName('method')[0].firstChild.data; + result = response.getElementsByTagName('result')[0].firstChild.data; + eval(method + '(\'\', result)'); + } +} + +function playerLoad() { + var anchors = document.getElementsByTagName('a'); + var anchors_length = anchors.length; + for (var i = 0; i < anchors_length; i++) { + if (anchors[i].className == 'taggedlink' && anchors[i].href.match(/\.mp3$/i)) { + _playerAdd(anchors[i]); + } + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf