mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-03-15 12:51:00 +08:00
CB-6964 ported manual tests
Fixed up style Fixed typo in addEventListener
This commit is contained in:
parent
fe2b8fb5db
commit
fa1bcac78a
@ -56,3 +56,43 @@ exports.defineAutoTests = function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||||
|
function eventOutput(s) {
|
||||||
|
var el = document.getElementById("results");
|
||||||
|
el.innerHTML = el.innerHTML + s + "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function printNetwork() {
|
||||||
|
eventOutput("navigator.connection.type=" + navigator.connection.type);
|
||||||
|
eventOutput("navigator.network.connection.type=" + navigator.network.connection.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEvent(e) {
|
||||||
|
eventOutput('Event of type: ' + e.type);
|
||||||
|
printNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var html = '<div id="info">' +
|
||||||
|
'<b>Results:</b><br>' +
|
||||||
|
'<span id="results"></span>' +
|
||||||
|
'</div><div id="actions"></div>';
|
||||||
|
|
||||||
|
document.addEventListener("online", onEvent, false);
|
||||||
|
document.addEventListener("offline", onEvent, false);
|
||||||
|
contentEl.innerHTML = html;
|
||||||
|
|
||||||
|
createActionButton('Show Network Connection', function () {
|
||||||
|
printNetwork();
|
||||||
|
}, 'actions');
|
||||||
|
|
||||||
|
createActionButton('Clear Log', function () {
|
||||||
|
document.getElementById('results').innerHTML = '';
|
||||||
|
}, 'actions');
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user