| | |
| | | self.vorlage_laden_und_fuellen("data/tpl/form_ablageort.tpl", "", function (html) { |
| | | document.querySelector(".zentraler-inhalt").innerHTML = html; |
| | | self.addEvtListener('#ok-btn', 'click', function () { |
| | | // hier neuen Ablageort speichern |
| | | var a = new Ablageort( |
| | | document.querySelector('#ablageort-name').value, |
| | | document.querySelector('#ablageort-ort').value, |
| | | document.querySelector('#ablageort-url').value |
| | | ); |
| | | // {"name":"Katalog","ort":"/home/ulrich/Videos","url":"/media/test"} |
| | | var daten = JSON.stringify(a); |
| | | self.http_post('../api/store/Ablageort', daten, function (responseText) { |
| | | // hier die Antwort verarbeiten |
| | | }); |
| | | }); |
| | | self.addEvtListener('#cancel-btn', 'click', function () { |
| | | // hier die Aktion abbrechen |
| | | document.querySelector(".zentraler-inhalt").innerHTML = ''; |
| | | }); |
| | | self.addEvtListener('#loeschen-btn', 'click', function() { |
| | | var aoname = document.querySelector('#ablageort-name').value; |
| | | var dlgdata = {"del-elem": aoname}; |
| | | self.dialog_laden_und_zeigen('data/tpl/dlg-loeschen.tpl', dlgdata, function() { |
| | | self.addEvtListener('#nein-btn', 'click', self.dialog_schliessen); |
| | | self.addEvtListener('#ja-btn', 'click', function() { |
| | | // hier loeschen |
| | | }); |
| | | }); |
| | | }); |
| | | }); |
| | | }; |
| | |
| | | self.http_call('POST', u, data, cb); |
| | | }; |
| | | |
| | | this.http_delete = function (u, data, cb) { |
| | | self.http_call('DELETE', u, data, cb); |
| | | }; |
| | | |
| | | this.http_call = function (method, u, data, scallback) { |
| | | var xhr = new XMLHttpRequest(); |
| | | var url = u; |
| | |
| | | vurl - URL zur Dialogvorlage |
| | | msgTpl - URL mit einer Vorlage eines Mitteilungstextes (optional) |
| | | */ |
| | | this.dialog_laden_und_zeigen = function (vurl, msgTpl) { |
| | | if (msgTpl !== '') { |
| | | fetch(msgTpl) |
| | | .then(data => { |
| | | // Handle data |
| | | self.dialog_zeigen(vurl, data); |
| | | }).catch(error => { |
| | | // Handle error |
| | | this.dialog_laden_und_zeigen = function (vurl, msgTpl, cb) { |
| | | var vorlage = self.cache[vurl]; |
| | | if(vorlage === undefined) { |
| | | self.http_get(vurl, function(antwort) { |
| | | self.cache[vurl] = antwort; |
| | | self.dialog_zeigen(vurl, msgTpl, cb); |
| | | //self.dialog_zeigen(vurl, antwort, cb); |
| | | //self.vorlage_fuellen(vurl, inhalt, cb); |
| | | }); |
| | | } else { |
| | | self.dialog_zeigen(vurl, ''); |
| | | self.dialog_zeigen(vurl, msgTpl, cb); |
| | | //self.dialog_zeigen(vurl, vorlage, cb); |
| | | } |
| | | }; |
| | | |
| | | this.dialog_zeigen = function (vurl, inhalt, cb) { |
| | | var dlg = document.querySelector(".dialog"); |
| | | self.html_erzeugen( |
| | | vurl, |
| | | inhalt, |
| | | function (html) { |
| | | //dlg.html(html); |
| | | dlg.style.height = '7em'; |
| | | dlg.innerHTML = html; |
| | | document.querySelector('.close-btn').addEventListener('click', self.dialog_schliessen); |
| | | //dlg.slideDown(300); |
| | | if(typeof(cb) !== 'function') { |
| | | // .. |
| | | } else { |
| | | cb(); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | |
| | | /* |
| | | this.dialog_zeigen = function (vurl, inhalt) { |
| | | var dlg = document.querySelector(".dialog"); |
| | | self.html_erzeugen( |
| | |
| | | //dlg.slideDown(300); |
| | | }); |
| | | }; |
| | | |
| | | */ |
| | | self.dialog_schliessen = function () { |
| | | document.querySelector('.close-btn').removeEventListener('click', self.dialog_schliessen); |
| | | //$('.dialog').slideUp(300); |