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 = ""
|
||||
}, 1500 );
|
||||
var div = document.createElement ( 'div' );
|
||||
div.innerHTML = response [ 'last_insert' ] + " | " + url;
|
||||
document.getElementById ( "urllist" ).appendChild ( div );
|
||||
div.classList.add ( "urlContainer" );
|
||||
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 = "";
|
||||
}
|
||||
else {
|
||||
@ -24,9 +44,6 @@ function insertNewURL() {
|
||||
}, 1500 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log ( 'Server communication error: ' + xhr.statusText );
|
||||
}
|
||||
}
|
||||
else {
|
||||
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
|
||||
@ -75,10 +92,8 @@ function editURL(node) {
|
||||
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() {
|
||||
function makeURLEditable ( node ) {
|
||||
node.onclick = function() {
|
||||
var oldText = this.value;
|
||||
this.parentNode.childNodes[5].style.display = "";
|
||||
this.parentNode.childNodes[5].childNodes[1].onclick = function() {
|
||||
@ -90,5 +105,10 @@ function editURL(node) {
|
||||
this.parentNode.style.display = "none";
|
||||
};
|
||||
}
|
||||
}
|
||||
(function(){
|
||||
var URLs = document.getElementsByClassName("urlLink");
|
||||
for(i=0;i<URLs.length;i++) {
|
||||
makeURLEditable(URLs[i]);
|
||||
}
|
||||
})();
|
||||
|
Reference in New Issue
Block a user