blob: 303aec891799607ad5938008d8245f30f9451e82 (
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
|
<html>
<head>
<meta charset="utf-8">
<title>Journal Share</title>
<link href="style.css" rel="stylesheet" type="text/css"/>
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
local = (window.location.hostname == '0.0.0.0');
function add_tr(item) {
id = item.id;
title = item.title;
desc = item.desc;
shared_by = item.shared_by;
downloaded_by = item.downloaded_by;
downloaded_list = '';
if (downloaded_by.length > 0) {
for (var i = 0; i < downloaded_by.length; i++) {
user_data = downloaded_by[i];
downloaded_list += downloaded_list.concat(user_data.from);
}
}
$('#journaltable').append("<tr id=" + id + ">" +
"<td><img src='/datastore/preview_id_" + id + "?v=x'></td>"+
"<td class='desc_td'>"+
"<table class='desc_table'>"+
"<tr><td class='title'>" + title + "</td></tr>"+
(shared_by.from != '' ? "<tr><td>Shared by " + shared_by.from +
"</td></tr>" : "") +
(desc != '' ? "<tr><td>" + desc + "</td></tr>" : "")+
(downloaded_list != '' ? "<tr><td>Downloaded by " + downloaded_list +
"</td></tr>" : "") +
(!local ? "<tr><td>"+
"<a class='download_link' href='/datastore/id_" + id +".journal'>"+
"Download</a></td></tr>" : "") +
"</table>"+
"</td>" +
"</tr>");
}
function init() {
$.getJSON("/datastore/owner_info.json", function(owner_info) {
$('#header').append("Journal of " + owner_info.nick_name);
$('#header').css('color', owner_info.stroke_color);
$('#header').css('background-color', owner_info.fill_color);
});
$.getJSON("/datastore/selected.json", function(selected) {
for (var i = 0; i < selected.length; i++) {
add_tr(selected[i]);
}
if (selected.length == 0) {
$('#journaltable').append("<tr id='noelements'>" +
"<td class='error_msg'>No item selected, " +
"add items to share from your Journal." +
"</td></tr>");
}
});
}
// test websockets
websocket_url = "ws://" + window.location.hostname + ":" +
window.location.port + "/websocket";
var ws = new WebSocket(websocket_url);
ws.onmessage = function (evt) {
$('#noelements').hide();
new_list = eval(evt.data);
for (var i = 0; i < new_list.length; i++) {
id = new_list[i].id;
if ($('#' + id).length == 0) {
add_tr(new_list[i]);
}
}
};
</script>
</head>
<body onload="init()">
<div id="header">
</div>
<table id="journaltable">
</table>
</body>
</html>
|