Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-05-08 19:39:32 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-05-08 19:55:19 (GMT)
commitaa72d1b83337c5af27a72f96ce402302d09bd4d2 (patch)
tree69a704a77ab7ae20e9df47492b8c68eb2fe57cdd
parent0addc61527e5be88292c0e98c691d969ceaf1f62 (diff)
Update the view when one download finish
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--web/index.html31
1 files changed, 24 insertions, 7 deletions
diff --git a/web/index.html b/web/index.html
index 303aec8..e0ff3a3 100644
--- a/web/index.html
+++ b/web/index.html
@@ -8,7 +8,7 @@
local = (window.location.hostname == '0.0.0.0');
- function add_tr(item) {
+ function create_tr(item, tr) {
id = item.id;
title = item.title;
desc = item.desc;
@@ -22,8 +22,11 @@
}
}
- $('#journaltable').append("<tr id=" + id + ">" +
- "<td><img src='/datastore/preview_id_" + id + "?v=x'></td>"+
+ if (tr == null) {
+ var tr = document.createElement('tr');
+ tr.id = id;
+ }
+ tr.innerHTML = "<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>"+
@@ -36,11 +39,13 @@
"<a class='download_link' href='/datastore/id_" + id +".journal'>"+
"Download</a></td></tr>" : "") +
"</table>"+
- "</td>" +
- "</tr>");
+ "</td>";
+ return tr;
}
+ var shared_items = [];
+
function init() {
$.getJSON("/datastore/owner_info.json", function(owner_info) {
$('#header').append("Journal of " + owner_info.nick_name);
@@ -49,8 +54,9 @@
});
$.getJSON("/datastore/selected.json", function(selected) {
+ shared_items = selected;
for (var i = 0; i < selected.length; i++) {
- add_tr(selected[i]);
+ $('#journaltable').append(create_tr(selected[i], null));
}
if (selected.length == 0) {
@@ -73,10 +79,21 @@
new_list = eval(evt.data);
for (var i = 0; i < new_list.length; i++) {
id = new_list[i].id;
+ // if is a new shared item
if ($('#' + id).length == 0) {
- add_tr(new_list[i]);
+ $('#journaltable').append(create_tr(new_list[i], null));
+ } else {
+ // verify if the information changed
+ for (var j = 0; j < shared_items.length; j++) {
+ if (shared_items[j].id == id) {
+ if (shared_items[j] != new_list[i]) {
+ create_tr(new_list[i],$('#' + id)[0]);
+ }
+ }
+ }
}
}
+ shared_items = new_list;
};
</script>