-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
106 lines (90 loc) · 2.72 KB
/
background.html
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
<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
/**
* HTML5 local storage keys
*/
var LOCAL_STORAGE_KEY_SEARCH_STRING = "8tracksSearchString";
var LOCAL_STORAGE_KEY_SORT_BY = "8tracksSearchSortBy";
var LOCAL_STORAGE_TO_REMEMBER_LAST_SEARCH = "8tracksSearchToRememberLastSearch";
var toRememberLastSearch;
/**
* State variables
*/
var searchString = null;
var sortBy = null;
var mixPlaying = false;
var mixPageUrl = null;
/**
* Saves state into localStorage and updates local vars. If toRememberLastSearch is false, clear state stored in localStorage.
*/
function saveState(state) {
searchString = state.searchString;
sortBy = state.sortBy;
if (!toRememberLastSearch || searchString == null || searchString == "" || sortBy == null || sortBy == "") {
sortBy = null;
searchString = null;
delete localStorage[LOCAL_STORAGE_KEY_SEARCH_STRING];
delete localStorage[LOCAL_STORAGE_KEY_SORT_BY];
} else {
localStorage[LOCAL_STORAGE_KEY_SEARCH_STRING] = searchString;
localStorage[LOCAL_STORAGE_KEY_SORT_BY] = sortBy;
}
}
/**
* Saves settings into localStorage and then reload settings.
*/
function saveSettings(settings) {
localStorage[LOCAL_STORAGE_TO_REMEMBER_LAST_SEARCH] = settings.toRememberLastSearch;
loadSettings();
}
/**
* Loads state from localStorage and update local vars.
*/
function loadState() {
searchString = localStorage[LOCAL_STORAGE_KEY_SEARCH_STRING];
if (searchString == undefined || searchString == "") {
searchString = null;
}
sortBy = localStorage[LOCAL_STORAGE_KEY_SORT_BY];
if (sortBy == undefined || sortBy == "") {
sortBy = null;
}
}
/**
* Loads settings
*/
function loadSettings() {
toRememberLastSearch = localStorage[LOCAL_STORAGE_TO_REMEMBER_LAST_SEARCH] != "0";
if (!toRememberLastSearch) {
saveState({"searchString": null, "sortBy": null});
}
}
/**
* Plays mix in this DOM document.
*/
function playMix(id) {
var so = new SWFObject("http://8tracks.com/mixes/" + id + "/player_v2", "mixplayer_" + id, "100%", "120", "8", "#000000");
so.addVariable("auto_play", "true");
so.write("bgMixPlayer");
mixPlaying = true;
mixPageUrl = "http://8tracks.com/mixes/" + id;
}
/**
* Stops the current mix playing in the background, killing the flash object.
*/
function stopMix() {
document.getElementById("bgMixPlayer").innerHTML = "";
mixPlaying = false;
mixPageUrl = null;
}
loadState();
loadSettings();
</script>
</head>
<body>
<div id="bgMixPlayer">
</div>
</body>
</html>