1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Monitoring 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
Notification info. Wait several seconds, until notification will be get
12
<div id="container">
13
  <div id="close_popup"> x </div>
14
  Notification count <span id="count"></span><br>
15
  <table id="notification">
16
    <tr>
17
      <td>Name</td>
18
      <td>Text</td>
19
      <td>Delete</td>
20
    </tr>
21
  </table>
22
</div>
23
<div id="log"></div>
24
25
</body>
26
</html>
HTML
37
 
1
#log, td { 
2
    border: 1px solid #c6c6c6; 
3
}
4
5
#container{
6
    position: relative;
7
    padding: 5px;
8
    padding-top: 25px;
9
    margin: 10px 0;
10
    width: 100%;
11
    height: 300px;
12
    overflow-y: auto;
13
    border: 1px solid #c6c6c6;  
CSS
59
 
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 = wialon.item.Item.dataFlag.base | wialon.item.Resource.dataFlag.base | wialon.item.Item.dataFlag.messages | wialon.item.Resource.dataFlag.notifications;
8
    
9
    sess.loadLibrary("resourceNotifications"); // load Notification Library 
10
    
11
    sess.updateDataFlags( // load items to current session
12
    [{type: "type", data: "avl_resource", flags: flags, mode: 1}], // Items (avl_resource) specification
13
    function (code) { // updateDataFlags callback
14
        if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code 
15
16
        // get loaded 'avl_resource's items with edit notification access 
17
        var res = sess.getItems("avl_resource");
JS
Result
Source code of example Close ✕
1
 
1
/*source*/