From c49a4043bff032941a1def7060f59708de62df4e Mon Sep 17 00:00:00 2001
From: Hermann Blum <hermannsblum@yahoo.de>
Date: Sat, 10 Mar 2018 16:49:32 +0100
Subject: [PATCH] update selectList to also use the infinite scroll view

---
 src/userTool.js           |   9 +-
 src/views/selectList.js   | 210 +++++++---
 tools/annoucetool.tool    |   0
 tools/bk.tool             | 108 ------
 tools/events.tool         | 797 --------------------------------------
 tools/groups.tool         | 355 -----------------
 tools/home.tool           |  26 --
 tools/studydocuments.tool | 326 ----------------
 tools/users.tool          | 347 -----------------
 9 files changed, 159 insertions(+), 2019 deletions(-)
 delete mode 100644 tools/annoucetool.tool
 delete mode 100644 tools/bk.tool
 delete mode 100644 tools/events.tool
 delete mode 100644 tools/groups.tool
 delete mode 100644 tools/home.tool
 delete mode 100644 tools/studydocuments.tool
 delete mode 100644 tools/users.tool

diff --git a/src/userTool.js b/src/userTool.js
index 41eeb50..4380654 100644
--- a/src/userTool.js
+++ b/src/userTool.js
@@ -5,6 +5,7 @@ import { inputGroup, selectGroup, submitButton } from './views/elements';
 import SelectList from './views/selectList';
 import { users as config } from './config.json';
 import DatalistController from './listcontroller';
+import { ListTile } from 'polythene-mithril';
 
 const m = require('mithril');
 
@@ -53,8 +54,8 @@ class UserView extends ItemView {
       membershipBadge = m('span.label.label-success', 'Member');
     } else if (this.data.membership === 'extraordinary') {
       membershipBadge = m('span.label.label-success', 'Extraordinary Member');
-    } else if (this.data.membership === 'honory') {
-      membershipBadge = m('span.label.label-warning', 'Honory Member');
+    } else if (this.data.membership === 'honorary') {
+      membershipBadge = m('span.label.label-warning', 'Honorary Member');
     }
 
     const detailKeys = [
@@ -64,9 +65,7 @@ class UserView extends ItemView {
     // groupmemberships. Selects a group to request membership for.
     const groupSelect = m(SelectList, {
       controller: this.groupcontroller,
-      itemView: {
-        view({ attrs }) { return m('span', attrs.name); },
-      },
+      listTileAttrs: data => Object.assign({}, { title: data.name }),
       onSubmit: (group) => {
         this.groupchoice = false;
         this.groupmemberships.handler.post({
diff --git a/src/views/selectList.js b/src/views/selectList.js
index 2e7739e..5fa5510 100644
--- a/src/views/selectList.js
+++ b/src/views/selectList.js
@@ -1,68 +1,168 @@
-import { submitButton } from './elements';
+import m from 'mithril';
+import Stream from 'mithril/stream';
+import {
+  List, ListTile, Search, IconButton, Button, Shadow, Toolbar,
+  ToolbarTitle,
+} from 'polythene-mithril';
+import infinite from 'mithril-infinite';
 import { debounce } from '../utils';
 
-const m = require('mithril');
+const iconSearchSVG = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\"/></svg>";
+const iconBackSVG = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\"/></svg>";
+const iconClearSVG = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/></svg>";
+
+const createSearchField = () => {
+  const BackButton = {
+    view: ({ attrs }) => m(IconButton, {
+      icon: { svg: m.trust(iconBackSVG) },
+      ink: false,
+      events: { onclick: attrs.leave },
+    }),
+  };
+  const ClearButton = {
+    view: ({ attrs }) => m(IconButton, {
+      icon: { svg: m.trust(iconClearSVG) },
+      ink: false,
+      events: { onclick: attrs.clear },
+    }),
+  };
+  const SearchIcon = {
+    view: () => m(IconButton, {
+      icon: { svg: m.trust(iconSearchSVG) },
+      inactive: true,
+    }),
+  };
+
+  return {
+    oninit: vnode => {
+      const value = Stream("");
+      const setInputState = Stream();
+
+      //const clear = () => setInputState()({ value: '', focus: false});
+      const clear = () => value('');
+      const leave = () => value('');
+
+      vnode.state = {
+        value,
+        setInputState,
+        clear,
+        leave
+      };
+    },
+    view: ({ state, attrs }) => {
+      // incoming value and focus added for result list example:
+      const value = attrs.value !== undefined ? attrs.value : state.value();
+      return m(Search, Object.assign(
+        {},
+        {
+          textfield: {
+            label: "Search",
+            onChange: (newState) => {
+              state.value(newState.value);
+              state.setInputState(newState.setInputState);
+              // onChange callback added for result list example:
+              attrs.onChange && attrs.onChange(newState, state.setInputState);
+            },
+            value,
+            // incoming label and defaultValue added for result list example:
+            label: attrs.label || "Search",
+            defaultValue: attrs.defaultValue,
+          },
+          buttons: {
+            none: {
+              before: m(SearchIcon),
+            },
+            focus: {
+              before: m(BackButton, { leave: state.leave }),
+            },
+            focus_dirty: {
+              before: m(BackButton, { leave: state.leave }),
+              after: m(ClearButton, { clear: state.clear }),
+            },
+            dirty: {
+              before: m(BackButton, { leave: state.leave }),
+              after: m(ClearButton, { clear: state.clear }),
+            },
+          },
+          before: m(Shadow),
+        },
+        attrs,
+      ));
+    },
+  };
+};
+
+const SearchField = createSearchField();
+
 
 export default class SelectList {
-  constructor() {
+  constructor({ attrs: { listTileAttrs } }) {
     this.selected = null;
     this.showList = false;
+    this.searchValue = '';
+    this.listTileAttrs = listTileAttrs;
   }
 
-  view({ attrs: { controller, itemView, onSubmit = () => {} } }) {
-    // input search and select field
-    const updateList = debounce(() => {
-      controller.refresh();
-    }, 500);
-
-    let input = m('input.form-control', {
-      onfocus: () => { this.showList = true; },
-      onblur: debounce(() => { this.showList = false; m.redraw(); }, 100),
-      onkeyup: (e) => {
-        controller.setSearch(e.target.value);
-        updateList();
-      },
-    });
-    if (this.selected !== null) {
-      input = m('div.btn-group', [
-        m('div.btn.btn-default', m(itemView, this.selected)),
-        m('div.btn.btn-primary', {
-          onclick: () => {
-            this.selected = null;
-            controller.setSearch('');
-            controller.refresh();
-          },
-        }, m('span.glyphicon.glyphicon-remove-sign')),
-      ]);
-    }
-
-    // list of items
-    const list = m('ul.list-group', controller.items.map(item =>
-      m('button.list-group-item', {
-        onclick: () => { this.selected = item; this.showList = false; },
-      }, m(itemView, item))));
+  item() {
+    return (data) => {
+      const attrs = {
+        compactFront: true,
+        hoverable: true,
+        className: 'themed-list-tile',
+        events: {
+          onclick: () => { this.selected = data; this.showList = false; },
+        },
+      };
+      // Overwrite default attrs
+      Object.assign(attrs, this.listTileAttrs(data));
+      return m(ListTile, attrs);
+    };
+  }
 
-    return m('div', {
-    }, [
-      m('div.row', [
-        m('div.col-xs-6', [
-          input,
-          m(submitButton, {
-            text: 'Submit',
-            active: this.selected !== null,
-            args: {
-              class: 'btn-primary',
-              onclick: () => {
-                onSubmit(this.selected);
-                this.selected = null;
-                controller.setSearch('');
-                controller.refresh();
-              },
+  view({ attrs: { controller, onSubmit = () => {} } }) {
+    return m('div', [
+      this.selected ? m(Toolbar, { compact: true }, [
+        m(IconButton, {
+          icon: { svg: m.trust(iconClearSVG) },
+          ink: false,
+          events: { onclick: () => { this.selected = null; } },
+        }),
+        m(ToolbarTitle, { text: this.selected.name }),
+        m(Button, {
+          label: 'Submit',
+          className: 'blue-button',
+          events: {
+            onclick: () => {
+              onSubmit(this.selected);
+              this.selected = null;
+              controller.setSearch('');
+              controller.refresh();
             },
-          }),
-        ]),
-      ]),
-      this.showList ? list : '',
+          },
+        }),
+      ]) : m(SearchField, Object.assign({}, {
+        label: 'type here',
+        onChange: ({ value, focus }) => {
+          if (focus) {
+            this.showList = true;
+          }
+          if (value !== this.searchValue) {
+            // if we always update the search value, this would also happen
+            // immidiately in the moment where we click on the listitem.
+            // Then, the list get's updated before the click is registered.
+            // So, we make sure this state change is due to value change and
+            // not due to focus change.
+            this.searchValue = value;
+            controller.setSearch(value);
+            debounce(() => { controller.refresh(); }, 500);
+          }
+        },
+        defaultValue: '',
+      })),
+      this.showList ? m(List, {
+        className: 'scrollTable',
+        tiles: m(infinite, controller.infiniteScrollParams(this.item())),
+      }) : null,
     ]);
   }
 }
diff --git a/tools/annoucetool.tool b/tools/annoucetool.tool
deleted file mode 100644
index e69de29..0000000
diff --git a/tools/bk.tool b/tools/bk.tool
deleted file mode 100644
index d99a4aa..0000000
--- a/tools/bk.tool
+++ /dev/null
@@ -1,108 +0,0 @@
-<style>
-  .bk-bg {
-    width: 100%;
-    height: calc(100vh - 64px);
-    background-image: url("res/bg/cab.jpg");
-    background-size: cover;
-    background-position: center center;
-    justify-content: center;
-    align-items: center;
-    display: flex;
-  }
-
-  .bk-bg>.mdl-card {
-    margin: 15px;
-  }
-
-  .bk-bg>.mdl-card>.mdl-card__title {
-    height: 180px;
-    background-position: cover;
-    background-position: center center;
-    background-repeat: no-repeat;
-    box-shadow: 0 6px 15px -3px rgba(0, 0, 0, 0.4);
-  }
-
-  .bk-bg>.mdl-card:first-child>.mdl-card__title {
-    background: url("res/bg/coffee_a.png");
-  }
-
-  .bk-bg>.mdl-card:last-child>.mdl-card__title {
-    background: url("res/bg/beer_a.png");
-  }
-
-  .bk-bg>.mdl-card>.mdl-card__title h2 {
-    background: rgba(255, 255, 255, 0.8);
-    padding: 2px;
-    border-radius: 3px;
-  }
-
-  .bk-bg .mdl-data-table {
-    width: 100%;
-  }
-</style>
-<div class="bk-bg">
-  <!-- Coffee -->
-  <div class="demo-card-wide mdl-card mdl-shadow--2dp">
-    <div class="mdl-card__title">
-      <h2 class="mdl-card__title-text mdl-shadow--2dp">Coffee</h2>
-    </div>
-    <div class="mdl-card__supporting-text">
-      <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
-        <thead>
-          <tr>
-            <th class="mdl-data-table__cell--non-numeric">SuperHero</th>
-            <th>Coffee</th>
-          </tr>
-        </thead>
-        <tbody>
-        </tbody>
-      </table>
-    </div>
-    <div class="mdl-card__actions mdl-card--border">
-      <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">Menu</a>
-    </div>
-  </div>
-  <!-- Beer -->
-  <div class="demo-card-wide mdl-card mdl-shadow--2dp">
-    <div class="mdl-card__title">
-      <h2 class="mdl-card__title-text mdl-shadow--2dp">Beer</h2>
-    </div>
-    <div class="mdl-card__supporting-text">
-      <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
-        <thead>
-          <tr>
-            <th class="mdl-data-table__cell--non-numeric">SuperHero</th>
-            <th>Beers</th>
-          </tr>
-        </thead>
-        <tbody>
-        </tbody>
-      </table>
-    </div>
-    <div class="mdl-card__actions mdl-card--border">
-      <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">Stats</a>
-      <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">Lock Beer Machine</a>
-    </div>
-  </div>
-</div>
-<script>
-  var superheroes = [
-    [
-      ['Anon', 34],
-      ['Trololo', 23],
-      ['Random Dude', 13]
-    ],
-    [
-      ['Anon', 138],
-      ['Trololo', 97],
-      ['Random Dude', 72]
-    ]
-  ];
-  var i = 0;
-  $('.mdl-card__supporting-text tbody').each(function() {
-    $(this).html('');
-    for (var n = 0; n < superheroes[i].length; n++)
-      $(this).append('<tr><td class="mdl-data-table__cell--non-numeric">' + superheroes[i][n][0] + '</td><td>' + superheroes[i][n][1] + '</td></tr>');
-    i++;
-  })
-</script>
diff --git a/tools/events.tool b/tools/events.tool
deleted file mode 100644
index 3dd8538..0000000
--- a/tools/events.tool
+++ /dev/null
@@ -1,797 +0,0 @@
-<div class="events-table-wrapper">
-    <div class="tools-full-height">
-        <table class="table table-hover events-table" id="events-table">
-            <thead>
-                <tr>
-                    <th>Title</th>
-                    <th>Date</th>
-                    <th>on website</th>
-                    <th>spots</th>
-                    <th>signups</th>
-                </tr>
-            </thead>
-            <tbody>
-            </tbody>
-        </table>
-    </div>
-</div>
-
-<!-- modal for creating new events, easier to do it this way than js-->
-
-<div class="modal fade" id="event-modal" role="dialog" data-etag="" data-backdrop="static">
-    <div class="modal-dialog">
-        <div class="modal-content">
-            <div class="modal-header">
-                <button type="button" class="close" data-dismiss="modal">&times;</button>
-                <h4 class="modal-title" id="event-modal-title"></h4>
-            </div>
-            <div class="modal-body">
-                <form id="event-modal-form">
-                    <div class="form-group">
-                        <label for="title_de">Title</label>
-                        <input type="text" class="form-control" id="title_de"></input>
-                    </div>
-                    <div class="form-group">
-                        <label for="description_de">Description</label>
-                        <textarea type="text" class="form-control" rows="3" id="description_de"></textarea>
-                    </div>
-                    <div class="form-group">
-                        <label for="catchphrase_de">Catchphrase</label>
-                        <input type="text" class="form-control" id="catchphrase_de"></input>
-                    </div>
-
-                    <!-- <div class="container"> -->
-                    <!-- <div class="col-md-3"> -->
-                    <div class="form-group">
-                        <label for="time_start">Start Time</label>
-                        <div class="input-group date" id="time_start">
-                            <input type="text" class="form-control" />
-                            <span class="input-group-addon">
-                                <span class="glyphicon-calendar glyphicon"></span>
-                            </span>
-                        </div>
-                    </div>
-                    <!-- </div> -->
-                    <!-- <div class="col-md-3"> -->
-                    <div class="form-group">
-                        <label for="time_end">End Time</label>
-                        <div class="input-group date" id="time_end">
-                            <input type="text" class="form-control" />
-                            <span class="input-group-addon">
-                                <span class="glyphicon-calendar glyphicon"></span>
-                            </span>
-                        </div>
-                    </div>
-
-
-                    <div class="form-group">
-                        <label for="time_start">Start Advertising</label>
-                        <div class="input-group date" id="time_advertising_start">
-                            <input type="text" class="form-control" />
-                            <span class="input-group-addon">
-                                <span class="glyphicon-calendar glyphicon"></span>
-                            </span>
-                        </div>
-                    </div>
-                    <!-- </div> -->
-                    <!-- <div class="col-md-3"> -->
-                    <div class="form-group">
-                        <label for="time_end">End Advertising</label>
-                        <div class="input-group date" id="time_advertising_end">
-                            <input type="text" class="form-control" />
-                            <span class="input-group-addon">
-                                <span class="glyphicon-calendar glyphicon"></span>
-                            </span>
-                        </div>
-                    </div>
-                    <!-- </div> -->
-                    <!-- </div> -->
-
-                    <label class="checkbox-inline">
-                        <input type="checkbox" id="signup-required" value="">No Signup
-                    </label>
-
-                    <label class="checkbox-inline">
-                        <input type="checkbox" id="no-signup-limit" value="">No Signup Limit
-                    </label>
-
-                    <div class="form-group">
-                        <label for="spots">Spots</label>
-                        <input type="number" class="form-control" min="-1" id="spots"></input>
-                    </div>
-
-                    <!-- <div class="container"> -->
-                    <!-- <div class="col-md-3"> -->
-                    <div class="form-group">
-                        <label for="time_register_start">Start of Registration</label>
-                        <div class="input-group date" id="time_register_start">
-                            <input type="text" class="form-control" />
-                            <span class="input-group-addon">
-                                <span class="glyphicon-calendar glyphicon"></span>
-                            </span>
-                        </div>
-                    </div>
-                    <!-- </div> -->
-                    <!-- <div class="col-md-3"> -->
-                    <div class="form-group">
-                        <label for="time_register_end">End of Registration</label>
-                        <div class="input-group date" id="time_register_end">
-                            <input type="text" class="form-control" />
-                            <span class="input-group-addon">
-                                <span class="glyphicon-calendar glyphicon"></span>
-                            </span>
-                        </div>
-                    </div>
-                    <!-- </div> -->
-                    <!-- </div> -->
-
-                    <label class="checkbox-inline">
-                        <input type="checkbox" id="allow_email_signup" value="">Only amiv Members
-                    </label>
-
-                    <div class="form-group">
-                        <label for="location">Location</label>
-                        <input type="text" class="form-control" id="location"></input>
-                    </div>
-
-                    <div class="form-group">
-                        <label for="price">Price [CHF]</label>
-                        <input type="number" class="form-control" min="0" id="price"></input>
-                    </div>
-
-                    <div>
-                        <label class="checkbox-inline">
-                            <input type="checkbox" id="show_website" value="">Show on Webstite (requires banner image and title)
-                        </label>
-                    </div>
-                    <div>
-                        <label class="checkbox-inline">
-                            <input type="checkbox" id="show_infoscreen" value="">Show ond Infoscreen (requires infoscreen image)
-                        </label>
-                    </div>
-                    <div>
-                        <label class="checkbox-inline">
-                            <input type="checkbox" id="show_announce" value="">Show in Announce (requires stuff)
-                        </label>
-                    </div>
-
-                    <div class="form-group">
-                        <label for="price">Priority [1-10]</label>
-                        <input type="number" class="form-control" min="0" id="priority" value=5></input>
-                    </div>
-
-                    <div class="form-group">
-                        <label for="description_de">Additional Fields (JSON schema)</label>
-                        <textarea type="text" class="form-control" rows="3" id="additional_fields"></textarea>
-                    </div>
-
-                    <label for="selection-strategy">Selection strategy</label>
-                    <fieldset class="form-group" id="selection-strategy">
-                        <div class="form-check">
-                            <label class="form-check-label">
-                                <input type="radio" class="form-check-input" name="selection-strategy-radio" id="selection-strategy-radio1" value="fcfs" checked>
-                                first come first serve
-                            </label>
-                        </div>
-                        <div class="form-check">
-                            <label class="form-check-label">
-                                <input type="radio" class="form-check-input" name="selection-strategy-radio" id="selection-strategy-radio2" value="manual">
-                                manual
-                            </label>
-                        </div>
-                    </fieldset>
-
-                    <div class="form-group">
-                        <label for="img_infoscreen">Infoscreen Image</label>
-                        <input type="file" id="img_infoscreen" name="myFile"/>
-                        <img class="event-image" visibility="invisble" src="" id="actual_img_infoscreen">
-                    </div>
-                    <div class="form-group"> 
-                        <label for="img_banner">Banner Image</label>
-                        <input type="file" id="img_banner"/>
-                        <img class="event-image" visibility="invisble" src="" id="actual_img_banner">
-                    </div>
-                    <div class="form-group">
-                        <label for="img_poster">Poster Image</label>
-                        <input type="file" id="img_poster"/>
-                        <img class="event-image" visibility="invisble" src="" id="actual_img_poster">
-                    </div>
-                    <div class="form-group">
-                        <label for="img_thumbnail">Thumbnail</label>
-                        <input type="file" id="img_thumbnail"/>
-                        <img class="event-image" visibility="invisble" src="" id="actual_img_thumbnail">
-                    </div>
-
-
-                    <button type="button" class "btn" data-toggle="collapse" data-target="#english-collapse">show english fields</button>
-
-                    <div id="english-collapse" class="collapse">
-                        <div class="form-group">
-                            <label for="title_en">Title english</label>
-                            <input type="text" class="form-control" id="title_en"></input>
-                        </div>
-                        <div class="form-group">
-                            <label for="description_en">Description english</label>
-                            <textarea type="text" class="form-control" rows="3" id="description_en"></textarea>
-                        </div>
-                        <div class="form-group">
-                            <label for="catchphrase_en">Catchphrase english</label>
-                            <input type="text" class="form-control" id="catchphrase_en"></input>
-                        </div>
-                    </div>
-
-                    <div id="additional_info">
-                    </div>
-                    <!-- <input type="submit"> -->
-                </form>
-            </div>
-            <div class="modal-footer" id="event-modal-footer">
-                <!-- footer content here -->
-            </div>
-        </div>
-    </div>
-</div>
-
-<style>
-    .events-table-wrapper {
-        position: relative;
-    }
-
-    .events-table-wrapper>div {
-        overflow: auto;
-    }
-
-    #event-modal {
-        overflow: auto;
-    }
-
-    #event-modal .checkbox-inline {
-        margin-bottom: 10px;
-    }
-
-    .users-sidebar {
-        background: #fff;
-    }
-
-    .tooltip-inner {
-        white-space: nowrap;
-        max-width: none;
-    }
-
-    .event-image {
-        margin-top: 10px;
-        max-width: 100%;
-    }
-</style>
-
-    <script type="text/javascript">
-    var events = {
-        API_url: 'https://amiv-api.ethz.ch',
-        somethingChanged: false,
-        showInTable: ['title_de', 'time_start', 'show_website', 'spots', 'signup_count'],
-        curEventData: null,
-
-        // Page
-        page: {
-            max: Number.MAX_VALUE,
-            cur: function() {
-                return parseInt(tools.mem.session.get('curPage'));
-            },
-            set: function(num) {
-                num = parseInt(num);
-                if (num > 0 && num < events.page.max + 1)
-                    tools.mem.session.set('curPage', num);
-                $('.events-cur-page-cont').html(events.page.cur());
-                events.get();
-            },
-            inc: function() {
-                events.page.set(events.page.cur() + 1);
-            },
-            dec: function() {
-                events.page.set(events.page.cur() - 1);
-            }
-        },
-
-        //Sorting
-        sort: {
-            cur: function() {
-                return tools.mem.session.get('curSort');
-            },
-            set: function(sort) {
-                tools.mem.session.set('curSort', sort);
-                events.get();
-            },
-            inv: function() {
-                var tmp = events.sort.cur();
-                if (tmp.charAt(0) == '-')
-                    events.sort.set(tmp.slice(1));
-                else
-                    events.sort.set('-' + tmp);
-            }
-        },
-
-        //Searching
-        search: {
-            cur: function() {
-                return tools.mem.session.get('search');
-            },
-            set: function(dom, val) {
-                tools.mem.session.set('search', dom + '==' + val);
-                events.page.set(1);
-            },
-            clr: function() {
-                tools.mem.session.set('search', '');
-                events.page.set(1);
-            },
-        },
-
-        get: function() {
-            $('#wheel-logo').css('transform', 'rotate(360deg)');
-            console.log('getting events...');
-            amivcore.events.GET({
-                data: {
-                    'max_results': '50',
-                    page: events.page.cur(),
-                    sort: events.sort.cur(),
-                    where: events.search.cur(),
-                }
-            }, function(ret) {
-                console.log(ret);
-                if (ret === undefined || ret['_items'].length == 0) {
-                    tools.log('No Data', 'w');
-                    // Clear table from previous contentent
-                    $('.events-table tbody').html('');
-                    return;
-                }
-                events.meta = ret['_meta'];
-                events.page.max = Math.ceil(events.meta.total / events.meta.max_results);
-                $('.events-page-max-cont').html(events.page.max);
-
-                // Clear table from previous contentent
-                $('.events-table tbody').html('');
-
-                for (var n in ret['_items']) {
-                    var tmp = '';
-                    events.showInTable.forEach(function(i) {
-                        tmp += '<td>' + ret['_items'][n][i] + '</td>';
-                    });
-                    $('.events-table tbody').append('<tr data-id="' + ret['_items'][n]['_id'] + '">' + tmp + '</tr>');
-                }
-                $('.events-table tbody tr').click(events.showDetails);
-                $('#wheel-logo').css('transform', 'rotate(0deg)');
-            });
-
-        },
-
-        createEvent: function() {
-            
-            $("#event-modal-title").text("Create Event");
-            $('#event-modal-footer').html('<button type="button" class="btn btn-default" data-dismiss="modal">Close</button><button type="button" class="btn btn-primary" onclick="events.submitEvent(true)">Submit</button>');
-            $('#event-modal').modal('show');
-        },
-
-        //show details of an event in a modal
-        //TODO: fill the more beautiful event-modal
-        showDetails: function() {
-            somethingChanged = false;
-            console.log($(this).attr('data-id'));
-            amivcore.events.GET({
-                id: $(this).attr('data-id')
-            }, function(ret) {
-                curEventData = ret;
-                console.log(curEventData);
-                etag = ret['_etag'];
-                $("#event-modal-title").text("Edit Event");
-                $('#event-modal-footer').html('<button type="button" class="btn btn-default" data-dismiss="modal">Close</button><button type="button" class="btn btn-primary" onclick="events.submitEvent(false)">update</button><button type="button" class="btn btn-danger" onclick="events.deleteEvent()">Delete</button>');
-
-                imageData = ['img_infoscreen', 'img_thumbnail', 'img_poster', 'img_banner'];
-
-                for (i = 0; i < imageData.length; i++){
-                    if (ret[imageData[i]]){
-                        console.log(events.API_url + ret[imageData[i]]['file']);
-                        $('#actual_' + imageData[i]).attr('src', events.API_url + ret[imageData[i]]['file']);
-                    }
-                }
-
-                //fill fields of the form with content that has the same ID
-                $('#event-modal-form').find('input, textarea').val(function (index, value) {
-                    if (this.type != 'file')
-                        return ret[this.id];
-                });
-
-                //array of elements that are represented by checkboxes
-                var booleanEventData = ['no-signup-limit', 'allow_email_signup', 'show_website', 'show_infoscreen', 'show_announce'];
-
-                var dateEventData = ['time_start', 'time_end', 'time_register_start', 'time_register_end', 'time_advertising_start', 'time_advertising_end'];
-
-                //set the datepickers
-                for (i = 0; i < dateEventData.length; i++){
-                    if (ret[dateEventData[i]] != null){
-                        $('#' + dateEventData[i]).data("DateTimePicker").date(new Date(ret[dateEventData[i]]));
-                    }
-                }
-
-                for (i = 0; i < booleanEventData.length; i++){
-                    $("#" + booleanEventData[i]).prop('checked', ret[booleanEventData[i]]);
-                }
-
-                //radios
-                if (ret['selection_strategy'] == "fcfs")
-                    $('#selection-strategy-radio1').prop('checked', true);
-                else if (ret['selection_strategy'] == "manual")
-                    $('#selection-strategy-radio2').prop('checked', true);
-
-                //edge cases (signup required is inverted)
-                if (ret['spots'] == 0)
-                    $('#signup-required').prop('checked', true);
-
-                //add additional (immutable) data to the modal
-                additionalInfo = {
-                    'created': '_created',
-                    'updated': '_updated',
-                    'number of signps': 'signup_count'
-                }
-
-                tempString = '<p>';
-
-                for (field in additionalInfo){
-                    tempString += "<br><b>" + field + ":</b> " + curEventData[additionalInfo[field]];
-                }
-                tempString += '</p>';
-
-                $('#additional_info').html(tempString);
-
-                $('#event-modal').modal('show');
-
-                
-            });
-        },
-
-
-        deleteEvent: function() {
-            console.log(curEventData._etag);
-            if (confirm("Delete " + curEventData.title_de + "?")) {
-                amivcore.events.DELETE({
-                    id: curEventData._id,
-                    header: {
-                        // 'If-Match': $('#event-modal').attr('data-etag')
-                        'If-Match': curEventData._etag
-                    }
-                }, function(response) {
-                    console.log(response);
-                });
-                events.get();
-                tools.log('Event deleted', 'w');
-                tools.modalClose();
-            } else {
-                tools.log('Event not Deleted', 'i');
-            }
-        },
-
-
-        showSignups: function(curEventData) {
-            var tmp = '<table class="table table-hover events-edit-table" data-etag="' + curEventData['_etag'] + '"><tbody>';
-            for (var user in curEventData['signups']) {
-                tmp += '<tr><td>' + user + '</td><td contenteditable>' + curEventData['signups'][cur] + '</td></tr>';
-            }
-            tmp += '</tbody></table>';
-            tools.modal({
-                head: curEventData.title_de,
-                body: tmp,
-                button: {
-                    'Update': {
-                        type: 'success',
-                        close: false
-                        //callback
-                    }
-                }
-            });
-        },
-
-        submitEvent: function(isNew) {
-            console.log("submitting new event");
-            var newEvent = {
-                data: {}
-            };
-            if ($("#title_de") !== "")
-                newEvent["data"]["title_de"] = $("#title_de").val();
-            if ($("#description_de") !== "")
-                newEvent["data"]["description_de"] = $("#description_de").val();
-            if ($("#catchphrase_de") !== "")
-                newEvent["data"]["catchphrase_de"] = $("#catchphrase_de").val();
-
-            if (!($("#time_start").data("DateTimePicker").date() == null)) {
-                newEvent["data"]["time_start"] = $("#time_start").data("DateTimePicker").date().toISOString().split('.')[0]+"Z";
-            }
-            if (!($("#time_end").data("DateTimePicker").date() == null)) {
-                newEvent["data"]["time_end"] = $("#time_end").data("DateTimePicker").date().toISOString().split('.')[0]+"Z";
-            }
-
-
-            if (!($("#time_advertising_start").data("DateTimePicker").date() == null)) {
-                newEvent["data"]["time_advertising_start"] = $("#time_advertising_start").data("DateTimePicker").date().toISOString().split('.')[0]+"Z";
-            }
-            if (!($("#time_advertising_end").data("DateTimePicker").date() == null)) {
-                newEvent["data"]["time_advertising_end"] = $("#time_advertising_end").data("DateTimePicker").date().toISOString().split('.')[0]+"Z";
-            }
-
-
-
-            if (!$("#signup-required").is(":checked")) {
-                if ($("#no-signup-limit").is(":checked")) {
-                    newEvent["data"]["spots"] = 0;
-                } else {
-                    if ($("#spots").val() === "") {
-                        tools.log("Please specify a number of Spots", "e");
-                        return;
-                    }
-                    newEvent["data"]["spots"] = parseInt($("#spots").val());
-
-                }
-                if (!($("#time_register_start").data("DateTimePicker").date() == null)) {
-                    newEvent["data"]["time_register_start"] = $("#time_register_start").data("DateTimePicker").date();
-                } else {
-                    tools.log('field "Start of Registration" required', 'e');
-                    return;
-                }
-                if (!($("#time_register_end").data("DateTimePicker").date() == null)) {
-                    newEvent["data"]["time_register_end"] = $("#time_register_end").data("DateTimePicker").date();
-                } else {
-                    tools.log('field "End of Registration" required', 'e');
-                    return;
-                }
-                newEvent["data"]["allow_email_signup"] = $("#allow_email_signup").is(':checked');
-            } else {
-            }
-
-            if ($("#location").val() !== "")
-                newEvent["data"]["location"] = $("#location").val();
-
-            if (!($("#price").val() === ""))
-                newEvent["data"]["price"] = Math.floor((parseFloat($("#price").val()) * 100));
-
-            newEvent["data"]["show_website"] = $("#show_website").is(':checked');
-            newEvent["data"]["show_infoscreen"] = $("#show_infoscreen").is(':checked');
-            newEvent["data"]["show_announce"] = $("#show_announce").is(':checked');
-            newEvent["data"]["priority"] = parseInt($("#priority").val());
-            if ($("#additional_fields").val() !== "")
-                newEvent["data"]["additional_fields"] = $("#additional_fields").val();
-
-            if ($('#selection-strategy-radio1').is(":checked"))
-                newEvent['data']['selection_strategy'] = "fcfs";
-            else if($('#selection-strategy-radio2').is(":checked"))
-                newEvent['data']['selection_strategy'] = "manual";
-
-            if ($("#title_en").val !== "")
-                newEvent["data"]["title_en"] = $("#title_en").val();
-            if ($("#description_en").val !== "")
-                newEvent["data"]["description_en"] = $("#description_en").val();
-            if ($("#catchphrase_en").val !== "")
-                newEvent["data"]["catchphrase_en"] = $("#catchphrase_en").val();
-
-            var imageData = ['img_infoscreen', 'img_thumbnail', 'img_poster', 'img_banner'];
-            for (i = 0; i < imageData.length; i++){
-                if ($('#' + imageData[i])[0].files[0] != undefined)
-                    newEvent["data"][imageData[i]] = $('#' + imageData[i])[0].files[0];
-            }
-            console.log(newEvent);
-
-            console.log(JSON.stringify(newEvent));
-            if(isNew) {
-                var response = amivcore.events.POST(newEvent, function(ret) {
-                    if (!ret.hasOwnProperty('_status') || ret['_status'] != 'OK')
-                        tools.log(JSON.stringify(ret.responseJSON['_issues']), 'e');
-                    else {
-                        console.log(ret);
-                        curEventData = ret;
-                        tools.log('Event Added', 's');
-                        $('#event-modal').modal('hide');
-                        $("#event-modal-form").trigger('reset');
-                        events.get();
-                    }
-                });
-            } 
-            else {
-                newEvent['header'] = {};
-                newEvent['header']['If-Match'] = curEventData._etag;
-                newEvent['id'] = curEventData._id;
-                console.log(newEvent);
-                var response = amivcore.events.PATCH(newEvent, function(ret) {
-                    if (!ret.hasOwnProperty('_status') || ret['_status'] != 'OK')
-                        tools.log(JSON.stringify(ret.responseJSON['_issues']), 'e');
-                    else {
-                        console.log(ret);
-                        curEventData = ret;
-                        tools.log('Event Added', 's');
-                        $('#event-modal').modal('hide');
-                        $("#event-modal-form").trigger('reset');
-                        events.get();
-                    }
-                });
-            }
-        }
-    }
-
-
-//setting up the date time picker
-$(function() {
-    $('#time_start').datetimepicker({
-        locale: "de",
-        sideBySide: true
-    });
-
-    $('#time_end').datetimepicker({
-        locale: "de",
-        useCurrent: false, //Important! See issue #1075aa
-        sideBySide: true
-    });
-
-    $('#time_advertising_start').datetimepicker({
-        locale: "de",
-        sideBySide: true
-    });
-
-    $('#time_advertising_end').datetimepicker({
-        locale: "de",
-        useCurrent: false, //Important! See issue #1075aa
-        sideBySide: true
-    });
-
-    $('#time_register_start').datetimepicker({
-        locale: "de",
-        sideBySide: true
-    });
-    $('#time_register_end').datetimepicker({
-        locale: "de",
-        useCurrent: false, //Important! See issue #107534
-        sideBySide: true
-    });
-    $("#time_register_start").on("dp.change", function(e) {
-        $('#time_register_end').data("DateTimePicker").minDate(e.date);
-    });
-    $("#time_register_end").on("dp.change", function(e) {
-        $('#time_register_start').data("DateTimePicker").maxDate(e.date);
-    });
-    $("#time_advertising_start").on("dp.change", function(e) {
-        $('#time_advertising_end').data("DateTimePicker").minDate(e.date);
-    });
-    $("#time_advertising_end").on("dp.change", function(e) {
-        $('#time_advertising_start').data("DateTimePicker").maxDate(e.date);
-    });
-    $("#time_start").on("dp.change", function(e) {
-        $('#time_end').data("DateTimePicker").minDate(e.date);
-    });
-    $("#time_end").on("dp.change", function(e) {
-        $('#time_start').data("DateTimePicker").maxDate(e.date);
-    });
-});
-
-$('#signup-required').click(function() {
-    $('#no-signup-limit').attr('disabled', this.checked);
-    $('#spots').attr('disabled', this.checked);
-    $('#time_register_end>input').attr('disabled', this.checked);
-    $('#time_register_start>input').attr('disabled', this.checked);
-});
-
-$('#no-signup-limit').click(function() {
-    $('#spots').attr('disabled', this.checked);
-});
-
-$('#event-modal').on('hidden.bs.modal', function () {
-    // do something…
-    $('#event-modal img').attr('src', '');
-    $("#event-modal-form").trigger('reset');
-})
-
-// tools in the top bar
-tools.ui.menu({
-    '<span class="glyphicon glyphicon-plus"  data-toggle="tooltip" aria-hidden="true" title="Create new Event" data-placement="bottom"></span>': {
-        callback: events.createEvent
-    },
-    '<span class="glyphicon glyphicon-refresh" aria-hidden="true"  data-toggle="tooltip" title="Refresh" data-placement="bottom"></span>': {
-        callback: events.get
-    },
-    '<span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span>': {
-        callback: events.page.dec
-    },
-    '<span class="events-cur-page-cont" aria-hidden="true"></span> / <span class="events-page-max-cont" aria-hidden="true"></span>': {
-        callback: function() {
-            tools.modal({
-                head: 'Go To Page:',
-                body: '<div class="form-group"><input type="number" value="' + events.page.cur() + '" class="form-control events-go-page"></div>',
-                button: {
-                    'Go': {
-                        type: 'success',
-                        close: true,
-                        callback: function() {
-                            events.page.set($('.events-go-page').val());
-                        },
-                    }
-                }
-            });
-        }
-    },
-    '<span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>': {
-        callback: events.page.inc
-    },
-    '<span class="glyphicon glyphicon-sort" aria-hidden="true" data-toggle="tooltip" title="Sort" data-placement="bottom"></span>': {
-        callback: function() {
-            var tmp = '<div class="form-group"><select class="form-control events-sort-select">';
-            var cur = events.sort.cur();
-            ['_id', 'title_de', 'description_de', 'time_start', 'time_register_start', 'time_end', 'time_register_end', 'show_website', 'show_announce', 'show_infoscreen', 'price', '_updated', 'location'].forEach(function(i) {
-                tmp += '<option value="' + i + '"' + ((i == cur) ? ' selected' : '') + '>&#8673; ' + i + '</option>';
-                tmp += '<option value="-' + i + '"' + (('-' + i == cur) ? ' selected' : '') + '>&#8675; ' + i + '</option>';
-            });
-            tmp += '</select></div>';
-            tools.modal({
-                head: 'Sort',
-                body: tmp,
-                button: {
-                    'Sort': {
-                        type: 'success',
-                        close: true,
-                        callback: function() {
-                            events.sort.set($('.events-sort-select').val());
-                        }
-                    }
-                }
-
-            });
-        }
-    },
-    '<span class="glyphicon glyphicon-search" aria-hidden="true" data-toggle="tooltip" title="Search" data-placement="bottom"></span>': {
-        callback: function() {
-            var tmp = '<div class="form-group"><select class="form-control events-search-select">';
-            var cur = events.search.cur();
-            if (cur === null || cur == '')
-                cur = '';
-            else
-                cur = cur.split('==')[1];
-            ['_id', 'title_de', 'description_de', 'title_en', 'description_en', 'time_start', 'time_register_start', 'time_end', 'time_register_end', 'show_website', 'show_announce', 'show_infoscreen', 'price', '_updated', 'location']
-                .forEach(
-                    function(i) {
-                        tmp += '<option value="' + i + '"' + ((i == cur) ? ' selected' : '') + '>' + i + '</option>';
-                    });
-            tmp += '</select><br><input type="text" value="' + cur + '" class="form-control events-search-val"></div>';
-            tools.modal({
-                head: 'Search',
-                body: tmp,
-                button: {
-                    'Clear': {
-                        type: 'warning',
-                        close: true,
-                        callback: events.search.clr,
-                    },
-                    'Search': {
-                        type: 'success',
-                        close: true,
-                        callback: function() {
-                            events.search.set($('.events-search-select').val(), $('.events-search-val').val());
-                        }
-                    },
-                }
-            })
-        }
-    }
-});
-
-if (events.page.cur() === null || isNaN(events.page.cur()))
-    events.page.set(1);
-else
-    events.page.set(events.page.cur());
-
-$(document).ready(function() {
-    $('[data-toggle="tooltip"]').tooltip();
-    $('#event-modal-form').on('keyup change', 'input, select, textarea, span ', function(){
-        console.log('changed shit');
-        events.somethingChanged = true;
-    });
-});
-
-function setNullIfEmpty(formData) {
-    if (formData === "") {
-        return null;
-    }
-    return formData;
-}
-</script>
diff --git a/tools/groups.tool b/tools/groups.tool
deleted file mode 100644
index 66cafef..0000000
--- a/tools/groups.tool
+++ /dev/null
@@ -1,355 +0,0 @@
-<div>
-    <table class="table table-hover groups-table">
-        <thead>
-            <tr>
-            </tr>
-        </thead>
-        <tbody>
-        </tbody>
-    </table>
-</div>
-
-<script type="text/javascript">
-    var groups = {
-        showInTable: ['name'],
-        curUserData: null,
-
-        // Page
-        page: {
-            max: Number.MAX_VALUE,
-            cur: function() {
-                return parseInt(tools.mem.session.get('curPage'));
-            },
-            set: function(num) {
-                num = parseInt(num);
-                if (num > 0 && num < groups.page.max + 1)
-                    tools.mem.session.set('curPage', num);
-                $('.groups-cur-page-cont').html(groups.page.cur());
-                groups.get();
-            },
-            inc: function() {
-                groups.page.set(groups.page.cur() + 1);
-            },
-            dec: function() {
-                groups.page.set(groups.page.cur() - 1);
-            }
-        },
-
-        //Sorting
-        sort: {
-            cur: function() {
-                return tools.mem.session.get('curSort');
-            },
-            set: function(sort) {
-                tools.mem.session.set('curSort', sort);
-                groups.get();
-            },
-            inv: function() {
-                var tmp = groups.sort.cur();
-                if (tmp.charAt(0) == '-')
-                    groups.sort.set(tmp.slice(1));
-                else
-                    groups.sort.set('-' + tmp);
-            }
-        },
-
-        //Searching
-        search: {
-            cur: function() {
-                return tools.mem.session.get('search');
-            },
-            set: function(dom, val) {
-                tools.mem.session.set('search', dom + '==' + val);
-                groups.page.set(1);
-            },
-            clr: function() {
-                tools.mem.session.set('search', '');
-                groups.page.set(1);
-            },
-        },
-
-        // Get groups
-        get: function() {
-            amivcore.groups.GET({
-                data: {
-                    'max_results': '50',
-                    page: groups.page.cur(),
-                    sort: groups.sort.cur(),
-                    where: groups.search.cur(),
-                }
-            }, function(ret) {
-                console.log(ret);
-                if (ret === undefined || ret['_items'].length == 0) {
-                    tools.log('No Data', 'w');
-                    return;
-                }
-
-                groups.meta = ret['_meta'];
-                groups.page.max = Math.ceil(groups.meta.total / groups.meta.max_results);
-                $('.groups-page-max-cont').html(groups.page.max);
-
-                // Clear table from previous contentent
-                $('.groups-table thead tr, .groups-table tbody').html('');
-
-                groups.showInTable.forEach(function(i) {
-                    $('.groups-table thead tr').append('<th>' + i + '</th>');
-                });
-
-                for (var n in ret['_items']) {
-                    var tmp = '';
-                    groups.showInTable.forEach(function(i) {
-                        tmp += '<td>' + ret['_items'][n][i] + '</td>';
-                    });
-                    $('.groups-table tbody').append('<tr data-id="' + ret['_items'][n]['_id'] + '">' + tmp + '</tr>');
-                }
-                $('.groups-table tbody tr').click(groups.showDetails);
-            });
-        },
-
-        // Make Modal with editable table data
-        showDetails: function() {
-            amivcore.groups.GET({
-                id: $(this).attr('data-id')
-            }, function(ret) {
-                console.log(ret);
-                curUserData = ret;
-
-                var tmp = '<div class="groups-edit-cont" data-etag="' + ret['_etag'] + '" data-id="' + ret['_id'] + '">';
-                for (var cur in ret)
-                    if (cur.charAt(0) != '_')
-                        if (cur == 'user_subscribers') {
-                            tmp += '<p><strong>Subscribed: <kbd>' + ret[cur].length + '</kbd> <kbd class="groups-show-users"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></kbd></strong></p>';
-                        } else {
-                            switch (amivcore.getParamType('groups', cur)) {
-                                case 'boolean':
-                                    tmp += '<div class="checkbox"><label><input type="checkbox" value="' + ret[cur] + '" name="' + cur + '">' + cur + '</label></div>';
-                                    break;
-
-                                case 'integer':
-                                    tmp += '<div class="form-group"><label>' + cur + ':</label><input type="number" value="' + ret[cur] + '" class="form-control" name="' + cur + '" min="0" step="1"></div>';
-                                    break;
-
-                                default:
-                                    tmp += '<div class="form-group"><label>' + cur + ':</label><input type="text" value="' + ret[cur] + '" class="form-control" name="' + cur + '"></div>';
-                                    break;
-                            }
-                        }
-                tmp += '</div>';
-
-                tools.modal({
-                    head: ret.firstname + ' ' + ret.lastname,
-                    body: tmp,
-                    button: {
-                        'Delete': {
-                            type: 'danger',
-                            callback: function() {
-                                if (confirm('Fo\' shizzle my nizzle? U fo\' real?'))
-                                    amivcore.groups.DELETE({
-                                        id: $('.groups-edit-cont').first().attr('data-id'),
-                                        header: {
-                                            'If-Match': $('.groups-edit-cont').attr('data-etag')
-                                        },
-                                    }, function(ret) {
-                                        if (ret === undefined) {
-                                            tools.log('Group successfully deleted', 's');
-                                            groups.get();
-                                            tools.modalClose();
-                                        } else {
-                                            tools.log('Error', 'e');
-                                        }
-                                    });
-                            }
-                        },
-                        'Update': {
-                            type: 'success',
-                            close: true,
-                            callback: groups.inspect,
-                        },
-                    }
-                });
-
-            });
-
-            $('.groups-show-users').off('click').on('click', function() {
-                console.log($('groups-edit-cont').first().attr('data-id'));
-            });
-        },
-
-        // Check wether changes were maid and saves it in that case
-        inspect: function() {
-            var newUserData = {};
-            $('.groups-edit-cont tr').each(function() {
-                newUserData[$(this).children('td:nth-child(1)').html()] = $(this).children('td:nth-child(2)').html();
-            });
-            var changed = false,
-                curUserDataChanged = {};
-            for (var i in newUserData) {
-                if (newUserData[i] != String(curUserData[i])) {
-                    changed = true;
-                    curUserDataChanged[i] = newUserData[i];
-                }
-            }
-            if (changed) {
-                amivcore.groups.PATCH({
-                    id: curUserData._id,
-                    header: {
-                        'If-Match': $('.groups-edit-cont').attr('data-etag')
-                    },
-                    data: curUserDataChanged
-                }, function() {
-                    tools.log('User Updated', 's');
-                    groups.get();
-                });
-            }
-        },
-
-        //Make new user
-        add: function() {
-            var tmp = '<div class="row groups-user-add-form">' +
-                '<div class="form-group"><label for="groups-name">Name:</label><input type="text" class="form-control" name="name" id="groups-name"></div>' +
-                '<div class="form-group"><label for="groups-moderator">Group Admin:</label><input type="text" class="form-control" id="groups-moderator" name="moderator_id"></div>' +
-                '<label class="checkbox-inline"><input type="checkbox" name="has_zoidberg_share">Has Zoidberg share</label>' +
-                '<label class="checkbox-inline pull-right"><input type="checkbox" name="allow_self_enrollment">Self-Enrollment</label>' +
-                '</div>';
-            tools.modal({
-                head: 'Create Group',
-                body: tmp,
-                button: {
-                    'Add': {
-                        type: 'success',
-                        callback: function() {
-                            var modName = $('#groups-moderator').val().trim().split(' ');
-                            if (modName.length != 2) {
-                                tools.log('Wrong input for Moderator', 'w');
-                                return;
-                            }
-                            amivcore.users.GET({
-                                data: {
-                                    where: 'firstname==' + modName[0] + ';lastname==' + modName[1]
-                                }
-                            }, function(ret) {
-                                if (ret['_items'].length !== 1) {
-                                    tools.log('Moderator not found', 'w');
-                                    return;
-                                }
-                                var newUserData = {};
-                                $('.groups-user-add-form input').each(function() {
-                                    newUserData[$(this).attr('name')] = $(this).val();
-                                });
-                                newUserData['moderator_id'] = ret['_items'][0]['_id'];
-                                console.log(newUserData);
-                                amivcore.groups.POST({
-                                    data: newUserData
-                                }, function(ret) {
-                                    if (!ret.hasOwnProperty('_status') || ret['_status'] != 'OK')
-                                        tools.log(JSON.stringify(ret.responseJSON['_issues']), 'e');
-                                    else {
-                                        tools.modalClose();
-                                        tools.log('Group Created', 's');
-                                        groups.get();
-                                    }
-                                });
-                            });
-                        }
-                    }
-                }
-            });
-        }
-    };
-
-    // Setup Menu
-    tools.ui.menu({
-        '<span class="glyphicon glyphicon-plus" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="New Group"></span>': {
-            callback: groups.add
-        },
-        '<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Previous Page"></span>': {
-            callback: groups.page.dec
-        },
-        '<span data-toggle="tooltip" data-placement="bottom" title="Set Page"><span class="groups-cur-page-cont" aria-hidden="true"></span> / <span class="groups-page-max-cont" aria-hidden="true"></span></span>': {
-            callback: function() {
-                tools.modal({
-                    head: 'Go To Page:',
-                    body: '<div class="form-group"><input type="number" value="' + groups.page.cur() + '" class="form-control groups-go-page"></div>',
-                    button: {
-                        'Go': {
-                            type: 'success',
-                            close: true,
-                            callback: function() {
-                                groups.page.set($('.groups-go-page').val());
-                            },
-                        }
-                    }
-                });
-            }
-        },
-        '<span class="glyphicon glyphicon-arrow-right" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Next Page"></span>': {
-            callback: groups.page.inc
-        },
-        '<span class="glyphicon glyphicon-sort" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Sort"></span>': {
-            callback: function() {
-                var tmp = '<div class="form-group"><select class="form-control groups-sort-select">';
-                var cur = groups.sort.cur();
-                ['name'].forEach(function(i) {
-                    tmp += '<option value="' + i + '"' + ((i == cur) ? ' selected' : '') + '>&#8673; ' + i + '</option>';
-                    tmp += '<option value="-' + i + '"' + (('-' + i == cur) ? ' selected' : '') + '>&#8675; ' + i + '</option>';
-                });
-                tmp += '</select></div>';
-                tools.modal({
-                    head: 'Sort',
-                    body: tmp,
-                    button: {
-                        'Sort': {
-                            type: 'success',
-                            close: true,
-                            callback: function() {
-                                groups.sort.set($('.groups-sort-select').val());
-                            }
-                        }
-                    }
-
-                });
-            }
-        },
-        '<span class="glyphicon glyphicon-search" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Search"></span>': {
-            callback: function() {
-                var tmp = '<div class="form-group"><select class="form-control groups-search-select">';
-                var cur = groups.search.cur();
-                if (cur === null || cur == '')
-                    cur = '';
-                else
-                    cur = cur.split('==')[1];
-                ['name'].forEach(function(i) {
-                    tmp += '<option value="' + i + '"' + ((i == cur) ? ' selected' : '') + '>' + i + '</option>';
-                });
-                tmp += '</select><br><input type="text" value="' + cur + '" class="form-control groups-search-val"></div>';
-                tools.modal({
-                    head: 'Search',
-                    body: tmp,
-                    button: {
-                        'Clear': {
-                            type: 'warning',
-                            close: true,
-                            callback: groups.search.clr,
-                        },
-                        'Search': {
-                            type: 'success',
-                            close: true,
-                            callback: function() {
-                                groups.search.set($('.groups-search-select').val(), $('.groups-search-val').val());
-                            }
-                        },
-                    }
-                })
-            }
-        }
-    });
-
-    //Set Toolpit
-    $('[data-toggle="tooltip"]').tooltip()
-
-    // Set Initail Page and get first groups
-    if (groups.page.cur() === null || isNaN(groups.page.cur()))
-        groups.page.set(1);
-    else
-        groups.page.set(groups.page.cur());
-</script>
diff --git a/tools/home.tool b/tools/home.tool
deleted file mode 100644
index d8630a0..0000000
--- a/tools/home.tool
+++ /dev/null
@@ -1,26 +0,0 @@
-<style>
-	.home-bg {
-		background: url('res/bg/cab-2880.jpg') center / cover;
-		width: 100%;
-		height: 100%;
-		text-align: center;
-		display: flex;
-		align-items: center;
-		justify-content: center;
-	}
-	.home-bg span {
-		font-weight: bold;
-		color: rgb(232, 70, 43);
-		background-color: rgb(31, 45, 84);
-	}
-</style>
-<div class="home-bg">
-	<div>
-		<h1>
-			<span>Ich schwöre feierlich, dass ich ein Tunichtgut bin. - AMIV Admintool</span>
-		</h1>
-		<a href="http://www.amiv.ethz.ch/" target="_blank">
-			<img src="res/logo/main.svg" height="64px" copyright="2013 Wegmann">
-		</a>
-	</div>
-</div>
diff --git a/tools/studydocuments.tool b/tools/studydocuments.tool
deleted file mode 100644
index e8601f6..0000000
--- a/tools/studydocuments.tool
+++ /dev/null
@@ -1,326 +0,0 @@
-<div class="studydocuments-table-wrapper">
-	<table class="table table-hover studydocuments-table">
-		<thead>
-			<tr>
-			</tr>
-		</thead>
-		<tbody>
-		</tbody>
-	</table>
-</div>
-<script type="text/javascript">
-	var studydocuments = {
-		showInTable: ['_id', '_updated', '_created', 'author'],
-		curStudydocumentsData: null,
-
-		// Page
-		page: {
-			max: Number.MAX_VALUE,
-			cur: function() {
-				return parseInt(tools.mem.session.get('curPage'));
-			},
-			set: function(num) {
-				num = parseInt(num);
-				if (num > 0 && num < studydocuments.page.max + 1)
-					tools.mem.session.set('curPage', num);
-				$('.studydocuments-cur-page-cont').html(studydocuments.page.cur());
-				studydocuments.get();
-			},
-			inc: function() {
-				studydocuments.page.set(studydocuments.page.cur() + 1);
-			},
-			dec: function() {
-				studydocuments.page.set(studydocuments.page.cur() - 1);
-			}
-		},
-
-		//Sorting
-		sort: {
-			cur: function() {
-				return tools.mem.session.get('curSort');
-			},
-			set: function(sort) {
-				tools.mem.session.set('curSort', sort);
-				studydocuments.get();
-			},
-			inv: function() {
-				var tmp = studydocuments.sort.cur();
-				if (tmp.charAt(0) == '-')
-					studydocuments.sort.set(tmp.slice(1));
-				else
-					studydocuments.sort.set('-' + tmp);
-			}
-		},
-
-		//Searching
-		search: {
-			cur: function() {
-				return tools.mem.session.get('search');
-			},
-			set: function(dom, val) {
-				tools.mem.session.set('search', dom + '==' + val);
-				studydocuments.page.set(1);
-			},
-			clr: function() {
-				tools.mem.session.set('search', '');
-				studydocuments.page.set(1);
-			},
-		},
-
-		// Get studydocuments
-		get: function() {
-			amivcore.studydocuments.GET({
-				data: {
-					'max_results': '50',
-					page: studydocuments.page.cur(),
-					sort: studydocuments.sort.cur(),
-					where: studydocuments.search.cur(),
-				}
-			}, function(ret) {
-
-				if (ret === undefined || ret['_items'].length == 0) {
-					tools.log('No Data', 'w');
-					return;
-				}
-
-				studydocuments.meta = ret['_meta'];
-				studydocuments.page.max = Math.ceil(studydocuments.meta.total / studydocuments.meta.max_results);
-				$('.studydocuments-page-max-cont').html(studydocuments.page.max);
-
-				// Clear table from previous contentent
-				$('.studydocuments-table thead tr, .studydocuments-table tbody').html('');
-
-				studydocuments.showInTable.forEach(function(i) {
-					$('.studydocuments-table thead tr').append('<th>' + i + '</th>');
-				});
-
-				for (var n in ret['_items']) {
-					var tmp = '';
-					studydocuments.showInTable.forEach(function(i) {
-						tmp += '<td>' + ret['_items'][n][i] + '</td>';
-					});
-					$('.studydocuments-table tbody').append('<tr data-id="' + ret['_items'][n]['_id'] + '">' + tmp + '</tr>');
-				}
-				$('.studydocuments-table tbody tr').click(studydocuments.showDetails);
-			});
-		},
-
-		// Make Modal with editable table data
-		showDetails: function() {
-			amivcore.studydocuments.GET({
-				id: $(this).attr('data-id')
-			}, function(ret) {
-				curStudydocumentsData = ret;
-				var tmp = '<table class="table table-hover studydocuments-studydocuments-edit-table" data-etag="' + ret['_etag'] + '" data-id="' + ret._id + '"><tbody>';
-				for (var cur in ret)
-					if (cur.charAt(0) != '_'){
-						if (cur == 'files'){
-							tmp += '<tr><td>' + cur + '</td><td contenteditable>';
-							for (var fileIdx in ret[cur]){
-								var file = ret[cur][fileIdx];
-								console.log(file)
-								tmp += file.name;
-							}
-							tmp += '</td></tr>';
-						}else{
-							tmp += '<tr><td>' + cur + '</td><td contenteditable>' + ret[cur] + '</td></tr>';
-						}
-					}
-				tmp += '</tbody></table>';
-
-				tools.modal({
-					head: ret.firstname + ' ' + ret.lastname,
-					body: tmp,
-					button: {
-						'Delete': {
-							type: 'danger',
-							callback: function() {
-								if (confirm('Fo\' shizzle my nizzle? U fo\' real?'))
-									amivcore.studydocuments.DELETE({
-										id: $('.studydocuments-studydocuments-edit-table').first().attr('data-id'),
-										header: {
-											'If-Match': $('.studydocuments-studydocuments-edit-table').attr('data-etag')
-										},
-									}, function(ret) {
-										if (ret === undefined) {
-											tools.log('Studydocuments successfully deleted', 's');
-											studydocuments.get();
-											tools.modalClose();
-										} else {
-											tools.log('Error', 'e');
-										}
-									});
-							}
-						},
-						'Update': {
-							type: 'success',
-							close: true,
-							callback: studydocuments.inspectStudydocuments,
-						}
-					}
-				});
-
-			});
-		},
-
-		// Check wether changes were maid and saves it in that case
-		inspectStudydocuments: function() {
-			var newStudydocumentsData = {};
-			$('.studydocuments-studydocuments-edit-table tr').each(function() {
-				newStudydocumentsData[$(this).children('td:nth-child(1)').html()] = $(this).children('td:nth-child(2)').html();
-			});
-			var changed = false,
-				curStudydocumentsDataChanged = {};
-			for (var i in newStudydocumentsData) {
-				if (newStudydocumentsData[i] != String(curStudydocumentsData[i])) {
-					changed = true;
-					curStudydocumentsDataChanged[i] = newStudydocumentsData[i];
-				}
-			}
-			if (changed) {
-				amivcore.studydocuments.PATCH({
-					id: curStudydocumentsData._id,
-					header: {
-						'If-Match': $('.studydocuments-studydocuments-edit-table').attr('data-etag')
-					},
-					data: curStudydocumentsDataChanged
-				}, function() {
-					tools.log('Studydocuments Updated', 's');
-					studydocuments.get();
-				});
-			}
-		},
-
-		//Make new studydocuments
-		add: function() {
-			var tmp = '<div class="row studydocuments-studydocuments-add-form"><div class="form-group col-xs-6"><label for="studydocuments-fn">Firstname:</label><input type="text" class="form-control" name="firstname" id="studydocuments-fn"></div>' +
-				'<div class="form-group col-xs-6"><label for="studydocuments-ln">Lastname:</label><input type="text" class="form-control" id="studydocuments-ln" name="lastname"></div>' +
-				'<div class="form-group"><label for="studydocuments-email">E-Mail:</label><input type="email" class="form-control" id="studydocuments-email" name="email"></div>' +
-				'<div class="form-group col-xs-6"><label for="studydocuments-membership">Membership:</label><select class="form-control" id="studydocuments-membership" name="membership"><option>regular</option><option>honorary</option><option>extraordinary</option></select></div>' +
-				'<div class="form-group col-xs-6"><label for="studydocuments-gender">Gender:</label><select class="form-control" id="studydocuments-gender" name="gender"><option>male</option><option>female</option></select></div>' +
-				'</div>';
-			tools.modal({
-				head: 'Spawn new AMIV slave',
-				body: tmp,
-				button: {
-					'Add': {
-						type: 'success',
-						callback: function() {
-							var newStudydocumentsData = {};
-							$('.studydocuments-studydocuments-add-form input, .studydocuments-studydocuments-add-form select').each(function() {
-								newStudydocumentsData[$(this).attr('name')] = $(this).val();
-							});
-							amivcore.studydocuments.POST({
-								data: newStudydocumentsData
-							}, function(ret) {
-								if (!ret.hasOwnProperty('_status') || ret['_status'] != 'OK')
-									tools.log(JSON.stringify(ret.responseJSON['_issues']), 'e');
-								else {
-									tools.modalClose();
-									tools.log('Studydocuments Added', 's');
-									studydocuments.get();
-								}
-							});
-						}
-					}
-				}
-			});
-		}
-	};
-
-	// Setup Menu
-	tools.ui.menu({
-		'<span class="glyphicon glyphicon-plus" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Create Studydocuments"></span>': {
-			callback: studydocuments.add
-		},
-		'<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Previous Page"></span>': {
-			callback: studydocuments.page.dec
-		},
-		'<span data-toggle="tooltip" data-placement="bottom" title="Set Page"><span class="studydocuments-cur-page-cont" aria-hidden="true"></span> / <span class="studydocuments-page-max-cont" aria-hidden="true"></span></span>': {
-			callback: function() {
-				tools.modal({
-					head: 'Go To Page:',
-					body: '<div class="form-group"><input type="number" value="' + studydocuments.page.cur() + '" class="form-control studydocuments-go-page"></div>',
-					button: {
-						'Go': {
-							type: 'success',
-							close: true,
-							callback: function() {
-								studydocuments.page.set($('.studydocuments-go-page').val());
-							},
-						}
-					}
-				});
-			}
-		},
-		'<span class="glyphicon glyphicon-arrow-right" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Next Page"></span>': {
-			callback: studydocuments.page.inc
-		},
-		'<span class="glyphicon glyphicon-sort" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Sort"></span>': {
-			callback: function() {
-				var tmp = '<div class="form-group"><select class="form-control studydocuments-sort-select">';
-				var cur = studydocuments.sort.cur();
-				studydocuments.showInTable.forEach(function(i) {
-					tmp += '<option value="' + i + '"' + ((i == cur) ? ' selected' : '') + '>&#8673; ' + i + '</option>';
-					tmp += '<option value="-' + i + '"' + (('-' + i == cur) ? ' selected' : '') + '>&#8675; ' + i + '</option>';
-				});
-				tmp += '</select></div>';
-				tools.modal({
-					head: 'Sort',
-					body: tmp,
-					button: {
-						'Sort': {
-							type: 'success',
-							close: true,
-							callback: function() {
-								studydocuments.sort.set($('.studydocuments-sort-select').val());
-							}
-						}
-					}
-
-				});
-			}
-		},
-		'<span class="glyphicon glyphicon-search" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Search"></span>': {
-			callback: function() {
-				var tmp = '<div class="form-group"><select class="form-control studydocuments-search-select">';
-				var cur = studydocuments.search.cur();
-				if (cur === null || cur == '')
-					cur = '';
-				else
-					cur = cur.split('==')[1];
-				['_id', 'firstname', 'lastname'].forEach(function(i) {
-					tmp += '<option value="' + i + '"' + ((i == cur) ? ' selected' : '') + '>' + i + '</option>';
-				});
-				tmp += '</select><br><input type="text" value="' + cur + '" class="form-control studydocuments-search-val"></div>';
-				tools.modal({
-					head: 'Search',
-					body: tmp,
-					button: {
-						'Clear': {
-							type: 'warning',
-							close: true,
-							callback: studydocuments.search.clr,
-						},
-						'Search': {
-							type: 'success',
-							close: true,
-							callback: function() {
-								studydocuments.search.set($('.studydocuments-search-select').val(), $('.studydocuments-search-val').val());
-							}
-						},
-					}
-				})
-			}
-		}
-	});
-
-	//Set Toolpit
-	$('[data-toggle="tooltip"]').tooltip()
-
-	// Set Initail Page and get first studydocuments
-	if (studydocuments.page.cur() === null || isNaN(studydocuments.page.cur()))
-		studydocuments.page.set(1);
-	else
-		studydocuments.page.set(studydocuments.page.cur());
-</script>
diff --git a/tools/users.tool b/tools/users.tool
deleted file mode 100644
index 5d2c636..0000000
--- a/tools/users.tool
+++ /dev/null
@@ -1,347 +0,0 @@
-<div class="users-table-wrapper">
-	<table class="table table-hover users-table">
-		<thead>
-			<tr>
-			</tr>
-		</thead>
-		<tbody>
-		</tbody>
-	</table>
-</div>
-<style>
-	.users-search-table-remove-cell {width:30px}
-	.users-search-table-field-cell {width:240px}
-</style>
-<script type="text/javascript">
-	var users = {
-		showInTable: ['firstname', 'lastname', 'nethz', 'legi', 'membership'],
-		curUserData: null,
-
-		// Page
-		page: {
-			max: Number.MAX_VALUE,
-			cur: function() {
-				return parseInt(tools.mem.session.get('curPage'));
-			},
-			set: function(num) {
-				num = parseInt(num);
-				if (num > 0 && num < users.page.max + 1)
-					tools.mem.session.set('curPage', num);
-				$('.users-cur-page-cont').html(users.page.cur());
-				users.get();
-			},
-			inc: function() {
-				users.page.set(users.page.cur() + 1);
-			},
-			dec: function() {
-				users.page.set(users.page.cur() - 1);
-			}
-		},
-
-		//Sorting
-		sort: {
-			cur: function() {
-				return tools.mem.session.get('curSort');
-			},
-			set: function(sort) {
-				tools.mem.session.set('curSort', sort);
-				users.get();
-			},
-			inv: function() {
-				var tmp = users.sort.cur();
-				if (tmp.charAt(0) == '-')
-					users.sort.set(tmp.slice(1));
-				else
-					users.sort.set('-' + tmp);
-			}
-		},
-
-		//Searching
-		search: {
-			cur: function() {
-				return tools.mem.session.get('search');
-			},
-			set: function(searchParameters) {
-				tools.mem.session.set('search', JSON.stringify(searchParameters));
-				users.page.set(1);
-			},
-			clr: function() {
-				tools.mem.session.set('search', '');
-				users.page.set(1);
-			},
-		},
-
-		// Get users
-		get: function() {
-			amivcore.users.GET({
-				'max_results': '50',
-				page: users.page.cur(),
-				sort: users.sort.cur(),
-				where: users.search.cur(),
-			}, function(ret) {
-
-				if (ret === undefined || ret['_items'].length == 0) {
-					tools.log('No Data', 'w');
-					return;
-				}
-
-				users.meta = ret['_meta'];
-				users.page.max = Math.ceil(users.meta.total / users.meta.max_results);
-				$('.users-page-max-cont').html(users.page.max);
-
-				// Clear table from previous contentent
-				$('.users-table thead tr, .users-table tbody').html('');
-
-				users.showInTable.forEach(function(i) {
-					$('.users-table thead tr').append('<th>' + i + '</th>');
-				});
-
-				for (var n in ret['_items']) {
-					var tmp = '';
-					users.showInTable.forEach(function(i) {
-						tmp += '<td>' + ret['_items'][n][i] + '</td>';
-					});
-					$('.users-table tbody').append('<tr data-id="' + ret['_items'][n]['_id'] + '">' + tmp + '</tr>');
-				}
-				$('.users-table tbody tr').click(users.showDetails);
-			});
-		},
-
-		// Make Modal with editable table data
-		showDetails: function() {
-			amivcore.users.GET({
-				id: $(this).attr('data-id')
-			}, function(ret) {
-				curUserData = ret;
-				var tmp = '<table class="table table-hover users-user-edit-table" data-etag="' + ret['_etag'] + '" data-id="' + ret._id + '"><tbody>';
-				for (var cur in ret)
-					if (cur.charAt(0) != '_')
-						tmp += '<tr><td>' + cur + '</td><td contenteditable>' + ret[cur] + '</td></tr>'
-				tmp += '</tbody></table>';
-
-				tools.modal({
-					head: ret.firstname + ' ' + ret.lastname,
-					body: tmp,
-					button: {
-						'Delete': {
-							type: 'danger',
-							callback: function() {
-								if (confirm('Fo\' shizzle my nizzle? U fo\' real?'))
-									amivcore.users.DELETE({
-										id: $('.users-user-edit-table').first().attr('data-id'),
-										header: {
-											'If-Match': $('.users-user-edit-table').attr('data-etag')
-										},
-									}, function(ret) {
-										if (ret === undefined) {
-											tools.log('User successfully deleted', 's');
-											users.get();
-											tools.modalClose();
-										} else {
-											tools.log('Error', 'e');
-										}
-									});
-							}
-						},
-						'Update': {
-							type: 'success',
-							close: true,
-							callback: users.inspectUser,
-						}
-					}
-				});
-
-			});
-		},
-
-		// Check wether changes were maid and saves it in that case
-		inspectUser: function() {
-			var newUserData = {};
-			$('.users-user-edit-table tr').each(function() {
-				newUserData[$(this).children('td:nth-child(1)').html()] = $(this).children('td:nth-child(2)').html();
-			});
-			var changed = false,
-				curUserDataChanged = {};
-			for (var i in newUserData) {
-				if (newUserData[i] != String(curUserData[i])) {
-					changed = true;
-					curUserDataChanged[i] = newUserData[i];
-				}
-			}
-			if (changed) {
-				amivcore.users.PATCH({
-					id: curUserData._id,
-					header: {
-						'If-Match': $('.users-user-edit-table').attr('data-etag')
-					},
-					data: curUserDataChanged
-				}, function() {
-					tools.log('User Updated', 's');
-					users.get();
-				});
-			}
-		},
-
-		//Make new user
-		add: function() {
-			var tmp = '<div class="row users-user-add-form"><div class="form-group col-xs-6"><label for="users-fn">Firstname:</label><input type="text" class="form-control" name="firstname" id="users-fn"></div>' +
-				'<div class="form-group col-xs-6"><label for="users-ln">Lastname:</label><input type="text" class="form-control" id="users-ln" name="lastname"></div>' +
-				'<div class="form-group"><label for="users-email">E-Mail:</label><input type="email" class="form-control" id="users-email" name="email"></div>' +
-				'<div class="form-group col-xs-6"><label for="users-membership">Membership:</label><select class="form-control" id="users-membership" name="membership"><option>regular</option><option>honorary</option><option>extraordinary</option></select></div>' +
-				'<div class="form-group col-xs-6"><label for="users-gender">Gender:</label><select class="form-control" id="users-gender" name="gender"><option>male</option><option>female</option></select></div>' +
-				'</div>';
-			tools.modal({
-				head: 'Spawn new AMIV slave',
-				body: tmp,
-				button: {
-					'Add': {
-						type: 'success',
-						callback: function() {
-							var newUserData = {};
-							$('.users-user-add-form input, .users-user-add-form select').each(function() {
-								newUserData[$(this).attr('name')] = $(this).val();
-							});
-							amivcore.users.POST({
-								data: newUserData
-							}, function(ret) {
-								if (!ret.hasOwnProperty('_status') || ret['_status'] != 'OK')
-									tools.log(JSON.stringify(ret.responseJSON['_issues']), 'e');
-								else {
-									tools.modalClose();
-									tools.log('User Added', 's');
-									users.get();
-								}
-							});
-						}
-					}
-				}
-			});
-		}
-	};
-
-	// Setup Menu
-	tools.ui.menu({
-		'<span class="glyphicon glyphicon-plus" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Create User"></span>': {
-			callback: users.add
-		},
-		'<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Previous Page"></span>': {
-			callback: users.page.dec
-		},
-		'<span data-toggle="tooltip" data-placement="bottom" title="Set Page"><span class="users-cur-page-cont" aria-hidden="true"></span> / <span class="users-page-max-cont" aria-hidden="true"></span></span>': {
-			callback: function() {
-				tools.modal({
-					head: 'Go To Page:',
-					body: '<div class="form-group"><input type="number" value="' + users.page.cur() + '" class="form-control users-go-page"></div>',
-					button: {
-						'Go': {
-							type: 'success',
-							close: true,
-							callback: function() {
-								users.page.set($('.users-go-page').val());
-							},
-						}
-					}
-				});
-			}
-		},
-		'<span class="glyphicon glyphicon-arrow-right" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Next Page"></span>': {
-			callback: users.page.inc
-		},
-		'<span class="glyphicon glyphicon-sort" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Sort"></span>': {
-			callback: function() {
-				var tmp = '<div class="form-group"><select class="form-control users-sort-select">';
-				var cur = users.sort.cur();
-				['_id', 'firstname', 'lastname', 'membership', 'nethz'].forEach(function(i) {
-					tmp += '<option value="' + i + '"' + ((i == cur) ? ' selected' : '') + '>&#8673; ' + i + '</option>';
-					tmp += '<option value="-' + i + '"' + (('-' + i == cur) ? ' selected' : '') + '>&#8675; ' + i + '</option>';
-				});
-				tmp += '</select></div>';
-				tools.modal({
-					head: 'Sort',
-					body: tmp,
-					button: {
-						'Sort': {
-							type: 'success',
-							close: true,
-							callback: function() {
-								users.sort.set($('.users-sort-select').val());
-							}
-						}
-					}
-
-				});
-			}
-		},
-		'<span class="glyphicon glyphicon-search" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Search"></span>': {
-			callback: function() {
-				var tmp = '<table class="table table-hover users-search-table"><tbody>';
-				var tmpOptions = '';
-				var cur = users.search.cur();
-				var val = '';
-				if (cur === null || cur == '')
-					cur = JSON.parse('{}');
-				else
-					cur = JSON.parse(users.search.cur());
-				['_id', 'firstname', 'lastname'].forEach(function(i) {
-					if (cur[i] !== undefined) {
-						tmp += '<tr><td class="users-search-table-field-cell">' + i + '</td><td contenteditable="true" placeholder="Place text here...">' + cur[i] + '</td><td class="users-search-table-remove-cell"><button type="button" class="close users-search-remove-btn" aria-label="Close" data-field="' + i + '"><span aria-hidden="true">&times;</span></button></td></tr>';
-					}
-					tmpOptions += '<option class="users-search-field-' + i + ' ' + ((cur[i] !== undefined) ? ' hidden' : '') + '" value="' + i + '">' + i + '</option>';
-				});
-				tmp += '</tbody></table>';
-				tmp += '<select class="form-control users-search-select" placeholder="Select a field...">' + tmpOptions + '</select>';
-				tmp += '<button type="button" class="btn btn-default users-search-add-btn">Add field</button>';
-				tools.modal({
-					head: 'Search',
-					body: tmp,
-					button: {
-						'Clear': {
-							type: 'warning',
-							close: true,
-							callback: users.search.clr,
-						},
-						'Search': {
-							type: 'success',
-							close: true,
-							callback: function() {
-								var newSearchParameters = {};
-								$('.users-search-table tr').each(function() {
-									newSearchParameters[$(this).children('td:nth-child(1)').html()] = $(this).children('td:nth-child(2)').html();
-								});
-								users.search.set(newSearchParameters);
-							}
-						},
-					}
-				});
-				var initRemoveBtn = function() {
-					$('.users-search-remove-btn').off('click');
-					$('.users-search-remove-btn').click(function() {
-						var field = $(this).data('field');
-						$('.users-search-field-' + field).removeClass('hidden');
-						$(this).parents('tr').remove();
-					});
-				};
-				initRemoveBtn();
-				$('.users-search-add-btn').click(function() {
-					var field = $('.users-search-select').val();
-					$('.users-search-select').val(undefined);
-					tmp = '<tr><td class="users-search-table-field-cell">' + field + '</td><td contenteditable="true" placeholder="Place text here..."></td><td class="users-search-table-remove-cell"><button type="button" class="close users-search-remove-btn" aria-label="Close" data-field="' + field + '"><span aria-hidden="true">&times;</span></button></td></tr>';
-					$('.users-search-table').append(tmp);
-					$('.users-search-field-' + field).addClass('hidden');
-					initRemoveBtn();
-				});
-				
-				
-			}
-		}
-	});
-
-	//Set Toolpit
-	$('[data-toggle="tooltip"]').tooltip()
-
-	// Set Initail Page and get first users
-	if (users.page.cur() === null || isNaN(users.page.cur()))
-		users.page.set(1);
-	else
-		users.page.set(users.page.cur());
-</script>
-- 
GitLab