VulpesOS/gaia/apps/system/mobile_id/js/controller.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

80 lines
1.8 KiB
JavaScript
Executable file

/* exports Controller */
/* global UI */
(function(exports) {
'use strict';
function _localize(appName) {
navigator.mozL10n.ready(function localized() {
UI.localize(appName);
});
}
var Controller = {
init: function c_init() {
window.addEventListener(
'init',
this
);
window.addEventListener(
'shown',
this
);
window.addEventListener(
'onverifying',
this
);
window.addEventListener(
'onverified',
this
);
window.addEventListener(
'onerror',
this
);
window.addEventListener(
'onverificationcode',
this
);
},
handleEvent: function c_handleEvent(e) {
switch(e.type) {
case 'init':
_localize(e.detail.appName);
UI.render(e.detail.candidates);
break;
case 'shown':
UI.setScroll();
break;
case 'onverifying':
UI.onVerifying();
break;
case 'onverified':
UI.onVerified(e.detail.phoneNumber);
break;
case 'onerror':
UI.onerror(e.detail.error);
break;
case 'onverificationcode':
UI.onVerificationCode(e.detail);
break;
}
},
requestCode: function c_requestCode() {
window.parent.MobileIdManager.requestNewCode();
},
postIdentity: function c_postIdentity(params) {
window.parent.MobileIdManager.sendMsisdn(params);
},
postVerificationCode: function c_postIdentity(params) {
window.parent.MobileIdManager.sendVerificationCode(params);
},
postCloseAction: function c_postCloseAction(isVerified) {
window.parent.MobileIdManager.close(isVerified);
}
};
exports.Controller = Controller;
}(this));