Use convenient JS/JSON filter when javascript is enabled
authorJoey Schulze <joey@infodrom.org>
Sat, 29 Aug 2015 13:25:25 +0000 (13:25 +0000)
committerJoey Schulze <joey@infodrom.org>
Sat, 29 Aug 2015 13:25:25 +0000 (13:25 +0000)
src/InfoCon/account/index.wml
src/InfoCon/account/list.wml
src/InfoCon/account/submenu.inc

index 45f387d..b0c1ad2 100644 (file)
@@ -21,6 +21,13 @@ Die folgenden Konten stehen zur Verf
 
 </blockquote>
 
+<protect><script type="text/javascript">
+$(function(){
+    $('blockquote ul li a').each(function(i,e){
+       $(this).attr('href', $(this).attr('href').replace('query.php','list.php'));
+    });
+});
+</script></protect>
 </page>
 
 # Local variables:
index f36c8cc..7b4334d 100644 (file)
@@ -99,10 +99,17 @@ function filter_account()
 
   return $out;
 }
+
+if (!empty($_POST['ajax']) && $_POST['ajax'] == 1) {
+    echo utf8_encode(filter_account());
+    exit;
+}
+
 ?>
 
 <page func=InfoCon title="Kontoführung">
 
+<calendar_init -5>
 <account_heading>
 <form_to_yyyymmdd>
 
@@ -130,7 +137,46 @@ $(function(){
            $(this).css('backgroundColor','');
     });
 });
+
+function filter_popup()
+{
+    if (!$('#filter_popup form input').length) {
+       $.get('query.php',
+             window.location.search.substr(1),
+             function(data) {
+                 var text = '<style type="text/css">';
+                 text += '#fc { z-index: 10; }';
+                 $(data).find('style').each(function(i,e){
+                     text += $(this).html();
+                 });
+                 text += '</style>';
+                 text += $(data).find('form').html();
+                 $('#filter_popup form').html(text);
+                 $('#filter_popup form input.button[type="submit"]').click(function(e){
+                     $.post('list.php',
+                            'ajax=1&'+$('#filter_popup form').serialize(),
+                            function(data){
+                                $('table.border tbody').html(data);
+                            });
+                     console.log($('#filter_popup form').serialize());
+                     return false;
+                 });
+         });
+    }
+
+    if ($('#filter_popup:visible').length)
+        $('#filter_popup').hide();
+    else
+        $('#filter_popup').show();
+
+    return false;
+}
+
 </script></protect>
+<div id="filter_popup" style="background:white;border:1px solid #CCC;height:auto;width:330px;position:absolute;right:10px;top:10px;padding:5px;display:none;">
+<div style="background:#EEE;margin-bottom:5px;font-weight:bold;">Filter setzen</div>
+<form id="filter_form"></form>
+</div>
 </page>
 
 # Local variables:
index 83f7ee3..83223c8 100644 (file)
 
 &nbsp;<menu-item base=all text="Alle&nbsp;Konten" href=all.php><br>
 &nbsp;<menu-item base=admin text="Admin" href=admin.php><br>
+<when <string-eq "<get-var WML_SRC_BASENAME>" "list" />>
+<script type="text/javascript">
+document.write('&nbsp;<a class="sm" onclick="return filter_popup()" href="#">Filter</a><br>');
+</script>
+</when>
 
 <menu-rule>