blob: 598844c63e666eb08de94b6c0af9a393cf7711c2 (
plain)
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
|
<!DOCTYPE HTML>
<html i18n-values="dir:textdirection;">
<head>
<meta charset="utf-8">
<title>Media Playlist</title>
<style type="text/css">
body {
background: #080809;
}
.playlist {
width: 100%;
height: 100%;
background: #080809;
color: #8AACE7;
font-size: .7em;
position: absolute;
top: 0;
left: 0;
}
.playlistitem {
width: 100%;
padding: 6px;
cursor: pointer;
}
.playing {
background: #393b41;
color: #dddde7;
font-weight: bold;
}
.tracknum {
width: 20px;
position: relative;
float: left;
}
.title {
}
.innertitle {
text-decoration: line-through;
}
.error {
color: red;
float: left;
padding-right: 5px;
}
</style>
<script src="shared/js/local_strings.js"></script>
<script>
function $(o) {
return document.getElementById(o);
}
function pathIsVideoFile(path) {
return /\.(mp4|ogg|mpg|avi)$/i.test(path);
};
function pathIsAudioFile(path) {
return /\.(mp3|m4a)$/i.test(path);
};
///////////////////////////////////////////////////////////////////////////////
// Document Functions:
/**
* Window onload handler, sets up the page.
*/
var currentPlaylist = null;
var currentOffset = -1;
function load() {
document.body.addEventListener('dragover', function(e) {
if (e.preventDefault) e.preventDefault();
});
document.body.addEventListener('drop', function(e) {
if (e.preventDefault) e.preventDefault();
});
chrome.send("getCurrentPlaylist", []);
};
function getDisplayNameFromPath(path) {
slash = path.lastIndexOf("/")
if (slash != -1) {
fileName = path.substring(slash+1,path.length)
return fileName;
} else {
return path;
}
};
function setPlaylistOffset(offset) {
chrome.send("setCurrentPlaylistOffset", ['' + offset]);
};
function updateUI() {
var main = $('main');
if (currentPlaylist) {
main.innerHTML = '';
var main = $('main');
for (var x = 0; x < currentPlaylist.length; x++) {
var rowdiv = document.createElement('div');
rowdiv.className = 'playlistitem';
var numberdiv = document.createElement('div');
numberdiv.className = 'tracknum';
numberdiv.textContent = '' + (x + 1);
rowdiv.appendChild(numberdiv);
var titlediv = document.createElement('div');
if (currentPlaylist[x].error) {
var errormark = document.createElement('div');
errormark.className = 'error';
errormark.textContent = 'X';
var innertitle = document.createElement('div');
innertitle.className = 'innertitle';
innertitle.textContent =
decodeURI(getDisplayNameFromPath(currentPlaylist[x].path));
titlediv.appendChild(errormark);
titlediv.appendChild(innertitle);
} else {
titlediv.className = 'title';
titlediv.textContent =
decodeURI(getDisplayNameFromPath(currentPlaylist[x].path));
}
rowdiv.appendChild(titlediv);
rowdiv.onclick = new Function('setPlaylistOffset(' + x + ')');
if (currentOffset == x) {
rowdiv.className = 'playlistitem playing';
}
main.appendChild(rowdiv);
}
}
};
function playlistChanged(info, playlist) {
currentPlaylist = playlist;
currentOffset = info.currentOffset;
updateUI();
};
</script>
<body onload='load();' onselectstart='return false'>
<div id='main' class='playlist'>
</div>
</body>
</html>
|