1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Account parameters</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 resource: <select id="res"><option></option></select>
12
<input type="button" id="get_btn" value="Get account parameters" disabled="disabled"/>
13
<div id="log"></div>
14
15
</body>
16
</html>
HTML
1
 
1
#log { border: 1px solid #c6c6c6; }
CSS
60
 
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 flags = wialon.item.Item.dataFlag.base | wialon.item.Item.dataFlag.billingProps;
8
9
    sess.loadLibrary("resourceAccounts"); // load Accounts Library
10
    sess.updateDataFlags( // load items to current session
11
        [{type: "type", data: "avl_resource", flags: flags, mode: 0}], // Items specification
12
        function (code) { // updateDataFlags callback
13
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
14
            var res = sess.getItems("avl_resource"); // get loaded 'avl_resource' items
15
            if (!res || !res.length){ msg("No resources found"); return; } // check if resources found
16
            for (var i=0; i<res.length; i++) // construct Select list using found resources
17
                $("#res").append("<option value='" + res[i].getId() + "'>" + res[i].getName() + "</option>");
JS
Result
Source code of example Close ✕
1
 
1
/*source*/