1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Get messages</title>
6
    <script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
7
    <script type="text/javascript" src="//hst-api.wialon.com/wsdk/script/wialon.js"></script>
8
</head>
9
<body>
10
11
Select unit: <select id="units"><option></option></select>
12
<input type="button" value="Load messages for last 24 hours" id="load_btn"/><br/>
13
Show messages from <input type="text" id="show_from" value="0"/>
14
to <input type="text" id="show_to" value="100"/>
15
<input type="button" value="Show messages" id="show_btn"/>
16
<div class="wrap"><table id="messages"></table></div>
17
<div id="log"></div>
18
19
</body>
20
</html>
HTML
4
 
1
#log{border: 1px solid #c6c6c6;}
2
.wrap{max-height:100px; overflow:auto;}
3
td{white-space: nowrap;}
4
.odd{background:#EEE;}
CSS
77
 
1
// Print message to log
2
function msg(text) { $("#log").prepend(text + "<br/>"); }
3
4
function init() { // Execute after login succeed
5
    // flags to specify what kind of data should be returned
6
    var flags = wialon.item.Item.dataFlag.base;
7
    wialon.core.Session.getInstance().updateDataFlags( // load items to current session
8
        [{type: "type", data: "avl_unit", flags: flags,mode: 0}], // Items specification
9
        function (code) {  // updateDataFlags callback
10
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
11
            initData(); // execute if items load succeed
12
    });
13
}
14
15
function initData() { // Execute after items load to Session
16
    var sess = wialon.core.Session.getInstance(); // get instance of current Session
17
    var units = sess.getItems("avl_unit"); // get loaded 'avl_unit's items  
JS
Result
Source code of example Close ✕
1
 
1
/*source*/