Merge branch 'issue_#2' of bryanpedini/OpenShorte into master
This commit is contained in:
commit
923184ab68
@ -13,8 +13,28 @@ function insertNewURL() {
|
|||||||
document.getElementById ( 'responsetext' ).innerHTML = ""
|
document.getElementById ( 'responsetext' ).innerHTML = ""
|
||||||
}, 1500 );
|
}, 1500 );
|
||||||
var div = document.createElement ( 'div' );
|
var div = document.createElement ( 'div' );
|
||||||
div.innerHTML = response [ 'last_insert' ] + " | " + url;
|
div.classList.add ( "urlContainer" );
|
||||||
document.getElementById ( "urllist" ).appendChild ( div );
|
div.appendChild ( document.createElement ( 'text' ) );
|
||||||
|
div.appendChild ( document.createElement ( 'div' ) );
|
||||||
|
div.childNodes [ 1 ].classList.add ( "urlId" );
|
||||||
|
div.childNodes [ 1 ].innerHTML = response [ 'last_insert' ];
|
||||||
|
div.appendChild ( document.createElement ( 'text' ) );
|
||||||
|
div.appendChild ( document.createElement ( 'input' ) );
|
||||||
|
div.childNodes [ 3 ].type = 'text';
|
||||||
|
div.childNodes [ 3 ].classList.add ( "urlLink" );
|
||||||
|
div.childNodes [ 3 ].setAttribute ( 'value', url );
|
||||||
|
div.appendChild ( document.createElement ( 'text' ) );
|
||||||
|
div.appendChild ( document.createElement ( 'div' ) );
|
||||||
|
div.childNodes [ 5 ].classList.add ( "urlControl" );
|
||||||
|
div.childNodes [ 5 ].setAttribute ( 'style', "display: none;" );
|
||||||
|
div.childNodes [ 5 ].appendChild ( document.createElement ( 'text' ) );
|
||||||
|
div.childNodes [ 5 ].appendChild ( document.createElement ( 'button' ) );
|
||||||
|
div.childNodes [ 5 ].childNodes [ 1 ].innerHTML = "<i class=\"fas fa-check\"></i>";
|
||||||
|
div.childNodes [ 5 ].appendChild ( document.createElement ( 'text' ) );
|
||||||
|
div.childNodes [ 5 ].appendChild ( document.createElement ( 'button' ) );
|
||||||
|
div.childNodes [ 5 ].childNodes [ 3 ].innerHTML = "<i class=\"fas fa-times\"></i>";
|
||||||
|
makeURLEditable ( div.childNodes [ 3 ] );
|
||||||
|
document.getElementsByClassName ( "urlList" ) [ 0 ].appendChild ( div );
|
||||||
document.getElementById ( "form-url" ).value = "";
|
document.getElementById ( "form-url" ).value = "";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -24,9 +44,6 @@ function insertNewURL() {
|
|||||||
}, 1500 );
|
}, 1500 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
console.log ( 'Server communication error: ' + xhr.statusText );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
|
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
|
||||||
@ -75,20 +92,23 @@ function editURL(node) {
|
|||||||
data.append('url_id', url_id);
|
data.append('url_id', url_id);
|
||||||
xhr.send( data );
|
xhr.send( data );
|
||||||
}
|
}
|
||||||
|
function makeURLEditable ( node ) {
|
||||||
|
node.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";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
(function(){
|
(function(){
|
||||||
var URLs = document.getElementsByClassName("urlLink");
|
var URLs = document.getElementsByClassName("urlLink");
|
||||||
for(i=0;i<URLs.length;i++) {
|
for(i=0;i<URLs.length;i++) {
|
||||||
URLs[i].onclick = function() {
|
makeURLEditable(URLs[i]);
|
||||||
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";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Reference in New Issue
Block a user