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
    <td>Select geofences:<br/><select id="zones" multiple="multiple"></select></td>
14
    <td>Select units:<br/><select id="units" multiple="multiple"></select></td>
15
</tr><tr>
16
    <td>Control type</td>
17
    <td>
18
        <select id="type">
19
            <option value="0">Entries to a geofence</option>
20
            <option value="1">Exits from a geofence</option>
21
        </select>    
22
    </td>
23
</tr><tr>
24
    <td>Notification name</td>
25
    <td><input type="text" id="notif_name"/></td>
26
</tr></table>
27
<input type="button" id="create_btn" value="Create notification"/>
28
<div id="log"></div>
29
30
</body>
31
</html>
HTML
1
 
1
#log, td { border: 1px solid #c6c6c6; }
CSS
90
 
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 | wialon.item.Resource.dataFlag.zones;
8
    var flags_units = wialon.item.Item.dataFlag.base;
9
    
10
    sess.loadLibrary("resourceZones"); // load Geofences Library 
11
    sess.loadLibrary("resourceNotifications"); // load Notification Library 
12
    sess.updateDataFlags( // load items to current session
13
        [{type: "type", data: "avl_resource", flags: flags_res, mode: 0}, // Items (avl_resource) specification
14
        {type: "type", data: "avl_unit", flags: flags_units, mode: 0}], // Items (avl_unit) specification
15
        function (code) { // updateDataFlags callback
16
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code 
17
            // get loaded 'avl_resource's items with edit notification access 
JS
Result
Source code of example Close ✕
1
 
1
/*source*/