includes/clientside/static/misc.js
author Dan
Sat, 07 Jun 2008 12:40:53 -0400
changeset 559 cfdc0aa8af50
parent 550 685e839d934e
child 581 5e8fd89c02ea
permissions -rw-r--r--
[YSlow] Added Expires header on jsres.php
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
// Some additional DHTML functions
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
function fetch_offset(obj) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
  var left_offset = obj.offsetLeft;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     5
  var top_offset = obj.offsetTop;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
  while ((obj = obj.offsetParent) != null) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
    left_offset += obj.offsetLeft;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
    top_offset += obj.offsetTop;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
  return { 'left' : left_offset, 'top' : top_offset };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
function fetch_dimensions(o) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
  var w = o.offsetWidth;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    15
  var h = o.offsetHeight;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    16
  return { 'w' : w, 'h' : h };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    17
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    18
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    19
function findParentForm(o)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    20
{
74
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    21
  if ( o.tagName == 'FORM' )
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    22
    return o;
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    23
  while(true)
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    24
  {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    25
    o = o.parentNode;
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    26
    if ( !o )
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    27
      return false;
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    28
    if ( o.tagName == 'FORM' )
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    29
      return o;
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    30
  }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
    31
  return false;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    32
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    34
function ajaxReverseDNS(o, text)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    35
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    36
  if(text) var ipaddr = text;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    37
  else var ipaddr = o.innerHTML;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    38
  rDnsObj = o;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    39
  rDnsBannerObj = bannerOn('Retrieving reverse DNS info...');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    40
  ajaxGet(stdAjaxPrefix+'&_mode=rdns&ip='+ipaddr, function() {
407
35d94240a197 Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents: 372
diff changeset
    41
      if ( ajax.readyState == 4 && ajax.status == 200 )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    42
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    43
        off = fetch_offset(rDnsObj);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    44
        dim = fetch_dimensions(rDnsObj);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    45
        right = off['left'] + dim['w'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    46
        top = off['top'] + dim['h'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    47
        var thediv = document.createElement('div');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    48
        thediv.className = 'info-box';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    49
        thediv.style.margin = '0';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    50
        thediv.style.position = 'absolute';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    51
        thediv.style.top  = top  + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    52
        thediv.style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    53
        thediv.style.zIndex = getHighestZ() + 2;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    54
        thediv.id = 'mdgDynamic_rDnsInfoDiv_'+Math.floor(Math.random() * 1000000);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    55
        thediv.innerHTML = '<b>Reverse DNS:</b><br />'+ajax.responseText+' <a href="#" onclick="elem = document.getElementById(\''+thediv.id+'\'); elem.innerHTML = \'\'; elem.style.display = \'none\';return false;">Close</a>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    56
        var body = document.getElementsByTagName('body');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    57
        body = body[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    58
        bannerOff(rDnsBannerObj);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    59
        body.appendChild(thediv);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    60
        thediv.style.display = 'block';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    61
        left = fetch_dimensions(thediv);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    62
        thediv.style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    63
        left = right - left['w'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    64
        thediv.style.left = left + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    65
        thediv.style.display = 'block';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    66
        fadeInfoBoxes();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    67
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    68
    });
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    69
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    70
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    71
function bannerOn(text)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    72
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    73
  darken(true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    74
  var thediv = document.createElement('div');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    75
  thediv.className = 'mdg-comment';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
  thediv.style.padding = '0';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    77
  thediv.style.marginLeft = '0';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    78
  thediv.style.position = 'absolute';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    79
  thediv.style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    80
  thediv.style.padding = '4px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    81
  thediv.style.fontSize = '14pt';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    82
  thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    83
  thediv.innerHTML = text;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    84
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    85
  var body = document.getElementsByTagName('body');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    86
  body = body[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    87
  body.appendChild(thediv);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    88
  body.style.cursor = 'wait';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    89
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    90
  thediv.style.display = 'block';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    91
  dim = fetch_dimensions(thediv);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    92
  thediv.style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    93
  bdim = { 'w' : getWidth(), 'h' : getHeight() };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    94
  so = getScrollOffset();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
  
40
723bb7acf914 Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents: 9
diff changeset
    96
  var left = (bdim['w'] / 2) - ( dim['w'] / 2 );
723bb7acf914 Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents: 9
diff changeset
    97
  
723bb7acf914 Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents: 9
diff changeset
    98
  var top  = (bdim['h'] / 2);
723bb7acf914 Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents: 9
diff changeset
    99
  top  = top - ( dim['h'] / 2 );
723bb7acf914 Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents: 9
diff changeset
   100
  
723bb7acf914 Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents: 9
diff changeset
   101
  top = top + so;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   102
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   103
  thediv.style.top  = top  + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   104
  thediv.style.left = left + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   105
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   106
  thediv.style.display = 'block';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   107
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   108
  return thediv.id;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   109
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   110
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   111
function bannerOff(id)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   112
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   113
  e = document.getElementById(id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   114
  if(!e) return;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   115
  e.innerHTML = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   116
  e.style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   117
  var body = document.getElementsByTagName('body');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   118
  body = body[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   119
  body.style.cursor = 'default';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   120
  enlighten(true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   121
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   122
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   123
function disableUnload(message)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   124
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   125
  if(typeof message != 'string') message = 'You may want to save your changes first.';
440
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   126
  window._unloadmsg = message;
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   127
  window.onbeforeunload = function(e)
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   128
  {
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   129
    if ( !e )
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   130
      e = window.event;
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   131
    e.returnValue = window._unloadmsg;
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   132
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   133
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   134
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   135
function enableUnload()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   136
{
440
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   137
  window._unloadmsg = null;
105457df35e5 Integrating patch for PHP 6.0-dev compatibility
Dan
parents: 339
diff changeset
   138
  window.onbeforeunload = null;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   139
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   140
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   141
/**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   142
 * Gets the highest z-index of all divs in the document
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   143
 * @return integer
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   144
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   145
function getHighestZ()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   146
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   147
  z = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   148
  var divs = document.getElementsByTagName('div');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   149
  for(var i = 0; i < divs.length; i++)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   150
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   151
    if(divs[i].style.zIndex > z) z = divs[i].style.zIndex;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   152
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   153
  return z;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   154
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   155
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   156
function isKeyPressed(event)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   157
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   158
  if (event.shiftKey==1)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   159
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   160
    shift = true;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   161
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   162
  else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   163
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   164
    shift = false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   165
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   166
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   167
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   168
function moveDiv(div, newparent)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   169
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   170
  var backup = div;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   171
  var oldparent = div.parentNode;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   172
  oldparent.removeChild(div);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   173
  newparent.appendChild(backup);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   174
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   175
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   176
function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   177
function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   178
function eraseCookie(name) {createCookie(name,"",-1);}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   179
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   180
var busyBannerID;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   181
function goBusy(msg)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   182
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   183
  if(!msg) msg = 'Please wait...';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   184
  body = document.getElementsByTagName('body');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   185
  body = body[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   186
  body.style.cursor = 'wait';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   187
  busyBannerID = bannerOn(msg);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   188
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   189
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   190
function unBusy()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   191
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   192
  body = document.getElementsByTagName('body');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   193
  body = body[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   194
  body.style.cursor = 'default';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   195
  bannerOff(busyBannerID);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   196
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   197
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   198
function setAjaxLoading()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   199
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   200
  if ( document.getElementById('ajaxloadicon') )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   201
  {
200
63fddf1335d9 Nothing real special. The AJAX loading icon can be changed using the Javascript variable ajax_load_icon in header.tpl.
Dan
parents: 176
diff changeset
   202
    document.getElementById('ajaxloadicon').src=ajax_load_icon;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   203
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   204
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   205
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   206
function unsetAjaxLoading()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   207
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   208
  if ( document.getElementById('ajaxloadicon') )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   209
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   210
    document.getElementById('ajaxloadicon').src=scriptPath + '/images/spacer.gif';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   211
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   212
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   213
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   214
/*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   215
 * AJAX login box (experimental)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents: 426
diff changeset
   216
 * Moved / rewritten in login.js
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   217
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   218
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents: 426
diff changeset
   219
// Included only for API-compatibility
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   220
function ajaxPromptAdminAuth(call_on_ok, level)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   221
{
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents: 426
diff changeset
   222
  ajaxLogonInit(call_on_ok, level);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   223
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   224
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   225
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   226
function sprintf()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   227
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   228
  if (!arguments || arguments.length < 1 || !RegExp)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   229
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   230
    return;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   231
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   232
  var str = arguments[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   233
  var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   234
  var a = b = [], numSubstitutions = 0, numMatches = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   235
  while (a = re.exec(str))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   236
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   237
    var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   238
    var pPrecision = a[5], pType = a[6], rightPart = a[7];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   239
    
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   240
    //alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   241
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   242
    numMatches++;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   243
    if (pType == '%')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   244
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   245
      subst = '%';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   246
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   247
    else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   248
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   249
      numSubstitutions++;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   250
      if (numSubstitutions >= arguments.length)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   251
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   252
        alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   253
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   254
      var param = arguments[numSubstitutions];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   255
      var pad = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   256
             if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   257
        else if (pPad) pad = pPad;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   258
      var justifyRight = true;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   259
             if (pJustify && pJustify === "-") justifyRight = false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   260
      var minLength = -1;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   261
             if (pMinLength) minLength = parseInt(pMinLength);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   262
      var precision = -1;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   263
             if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   264
      var subst = param;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   265
             if (pType == 'b') subst = parseInt(param).toString(2);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   266
        else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   267
        else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   268
        else if (pType == 'u') subst = Math.abs(param);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   269
        else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   270
        else if (pType == 'o') subst = parseInt(param).toString(8);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   271
        else if (pType == 's') subst = param;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   272
        else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   273
        else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   274
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   275
    str = leftpart + subst + rightPart;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   276
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   277
  return str;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   278
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   279
74
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   280
/**
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   281
 * Insert a DOM object _after_ the specified child.
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   282
 * @param object Parent node
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   283
 * @param object Node to insert
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   284
 * @param object Node to insert after
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   285
 */
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   286
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   287
function insertAfter(parent, baby, bigsister)
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   288
{
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   289
  try
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   290
  {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   291
    if ( parent.childNodes[parent.childNodes.length-1] == bigsister )
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   292
      parent.appendChild(baby);
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   293
    else
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   294
      parent.insertBefore(baby, bigsister.nextSibling);
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   295
  }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   296
  catch(e)
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   297
  {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   298
    alert(e.toString());
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   299
    if ( window.console )
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   300
    {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   301
      // Firebug support
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   302
      window.console.warn(e);
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   303
    }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   304
  }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   305
}
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   306
125
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   307
/**
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   308
 * Validates an e-mail address.
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   309
 * @param string E-mail address
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   310
 * @return bool
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   311
 */
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   312
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   313
function validateEmail(email)
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   314
{
504
bc8e0e9ee01d Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents: 501
diff changeset
   315
  return ( email.match(/^(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*)*<[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*>)$/) ) ? true : false;
125
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   316
}
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   317
334
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   318
/**
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   319
 * Validates a username.
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   320
 * @param string Username to test
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   321
 * @return bool
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   322
 */
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   323
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   324
function validateUsername(username)
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   325
{
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   326
  var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', '');
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   327
  return ( username.match(regex) ) ? true : false;
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   328
}
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   329
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   330
/**
334
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   331
 * Equivalent of PHP's time()
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   332
 * @return int
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   333
 */
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   334
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   335
function unix_time()
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   336
{
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   337
  return parseInt((new Date()).getTime()/1000);
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   338
}
c72b545f1304 More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents: 326
diff changeset
   339
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   340
/*
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   341
 * Utility functions, moved from windows.js
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   342
 */
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   343
 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   344
// getElementWidth() and getElementHeight()
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   345
// Source: http://www.aspandjavascript.co.uk/javascript/javascript_api/get_element_width_height.asp
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   346
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   347
function getElementHeight(Elem) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   348
  if (ns4) 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   349
  {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   350
    var elem = getObjNN4(document, Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   351
    return elem.clip.height;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   352
  } 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   353
  else
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   354
  {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   355
    if(document.getElementById) 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   356
    {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   357
      var elem = document.getElementById(Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   358
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   359
    else if (document.all)
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   360
    {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   361
      var elem = document.all[Elem];
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   362
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   363
    if (op5) 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   364
    { 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   365
      xPos = elem.style.pixelHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   366
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   367
    else
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   368
    {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   369
      xPos = elem.offsetHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   370
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   371
    return xPos;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   372
  } 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   373
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   374
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   375
function getElementWidth(Elem) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   376
  if (ns4) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   377
    var elem = getObjNN4(document, Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   378
    return elem.clip.width;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   379
  } else {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   380
    if(document.getElementById) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   381
      var elem = document.getElementById(Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   382
    } else if (document.all){
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   383
      var elem = document.all[Elem];
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   384
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   385
    if (op5) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   386
      xPos = elem.style.pixelWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   387
    } else {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   388
      xPos = elem.offsetWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   389
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   390
    return xPos;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   391
  }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   392
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   393
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   394
function getHeight() {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   395
  var myHeight = 0;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   396
  if( typeof( window.innerWidth ) == 'number' ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   397
    myHeight = window.innerHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   398
  } else if( document.documentElement &&
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   399
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   400
    myHeight = document.documentElement.clientHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   401
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   402
    myHeight = document.body.clientHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   403
  }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   404
  return myHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   405
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   406
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   407
function getWidth() {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   408
  var myWidth = 0;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   409
  if( typeof( window.innerWidth ) == 'number' ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   410
    myWidth = window.innerWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   411
  } else if( document.documentElement &&
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   412
      ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   413
    myWidth = document.documentElement.clientWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   414
  } else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   415
    myWidth = document.body.clientWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   416
  }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   417
  return myWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   418
}
426
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   419
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   420
/**
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   421
 * Sanitizes a page URL string so that it can safely be stored in the database.
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   422
 * @param string Page ID to sanitize
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   423
 * @return string Cleaned text
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   424
 */
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   425
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   426
function sanitize_page_id(page_id)
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   427
{
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   428
  // Remove character escapes
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   429
  page_id = dirtify_page_id(page_id);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   430
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   431
  var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   432
  pid_clean = page_id.replace(regex, 'X');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   433
  var pid_dirty = [];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   434
  for ( var i = 0; i < pid_clean.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   435
    pid_dirty[i] = pid_clean.substr(i, 1);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   436
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   437
  for ( var i = 0; i < pid_dirty.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   438
  {
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 537
diff changeset
   439
    var chr = pid_dirty[i];
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 537
diff changeset
   440
    if ( chr == 'X' )
426
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   441
      continue;
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 537
diff changeset
   442
    var cid = chr.charCodeAt(0);
426
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   443
    cid = cid.toString(16).toUpperCase();
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   444
    if ( cid.length < 2 )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   445
    {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   446
      cid = '0' + cid;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   447
    }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   448
    pid_dirty[i] = "." + cid;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   449
  }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   450
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   451
  var pid_chars = [];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   452
  for ( var i = 0; i < page_id.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   453
    pid_chars[i] = page_id.substr(i, 1);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   454
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   455
  var page_id_cleaned = '';
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   456
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   457
  for ( var id in pid_chars )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   458
  {
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 537
diff changeset
   459
    var chr = pid_chars[id];
426
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   460
    if ( pid_dirty[id] == 'X' )
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 537
diff changeset
   461
      page_id_cleaned += chr;
426
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   462
    else
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   463
      page_id_cleaned += pid_dirty[id];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   464
  }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   465
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   466
  return page_id_cleaned;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   467
}
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   468
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   469
/**
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   470
 * Removes character escapes in a page ID string
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   471
 * @param string Page ID string to dirty up
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   472
 * @return string
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   473
 */
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   474
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   475
function dirtify_page_id(page_id)
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   476
{
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   477
  // First, replace spaces with underscores
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   478
  page_id = page_id.replace(/ /g, '_');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   479
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   480
  var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   481
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   482
  if ( matches != null )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   483
  {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   484
    for ( var i = 0; i < matches.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   485
    {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   486
      var match = matches[i];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   487
      var byt = (match.substr(1)).toUpperCase();
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   488
      var code = eval("0x" + byt);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   489
      var regex = new RegExp('\\.' + byt, 'g');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   490
      page_id = page_id.replace(regex, String.fromCharCode(code));
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   491
    }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   492
  }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   493
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   494
  return page_id;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   495
}
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   496
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   497
/*
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   498
 * Expandable fieldsets
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   499
 */
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   500
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   501
var expander_onload = function()
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   502
{
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   503
  var sets = document.getElementsByTagName('fieldset');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   504
  if ( sets.length < 1 )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   505
    return false;
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   506
  var init_us = [];
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   507
  for ( var index = 0; index < sets.length; index++ )
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   508
  {
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   509
    var mode = sets[index].getAttribute('enano:expand');
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   510
    if ( mode == 'closed' || mode == 'open' )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   511
    {
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   512
      init_us.push(sets[index]);
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   513
    }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   514
  }
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   515
  for ( var k = 0; k < init_us.length; k++ )
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   516
  {
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   517
    expander_init_element(init_us[k]);
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   518
  }
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   519
}
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   520
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   521
function expander_init_element(el)
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   522
{
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   523
  // get the legend tag
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   524
  var legend = el.getElementsByTagName('legend')[0];
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   525
  if ( !legend )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   526
    return false;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   527
  // existing content
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   528
  var existing_inner = legend.innerHTML;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   529
  // blank the innerHTML and replace it with a link
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   530
  legend.innerHTML = '';
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   531
  var button = document.createElement('a');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   532
  button.className = 'expander expander-open';
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   533
  button.innerHTML = existing_inner;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   534
  button.href = '#';
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   535
  
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   536
  legend.appendChild(button);
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   537
  
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   538
  button.onclick = function()
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   539
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   540
    try
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   541
    {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   542
      expander_handle_click(this);
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   543
    }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   544
    catch(e)
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   545
    {
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   546
      console.debug('Exception caught: ', e);
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   547
    }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   548
    return false;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   549
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   550
  
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   551
  if ( el.getAttribute('enano:expand') == 'closed' )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   552
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   553
    expander_close(el);
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   554
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   555
}
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   556
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   557
function expander_handle_click(el)
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   558
{
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   559
  if ( el.parentNode.parentNode.tagName != 'FIELDSET' )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   560
    return false;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   561
  var parent = el.parentNode.parentNode;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   562
  if ( parent.getAttribute('enano:expand') == 'closed' )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   563
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   564
    expander_open(parent);
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   565
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   566
  else
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   567
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   568
    expander_close(parent);
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   569
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   570
}
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   571
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   572
function expander_close(el)
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   573
{
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   574
  var children = el.childNodes;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   575
  for ( var i = 0; i < children.length; i++ )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   576
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   577
    var child = children[i];
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   578
    if ( child.tagName == 'LEGEND' )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   579
    {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   580
      var a = child.getElementsByTagName('a')[0];
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   581
      $(a).rmClass('expander-open');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   582
      $(a).addClass('expander-closed');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   583
      continue;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   584
    }
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   585
    if ( child.style )
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   586
    {
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   587
      child.expander_meta_old_state = child.style.display;
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   588
      child.style.display = 'none';
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   589
    }
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   590
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   591
  el.expander_meta_padbak = el.style.padding;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   592
  el.setAttribute('enano:expand', 'closed');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   593
}
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   594
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   595
function expander_open(el)
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   596
{
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   597
  var children = el.childNodes;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   598
  for ( var i = 0; i < children.length; i++ )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   599
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   600
    var child = children[i];
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   601
    if ( child.tagName == 'LEGEND' )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   602
    {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   603
      var a = child.getElementsByTagName('a')[0];
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   604
      $(a).rmClass('expander-closed');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   605
      $(a).addClass('expander-open');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   606
      continue;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   607
    }
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   608
    if ( child.expander_meta_old_state && child.style )
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   609
    {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   610
      child.style.display = child.expander_meta_old_state;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   611
      child.expander_meta_old_state = null;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   612
    }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   613
    else
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   614
    {
513
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   615
      if ( child.style )
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   616
      {
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   617
        child.style.display = null;
c15fbf197a54 AJAX interface for listing ACL rules implemented
Dan
parents: 504
diff changeset
   618
      }
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   619
    }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   620
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   621
  if ( el.expander_meta_padbak )
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   622
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   623
    el.style.padding = el.expander_meta_padbak;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   624
    el.expander_meta_padbak = null;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   625
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   626
  else
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   627
  {
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   628
    el.style.padding = null;
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   629
  }
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   630
  el.setAttribute('enano:expand', 'open');
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   631
}
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   632
537
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   633
/**
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   634
 * Equivalent to PHP's explode function.
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   635
 */
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   636
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   637
function explode(needle, haystack)
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   638
{
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   639
  return haystack.split(needle);
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   640
}
547b7ba6d535 Added a really simple message box system based on miniPrompts, this will be used for confirmation windows like delete_page, clear_logs, delvote, etc.
Dan
parents: 520
diff changeset
   641
501
9367161b2457 Added support for an enano:expand=(closed|open) attribute on fieldsets to make them act like GTK expandable widgets; implementation is on Special:CreatePage
Dan
parents: 458
diff changeset
   642
addOnloadHook(expander_onload);