in mikrotik wiki api there is the following code:
var api = require(‘mikronode’);
var connection = new api(‘192.168.0.1’,‘admin’,‘password’);
connection.connect(function(conn) {
conn.closeOnDone(true); // All channels need to complete before the connection will close.
var listenChannel=conn.openChannel();
listenChannel.write('/interface/listen',function(chan) {
chan.on('read',function(data) {
packet=api.parseItems([data])[0];
console.log('Interface change: '+JSON.stringify(packet));
});
});
var actionChannel=conn.openChannel();
// These will run synchronsously
actionChannel.write(['/interface/set','=disabled=yes','=.id=ether1']); // don't care to do anything after it's done.
actionChannel.write(['/interface/set','=disabled=no','=.id=ether1']); // don't care to do anything after it's done.
actionChannel.write('/interface/getall',function(chan) {
chan.on('done',function(data) {
packets=api.parseItems(data);
packets.forEach(function(packet) {
console.log('Interface: '+JSON.stringify(packet));
});
listenChannel.close(); // This should call the /cancel command to stop the listen.
});
});
actionChannel.close(); // The above commands will complete before this is closed.
});i have login.html page in mikrotik router ,
where should i put the previous code ? and how can i call it from login.html page?