From 18af7c28471d8ea28ad50a061b7d815e710bfd7f Mon Sep 17 00:00:00 2001
From: hilgeru <hilgeru@msgn07482.int.root.msg.ag>
Date: Tue, 27 Feb 2018 14:43:52 +0000
Subject: [PATCH] SenderApi fertig

---
 web/app.js |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/web/app.js b/web/app.js
index e2a07e8..b474eb6 100644
--- a/web/app.js
+++ b/web/app.js
@@ -221,6 +221,9 @@
         */
         $('#sender-loeschen').on('click', function() {
           $('#sender-loeschen').off('click');
+          
+          app_sender_entfernen(s);
+          
           app_kachel_entfernen(s);
           app_dialog_schliessen();
           app_meldung_mit_timeout('Loeschen gewaehlt ' + s.name, 1500);
@@ -463,17 +466,25 @@
   });
 }
 
+/* SenderApi */
+
+var URL_SENDER_API = "api?c=de.uhilger.radiozentrale.api.SenderApi&m=";
+
 function app_neuen_sender_speichern(sender) {
-  var obj = serialisieren(sender);
-  var url = 'api?c=de.uhilger.radiozentrale.api.SenderApi&m=neuerSender';
-  $.post( url, 'p=' + obj, function( result ) {
-    console.log( result );
-  }, "json");
+  app_sender_api('neuerSender', sender);
 }
 
 function app_sender_aendern(sender) {
+  app_sender_api('senderAendern', sender);
+}
+
+function app_sender_entfernen(sender) {
+  app_sender_api('senderLoeschen', sender);
+}
+
+function app_sender_api(methode, sender) {
   var obj = serialisieren(sender);
-  var url = 'api?c=de.uhilger.radiozentrale.api.SenderApi&m=senderAendern';
+  var url = URL_SENDER_API + methode;
   $.post( url, 'p=' + obj, function( result ) {
     console.log( result );
   }, "json");

--
Gitblit v1.9.3