[66] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | function checkButtonVerbage() |
---|
| 19 | { |
---|
| 20 | var inputs = document.getElementsByName("jobCheckBox"); |
---|
| 21 | var check = getCheckStatus(inputs); |
---|
| 22 | |
---|
| 23 | setCheckButtonVerbage(! check); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | function selectAll() |
---|
| 27 | { |
---|
| 28 | var inputs = document.getElementsByName("jobCheckBox"); |
---|
| 29 | var check = getCheckStatus(inputs); |
---|
| 30 | |
---|
| 31 | for (var i in inputs) { |
---|
| 32 | if ('jobCheckBox' == inputs[i].name) { |
---|
| 33 | if ( inputs[i].parentNode.parentNode.style.display != 'none') { |
---|
| 34 | inputs[i].checked = ! check; |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | setCheckButtonVerbage(check); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | function getCheckStatus(inputs) |
---|
| 43 | { |
---|
| 44 | var check = true; |
---|
| 45 | |
---|
| 46 | for (var i in inputs) { |
---|
| 47 | if ('jobCheckBox' == inputs[i].name) { |
---|
| 48 | if ( inputs[i].parentNode.parentNode.style.display != 'none') { |
---|
| 49 | check = (inputs[i].checked && check); |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | return check; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | function setCheckButtonVerbage(check) |
---|
| 59 | { |
---|
| 60 | var op = document.getElementById("checkEm"); |
---|
| 61 | op.value = check ? "Select All" : "Deselect All"; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | function applyfilter() |
---|
| 65 | { |
---|
| 66 | var cols = ["job","priority","user","name"]; |
---|
| 67 | var nodes = []; |
---|
| 68 | var filters = []; |
---|
| 69 | |
---|
| 70 | for (var i = 0; i < cols.length; ++i) { |
---|
| 71 | nodes[i] = document.getElementById(cols[i] + "_0" ); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | var filter = document.getElementById("filter"); |
---|
| 75 | filters = filter.value.split(' '); |
---|
| 76 | |
---|
| 77 | var row = 0; |
---|
| 78 | while ( nodes[0] != null ) { |
---|
| 79 | //default display status |
---|
| 80 | var display = true; |
---|
| 81 | |
---|
| 82 | // for each filter |
---|
| 83 | for (var filter_idx = 0; filter_idx < filters.length; ++filter_idx) { |
---|
| 84 | |
---|
| 85 | // go check each column |
---|
| 86 | if ((getDisplayStatus(nodes, filters[filter_idx], cols)) == 0) { |
---|
| 87 | display = false; |
---|
| 88 | break; |
---|
| 89 | } |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | // set the display status |
---|
| 93 | nodes[0].parentNode.style.display = display ? '' : 'none'; |
---|
| 94 | |
---|
| 95 | // next row |
---|
| 96 | ++row; |
---|
| 97 | |
---|
| 98 | // next set of controls |
---|
| 99 | for (var i = 0; i < cols.length; ++i) { |
---|
| 100 | nodes[i] = document.getElementById(cols[i] + "_" + row); |
---|
| 101 | } |
---|
| 102 | } // while |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | function getDisplayStatus(nodes, filter, cols) |
---|
| 106 | { |
---|
| 107 | var offset = filter.indexOf(':'); |
---|
| 108 | |
---|
| 109 | var search = offset != -1 ? filter.substring(offset + 1).toLowerCase() : filter.toLowerCase(); |
---|
| 110 | |
---|
| 111 | for (var col = 0; col < cols.length; ++col) { |
---|
| 112 | // a column specific filter |
---|
| 113 | if (offset != -1 ) { |
---|
| 114 | var searchCol = filter.substring(0, offset).toLowerCase(); |
---|
| 115 | |
---|
| 116 | if (searchCol == cols[col]) { |
---|
| 117 | // special case jobs to remove unnecessary stuff |
---|
| 118 | return containsIgnoreCase(stripHtml(nodes[col].innerHTML), search); |
---|
| 119 | } |
---|
| 120 | } else if (containsIgnoreCase(stripHtml(nodes[col].innerHTML), filter)) { |
---|
| 121 | return true; |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | return false; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | function stripHtml(text) |
---|
| 129 | { |
---|
| 130 | return text.replace(/<[^>]*>/g,'').replace(/&[^;]*;/g,''); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | function containsIgnoreCase(haystack, needle) |
---|
| 134 | { |
---|
| 135 | return haystack.toLowerCase().indexOf(needle.toLowerCase()) != -1; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | function confirmAction() |
---|
| 139 | { |
---|
| 140 | return confirm("Are you sure?"); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | function toggle(id) |
---|
| 144 | { |
---|
| 145 | if ( document.getElementById(id).style.display != 'block') { |
---|
| 146 | document.getElementById(id).style.display = 'block'; |
---|
| 147 | } |
---|
| 148 | else { |
---|
| 149 | document.getElementById(id).style.display = 'none'; |
---|
| 150 | } |
---|
| 151 | } |
---|