0
0

Added new lines at the end of files, added edit functionality

This commit is contained in:
Bryan
2019-06-02 14:46:51 +02:00
parent ed20989e14
commit 312d03599f
13 changed files with 137 additions and 11 deletions

View File

@@ -39,3 +39,56 @@ function insertNewURL() {
data.append('url', url);
xhr.send( data );
}
function editURL(node) {
var url = node.childNodes[3].value;
var url_id = node.childNodes[1].innerHTML
var xhr = new XMLHttpRequest ( );
xhr.open ( "POST", 'edit', true );
xhr.onreadystatechange = function ( ) {
if ( xhr.status == 200 ) {
if ( xhr.readyState == XMLHttpRequest.DONE ) {
var response = xhr.responseText;
response = JSON.parse ( response );
if ( response [ 'status' ] == 200 ) {
document.getElementById ( "responsetext" ).innerHTML = response [ 'message' ];
setTimeout( function( ) {
document.getElementById ( 'responsetext' ).innerHTML = ""
}, 1500 );
}
else {
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
setTimeout( function( ) {
document.getElementById ( 'responsetext' ).innerHTML = ""
}, 1500 );
}
}
}
else {
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
setTimeout( function( ) {
document.getElementById ( 'responsetext' ).innerHTML = ""
}, 1500 );
}
}
data = new FormData ( );
data.append('url', url);
data.append('url_id', url_id);
xhr.send( data );
}
(function(){
var URLs = document.getElementsByClassName("urlLink");
for(i=0;i<URLs.length;i++) {
URLs[i].onclick = function() {
var oldText = this.value;
this.parentNode.childNodes[5].style.display = "";
this.parentNode.childNodes[5].childNodes[1].onclick = function() {
editURL(this.parentNode.parentNode);
this.parentNode.style.display = "none";
}
this.parentNode.childNodes[5].childNodes[3].onclick = function() {
this.parentNode.parentNode.childNodes[3].value = oldText;
this.parentNode.style.display = "none";
};
}
}
})();

View File

@@ -246,4 +246,4 @@ function SHA512 ( str )
binarray.push ( H [ i ].lowOrder );
}
return binb2hex ( binarray );
}
}