Yana Stamcheva пре 11 година
родитељ
комит
40f4b10d23
2 измењених фајлова са 26 додато и 2 уклоњено
  1. 23
    0
      estos_log.js
  2. 3
    2
      index.html

+ 23
- 0
estos_log.js Прегледај датотеку

@@ -0,0 +1,23 @@
1
+Strophe.addConnectionPlugin('logger', {
2
+    // logs raw stanzas and makes them available for download as JSON
3
+    connection: null,
4
+    log: [],
5
+    init: function (conn) {
6
+        this.connection = conn;
7
+        this.connection.rawInput = this.log_incoming.bind(this);;
8
+        this.connection.rawOutput = this.log_outgoing.bind(this);;
9
+    },
10
+    log_incoming: function (stanza) {
11
+        this.log.push([new Date().getTime(), 'incoming', stanza]);
12
+    },
13
+    log_outgoing: function (stanza) {
14
+        this.log.push([new Date().getTime(), 'outgoing', stanza]);
15
+    },
16
+    // <a onclick="connection.logger.dump(event.target);">my download button</a>
17
+    dump: function (what, filename){
18
+        what.download = filename || 'xmpplog.json';
19
+        what.href = 'data:application/json;charset=utf-8,\n';
20
+        what.href += encodeURIComponent(JSON.stringify(this.log, null, '  '));
21
+        return true;
22
+    }
23
+});

+ 3
- 2
index.html Прегледај датотеку

@@ -5,6 +5,7 @@
5 5
     <script src="libs/strophejingle.bundle.js"></script><!-- strophe.jingle bundle -->
6 6
     <script src="libs/colibri.js"></script><!-- colibri focus implementation -->
7 7
     <script src="muc.js"></script><!-- simple MUC library -->
8
+    <script src="estos_log.js"></script><!-- simple stanza logger -->
8 9
     <script src="app.js"></script><!-- application logic -->
9 10
     <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
10 11
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
@@ -28,7 +29,7 @@
28 29
             <a class="button" onclick="openLinkDialog();"><i title="Invite others" class="fa fa-link fa-lg"></i></a>
29 30
             <div class="header_button_separator"></div>
30 31
             <a class="button" onclick='openChat();'><i id="chat" title="Open chat" class="fa fa-comments fa-lg"></i></a>
31
-            <!--i class='fa fa-external-link'>&nbsp;</i>Others can join you by just going to <span id='roomurl'></span-->
32
+ <!--i class='fa fa-external-link'>&nbsp;</i>Others can join you by just going to <span id='roomurl'></span-->
32 33
         </div>
33 34
     </div>
34 35
     <div id="settings">
@@ -61,7 +62,7 @@
61 62
         <div id="chatconversation"></div>
62 63
         <textarea id="usermsg" class= "animated" placeholder='Enter text...' autofocus></textarea>
63 64
     </div>
64
-
65
+    <a id="downloadlog" class="fa fa-cloud-download" title="Download logfile for support" onclick="connection.logger.dump(event.target);" style="position: absolute; bottom: 5; left: 5; overflow: visible; z-index: 100;"></a>
65 66
     <script>
66 67
     </script>
67 68
   </body>

Loading…
Откажи
Сачувај