1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Create notification</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
Resource:<select id="res"></select><br/>
12
<table><tr>
13
14
    <td>Select units:<br/><select id="units" multiple="multiple"></select></td>
15
</tr><tr>
16
17
</tr><tr>
18
    <td>Notification name</td>
19
    <td><input type="text" id="notif_name"/></td>
20
</tr></table>
21
<input type="button" id="create_btn" value="Create notification"/>
22
<div id="log"></div>
23
24
</body>
25
</html>
HTML
1
 
1
#log, td { border: 1px solid #c6c6c6; }
CSS
83
 
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
    //specify what kind of data should be returned (diffrent flags for 'avl_unit' and 'avl_resource')
7
    var flags_res = wialon.item.Item.dataFlag.base
8
    var flags_units = wialon.item.Item.dataFlag.base | wialon.item.Unit.dataFlag.sensors;
9
    
10
    
11
    sess.loadLibrary("unitSensors");
12
    sess.loadLibrary("resourceNotifications"); // load Notification Library 
13
    sess.updateDataFlags( // load items to current session
14
        [{type: "type", data: "avl_resource", flags: flags_res, mode: 0}, // Items (avl_resource) specification
15
        {type: "type", data: "avl_unit", flags: flags_units, mode: 0}], // Items (avl_unit) specification
16
        function (code) { // updateDataFlags callback
17
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code 
JS
Result
Source code of example Close ✕
1
 
1
/*source*/