scripts/volume.js
changeset 78 08f8a72b1f7b
parent 61 88b105a901be
equal deleted inserted replaced
77:e5f1f45ea7e2 78:08f8a72b1f7b
    44   set_volume_fill(current_volume);
    44   set_volume_fill(current_volume);
    45 }
    45 }
    46 
    46 
    47 function set_volume(level)
    47 function set_volume(level)
    48 {
    48 {
       
    49   if ( !verify_online() )
       
    50   {
       
    51     return false;
       
    52   }
       
    53   
    49   setAjaxLoading();
    54   setAjaxLoading();
    50   if ( level == current_volume )
    55   if ( level == current_volume )
    51     return false;
    56     return false;
    52   ajaxGet('/action.json/volume/' + level, function()
    57   ajaxGet('/action.json/volume/' + level, function()
    53     {
    58     {
   123             o.parentNode.removeChild(o);
   128             o.parentNode.removeChild(o);
   124           });
   129           });
   125       }
   130       }
   126     }
   131     }
   127   }
   132   }
       
   133   if ( window.iPhone )
       
   134   {
       
   135     // iPhone Safari can't do keyup events
       
   136     field.onblur = function()
       
   137     {
       
   138       if ( this.value == '' )
       
   139       {
       
   140         $(this.parentNode).fadeOut(250, function(o)
       
   141           {
       
   142             o.parentNode.removeChild(o);
       
   143           });
       
   144       }
       
   145       else if ( !this.value.match(/^[0-9]+$/) )
       
   146       {
       
   147         $(this.parentNode).insertBR().insertText('please enter a number');
       
   148       }
       
   149       else
       
   150       {
       
   151         set_volume(parseInt(this.value));
       
   152         $(this.parentNode).fadeOut(250, function(o)
       
   153           {
       
   154             o.parentNode.removeChild(o);
       
   155           });
       
   156       }
       
   157     }
       
   158   }
   128 }
   159 }
   129 
   160 
   130 addOnloadHook(function()
   161 addOnloadHook(function()
   131   {
   162   {
   132     window.onkeyup = function(e)
   163     window.onkeyup = function(e)