corrected newly inserted URLs not appearing in URL list in real time (fix #2)
This commit is contained in:
parent
3f1efd1103
commit
22e22c7de0
@ -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,10 +92,8 @@ function editURL(node) {
|
|||||||
data.append('url_id', url_id);
|
data.append('url_id', url_id);
|
||||||
xhr.send( data );
|
xhr.send( data );
|
||||||
}
|
}
|
||||||
(function(){
|
function makeURLEditable ( node ) {
|
||||||
var URLs = document.getElementsByClassName("urlLink");
|
node.onclick = function() {
|
||||||
for(i=0;i<URLs.length;i++) {
|
|
||||||
URLs[i].onclick = function() {
|
|
||||||
var oldText = this.value;
|
var oldText = this.value;
|
||||||
this.parentNode.childNodes[5].style.display = "";
|
this.parentNode.childNodes[5].style.display = "";
|
||||||
this.parentNode.childNodes[5].childNodes[1].onclick = function() {
|
this.parentNode.childNodes[5].childNodes[1].onclick = function() {
|
||||||
@ -90,5 +105,10 @@ function editURL(node) {
|
|||||||
this.parentNode.style.display = "none";
|
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