-
Notifications
You must be signed in to change notification settings - Fork 30
/
redirect.js
48 lines (45 loc) · 2.1 KB
/
redirect.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
function redirectToFrame(sidebarID, queryString) {
sessionStorage.setItem('sidebarID', sidebarID);
sessionStorage.setItem('queryString', queryString);
window.location.replace(window.location.href.substring(0, window.location.href.indexOf('glenwing.github.io/')) + 'glenwing.github.io/frame.html');
}
function frameLoadPage(sidebarID, directoryName, suffix) {
if (suffix === undefined) { suffix = ''; }
//console.log('frameLoadPage:', sidebarID, directoryName, suffix);
if (window.location.pathname.indexOf(directoryName) == -1) {
//DEBUG('frameLoadPage: history.replaceState triggered');
try {
history.replaceState(null, null, directoryName + suffix);
}
catch (DOMException) {
DEBUG('URL change falling back to hard load due to DOMException.');
//window.location.replace(window.location.href.substring(0, window.location.href.indexOf('glenwing.github.io')) + 'glenwing.github.io/' + directoryName + '/' + directoryName + '.html' + suffix);
}
}
if ($('#' + sidebarID).data('pageCache') === '') {
//console.log('Loading new page');
$('#MainWindow').load('./' + directoryName + '/' + directoryName + '.html', function () {
$('#' + sidebarID).data('pageCache', $('#MainWindow').html());
});
}
else {
//console.log('Loading page from cache');
$('#MainWindow').html($.parseHTML($('#' + sidebarID).data('pageCache')));
pageLoadFunction = $('#' + sidebarID).data('onLoad');
pageLoadFunction();
if ((sidebarID === 'Sidebar_DDC' || sidebarID === 'Sidebar_Matchmaker') && suffix.indexOf('#matchmaker') !== -1) {
//console.log('frameLoadPage: activateMatchmaker()');
activateMatchmaker();
}
else {
//console.log('frameLoadPage: deactivateMatchmaker()');
deactivateMatchmaker();
}
}
}
function navigateToDir(dir) {
return window.location.href.substring(0, window.location.href.indexOf('glenwing.github.io')) + 'glenwing.github.io/' + dir;
}
function pageLoadFunction() {
return;
}