-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
168 lines (142 loc) · 4.66 KB
/
scripts.js
File metadata and controls
168 lines (142 loc) · 4.66 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
$(document).ready(function() {
$.get('station_cnt.txt', function(data) {
$('div#station').html(data);
});
$('div#shoutbox').ajaxError(function() {
$(this).text( "Erreur lors de l'activation ajax :/" );
});
$("#sb_form").submit(function(event) {
/* stop form from submitting normally */
event.preventDefault();
post_shoutbox();
});
$("#du_form").submit(function(event) {
/* stop form from submitting normally */
event.preventDefault();
post_diskusage();
});
display_diskusage();
display_shoutbox();
// Add Tooltips
$('#du_form_button').tooltip();
// Spin menu icon and toggle nav
$('#menu-icon').click(function() {
$(this).toggleClass('rotate');
$('#top-nav').slideToggle();
});
// Closes the mobile nav
$('#top-nav a').click(function() {
if ($('#top-nav').is(':visible')
&& $('#menu-icon').is(':visible')) {
$('#top-nav').slideUp();
$('#menu-icon').toggleClass('rotate');
}
});
// Hides the welcome
$('#thanks').click(function() {
$('#welcome').slideUp();
});
// Detects window size
$(window).resize(function() {
if ($('#menu-icon').is(':visible')) {
$('#top-nav').hide();
} else {
$('#top-nav').show();
}
});
// smooth scrolling for internal links
function filterPath(string) {
return string
.replace(/^\//,'')
.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
.replace(/\/$/,'');
}
var locationPath = filterPath(location.pathname);
var scrollElem = scrollableElement('html', 'body');
$('a[href*=#]').each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
var $target = $(this.hash), target = this.hash;
if (target) {
var targetOffset = $target.offset().top;
$(this).click(function(event) {
event.preventDefault();
$(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
location.hash = target;
});
});
}
}
});
// use the first element that is "scrollable"
function scrollableElement(els) {
for (var i = 0, argLength = arguments.length; i <argLength; i++) {
var el = arguments[i],
$scrollElement = $(el);
if ($scrollElement.scrollTop()> 0) {
return el;
} else {
$scrollElement.scrollTop(1);
var isScrollable = $scrollElement.scrollTop()> 0;
$scrollElement.scrollTop(0);
if (isScrollable) {
return el;
}
}
}
return [];
}
});
function refresh_shoutbox () {
$.get('chat_content.html', function(data) {
$('div#shoutbox').html(data);
});
}
function refresh_time_sb () {
// Refresh rate in milli seconds
mytime=setTimeout('display_shoutbox()', 10000);
}
function post_shoutbox () {
$("#send-button").prop('value', 'Envoi...');
$("#send-button").prop('disabled', true);
$.post("/cgi-bin/psowrte.py" , $("#sb_form").serialize())
.success(function() {
refresh_shoutbox();
$("#send-button").prop('value', 'Message envoyé')
$("#send-button").prop('disabled', false);
});
$('#shoutbox-input .message').val('');
}
function display_shoutbox() {
refresh_shoutbox();
refresh_time_sb();
}
function refresh_diskusage() {
$.get('diskusage.html', function(data) {
$('div#diskusage').html(data);
});
}
function refresh_time_du () {
// Refresh rate in milli seconds
mytimedu=setTimeout('display_diskusage()', 10000);
}
function post_diskusage() {
$("#du_form_button").prop('value', 'En cours...');
$("#du_form_button").prop('disabled', true);
$.post("/cgi-bin/diskwrite.py")
.success(function() {
refresh_diskusage();
$("#du_form_button").prop('value', 'Actualisé');
$("#du_form_button").prop('disabled', false);
});
$('#diskusage-input .message').val('');
}
function display_diskusage() {
refresh_diskusage();
refresh_time_du();
}
function fnGetDomain(url) {
return url.match(/:\/\/(.[^/]+)/)[1];
}