blob: 7181c07a6f46c103cd1d9777f2aa17391175e32b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('mobile', function() {
function ChooseNetwork() {
}
cr.addSingletonGetter(ChooseNetwork);
ChooseNetwork.prototype = {
networks_: [],
showNetworks_: function(networks) {
this.networks_ = networks;
if (networks.length == 0) {
$('scanning').hidden = true;
$('choosing').hidden = true;
$('no-mobile-networks').hidden = false;
return;
}
var container = $('choosing');
container.innerHTML = '';
for (var i in networks) {
var elem = document.createElement('div');
elem.innerHTML =
'<input type="radio" name="network" id="network' + i + '" />' +
'<label for="network' + i + '" id="label' + i + '"></label>';
container.appendChild(elem);
$('label' + i).textContent = networks[i].operatorName;
if (networks[i].status == 'current') {
$('network' + i).checked = true;
$('connect').disabled = false;
} else if (networks[i].status == 'forbidden') {
$('network' + i).disabled = true;
elem.className = 'disabled';
} else {
$('network' + i).addEventListener('click', function(event) {
$('connect').disabled = false;
});
}
}
$('scanning').hidden = true;
$('choosing').hidden = false;
$('no-mobile-networks').hidden = true;
},
connect_: function() {
for (var i in this.networks_) {
if ($('network' + i).checked) {
chrome.send('connect', [this.networks_[i].networkId]);
ChooseNetwork.close();
return;
}
}
},
showScanning_: function() {
$('scanning').hidden = false;
$('choose').hidden = true;
$('no-mobile-networks').hidden = true;
}
};
ChooseNetwork.cancel = function() {
chrome.send('cancel');
ChooseNetwork.close();
};
ChooseNetwork.close = function() {
window.close();
};
ChooseNetwork.connect = function() {
ChooseNetwork.getInstance().connect_();
};
ChooseNetwork.showScanning = function() {
ChooseNetwork.getInstance().showScanning_();
};
ChooseNetwork.initialize = function() {
$('cancel').addEventListener('click', function(event) {
ChooseNetwork.cancel();
});
$('connect').disabled = true;
$('connect').addEventListener('click', function(event) {
ChooseNetwork.connect();
});
chrome.send('pageReady');
};
ChooseNetwork.showNetworks = function(networks) {
ChooseNetwork.getInstance().showNetworks_(networks);
};
// Export
return {
ChooseNetwork: ChooseNetwork
};
});
var ChooseNetwork = mobile.ChooseNetwork;
document.addEventListener('DOMContentLoaded', ChooseNetwork.initialize);
disableTextSelectAndDrag();
|