1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Commands</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"></select> available commands <select id="cmds"></select>
12
<table>
13
<tr>
HTML
3
 
1
#log, td{ border: 1px solid #c6c6c6; padding:5px; }
2
table select, table input { width:100%; }
3
#exec_btn{ margin-top:20px; }
CSS
163
 
1
var cur_cmd; // global variable
2
3
// Print message to log
4
function msg(text) { $("#log").prepend(text + "<br/>"); }
5
6
function init() { // Execute after login succeed
7
    var sess = wialon.core.Session.getInstance(); // get instance of current Session
8
    // flags to specify what kind of data should be returned
9
    var flags = wialon.item.Item.dataFlag.base |
10
                wialon.item.Unit.dataFlag.commands |
11
                wialon.item.Unit.dataFlag.commandAliases;
12
    sess.loadLibrary("unitCommandDefinitions"); // load Command Definitions Library
13
    sess.updateDataFlags( // load items to current session
14
        [{type: "type", data: "avl_unit", flags: flags, mode: 0}], // Items specification
15
        function (code) { // updateDataFlags callback
16
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
17
            // get loaded 'avl_unit's items with edit commands access 
JS
Result
Source code of example Close ✕
1
 
1
/*source*/