1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Bind driver to unit</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
Units and its drivers:
12
<table id='units'>
13
</table>
14
<div id="log"></div>
15
16
</body>
17
</html>
HTML
3
 
1
#units tr td, #units { 
2
  border: 1px solid #c6c6c6; 
3
}
CSS
123
 
1
// Print message to log
2
function msg(text) { $("#log").prepend(text + "<br/>"); }
3
4
function init() { // Execute after login succeed
5
    var sess = wialon.core.Session.getInstance(); // get instance of current Session
6
    // flags to specify what kind of data should be returned
7
    var unit_flags = wialon.util.Number.or(wialon.item.Item.dataFlag.base),
8
        res_flags =  wialon.util.Number.or(wialon.item.Item.dataFlag.base, wialon.item.Resource.dataFlag.drivers);
9
    
10
    // load Icon & Driver Library 
11
    sess.loadLibrary("resourceDrivers");
12
    sess.loadLibrary("itemIcon");
13
    
14
    // load items to current session
15
    sess.updateDataFlags( 
16
        [{type: "type", data: "avl_unit", flags: unit_flags, mode: 0}, 
17
         {type: "type", data: "avl_resource", flags: res_flags, mode: 0}], 
JS
Result
Source code of example Close ✕
1
 
1
/*source*/