-
Notifications
You must be signed in to change notification settings - Fork 149
/
_common_js.tt
97 lines (92 loc) · 4.38 KB
/
_common_js.tt
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
<script>
<!--
jQuery.noConflict();
[%- PROCESS _header_initial_states.tt -%]
var thruk_static_export = false;
var refresh_rate = [% IF refresh_rate %][% refresh_rate %][% ELSE %]null[% END %];
[%- IF auto_reload_fn +%]
var auto_reload_fn = function(cb) { return([% auto_reload_fn %](cb)) };
var datetime_format_long = '[% datetime_format_long %]';
[%- END +%]
var enable_shinken_features = [% enable_shinken_features %];
[%- IF enable_shinken_features +%]
var priorities = new Array('[% FOREACH prio = priorities.keys.sort.reverse %][% priorities.$prio %][% UNLESS loop.last %]', '[% END %][% END %]');
[%- END +%]
var url_prefix = '[% url_prefix %]';
var product_prefix = '[% product_prefix %]';
var cookie_path = '[% cookie_path %]';
var theme = '[% theme %]';
var theme_default = '[% c.config.default_theme %]';
var theme_default_dark = '[% c.config.default_theme_dark %]';
var has_expire_acks = [% IF has_expire_acks %]true[% ELSE %]false[% END %];
var fav_counter = [% IF fav_counter +%]true[% ELSE %]false[% END %];
var perf_bar_mode = '[% perf_bar_mode %]';
var perf_bar_pnp_popup = '[% perf_bar_pnp_popup %]';
var jquery_ui_url = '[% url_prefix %]vendor/jquery-ui-[% c.config.jquery_ui %]/js/jquery-ui-[% c.config.jquery_ui %].custom.min.js';
var jquery_ui_css = '[% url_prefix %]vendor/jquery-ui-[% c.config.jquery_ui %]/css/smoothness/jquery-ui-[% c.config.jquery_ui %].custom.min.css';
var thruk_debug_js = [% IF thruk_author %]true[% ELSE %]false[% END %];
var minimal = [% IF minimal %]true[% ELSE %]false[% END %];
var CSRFtoken = '[% get_user_token(c) %]';
[%- IF c.user_exists %]
var remote_user = '[% remote_user %]';
var remote_groups = [% json_encode(c.user.groups) %];
var thruk_user = [% json_encode(c.user.js_data) %];
[%- END %]
var omd_site = '[% omd_site %]';
var referer = '[% escape_js(uri_with(c, '_' => 'undef' )) %]';
var full_uri = '[% escape_html(full_uri(c)).replace('&', '&').replace('&', '&') %]';
var original_uri = '[% IF original_url %][% original_url.replace('^http.*cgi\-bin\/', '').replace('&', '&') | uri %][% END %]';
var show_sitepanel = '[% show_sitepanel %]';
var param_backend = [% json_encode(param_backend.list) %];
var backend_chooser = '[% backend_chooser %]';
var downtime_duration = [% downtime_duration %];
var has_debug_options = [% has_debug_options %];
var maximum_search_boxes = [% c.config.maximum_search_boxes %];
var escape_html_tags = [% IF escape_html_tags %]true[% ELSE %]false[% END %];
var is_executing_timeout = [% 1000 * c.config.is_executing_timeout %];
var sort_options = [% json_encode(data_sorted) %];
var menuState = [% json_encode(menu_states) %];
[%- PROCESS _common_js_bugs.tt -%]
[%- IF disable_backspace -%]
jQuery(document).on("keydown", function (e) {
if(e.which === 8 && !jQuery(e.target).is("input, textarea")) {
e.preventDefault();
}
});
[%- END -%]
[%- IF original_url -%]
var history_url = '[% original_url %]';
history_url = history_url.replace(/&/g, '&');
if(history.replaceState) {
history.replaceState({}, "", history_url);
}
[%- END -%]
jQuery(document).ready(function() {
init_page();
});
[%- IF fav_counter -%]
/* favicon counter */
[%- totals = set_favicon_counter(c) -%]
[%- IF totals.red > 0 && totals.yellow == 0 && totals.orange == 0 -%]
updateFaviconCounter([% totals.red %], '#FF5B33');
[%- ELSIF totals.red == 0 && totals.yellow > 0 && totals.orange == 0 -%]
updateFaviconCounter([% totals.yellow %], '#FFDE00');
[%- ELSIF totals.red == 0 && totals.yellow == 0 && totals.orange > 0 -%]
updateFaviconCounter([% totals.orange %], '#FF9E00');
[%- ELSE -%]
updateFaviconCounter([% totals.red + totals.yellow + totals.orange %], '#FF9E00');
[%- END -%]
[%- END -%]
// switch to dark theme if prefered by the user
var cookieTheme = readCookie('thruk_theme');
if(!cookieTheme || cookieTheme.match(/^auto:/)) {
switchTheme(cookieTheme);
}
// watch for changes
if(window.matchMedia) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
switchTheme(cookieTheme);
});
}
-->
</script>