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.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
define('panels/hotspot/hotspot',['require','shared/settings_listener'],function(require){'use strict';var SettingsListener=require('shared/settings_listener');const RE_ENABLE_WIFI_TETHERING_TIME=1000;var Hotspot=function(){this._settings=navigator.mozSettings;};Hotspot.prototype={_hotspotSetting:null,_usbHotspotSetting:null,_usbStorageSetting:null,_hotspotChangeListeners:[],_usbHotspotChangeListeners:[],_usbStorageChangeListeners:[],_incompatibleSettingsListeners:[],tetheringWifiKey:'tethering.wifi.enabled',tetheringUsbKey:'tethering.usb.enabled',usbStorageKey:'ums.enabled',init:function h_init(){this._bindEvents();},_bindEvents:function(){SettingsListener.observe(this.tetheringWifiKey,false,this._hotspotSettingChange.bind(this));SettingsListener.observe(this.tetheringUsbKey,false,this._usbHotspotSettingChange.bind(this));SettingsListener.observe(this.usbStorageKey,false,this._usbStorageSettingChange.bind(this));},_hotspotSettingChange:function(enabled){this._hotspotSetting=enabled;this._hotspotChangeListeners.forEach(function(listener){listener(enabled);});},_usbHotspotSettingChange:function(enabled){this._usbHotspotSetting=enabled;this._usbHotspotChangeListeners.forEach(function(listener){listener(enabled);});},_usbStorageSettingChange:function(enabled){this._usbStorageSetting=enabled;this._usbStorageChangeListeners.forEach(function(listener){listener(enabled);});},_incompatibleSettings:function(newSetting,oldSetting,bothConflicts){this._incompatibleSettingsListeners.forEach(function(listener){listener(newSetting,oldSetting,bothConflicts);});},checkIncompatibleSettings:function(newSetting,value){switch(newSetting){case this.tetheringWifiKey:if(!value){this._setWifiTetheringSetting(value);return;}
|
||||
if(value&&this._usbHotspotSetting){this._incompatibleSettings(this.tetheringWifiKey,this.tetheringUsbKey,false);}else{this._setWifiTetheringSetting(value);}
|
||||
break;case this.tetheringUsbKey:if(!value||(!this._hotspotSetting&&!this._usbStorageSetting)){this._setUsbTetheringSetting(value);return;}
|
||||
if(this._usbStorageSetting&&this._hotspotSetting){this._incompatibleSettings(this.tetheringUsbKey,null,true);}else{var oldSetting=this._usbStorageSetting?this.usbStorageKey:this.tetheringWifiKey;this._incompatibleSettings(this.tetheringUsbKey,oldSetting,false);}
|
||||
break;}},reEnableWifiTetheringSetting:function(){if(!this.wifiHotspotSetting){return;}
|
||||
this._setWifiTetheringSetting(false);setTimeout(()=>{this._setWifiTetheringSetting(true);},RE_ENABLE_WIFI_TETHERING_TIME);},_removeEventListener:function(listeners,callback){var index=listeners.indexOf(callback);if(index>=0){listeners.splice(index,1);}},_setWifiTetheringSetting:function(value){var cset={};cset[this.tetheringWifiKey]=value;this._settings.createLock().set(cset);},_setUsbTetheringSetting:function(value){var cset={};cset[this.tetheringUsbKey]=value;this._settings.createLock().set(cset);},addEventListener:function(eventName,callback){if(eventName==='incompatibleSettings'){this._incompatibleSettingsListeners.push(callback);}else if(eventName==='wifiHotspotChange'){this._hotspotChangeListeners.push(callback);}else if(eventName==='usbHotspotChange'){this._usbHotspotChangeListeners.push(callback);}else if(eventName==='usbStorageChange'){this._usbStorageChangeListeners.push(callback);}},removeEventListener:function(eventName,callback){if(eventName==='incompatibleSettings'){this._removeEventListener(this._incompatibleSettingsListeners,callback);}else if(eventName==='wifiHotspotChange'){this._removeEventListener(this._hotspotChangeListeners,callback);}else if(eventName==='usbHotspotChange'){this._removeEventListener(this._usbHotspotChangeListeners,callback);}else if(eventName==='usbStorageChange'){this._removeEventListener(this._usbStorageChangeListeners,callback);}},get wifiHotspotSetting(){return this._hotspotSetting;},get usbHotspotSetting(){return this._usbHotspotSetting;},get usbStorageSetting(){return this._usbStorageSetting;},set hotspotSetting(value){this._setWifiTetheringSetting(value);},set usbHotspotSetting(value){this._setUsbTetheringSetting(value);}};return function ctor_hotspot(){return new Hotspot();};});define('panels/hotspot/hotspot_settings',['require','shared/settings_listener','modules/settings_cache','modules/base/module','modules/mvvm/observable'],function(require){'use strict';var SettingsListener=require('shared/settings_listener');var SettingsCache=require('modules/settings_cache');var Module=require('modules/base/module');var Observable=require('modules/mvvm/observable');var HotspotSettings=Module.create(function HotspotSettings(){this.super(Observable).call(this);this._init();}).extend(Observable);Object.defineProperty(HotspotSettings.prototype,'tetheringSSIDKey',{get:function(){return'tethering.wifi.ssid';}});Object.defineProperty(HotspotSettings.prototype,'tetheringSecurityKey',{get:function(){return'tethering.wifi.security.type';}});Object.defineProperty(HotspotSettings.prototype,'tetheringPasswordKey',{get:function(){return'tethering.wifi.security.password';}});Observable.defineObservableProperty(HotspotSettings.prototype,'hotspotSSID',{readonly:true,value:''});Observable.defineObservableProperty(HotspotSettings.prototype,'hotspotSecurity',{readonly:true,value:''});Observable.defineObservableProperty(HotspotSettings.prototype,'hotspotPassword',{readonly:true,value:''});HotspotSettings.prototype._init=function(){this._settings=navigator.mozSettings;this._bindEvents();this._updatePasswordIfNeeded();};HotspotSettings.prototype._generateHotspotPassword=function(){var words=['amsterdam','ankara','auckland','belfast','berlin','boston','calgary','caracas','chicago','dakar','delhi','dubai','dublin','houston','jakarta','lagos','lima','madrid','newyork','osaka','oslo','porto','santiago','saopaulo','seattle','stockholm','sydney','taipei','tokyo','toronto'];var password=words[Math.floor(Math.random()*words.length)];for(var i=0;i<4;i++){password+=Math.floor(Math.random()*10);}
|
||||
return password;};HotspotSettings.prototype._updatePasswordIfNeeded=function(){var self=this;SettingsCache.getSettings(function(results){if(!results[self.tetheringPasswordKey]){var pwd=self._generateHotspotPassword();self.setHotspotPassword(pwd);}});};HotspotSettings.prototype.setHotspotSSID=function(value){var cset={};cset[this.tetheringSSIDKey]=value;this._settings.createLock().set(cset);};HotspotSettings.prototype.setHotspotSecurity=function(value){var cset={};cset[this.tetheringSecurityKey]=value;this._settings.createLock().set(cset);};HotspotSettings.prototype.setHotspotPassword=function(value){var cset={};cset[this.tetheringPasswordKey]=value;this._settings.createLock().set(cset);};HotspotSettings.prototype._onSSIDChange=function(value){this._hotspotSSID=value;};HotspotSettings.prototype._onSecurityChange=function(value){this._hotspotSecurity=value;};HotspotSettings.prototype._onPasswordChange=function(value){this._hotspotPassword=value;};HotspotSettings.prototype._bindEvents=function(){SettingsListener.observe(this.tetheringSSIDKey,'',this._onSSIDChange.bind(this));SettingsListener.observe(this.tetheringSecurityKey,'wpa-psk',this._onSecurityChange.bind(this));SettingsListener.observe(this.tetheringPasswordKey,'',this._onPasswordChange.bind(this));};return HotspotSettings;});define('panels/hotspot/panel',['require','modules/dialog_service','modules/settings_panel','panels/hotspot/hotspot','panels/hotspot/hotspot_settings'],function(require){'use strict';var DialogService=require('modules/dialog_service');var SettingsPanel=require('modules/settings_panel');var Hotspot=require('panels/hotspot/hotspot');var HotspotSettings=require('panels/hotspot/hotspot_settings');return function ctor_hotspot(){var elements;var hotspot=Hotspot();var hotspotSettings=HotspotSettings();var hotspotSSID;return SettingsPanel({onInit:function(panel){this._incompatibleSettingsDialog='incompatible-settings-dialog';elements={panel:panel,hotspotSettingBtn:panel.querySelector('#hotspot-settings-section a'),hotspotElement:panel.querySelector('#tethering-wifi-enabled'),hotspotMsg:panel.querySelector('#wifi-hotspot-msg'),usbTetheringElement:panel.querySelector('#tethering-usb-enabled')};this.incompatibleSettingsHandler=this._openIncompatibleSettingsDialog.bind(this);hotspot.init();},onBeforeShow:function(panel,options){hotspot.addEventListener('wifiHotspotChange',this._setHotspotSettingsEnabled);hotspot.addEventListener('usbHotspotChange',this._setUSBTetheringCheckbox);hotspot.addEventListener('incompatibleSettings',this.incompatibleSettingsHandler);elements.hotspotElement.addEventListener('change',this._onWifiHotspotChange);elements.usbTetheringElement.addEventListener('change',this._onUsbHotspotChange);elements.hotspotSettingBtn.addEventListener('click',this._onHotspotSettingsClick);hotspotSettings.observe('hotspotSSID',this._updateHotspotSSID);this._updateUI();},onBeforeHide:function(panel,options){hotspot.removeEventListener('wifiHotspotChange',this._setHotspotSettingsEnabled);hotspot.removeEventListener('usbHotspotChange',this._setUSBTetheringCheckbox);hotspot.removeEventListener('incompatibleSettings',this.incompatibleSettingsHandler);elements.hotspotElement.removeEventListener('change',this._onWifiHotspotChange);elements.usbTetheringElement.removeEventListener('change',this._onUsbHotspotChange);elements.hotspotSettingBtn.removeEventListener('click',this._onHotspotSettingsClick);hotspotSettings.unobserve('hotspotSSID');},_updateHotspotSSID:function(newValue){hotspotSSID=newValue;},_setHotspotSettingsEnabled:function(enabled){elements.hotspotElement.checked=enabled;if(enabled){document.l10n.setAttributes(elements.hotspotMsg,'wifi-hotspot-enabled-msg',{hotspotSSID:hotspotSSID});}else{elements.hotspotMsg.setAttribute('data-l10n-id','disabled');}},_setUSBTetheringCheckbox:function(enabled){elements.usbTetheringElement.checked=enabled;},_onWifiHotspotChange:function(event){var checkbox=event.target;hotspot.checkIncompatibleSettings(hotspot.tetheringWifiKey,checkbox.checked);},_onUsbHotspotChange:function(event){var checkbox=event.target;hotspot.checkIncompatibleSettings(hotspot.tetheringUsbKey,checkbox.checked);},_onHotspotSettingsClick:function(){DialogService.show('hotspot-wifiSettings',{settings:hotspotSettings}).then((result)=>{if(result.type==='submit'){hotspot.reEnableWifiTetheringSetting();}});},_openIncompatibleSettingsDialog:function(newSetting,oldSetting,bothConflicts){if(bothConflicts){return this._openIncompatibleSettingsDialog(hotspot.tetheringUsbKey,hotspot.tetheringWifiKey,null).then((updated)=>{updated&&this._openIncompatibleSettingsDialog(hotspot.tetheringUsbKey,hotspot.usbStorageKey,null);});}
|
||||
var headerL10nMap={'ums.enabled':'is-warning-storage-header','tethering.usb.enabled':'is-warning-tethering-header','tethering.wifi.enabled':'is-warning-wifi-header'};var messageL10nMap={'ums.enabled':{'tethering.usb.enabled':'is-warning-storage-tethering-message'},'tethering.usb.enabled':{'ums.enabled':'is-warning-tethering-storage-message','tethering.wifi.enabled':'is-warning-tethering-wifi-message'},'tethering.wifi.enabled':{'tethering.usb.enabled':'is-warning-wifi-tethering-message'}};var headerL10n=headerL10nMap[newSetting];var messageL10n=messageL10nMap[newSetting]&&messageL10nMap[newSetting][oldSetting];return DialogService.confirm(messageL10n,{title:headerL10n,submitButton:{id:'enable',style:'recommend'},cancelButton:{id:'cancel'},}).then((result)=>{var enabled=result.type==='submit';var lock=navigator.mozSettings.createLock();var cset={};cset[newSetting]=enabled;cset[oldSetting]=!enabled;lock.set(cset);return enabled;});},_updateUI:function(){this._setHotspotSettingsEnabled(hotspot.wifiHotspotSetting);this._setUSBTetheringCheckbox(hotspot.usbHotspotSetting);this._updateHotspotSSID(hotspotSettings.hotspotSSID);}});};});
|
||||
Loading…
Reference in a new issue