-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPD Satisfaction Survey filter.user.js
63 lines (56 loc) · 2.01 KB
/
PD Satisfaction Survey filter.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// ==UserScript==
// @name PD Satisfaction Survey filter
// @namespace http://nicholasbarry.com
// @version 0.1
// @downloadURL https://github.com/nickbarry/pd-helper-userscripts/raw/master/PD%20Satisfaction%20Survey%20filter.user.js
// @description Hides satisfaction surveys from clients of Rob's, and those with no comments
// @author Nicholas Barry
// @match http://www.peakdemocracy.com/admin/satisfaction_surveys*
// @grant none
// ==/UserScript==
// Bookmarklet generator: http://ted.mielczarek.org/code/mozilla/bookmarklet.html
/*
var tableRows = document.getElementsByTagName("tr"),
portalNum;
for(var i = 1, len = tableRows.length; i<len; i++){
portalNum = tableRows[i].children[3].firstChild.innerHTML;
if(!(portalNum == 93 | portalNum >= 198)){
tableRows[i].style.display = "none";
}else if(tableRows[i].children[1].innerHTML.length == 0){
tableRows[i].style.display = "none";
}
}
*/
function addClassesToRows(tr){
var portalNum = tr.children[3].firstChild.innerHTML;
if(!(portalNum == 93 | portalNum >= 198)){
$(tr).addClass("nonclient");
}else if(tr.children[1].innerHTML.length == 0){
$(tr).addClass("no-comments");
}
}
function toggleDisplay(){
//console.log($(this).text());
if($(this).text() == "Display hidden surveys"){
//console.log(true);
$('.nonclient').css('display','');
$('.no-comments').css('display','');
$(this).text("Hide surveys");
}else{
//console.log(false);
$('.nonclient').css('display','none');
$('.no-comments').css('display','none');
$(this).text("Display hidden surveys");
}
}
var rows = document.getElementsByTagName("tbody")[0].children;
[].forEach.call(rows,addClassesToRows);
// Initial display settings: Hide non-clients and rows without comments
$('.nonclient').css('display','none');
$('.no-comments').css('display','none');
var $displayButton = $('<button class="btn" id="displayButton">Display hidden surveys</button>').css({
position: "fixed",
top: 0,
right: 0
});
$displayButton.appendTo($('body')).on('click',toggleDisplay);