cordova-plugin-whois
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "cordova-plugin-whois", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Cordova Whois Plugin", | ||
@@ -25,3 +25,3 @@ "cordova": { | ||
"author": "t1st3", | ||
"license": "Apache-2.0" | ||
"license": "MIT" | ||
} |
@@ -10,2 +10,6 @@ | ||
> cordova plugin add cordova-plugin-whois | ||
or | ||
> cordova plugin add https://github.com/t1st3/cordova-plugin-whois.git | ||
@@ -15,3 +19,3 @@ | ||
This plugin defines a global `whois` object. | ||
This plugin defines a global `Whois` object. | ||
Although the object is in the global scope, it is not available until after the `deviceready` event. | ||
@@ -26,6 +30,12 @@ | ||
function onDeviceReady() { | ||
var w = new whois(['wikipedia.com']); | ||
setTimeout(function () { | ||
console.log(w.results); | ||
}, 5000); | ||
var w, success, err, queries; | ||
queries = ['wikipedia.com']; | ||
success = function (results) { | ||
console.log(results); | ||
}; | ||
err = function (e) { | ||
console.log('Error: ' + e); | ||
}; | ||
w = new Whois(); | ||
p.whois(queries, success, err); | ||
} | ||
@@ -41,6 +51,12 @@ ``` | ||
function onDeviceReady() { | ||
var w = new whois(['apache.org@whois.pir.org']); | ||
setTimeout(function () { | ||
console.log(w.results); | ||
}, 5000); | ||
var w, success, err, queries; | ||
queries = ['apache.org@whois.pir.org']; | ||
success = function (results) { | ||
console.log(results); | ||
}; | ||
err = function (e) { | ||
console.log('Error: ' + e); | ||
}; | ||
w = new Whois(); | ||
p.whois(queries, success, err); | ||
} | ||
@@ -58,24 +74,34 @@ ``` | ||
function onDeviceReady() { | ||
var w = new whois(['ovh.fr@whois.nic.fr', 'apache.org@whois.pir.org']); | ||
setTimeout(function () { | ||
console.log(w.results); | ||
}, 5000); | ||
var w, success, err, queries; | ||
queries = ['ovh.fr@whois.nic.fr', 'apache.org@whois.pir.org']; | ||
success = function (results) { | ||
console.log(results); | ||
}; | ||
err = function (e) { | ||
console.log('Error: ' + e); | ||
}; | ||
w = new Whois(); | ||
p.whois(queries, success, err); | ||
} | ||
``` | ||
## Properties | ||
## Methods | ||
- whois.results | ||
- Whois.whois | ||
## whois.results | ||
## Whois.whois | ||
Get the results of the query. | ||
This method takes the following arguments: | ||
Results look like this: | ||
* queries: an array of queries (domain or domain@whois-server) | ||
* success: a callback function that handles success | ||
* err: a callback function that handles error | ||
The callback function for success takes one argument, which is a JSON array of results: | ||
```json | ||
[ | ||
{ | ||
"querystatus": "apache.org@whois.pir.org", | ||
"whois": "success", | ||
"query": "apache.org@whois.pir.org", | ||
"status": "success", | ||
"result": "RESULT FROM WHOIS SERVER" | ||
@@ -86,4 +112,17 @@ } | ||
The callback function for error takes one argument, which is the error emitted. | ||
### Supported Platforms | ||
- Android | ||
***** | ||
## License | ||
This project is licensed under the [MIT license](https://opensource.org/licenses/MIT). Check the [LICENSE.md file](https://github.com/t1st3/cordova-plugin-whois/blob/master/LICENSE.md). | ||
## Dependencies | ||
For the Android part, this project depends on [Apache Commons Net 3.4](https://commons.apache.org/proper/commons-net/), which is distributed under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0). |
exports.defineAutoTests = function () { | ||
describe('Whois (window.whois)', function () { | ||
describe('Whois (window.Whois)', function () { | ||
it('should exist', function (done) { | ||
expect(window.whois).toBeDefined(); | ||
expect(window.Whois).toBeDefined(); | ||
done(); | ||
}); | ||
}); | ||
it('should contain a results specification that is an array', function (done) { | ||
var p = new window.whois(['apache.org@whois.pir.org']); | ||
setTimeout(function () { | ||
expect(p.results).toBeDefined(); | ||
expect(p.results.length > 0).toBe(true); | ||
describe('Success callback', function () { | ||
it('should take an argument that is an array of results', function (done) { | ||
var w, success, err; | ||
w = new window.Whois(); | ||
success = function (r) { | ||
expect(r).toBeDefined(); | ||
expect(r.length > 0).toBe(true); | ||
expect(r[0].query).toBe('apache.org@whois.pir.org'); | ||
expect(r[0].status).toBe('success'); | ||
expect(typeof r[0].result).toBe('string'); | ||
done(); | ||
}, 1000); | ||
}; | ||
err = function (e) { | ||
console.log(e); | ||
}; | ||
w.whois(['apache.org@whois.pir.org'], success, err); | ||
}); | ||
}); | ||
}; |
@@ -6,13 +6,21 @@ | ||
function Whois (ipList) { | ||
function Whois () { | ||
this.results = null; | ||
var self = this; | ||
self.doWhois(ipList, function (info) { | ||
self.results = info; | ||
}, function (e) { | ||
utils.alert('[ERROR] Error initializing Cordova: ' + e); | ||
}); | ||
} | ||
Whois.prototype.doWhois = function (ipList, successCallback, errorCallback) { | ||
Whois.prototype.whois = function (ipList, success, err) { | ||
var successCallback, errorCallback, self; | ||
self = this; | ||
successCallback = function (r) { | ||
self.results = r; | ||
if (success && typeof success === 'function') { | ||
success(r); | ||
} | ||
}; | ||
errorCallback = function (e) { | ||
utils.alert('[ERROR] Error initializing Cordova: ' + e); | ||
if (err && typeof err === 'function') { | ||
err(e); | ||
} | ||
}; | ||
exec(successCallback, errorCallback, "Whois", "getWhoisInfo", ipList); | ||
@@ -19,0 +27,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
145
123
305073