ginebra2/chrome/bedrockchrome/statusbar.snippet/statusbar.js
changeset 16 3c88a81ff781
parent 3 0954f5dd2cd0
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
     5 /*!
     5 /*!
     6   Class to handle displaying and updating the status bar. Only 1 status bar
     6   Class to handle displaying and updating the status bar. Only 1 status bar
     7   should be created for the browser. This class is not designed to be code
     7   should be created for the browser. This class is not designed to be code
     8   space efficient for creating multiple status bar objects.
     8   space efficient for creating multiple status bar objects.
     9 */
     9 */
       
    10 
       
    11 var LOCK_ICON_SRC = "/statusbar/lock.png";
       
    12 
       
    13 var BATTERY10_SRC = "/statusbar/batt10.png";
       
    14 var BATTERY20_SRC = "/statusbar/batt20.png";
       
    15 var BATTERY30_SRC = "/statusbar/batt30.png";
       
    16 var BATTERY40_SRC = "/statusbar/batt40.png";
       
    17 var BATTERY50_SRC = "/statusbar/batt50.png";
       
    18 var BATTERY60_SRC = "/statusbar/batt60.png";
       
    19 var BATTERY70_SRC = "/statusbar/batt70.png";
       
    20 var BATTERY80_SRC = "/statusbar/batt80.png";
       
    21 var BATTERY90_SRC = "/statusbar/batt90.png";
       
    22 var BATTERY100_SRC = "/statusbar/batt100.png";
       
    23 var BATTERY100_CHARGING_SRC = "/statusbar/batt100_charging.png";
       
    24 
       
    25 var SIGNAL10_SRC = "/statusbar/signal0.png";
       
    26 var SIGNAL25_SRC = "/statusbar/signal25.png";
       
    27 var SIGNAL50_SRC = "/statusbar/signal50.png";
       
    28 var SIGNAL75_SRC = "/statusbar/signal75.png";
       
    29 var SIGNAL100_SRC = "/statusbar/signal100.png";
       
    30 
    10 function StatusBar()
    31 function StatusBar()
    11 {
    32 {
    12     // Private Classes
    33     // Private Classes
    13 
    34 
    14     /*!
    35     /*!
   112       is not designed to be code space efficient for creating multiple objects.
   133       is not designed to be code space efficient for creating multiple objects.
   113     */
   134     */
   114     function LockStatus()
   135     function LockStatus()
   115     {
   136     {
   116         // Private Member Variables
   137         // Private Member Variables
   117         var secureIconSrc = "<img src=\"statusbar.snippet/icons/lock.png\">";
   138         var secureIconSrc = "<img src='" + LOCK_ICON_SRC + "'>";
   118         var noIconSrc =  "&nbsp;";
   139         var noIconSrc =  "&nbsp;";
   119 
   140 
   120         // Public Methods
   141         // Public Methods
   121 
   142 
   122         //! Shows lock icon in status bar if in webView.
   143         //! Shows lock icon in status bar if in webView.
   123         this.showLockIcon = function()
   144         this.showLockIcon = function()
   124         {
   145         {
   125             if (window.views.current().type == "webView") {
   146             if (window.views.current().type == "webView") {
   126                 document.getElementById('lock').innerHTML = "<img src=\"statusbar.snippet/icons/lock.png\">";
   147                 document.getElementById('lock').innerHTML = "<img src='" + LOCK_ICON_SRC + "'>";
   127                 //window.snippets.StatusBarChromeId.repaint();
   148                 //window.snippets.StatusBarChromeId.repaint();
   128             }
   149             }
   129         }
   150         }
   130 
   151 
   131         //! Removes lock icon from status bar.
   152         //! Removes lock icon from status bar.
   184     */
   205     */
   185     function NetworkStatus()
   206     function NetworkStatus()
   186     {
   207     {
   187         // Private Member Variables
   208         // Private Member Variables
   188         var networkIconSrc = new Array(
   209         var networkIconSrc = new Array(
   189             "<img src=\"statusbar.snippet/icons/signal/signal0.png\" alt=\"\">",
   210             "<img src='" + SIGNAL10_SRC + "' alt=''/>",
   190             "<img src=\"statusbar.snippet/icons/signal/signal0.png\" alt=\"\">",
   211             "<img src='" + SIGNAL10_SRC + "' alt=''/>",
   191             "<img src=\"statusbar.snippet/icons/signal/signal25.png\" alt=\"\">",
   212             "<img src='" + SIGNAL25_SRC + "' alt=''/>",
   192             "<img src=\"statusbar.snippet/icons/signal/signal50.png\" alt=\"\">",
   213             "<img src='" + SIGNAL50_SRC + "' alt=''/>",
   193             "<img src=\"statusbar.snippet/icons/signal/signal75.png\" alt=\"\">",
   214             "<img src='" + SIGNAL75_SRC + "' alt=''/>",
   194             "<img src=\"statusbar.snippet/icons/signal/signal100.png\" alt=\"\">");
   215             "<img src='" + SIGNAL100_SRC + "' alt=''/>");
       
   216 
   195         var enumNetworkStrengths = new Object();
   217         var enumNetworkStrengths = new Object();
   196         var currentState; // last known signal state - see enumNetworkStrengths
   218         var currentState; // last known signal state - see enumNetworkStrengths
   197 
   219 
   198         enumNetworkStrengths.state = {Offline:0, NoSignal:1, Signal1:2,
   220         enumNetworkStrengths.state = {Offline:0, NoSignal:1, Signal1:2,
   199             Signal2:3, Signal3:4, Signal4:5}
   221             Signal2:3, Signal3:4, Signal4:5}
   345     */
   367     */
   346     function BatteryStatus()
   368     function BatteryStatus()
   347     {
   369     {
   348         // Private Member Variables
   370         // Private Member Variables
   349         var batteryIconSrc = new Array(
   371         var batteryIconSrc = new Array(
   350             "<img src=\"statusbar.snippet/icons/battery/batt10.png\" alt=\"\">",
   372             "<img src='" + BATTERY10_SRC + "' alt=''>",
   351             "<img src=\"statusbar.snippet/icons/battery/batt20.png\" alt=\"\">",
   373             "<img src='" + BATTERY20_SRC + "' alt=''>",
   352             "<img src=\"statusbar.snippet/icons/battery/batt30.png\" alt=\"\">",
   374             "<img src='" + BATTERY30_SRC + "' alt=''>",
   353             "<img src=\"statusbar.snippet/icons/battery/batt40.png\" alt=\"\">",
   375             "<img src='" + BATTERY40_SRC + "' alt=''>",
   354             "<img src=\"statusbar.snippet/icons/battery/batt50.png\" alt=\"\">",
   376             "<img src='" + BATTERY50_SRC + "' alt=''>",
   355             "<img src=\"statusbar.snippet/icons/battery/batt60.png\" alt=\"\">",
   377             "<img src='" + BATTERY60_SRC + "' alt=''>",
   356             "<img src=\"statusbar.snippet/icons/battery/batt70.png\" alt=\"\">",
   378             "<img src='" + BATTERY70_SRC + "' alt=''>",
   357             "<img src=\"statusbar.snippet/icons/battery/batt80.png\" alt=\"\">",
   379             "<img src='" + BATTERY80_SRC + "' alt=''>",
   358             "<img src=\"statusbar.snippet/icons/battery/batt90.png\" alt=\"\">",
   380             "<img src='" + BATTERY90_SRC + "' alt=''>",
   359             "<img src=\"statusbar.snippet/icons/battery/batt100.png\" alt=\"\">",
   381             "<img src='" + BATTERY100_SRC + "' alt=''>",
   360             "<img src=\"statusbar.snippet/icons/battery/batt100_charging.png\" alt=\"\">");
   382             "<img src='" + BATTERY100_CHARGING_SRC + "' alt=''>");
   361         var enumBatteryLevels = new Object();
   383         var enumBatteryLevels = new Object();
   362 
   384 
   363         enumBatteryLevels.state = {Level10:0, Level20:1, Level30:2, Level40:3,
   385         enumBatteryLevels.state = {Level10:0, Level20:1, Level30:2, Level40:3,
   364             Level50:4, Level60:5, Level70:6, Level80:7, Level90:8, Level100:9,
   386             Level50:4, Level60:5, Level70:6, Level80:7, Level90:8, Level100:9,
   365             LevelCharging:10}
   387             LevelCharging:10}
   423     */
   445     */
   424     function DownloadStatus()
   446     function DownloadStatus()
   425     {
   447     {
   426         function _enableDownloadIndicator()
   448         function _enableDownloadIndicator()
   427         {
   449         {
   428             var src = 'statusbar.snippet/icons/download_statusbar_icon.png';
   450             var src = '/statusbar/download_statusbar_icon.png';
   429             var tag = '<img id="downloadImage" src="' + src + '" alt="">';
   451             var tag = '<img id="downloadImage" src="' + src + '" alt="">';
   430             document.getElementById('download').innerHTML = tag;
   452             document.getElementById('download').innerHTML = tag;
   431             window.snippets.StatusBarChromeId.repaint();
   453             window.snippets.StatusBarChromeId.repaint();
   432         }
   454         }
   433 
   455 
   499     // Connect page controller signals to slots.
   521     // Connect page controller signals to slots.
   500     window.pageController.titleChanged.connect(
   522     window.pageController.titleChanged.connect(
   501         function(title) {sbTitle.handleTitleChange(title);});
   523         function(title) {sbTitle.handleTitleChange(title);});
   502     window.pageController.partialUrlChanged.connect(
   524     window.pageController.partialUrlChanged.connect(
   503         function(partialUrl) {sbTitle.handlePartialUrlChange(partialUrl);});
   525         function(partialUrl) {sbTitle.handlePartialUrlChange(partialUrl);});
   504     window.pageController.hideSecureIcon.connect(
       
   505         function() {sbLockStatus.removeLockIcon();});
       
   506     window.pageController.showSecureIcon.connect(
   526     window.pageController.showSecureIcon.connect(
   507         function() {sbLockStatus.showLockIcon();});
   527         function(show) {
       
   528             if (show) {
       
   529                 sbLockStatus.showLockIcon();
       
   530             } else {
       
   531                 sbLockStatus.removeLockIcon();
       
   532             }
       
   533         }
       
   534     );
   508 
   535 
   509     // Connect view manager signals to slots.
   536     // Connect view manager signals to slots.
   510     window.views.currentViewChanged.connect(
   537     window.views.currentViewChanged.connect(
   511         function() {
   538         function() {
   512             sbTitle.handleCurrentViewChange();
   539             sbTitle.handleCurrentViewChange();