diff options
author | msquare <msquare@notrademark.de> | 2017-12-27 14:41:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-27 14:41:07 +0100 |
commit | e0ce3168e26ec392de922f8afcfd1e32bd9f27b6 (patch) | |
tree | 8da5c42f5c49ec15eceaf7a1a6de6990e0bd9900 /public | |
parent | 02b775684d643850e4a4ea3d9ac7028b6af3b469 (diff) | |
parent | b00743d6d3a47abf606cf6fc10e1a5792873893b (diff) |
Merge pull request #397 from MyIgel/master
Filter angel types based on account settings, closes #362
Diffstat (limited to 'public')
-rw-r--r-- | public/js/forms.js | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/public/js/forms.js b/public/js/forms.js index c7f4a095..1efd80bb 100644 --- a/public/js/forms.js +++ b/public/js/forms.js @@ -1,20 +1,25 @@ /** - * Runs through the DOM under the element with the given id, finds all - * checkboxes and sets them to the wanted state. + * Sets all checkboxes to the wanted state * - * @param String - * id Id of the element containing all the checkboxes - * @param Boolean - * checked True if the checkboxes should be checked + * @param {string} id Id of the element containing all the checkboxes + * @param {bool} checked True if the checkboxes should be checked */ function checkAll(id, checked) { - var obj = document.getElementById(id); - var boxes = obj.getElementsByTagName("input"); - for (var i = 0; i < boxes.length; i++) { - if (boxes[i].type === "checkbox" && !boxes[i].disabled) { - boxes[i].checked = checked; - } - } + $("#" + id + " input[type='checkbox']").each(function () { + this.checked = checked; + }); +} + +/** + * Sets the checkboxes according to the given type + * + * @param {string} id The elements ID + * @param {list} shifts_list A list of numbers + */ +function checkOwnTypes(id, shifts_list) { + $('#' + id + ' input[type=checkbox]').each(function () { + this.checked = $.inArray(parseInt(this.value), shifts_list); + }); } /** @@ -82,8 +87,8 @@ $(function () { $("input[type='submit']").prop("readonly", true).addClass("disabled"); return true; }); - - $(".dropdown-menu").css("max-height", function() { - return ($(window).height() - 50) + "px"; + + $(".dropdown-menu").css("max-height", function () { + return ($(window).height() - 50) + "px"; }).css("overflow-y", "scroll"); }); |