-
Notifications
You must be signed in to change notification settings - Fork 0
/
NYTA_BOOKING.user.js
150 lines (121 loc) · 4.75 KB
/
NYTA_BOOKING.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// ==UserScript==
// @name NYTA
// @namespace nytatennis
// @version 0.1
// @description Better time table
// @author DS
// @match https://nyta.chelseareservations.com/tennis/TNBookingMulti.aspx
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_addStyle
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
// @require https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js
// @require https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js
// @require https://cdn.datatables.net/buttons/1.2.2/js/buttons.bootstrap.min.js
// @require https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js
// ==/UserScript==
$("head").append (
'<link ' + 'href="//cdn.datatables.net/r/bs-3.3.5/jq-2.1.4,dt-1.10.8/datatables.min.css" ' + 'rel="stylesheet" type="text/css">' +
'<link ' + 'href="//cdn.datatables.net/buttons/1.2.2/css/buttons.bootstrap.min.css" ' + 'rel="stylesheet" type="text/css">'
);
(function() {
var dataTable;
var lastSearch = "";
var initDataTable = function() {
if ( $.fn.dataTable.isDataTable( '#RequestTabPage_pnlBooking_GridView3' ) ) {
return;
}
var timesTable = $("#RequestTabPage_pnlBooking_GridView3");
var thead = timesTable.find("thead");
var thRows = timesTable.find("tr:has(th)");
if (thead.length===0){
thead = $("<thead></thead>").appendTo(timesTable);
}
var copy = thRows.clone(true).appendTo("thead");
thRows.remove();
dataTable = timesTable.DataTable({
"pageLength": 100,
"dom": 'Bfti',
"search": {
"search": lastSearch
},
buttons: [
createButton('PM EAST'),
createButton('PM SOUTH'),
createButton('PM NORTH'),
createButton('AM EAST'),
createButton('AM SOUTH'),
createButton('AM NORTH'),
createButton('')
]
});
dataTable.on( 'search.dt', function () {
lastSearch = dataTable.search();
});
timesTable
.removeClass( 'label14 no-footer' )
.addClass("table table-striped table-bordered table-condensed");
$("#RequestTabPage_pnlBooking_GridView3_filter").css("text-align","center");
};
var hideCrap = function() {
var clockDiv = $("div.label22");
var hdr = $("div#header");
var refreshLbl = $("#lblRefresh");
var facilitySelection = $("#RequestTabPage_pnlBooking_Tr6");
var courtType = $("#RequestTabPage_pnlBooking_Tr7");
var buddyListChkbox = $("#cbAddtoBuddyList");
var buddyListChkboxLbl = $("#UpdatePanel1 > table > tbody > tr:nth-child(2) > td > span > label");
hdr.hide();
clockDiv.hide();
refreshLbl.hide();
facilitySelection.hide();
courtType.css('display', 'none');
buddyListChkbox.hide();
buddyListChkboxLbl.hide();
$("#RequestTabPage_pnlBooking_lblMaximumBookings").hide();
$("#RequestTabPage_pnlBooking_PanelGridView3 > div").css("height", "");
$("#RequestTabPage_header").hide();
};
var createButton = function(buttonText = "") {
var buttonObj = {
name: buttonText === '' ? 'ALL' : buttonText,
text: buttonText === '' ? 'ALL' : buttonText,
action: function ( e, dt, node, config ) {
dt.search( buttonText ).draw();
lastSearch = buttonText;
$(node).parent().children('a').each(function () {
$(this).removeClass('btn-primary');
});
$(node).addClass("btn-primary");
},
init: function ( dt, node, config ) {
if(config.text == lastSearch || (config.text == 'ALL' && lastSearch === '' )) {
$(node).addClass("btn-primary");
}
},
enabled: true
};
return buttonObj;
};
hideCrap();
var target = document.querySelector('#UpdatePanel1');
var observer = new MutationObserver(function() {
hideCrap();
initDataTable();
$('#RequestTabPage_pnlBooking_GridView3').find('.GridviewAltRow14').each(function(){
$(this).removeClass("GridviewAltRow14");
});
if(dataTable !== "") {
if(dataTable.search() !== lastSearch && lastSearch !== "") {
dataTable.search(lastSearch).draw();
}
}
});
var config = {
attributes: true,
childList: true,
characterData: true,
subtree: true
};
observer.observe(target, config);
})();