scripts/volume.js
author Dan
Tue, 26 May 2009 15:26:59 -0400
changeset 72 b8730fcd64a9
parent 61 88b105a901be
child 78 08f8a72b1f7b
permissions -rw-r--r--
Some UI changes I don't feel like auditing over and over until I understand (commiting some very old changes here)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
     1
/**
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
     2
 * Volume widget presentation code
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
     3
 * 
6
5f35ebc4f9bb First release version. Renamed to Greyhound and readme/license files added.
Dan
parents: 5
diff changeset
     4
 * Greyhound - real web management for Amarok
5
9b96265b5918 Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents: 2
diff changeset
     5
 * Copyright (C) 2008 Dan Fuhry
2
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
     6
 *
5
9b96265b5918 Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents: 2
diff changeset
     7
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
9b96265b5918 Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents: 2
diff changeset
     8
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
9b96265b5918 Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents: 2
diff changeset
     9
 *
9b96265b5918 Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents: 2
diff changeset
    10
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9b96265b5918 Relicensed to GPLv2. Previous revisions should not be downloaded as they do not contain copies of appropriate licenses, which will be added in a later commit. Completed interface for mobile devices.
Dan
parents: 2
diff changeset
    11
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
2
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    12
 */
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    13
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    14
var current_volume = 0;
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    15
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    16
function set_volume_fill(amount)
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    17
{
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    18
  amount = 10 * ( Math.round(amount / 10) );
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    19
  if ( amount == 0 )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    20
    amount = -10;
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    21
  for ( var i = 0; i <= amount; i += 10 )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    22
  {
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    23
    if ( !$('volbtn_' + i).hasClass('volume_button_active') )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    24
    {
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    25
      $('volbtn_' + i).addClass('volume_button_active');
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    26
    }
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    27
  }
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    28
  for ( ; i <= 100; i += 10 )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    29
  {
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    30
    if ( $('volbtn_' + i).hasClass('volume_button_active') )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    31
    {
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    32
      $('volbtn_' + i).rmClass('volume_button_active');
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    33
    }
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    34
  }
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    35
}
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    36
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    37
function volume_over(amount)
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    38
{
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    39
  set_volume_fill(amount);
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    40
}
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    41
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    42
function volume_out()
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    43
{
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    44
  set_volume_fill(current_volume);
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    45
}
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    46
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    47
function set_volume(level)
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    48
{
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    49
  setAjaxLoading();
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    50
  if ( level == current_volume )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    51
    return false;
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    52
  ajaxGet('/action.json/volume/' + level, function()
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    53
    {
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    54
      if ( ajax.readyState == 4 && ajax.status == 200 )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    55
      {
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    56
        unsetAjaxLoading();
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    57
        var response = (' ' + ajax.responseText).substr(1);
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    58
        // quickie JSON parser :)
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    59
        response = eval('(' + response + ')');
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    60
        // update volume
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    61
        if ( response.volume != current_volume )
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    62
        {
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    63
          set_volume_fill(response.volume);
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    64
          current_volume = response.volume;
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    65
        }
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    66
      }
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    67
    });
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    68
}
860ba7141641 Should be nearly finished now - includes volume control, length measurement, and seems pretty stable
Dan
parents:
diff changeset
    69
58
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    70
function volume_custom_form()
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    71
{
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    72
  if ( $('volumebox').object )
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    73
  {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    74
    return false;
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    75
  }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    76
  var box = document.createElement('div');
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    77
  $(box)
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    78
    .css('position', 'absolute')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    79
    .css('padding', '50px 80px')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    80
    .css('background-image', 'url(/trans80.png)')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    81
    .css('color', 'black')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    82
    .css('text-align', 'center')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    83
    .attr('id', 'volumebox')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    84
    .insertText('volume:')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    85
    .insertBR().insertBR()
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    86
    .opacity(0);
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    87
  document.body.appendChild(box);
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    88
  
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    89
  var field = document.createElement('input');
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    90
  $(field)
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    91
    .attr('type', 'text')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    92
    .attr('value', '')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    93
    .attr('size', '7')
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    94
    .css('text-align', 'center');
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    95
  box.appendChild(field);
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    96
  
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    97
  $(box)
60
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
    98
    .css('top',  (( getHeight() / 2 ) - ( $(box).Height() / 2 ) + getScrollOffset()) + 'px')
58
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
    99
    .css('left', (( $(document.body).Width() / 2 ) - ( $(box).Width() / 2 )) + 'px');
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   100
  
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   101
  $(box).fadeIn(250);
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   102
  field.focus();
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   103
  field.onkeyup = function(e)
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   104
  {
61
88b105a901be Escape key closes volume box
Dan
parents: 60
diff changeset
   105
    if ( e.keyCode == 13 || e.keyCode == 27 )
58
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   106
    {
61
88b105a901be Escape key closes volume box
Dan
parents: 60
diff changeset
   107
      if ( this.value == '' || e.keyCode == 27 )
58
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   108
      {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   109
        $(this.parentNode).fadeOut(250, function(o)
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   110
          {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   111
            o.parentNode.removeChild(o);
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   112
          });
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   113
      }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   114
      else if ( !this.value.match(/^[0-9]+$/) )
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   115
      {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   116
        $(this.parentNode).insertBR().insertText('please enter a number');
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   117
      }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   118
      else
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   119
      {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   120
        set_volume(parseInt(this.value));
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   121
        $(this.parentNode).fadeOut(250, function(o)
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   122
          {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   123
            o.parentNode.removeChild(o);
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   124
          });
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   125
      }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   126
    }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   127
  }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   128
}
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   129
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   130
addOnloadHook(function()
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   131
  {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   132
    window.onkeyup = function(e)
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   133
    {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   134
      if ( e.keyCode == 86 )
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   135
      {
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   136
        volume_custom_form();
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   137
      }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   138
    }
05a69bab5f10 Added custom volume setting function (press v in the playlist window)
Dan
parents: 6
diff changeset
   139
  });
59
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   140
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   141
function getHeight() {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   142
  var myHeight = 0;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   143
  if( typeof( window.innerWidth ) == 'number' ) {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   144
    myHeight = window.innerHeight;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   145
  } else if( document.documentElement &&
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   146
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   147
    myHeight = document.documentElement.clientHeight;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   148
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   149
    myHeight = document.body.clientHeight;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   150
  }
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   151
  return myHeight;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   152
}
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   153
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   154
function getWidth() {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   155
  var myWidth = 0;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   156
  if( typeof( window.innerWidth ) == 'number' ) {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   157
    myWidth = window.innerWidth;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   158
  } else if( document.documentElement &&
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   159
      ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   160
    myWidth = document.documentElement.clientWidth;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   161
  } else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   162
    myWidth = document.body.clientWidth;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   163
  }
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   164
  return myWidth;
a4ca1e7c0073 Fixed position of floating volume div
Dan
parents: 58
diff changeset
   165
}
60
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   166
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   167
function getScrollOffset(el)
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   168
{
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   169
  var position;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   170
  var s = el || self;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   171
  el = el || document;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   172
  if ( el.scrollTop )
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   173
  {
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   174
    position = el.scrollTop;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   175
  }
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   176
  else if (s.pageYOffset)
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   177
  {
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   178
    position = self.pageYOffset;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   179
  }
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   180
  else if (document.documentElement && document.documentElement.scrollTop)
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   181
  {
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   182
    position = document.documentElement.scrollTop;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   183
  }
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   184
  else if (document.body)
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   185
  {
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   186
    position = document.body.scrollTop;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   187
  }
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   188
  return position;
acc7755e15b6 ...it should be cool with scrolling now.
Dan
parents: 59
diff changeset
   189
}