< br / >
< div class = "alert alert-blue" > This tool scans for Business Apps servers on the local network. Tap on a server to view it in a web browser. Note: Cloud installations will not appear here.< / div >
< div class = "list-group" id = "zero-list" >
< div class = "list-group-item" id = "searching-message" >
< i class = "fa fa-spinner fa-spin" > < / i > Searching...
< / div >
< div class = "list-group-item" id = "not-found-message" style = "display: none;" >
< i class = "fa fa-search" > < / i > No services found on local network.
< / div >
< / div >
< div class = "btn btn-primary" onclick = "stopScanning(); scanZeroconf();" > < i class = "fa fa-refresh" > < / i > Rescan< / div >
< script >
var zeroconf = cordova.plugins.zeroconf;
zeroconf.registerAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)
zeroconf.watchAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)
function scanZeroconf() {
$("#searching-message").css('display', 'block');
$("#not-found-message").css('display', 'none');
zeroconf.watch('_http._tcp.', 'local.', function (result) {
var action = result.action;
var service = result.service;
// Ignore other services
if (typeof service.txtRecord.appid !== 'undefined' & & service.txtRecord.appid == "bizappserver") {
var ipaddr = service.ipv4Addresses[0];
var divid = "#server" + ipaddr.replace(/\./gi, '');
if (action == 'added') {
console.log('service added', service);
var model = service.txtRecord.model;
if ((service.txtRecord.webprotocol == "http" || service.txtRecord.webprotocol == "https") & & Number.isInteger(service.port)) {
var url = service.txtRecord.webprotocol
+ "://"
+ ipaddr
+ (service.port == 80 || service.port == 443 ? "" : ":" + service.port)
+ service.txtRecord.webpath;
var itemcontent = "< b > " + $('< span > ').text(ipaddr).html() + "< / b > < br / > URL: " + $('< span > ').text(url).html() + "< br / > Model: " + $('< span > ').text(model).html();
if (document.getElementById(divid) == null) {
$('#zero-list').append("< div class = \"list-group-item\" id = \"" + divid + " \ " data-zeroconf = \"1\" > " + itemcontent + "< / div > ");
} else {
$(divid).html(itemcontent);
}
document.getElementById(divid).onclick = function () {
window.open(url, "_system");
}
}
} else {
console.log('service removed', service);
$(divid).remove();
}
}
});
setTimeout(stopScanning, 10 * 1000);
}
function stopScanning() {
zeroconf.unwatch('_http._tcp.', 'local.');
$("#searching-message").css('display', 'none');
if ($(".list-group-item[data-zeroconf]").length != true) {
$("#not-found-message").css('display', 'block');
}
}
setnavbar("app", "Server Locator", "settings");
scanZeroconf();
< / script >