Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #13057 from KevinGrandon/bug_922658_settings_subpa…
Browse files Browse the repository at this point in the history
…nel_about

Bug 929813 - [Settings] Split up about.js and add declaration for subpanel dependencies r=arthurcc
  • Loading branch information
KevinGrandon committed Oct 25, 2013
2 parents cee2c03 + dda5df9 commit 9a1d3b0
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 133 deletions.
1 change: 1 addition & 0 deletions apps/settings/elements/about_more_info.html
Expand Up @@ -76,6 +76,7 @@ <h2 data-l10n-id="devSettings"> Developer Settings </h2>
</ul>
</div>

<script src="js/about_more_info.js"></script>
<script src="js/factory_reset.js"></script>

</template>
Expand Down
2 changes: 2 additions & 0 deletions apps/settings/elements/about_more_info_developer.html
Expand Up @@ -161,5 +161,7 @@ <h2 data-l10n-id="accessibility">Accessibility</h2>
</ul>
</div>

<script src="js/about_more_info_developer.js"></script>

</template>
</element>
29 changes: 17 additions & 12 deletions apps/settings/index.html
Expand Up @@ -144,6 +144,11 @@
- the « section[id^="wifi-"] » selector.
-
- Long story short: BE VERY CAREFUL WHEN CHANGING A SECTION ID!
-
- Regarding data-require-sub-panels: This is a temporary declarative way
- to say that a panel requires the all subpanels which match the pattern
- 'section[id^="' + panel.id + '-"]' to be loaded before loading.
- This is to be removed soon in bug 922658.
-->

<!--
Expand All @@ -163,7 +168,7 @@
<!-- Connectivity :: Wi-Fi :: Saved Networks -->
<section is="wifi-manageNetworks" role="region" id="wifi-manageNetworks"></section>
<!-- Connectivity :: Wi-Fi -->
<section is="wifi" role="region" id="wifi"></section>
<section is="wifi" role="region" id="wifi" data-require-sub-panels="true"></section>
<!-- Connectivity :: Call :: Call Forwarding Not Reachable -->
<section is="call-cf-notReachableSettings" role="region" id="call-cf-notReachableSettings"></section>
<!-- Connectivity :: Call :: Call Forwarding No Reply -->
Expand All @@ -188,15 +193,15 @@
<!-- Connectivity :: Call :: Fixed Dialing Numbers (FDN) :: Authorized Numbers :: Add -->
<section is="call-fdnList-add" role="region" id="call-fdnList-add"></section>
<!-- Connectivity :: Call :: Fixed Dialing Numbers (FDN) :: Authorized Numbers -->
<section is="call-fdnList" role="region" id="call-fdnList"></section>
<section is="call-fdnList" role="region" id="call-fdnList" data-require-sub-panels="true"></section>
<!-- Connectivity :: Call :: Fixed Dialing Numbers (FDN) :: SIM PIN2 Input -->
<section is="call-pin2-dialog" role="region" id="call-pin2-dialog"></section>
<!-- Connectivity :: Call :: Fixed Dialing Numbers (FDN) -->
<section is="call-fdnSettings" role="region" id="call-fdnSettings"></section>
<!-- Connectivity :: Call :: Voice Mail -->
<section is="call-voiceMailSettings" role="region" id="call-voiceMailSettings"></section>
<!-- Connectivity :: Call -->
<section is="call" role="region" id="call"></section>
<section is="call" role="region" id="call" data-require-sub-panels="true"></section>
<!-- Connectivity :: Cellular & Data :: Network Operator -->
<section is="carrier-operatorSettings" role="region" id="carrier-operatorSettings"></section>
<!-- Connectivity :: Cellular & Data :: Data Settings -->
Expand All @@ -210,18 +215,18 @@
<!-- Connectivity :: Cellular & Data :: Data Roaming Warnings -->
<section is="carrier-dr-warning" role="region" id="carrier-dr-warning"></section>
<!-- Connectivity :: Cellular & Data -->
<section is="carrier" role="region" id="carrier"></section>
<section is="carrier" role="region" id="carrier" data-require-sub-panels="true"></section>
<!-- Connectivity :: Bluetooth -->
<section is="bluetooth" role="region" id="bluetooth"></section>
<!-- Connectivity :: Internet Sharing :: Portable Wi-Fi Hotspot -->
<section is="hotspot-wifiSettings" role="region" id="hotspot-wifiSettings"></section>
<!-- Connectivity :: Internet Sharing -->
<section is="hotspot" role="region" id="hotspot"></section>
<section is="hotspot" role="region" id="hotspot" data-require-sub-panels="true"></section>

<!-- Personalization :: Sound :: Sound Selection -->
<section is="sound-selection" role="region" id="sound-selection"></section>
<!-- Personalization :: Sound -->
<section is="sound" role="region" id="sound"></section>
<section is="sound" role="region" id="sound" data-require-sub-panels="true"></section>
<!-- Personalization :: Display -->
<section is="display" role="region" id="display"></section>
<!-- Personalization :: Notifications -->
Expand All @@ -233,27 +238,27 @@
<!-- Personalization :: Homescreen :: details -->
<section is="homescreen-details" role="region" id="homescreen-details"></section>
<!-- Personalization :: Homescreen -->
<section is="homescreen" role="region" id="homescreen"></section>
<section is="homescreen" role="region" id="homescreen" data-require-sub-panels="true"></section>
<!-- Personalization :: Keyboard :: Select Keyboard :: Add More Keyboards -->
<section is="keyboard-selection-addMore" role="region" id="keyboard-selection-addMore"></section>
<!-- Personalization :: Keyboard :: Select Keyboard -->
<section is="keyboard-selection" role="region" id="keyboard-selection"></section>
<!-- Personalization :: Keyboard -->
<section is="keyboard" role="region" id="keyboard"></section>
<section is="keyboard" role="region" id="keyboard" data-require-sub-panels="true"></section>
<section is="keyboard-enabled-default" role="region" id="keyboard-enabled-default"></section>

<!-- Security :: Phone Lock :: PIN Input -->
<section is="phoneLock-passcode" role="region" id="phoneLock-passcode"></section>
<!-- Security :: Phone Lock -->
<section is="phoneLock" role="region" id="phoneLock" data-passcode-enabled="false" data-lockscreen-enabled="false"></section>
<section is="phoneLock" role="region" id="phoneLock" data-passcode-enabled="false" data-lockscreen-enabled="false" data-require-sub-panels="true"></section>
<!-- Security :: SIM Security :: SIM PIN Input -->
<section is="simpin-dialog" role="region" id="simpin-dialog"></section>
<!-- Security :: SIM Security -->
<section is="simpin" role="region" id="simpin"></section>
<section is="simpin" role="region" id="simpin" data-require-sub-panels="true"></section>
<!-- Security :: Application Permissions :: Details -->
<section is="appPermissions-details" role="region" id="appPermissions-details"></section>
<!-- Security :: Application Permissions -->
<section is="appPermissions" role="region" id="appPermissions"></section>
<section is="appPermissions" role="region" id="appPermissions" data-require-sub-panels="true"></section>
<!-- Security :: Do Not Track -->
<section is="doNotTrack" role="region" id="doNotTrack"></section>

Expand Down Expand Up @@ -288,7 +293,7 @@
<!-- Device :: Send Feedback -->
<section is="improveBrowserOS-chooseFeedback" role="region" id="improveBrowserOS-chooseFeedback"></section>
<!-- Device :: Improve Browser OS -->
<section is="improveBrowserOS" role="region" id="improveBrowserOS"></section>
<section is="improveBrowserOS" role="region" id="improveBrowserOS" data-require-sub-panels="true"></section>
<!-- Device :: Help -->
<section is="help" role="region" id="help"></section>

Expand Down
116 changes: 7 additions & 109 deletions apps/settings/js/about.js
Expand Up @@ -6,18 +6,9 @@
var About = {
init: function about_init() {
document.getElementById('check-update-now').onclick = this.checkForUpdates;
document.getElementById('ftuLauncher').onclick = this.launchFTU;
this.loadHardwareInfo();
this.loadGaiaCommit();
this.loadLastUpdated();
this.networkStatus();
// hide software home button whenever the device has no hardware home button
if (!ScreenLayout.getCurrentLayout('hardwareHomeButton')) {
document.getElementById('software-home-button').style.display = 'none';
// always set homegesture enabled on tablet, so hide the setting
if (!ScreenLayout.getCurrentLayout('tiny'))
document.getElementById('homegesture').style.display = 'none';
}
},

networkStatus: function about_networkStatus() {
Expand All @@ -31,51 +22,6 @@ var About = {
status[(window.navigator.onLine ? 'online' : 'offline')]();
},

loadGaiaCommit: function about_loadGaiaCommit() {
var GAIA_COMMIT = 'resources/gaia_commit.txt';

var dispDate = document.getElementById('gaia-commit-date');
var dispHash = document.getElementById('gaia-commit-hash');
if (dispHash.textContent)
return; // `gaia-commit.txt' has already been loaded

function dateToUTC(d) {
var arr = [];
[
d.getUTCFullYear(), (d.getUTCMonth() + 1), d.getUTCDate(),
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds()
].forEach(function(n) {
arr.push((n >= 10) ? n : '0' + n);
});
return arr.splice(0, 3).join('-') + ' ' + arr.join(':');
}

var req = new XMLHttpRequest();
req.onreadystatechange = (function(e) {
if (req.readyState === 4) {
if (req.status === 0 || req.status === 200) {
var data = req.responseText.split('\n');

/**
* XXX it would be great to pop a link to the github page showing the
* commit, but there doesn't seem to be any way to tell the browser
* to do it.
*/

var d = new Date(parseInt(data[1] + '000', 10));
dispDate.textContent = dateToUTC(d);
dispHash.textContent = data[0];
} else {
console.error('Failed to fetch gaia commit: ', req.statusText);
}
}
}).bind(this);

req.open('GET', GAIA_COMMIT, true); // async
req.responseType = 'text';
req.send();
},

loadLastUpdated: function about_loadLastUpdated() {
var settings = Settings.mozSettings;
if (!settings)
Expand Down Expand Up @@ -106,24 +52,13 @@ var About = {
if (!IccHelper.enabled)
return;

var deviceInfoIccid = document.getElementById('deviceInfo-iccid');
var deviceInfoMsisdn = document.getElementById('deviceInfo-msisdn');
var deviceInfoImei = document.getElementById('deviceInfo-imei');
var info = IccHelper.iccInfo;
if (!navigator.mozTelephony || !info) {
deviceInfoIccid.parentNode.hidden = true;
deviceInfoMsisdn.parentNode.hidden = true;
deviceInfoImei.parentNode.hidden = true;
} else {
deviceInfoIccid.textContent = info.iccid;
deviceInfoMsisdn.textContent = info.msisdn ||
navigator.mozL10n.get('unknown-phoneNumber');
var req = mobileConnection.sendMMI('*#06#');
req.onsuccess = function getIMEI() {
if (req.result && req.result.statusMessage) {
deviceInfoImei.textContent = req.result.statusMessage;
}
};
var deviceInfoMsisdn = document.getElementById('deviceInfo-msisdn');
var info = IccHelper.iccInfo;
if (!navigator.mozTelephony || !info) {
deviceInfoMsisdn.parentNode.hidden = true;
} else {
deviceInfoMsisdn.textContent = info.msisdn ||
navigator.mozL10n.get('unknown-phoneNumber');
}
},

Expand Down Expand Up @@ -213,43 +148,6 @@ var About = {
lock.set({
'gaia.system.checkForUpdates': true
});
},

launchFTU: function about_launchFTU() {
var settings = Settings.mozSettings;
if (!settings)
return;

var key = 'ftu.manifestURL';
var req = settings.createLock().get(key);
req.onsuccess = function ftuManifest() {
var ftuManifestURL = req.result[key];

// fallback if no settings present
if (!ftuManifestURL) {
ftuManifestURL = document.location.protocol +
'//communications.gaiamobile.org' +
(location.port ? (':' + location.port) : '') +
'/manifest.webapp';
}

var ftuApp = null;
navigator.mozApps.mgmt.getAll().onsuccess = function gotApps(evt) {
var apps = evt.target.result;
for (var i = 0; i < apps.length && ftuApp == null; i++) {
var app = apps[i];
if (app.manifestURL == ftuManifestURL) {
ftuApp = app;
}
}

if (ftuApp) {
ftuApp.launch('ftu');
} else {
alert(navigator.mozL10n.get('no-ftu'));
}
};
};
}
};

Expand Down
81 changes: 81 additions & 0 deletions apps/settings/js/about_more_info.js
@@ -0,0 +1,81 @@
'use strict';

var AboutMoreInfo = {

init: function about_init() {
this.loadHardwareInfo();
this.loadGaiaCommit();
},

loadGaiaCommit: function about_loadGaiaCommit() {
var GAIA_COMMIT = 'resources/gaia_commit.txt';

var dispDate = document.getElementById('gaia-commit-date');
var dispHash = document.getElementById('gaia-commit-hash');
if (dispHash.textContent)
return; // `gaia-commit.txt' has already been loaded

function dateToUTC(d) {
var arr = [];
[
d.getUTCFullYear(), (d.getUTCMonth() + 1), d.getUTCDate(),
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds()
].forEach(function(n) {
arr.push((n >= 10) ? n : '0' + n);
});
return arr.splice(0, 3).join('-') + ' ' + arr.join(':');
}

var req = new XMLHttpRequest();
req.onreadystatechange = (function(e) {
if (req.readyState === 4) {
if (req.status === 0 || req.status === 200) {
var data = req.responseText.split('\n');

/**
* XXX it would be great to pop a link to the github page showing the
* commit, but there doesn't seem to be any way to tell the browser
* to do it.
*/

var d = new Date(parseInt(data[1] + '000', 10));
dispDate.textContent = dateToUTC(d);
dispHash.textContent = data[0];
} else {
console.error('Failed to fetch gaia commit: ', req.statusText);
}
}
}).bind(this);

req.open('GET', GAIA_COMMIT, true); // async
req.responseType = 'text';
req.send();
},

loadHardwareInfo: function about_loadHardwareInfo() {
var mobileConnection = getMobileConnection();
if (!mobileConnection)
return;

if (!IccHelper.enabled)
return;

var deviceInfoIccid = document.getElementById('deviceInfo-iccid');
var deviceInfoImei = document.getElementById('deviceInfo-imei');
var info = IccHelper.iccInfo;
if (!navigator.mozTelephony || !info) {
deviceInfoIccid.parentNode.hidden = true;
deviceInfoImei.parentNode.hidden = true;
} else {
deviceInfoIccid.textContent = info.iccid;
var req = mobileConnection.sendMMI('*#06#');
req.onsuccess = function getIMEI() {
if (req.result && req.result.statusMessage) {
deviceInfoImei.textContent = req.result.statusMessage;
}
};
}
}
};

navigator.mozL10n.ready(AboutMoreInfo.init.bind(AboutMoreInfo));

0 comments on commit 9a1d3b0

Please sign in to comment.