showing results for - "ping javascript"
Samuel
19 May 2016
1function ping(ip, callback) {
2
3    if (!this.inUse) {
4        this.status = 'unchecked';
5        this.inUse = true;
6        this.callback = callback;
7        this.ip = ip;
8        var _that = this;
9        this.img = new Image();
10        this.img.onload = function () {
11            _that.inUse = false;
12            _that.callback('responded');
13
14        };
15        this.img.onerror = function (e) {
16            if (_that.inUse) {
17                _that.inUse = false;
18                _that.callback('responded', e);
19            }
20
21        };
22        this.start = new Date().getTime();
23        this.img.src = "http://" + ip;
24        this.timer = setTimeout(function () {
25            if (_that.inUse) {
26                _that.inUse = false;
27                _that.callback('timeout');
28            }
29        }, 1500);
30    }
31}
32var PingModel = function (servers) {
33    var self = this;
34    var myServers = [];
35    ko.utils.arrayForEach(servers, function (location) {
36        myServers.push({
37            name: location,
38            status: ko.observable('unchecked')
39        });
40    });
41    self.servers = ko.observableArray(myServers);
42    ko.utils.arrayForEach(self.servers(), function (s) {
43        s.status('checking');
44        new ping(s.name, function (status, e) {
45            s.status(status);
46        });
47    });
48};
49var komodel = new PingModel(['localhost',
50    'ws-bdimperio8',
51    'ws-bdimperio8.payformance.net',
52    'ws-bdimperio8.payformance.com',
53    'ws-bdimperio8.payspan.com',
54    'ws-bdimperio8/favicon.ico',
55    '127.0.0.1', 
56    'unknown'
57    ]);
58ko.applyBindings(komodel);
queries leading to this page
ping command in jsping pong game javascript code using jsping from browser javascriptjs ping urljs ping serverping command javascripthow to ping jsjavascript ping and locationping jsping pong game javascriptping pong game code javascriptping a url in javascriptpingpong jsping a server jsjs pinghow to measure ping in jsping js commandget the current ping javascriptcheck for ping jspingback url javascriptjavascript ping requesthow to get the ping of a website in jsping jsjavascript ping hostjavascript ping a serverpingback url script javascriptping pong javascripthow to get ping in jsping url in jshow to ping in js using a ping packagejavascript ping serverjavascript ping website for i 5bping pong game javascript code ping server from javascriptping to check internet javascriptjs send pinghow to ping a website in javascriptping url javascriptping server javascriptjs ping a serverping pong project javascriptjavascript pingjavascript ping a urlping method jsping pong game using javascriptjavascript ping testjavascript connection status and pinghow to js ping commandjavascript pingjs javascript ping addressping javascriptjavascript run ping commandping command jsjs url pingjavascript ping a websitehow to ping website in jsping request 2c pong return in javascripthow to check for ping in javascriptjavascript ping link with statusping with javascriptping test javascriptping pong jsjs ping commandjs browser pingjs timer pinghow to make js ping a websiteping url jsping javascript