I'm guilty for using jQuery here, also I've chosen $(window).load
over $(document).on('ready')
for this - furthermore it's untested!
$(window).load(function() {
/**
* Array of IPs to load
* Empty Cameras = {} object
* for Internal name-spacing.
**/
var Ips = ["192.168.1.10:80", "192.168.1.20:80"],
Suffix = "/jsv/SncViewer.js",
Cameras = {};
/**
* For each IP, get script from
* IP Array, Keep the saved variable/SNC
* within Camera.camX.
**/
for( var x = 0; x < Ips.length; x++ ) {
$.getScript({
url: "http://"+ Ips[x] + Suffix +"",
success: function( data ) {
//May be data.writeViewer..!
Cameras['cam'+ x +''] =
SNC.writeViewer({sz:'4',ptz:'1',fps:'15',iPS:'1'});
}
});
}
});
//Expected Output.
Cameras = {
cam1 : //SNC Obj,
cam2 : //SNC Obj
}