| | |
| | | function AppVorlage() { |
| | | function Ablageort(n, o, u) { |
| | | this.name = n; |
| | | this.ort = o; |
| | | this.url = u; |
| | | } |
| | | |
| | | |
| | | |
| | | function Mediazentrale() { |
| | | var self = this; |
| | | var appMenu; |
| | | // var vorlagen; |
| | | var cache; // mustache templates |
| | | |
| | | |
| | | |
| | | this.form_ablageort_neu = function() { |
| | | 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 = self.serialisieren(a); |
| | | var daten = JSON.stringify(a); |
| | | self.http_post('../api/store/Ablageort', daten, function(){ |
| | | // hier die Antwort verarbeiten |
| | | }); |
| | | }); |
| | | self.addEvtListener('#cancel-btn', 'click', function() { |
| | | // hier die Aktion abbrechen |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | this.addEvtListener = function(selector, eventName, func) { |
| | | var elems = document.querySelectorAll(selector); |
| | | var index; |
| | | for (index = 0; index < elems.length; index++) { |
| | | elems[index].addEventListener(eventName, func); |
| | | } |
| | | }; |
| | | |
| | | this.http_get = function(u, cb) { |
| | | self.http_call('GET', u, null, cb); |
| | | }; |
| | | |
| | | this.http_post = function(u, data, cb) { |
| | | self.http_call('POST', u, data, cb); |
| | | }; |
| | | |
| | | this.http_call = function (method, u, data, scallback) { |
| | | var xhr = new XMLHttpRequest(); |
| | | var url = u; |
| | | xhr.onreadystatechange = function() { |
| | | if (this.readyState === 4 && this.status === 200) { |
| | | scallback(this.responseText); |
| | | } |
| | | }; |
| | | xhr.open(method, url); |
| | | if(method === 'GET') { |
| | | xhr.send(); |
| | | } else if(method === 'POST' || method === 'PUT') { |
| | | xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); |
| | | xhr.send(data); |
| | | } |
| | | }; |
| | | |
| | | this.serialisieren = function(obj) { |
| | | return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}'; |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | /* ab hier aus App-Vorlage */ |
| | | |
| | | this.init = function() { |
| | | //self.vorlagen = new Vorlagen(); |
| | | self.cache = new Array(); |