Skip to content

Commit 46a7d3d

Browse files
authored
Merge pull request #58 from Ethkuil/master
Add GitHub-style filter for columns (fix #37)
2 parents bd33172 + b6c6312 commit 46a7d3d

File tree

5 files changed

+234
-96
lines changed

5 files changed

+234
-96
lines changed

website/index.html

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,6 @@
139139
<section class="modal-card-body">
140140
<p>Settings will be saved on your local browser and will apply to your future queries.</p><br/>
141141

142-
<!-- Amount of commit diffs for the automatic filtering. -->
143-
<div class="field is-horizontal">
144-
<div class="field-label is-normal">
145-
<label class="label">Ahead filter:</label>
146-
</div>
147-
<div class="field-body">
148-
<div class="field">
149-
<div class="control">
150-
<input id="uf_settings_filter" class="input is-small is-fullwidth has-tooltip-arrow"
151-
type="number" value="0" min="1"
152-
placeholder="Default is 0" required>
153-
</div>
154-
<p class="help mb-2"><strong>Default is 0.</strong> If the amount of 'ahead' commits is less than or equal to this value, the fork is automatically removed from the list.</p>
155-
</div>
156-
</div>
157-
</div>
158-
159142
<!-- Relationship used for the commit diff count. -->
160143
<div class="field is-horizontal">
161144
<div class="field-label is-normal">
@@ -195,7 +178,7 @@
195178
Display
196179
</label>
197180
</div>
198-
<p class="help mb-2"><strong>Default is checked.</strong> Determines whether to display or not the "<span class="is-family-monospace">Export table as CSV</span>" button when a scan ends.</p>
181+
<p class="help mb-2"><strong>Default is checked.</strong> Determines whether to display or not the "<span class="is-family-monospace">Export table below as CSV</span>" button when a scan ends.</p>
199182
</div>
200183
</div>
201184
</div>
@@ -231,6 +214,11 @@
231214
</button>
232215
</p>
233216
</div>
217+
<div class="control" id="filterContainer" hidden>
218+
<input class="input" type="text" id="filter" name="filter"
219+
title='There are aliases too (e.g. "a" for "ahead", "d" for the date, etc.). There is an implicit AND boolean operator in between each filter.'
220+
placeholder="Type your filter here. eg: ahead>=1 behind<5" />
221+
</div>
234222
</div>
235223
</div>
236224
<div class="container" id="useful_forks_inject">

website/src/csv-export.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,22 @@ const EXPORT_DIV_BTN = "uf_csv_export_btn";
33
const EXPORT_BTN = $('<a>', {id: EXPORT_DIV_BTN, class: "button is-dark is-outlined is-small"})
44
.attr("href", "#")
55
.prepend($('<img>', {src: "assets/csv_dl.svg", class: "mr-2", alt: "csv", width: "26", height: "26"}))
6-
.append("Export table as CSV");
6+
.append("Export table below as CSV");
77
const EXPORT_DIV = $('<div>', {id: EXPORT_DIV_ID, class: "mt-2"}).append(EXPORT_BTN);
88

99

1010
function displayCsvExportBtn() {
1111
if (!UF_SETTINGS_CSV_DISPLAY) {
1212
return;
1313
}
14-
if (!tableIsEmpty()) {
15-
JQ_ID_HEADER.append(EXPORT_DIV);
16-
setClickEvent();
17-
}
14+
JQ_ID_HEADER.append(EXPORT_DIV);
15+
setClickEvent();
1816
}
1917
function hideExportCsvBtn() {
2018
if (!UF_SETTINGS_CSV_DISPLAY) {
2119
return;
2220
}
23-
if (!tableIsEmpty()) {
24-
getJqId_$(EXPORT_DIV_ID).remove();
25-
}
21+
getJqId_$(EXPORT_DIV_ID).remove();
2622
}
2723
function setClickEvent() {
2824
EXPORT_BTN.on('click', function (event) {

website/src/queries-init.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const SELF_URL = "https://useful-forks.github.io/";
22

33
const JQ_REPO_FIELD = $('#repo');
4+
const JQ_FILTER_FIELD = $('#filter');
5+
const JQ_FILTER_CONTAINER = $('#filterContainer');
46
const JQ_SEARCH_BTN = $('#searchBtn');
57
const JQ_TOTAL_CALLS = $('#totalApiCalls');
68

@@ -21,11 +23,15 @@ const UF_MSG_API_RATE = "<b>GitHub API rate-limits exceeded.</b> Consider pr
2123
// list of messages which should not be cleared when the request ends
2224
const UF_PRESERVED_MSGS = [
2325
UF_MSG_NO_FORKS,
24-
UF_MSG_EMPTY_FILTER,
2526
UF_MSG_ERROR,
2627
UF_MSG_API_RATE
2728
];
2829

30+
// messages about the current state of the scan but not about the results
31+
const UF_MSGS_SCAN_STATE = [
32+
UF_MSG_SCANNING,
33+
UF_MSG_SLOWER
34+
];
2935

3036
const EXAMPLE_LINK_1 = `<a href="${buildAutoQueryURL('payne911/PieMenu')}"
3137
onclick="ga_shortExampleLink();">payne911/PieMenu</a>`;
@@ -102,18 +108,30 @@ function setMsg(msg) {
102108
.css("border-color", "rgba(0,0,0,0.25)")
103109
.css("border-style", "solid");
104110
}
111+
112+
function isMsgEmpty() {
113+
return JQ_ID_MSG.html() === "";
114+
}
115+
105116
function clearMsg() {
106117
JQ_ID_MSG
107118
.empty()
108119
.removeClass("box")
109120
.css("border-style", "");
110-
removeProgressBar();
111121
}
112122
function clearNonErrorMsg() {
113123
const msg = JQ_ID_MSG.html();
114124
if (!UF_PRESERVED_MSGS.includes(msg))
115125
clearMsg();
116126
}
127+
128+
function clearNonScanStateMsg() {
129+
const msg = JQ_ID_MSG.html();
130+
if (!UF_MSGS_SCAN_STATE.includes(msg) && !UF_PRESERVED_MSGS.includes(msg)) {
131+
clearMsg();
132+
}
133+
}
134+
117135
function setHeader(msg) {
118136
JQ_ID_HEADER.html(msg);
119137
}
@@ -151,6 +169,21 @@ function getQueryOrDefault(defaultVal) {
151169
return JQ_REPO_FIELD.val();
152170
}
153171

172+
function hideFilterContainer() {
173+
JQ_FILTER_CONTAINER.hide();
174+
}
175+
176+
function showFilterContainer() {
177+
JQ_FILTER_CONTAINER.show();
178+
}
179+
180+
function getFilterOrDefault(defaultVal) {
181+
if (!JQ_FILTER_FIELD.val()) {
182+
JQ_FILTER_FIELD.val(defaultVal);
183+
}
184+
return JQ_FILTER_FIELD.val();
185+
}
186+
154187
function setApiCallsLabel(total) {
155188
JQ_TOTAL_CALLS.html(total + " calls");
156189
}

0 commit comments

Comments
 (0)