Skip to content

Commit 671b797

Browse files
idodeclareVladimir Kotal
authored andcommitted
Add putjs() to streamline SCRIPTS insertions
1 parent 2b7010d commit 671b797

File tree

1 file changed

+20
-13
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/web

1 file changed

+20
-13
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/Scripts.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,26 @@ public String toHtml() {
106106
* @see HttpServletRequest#getContextPath()
107107
*/
108108
static {
109-
SCRIPTS.put("jquery", new FileScript("js/jquery-3.4.1.min.js", 10));
110-
SCRIPTS.put("jquery-ui", new FileScript("js/jquery-ui-1.12.1-custom.min.js", 11));
111-
SCRIPTS.put("jquery-tablesorter", new FileScript("js/jquery-tablesorter-2.26.6.min.js", 12));
112-
SCRIPTS.put("tablesorter-parsers", new FileScript("js/tablesorter-parsers-0.0.2.min.js", 13));
113-
SCRIPTS.put("tablesorter-parsers" + DEBUG_SUFFIX, new FileScript("js/tablesorter-parsers-0.0.2.js", 13));
114-
SCRIPTS.put("searchable-option-list", new FileScript("js/searchable-option-list-2.0.10.min.js", 14));
115-
SCRIPTS.put("utils", new FileScript("js/utils-0.0.34.min.js", 15));
116-
SCRIPTS.put("utils" + DEBUG_SUFFIX, new FileScript("js/utils-0.0.34.js", 15));
117-
SCRIPTS.put("repos", new FileScript("js/repos-0.0.2.min.js", 20));
118-
SCRIPTS.put("repos" + DEBUG_SUFFIX, new FileScript("js/repos-0.0.2.js", 20));
119-
SCRIPTS.put("diff", new FileScript("js/diff-0.0.4.min.js", 20));
120-
SCRIPTS.put("diff" + DEBUG_SUFFIX, new FileScript("js/diff-0.0.4.js", 20));
121-
SCRIPTS.put("jquery-caret", new FileScript("js/jquery.caret-1.5.2.min.js", 25));
109+
putjs("jquery", "js/jquery-3.4.1", 10);
110+
putjs("jquery-ui", "js/jquery-ui-1.12.1-custom", 11);
111+
putjs("jquery-tablesorter", "js/jquery-tablesorter-2.26.6", 12);
112+
putjs("tablesorter-parsers", "js/tablesorter-parsers-0.0.2", 13, true);
113+
putjs("searchable-option-list", "js/searchable-option-list-2.0.10", 14);
114+
putjs("utils", "js/utils-0.0.34", 15, true);
115+
putjs("repos", "js/repos-0.0.2", 20, true);
116+
putjs("diff", "js/diff-0.0.4", 20, true);
117+
putjs("jquery-caret", "js/jquery.caret-1.5.2", 25);
118+
}
119+
120+
private static void putjs(String key, String pathPrefix, int priority) {
121+
putjs(key, pathPrefix, priority, false);
122+
}
123+
124+
private static void putjs(String key, String pathPrefix, int priority, boolean debug) {
125+
SCRIPTS.put(key, new FileScript(pathPrefix + ".min.js", priority));
126+
if (debug) {
127+
SCRIPTS.put(key + DEBUG_SUFFIX, new FileScript(pathPrefix + ".js", priority));
128+
}
122129
}
123130

124131
private static final Comparator<Script> SCRIPTS_COMPARATOR = Comparator

0 commit comments

Comments
 (0)