blob: 80415f6634fc72e15ab78af768435f287d3267ab (
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
|
<!DOCTYPE HTML>
<html i18n-values="dir:textdirection;">
<head>
<meta charset="utf-8">
<title>Media Playlist</title>
<style type="text/css">
.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 {
}
</style>
<script src='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() {
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');
titlediv.classname = 'title';
titlediv.textContent = 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>
|