Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/web/index.html
blob: a2f133cda88540ec3069260e3f5462a0dd981c0b (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
<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(id, title, desc) {
            $('#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>"+
                "<tr><td>" + desc + "</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++) {
                    id = selected[i].id;
                    add_tr(id, selected[i].title, selected[i].desc);
                }

                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(id, new_list[i].title, new_list[i].desc);
                }
            }
        };

    </script>
  </head>
  <body onload="init()">
      <div id="header">
      </div>

      <table id="journaltable">

      </table>
  </body>
</html>