includes/clientside/static/misc.js
author Dan
Fri, 07 Mar 2008 00:16:15 -0500
changeset 488 5560ff856dd7
parent 458 c433348f3628
child 501 9367161b2457
permissions -rw-r--r--
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
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
 * Search boxes
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   216
 */
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
function buildSearchBoxes()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   219
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   220
  var divs = document.getElementsByTagName('*');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   221
  var boxes = new Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   222
  for ( var i = 0; i < divs.length; i++ )
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
    if ( divs[i].className)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   225
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   226
      if ( divs[i].className.substr(0, 9) == 'searchbox' )
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
        boxes.push(divs[i]);
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
    }
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
  for ( var i = 0; i < boxes.length; i++ )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   233
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   234
    if ( boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/) )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   235
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   236
      var width = boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   237
      width = parseInt(width[1]);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   238
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   239
    else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   240
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   241
      var width = 120;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   242
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   243
    createSearchBox(boxes[i], width);
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
}
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
function createSearchBox(parent, width)
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
  if ( typeof(parent) != 'object')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   250
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   251
    alert('BUG: createSearchBox(): parent is not an object');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   252
    return false;
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
  //parent.style.padding = '0px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   255
  //parent.style.textAlign = 'center';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   256
  parent.style.width = width + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   257
  var submit = document.createElement('div');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   258
  submit.onclick = function() { searchFormSubmit(this); };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   259
  submit.className = 'js-search-submit';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   260
  var input = document.createElement('input');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   261
  input.className = 'js-search-box';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   262
  input.value = 'Search';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   263
  input.name = 'q';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   264
  input.style.width = ( width - 28 ) + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   265
  input.onfocus = function() { if ( this.value == 'Search' ) this.value = ''; };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   266
  input.onblur  = function() { if ( this.value == '' ) this.value = 'Search'; };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   267
  parent.appendChild(input);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   268
  var off = fetch_offset(input);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   269
  var top = off['top'] + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   270
  var left = ( parseInt(off['left']) + ( width - 24 ) ) + 'px';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   271
  submit.style.top = top;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   272
  submit.style.left = left;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   273
  parent.appendChild(submit);
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
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   276
function searchFormSubmit(obj)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   277
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   278
  var input = obj.previousSibling;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   279
  if ( input.value == 'Search' || input.value == '' )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   280
    return false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   281
  var p = obj;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   282
  while(true)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   283
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   284
    p = p.parentNode;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   285
    if ( !p )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   286
      break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   287
    if ( typeof(p.tagName) != 'string' )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   288
      break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   289
    else if ( p.tagName.toLowerCase() == 'form' )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   290
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   291
      p.submit();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   292
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   293
    else if ( p.tagName.toLowerCase() == 'body' )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   294
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   295
      break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   296
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   297
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   298
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   299
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   300
/*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   301
 * AJAX login box (experimental)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents: 426
diff changeset
   302
 * Moved / rewritten in login.js
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   303
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   304
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents: 426
diff changeset
   305
// Included only for API-compatibility
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   306
function ajaxPromptAdminAuth(call_on_ok, level)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   307
{
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents: 426
diff changeset
   308
  ajaxLogonInit(call_on_ok, level);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   309
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   310
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   311
// 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
   312
function sprintf()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   313
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   314
  if (!arguments || arguments.length < 1 || !RegExp)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   315
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   316
    return;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   317
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   318
  var str = arguments[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   319
  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
   320
  var a = b = [], numSubstitutions = 0, numMatches = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   321
  while (a = re.exec(str))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   322
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   323
    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
   324
    var pPrecision = a[5], pType = a[6], rightPart = a[7];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   325
    
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   326
    //alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   327
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   328
    numMatches++;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   329
    if (pType == '%')
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   330
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   331
      subst = '%';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   332
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   333
    else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   334
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   335
      numSubstitutions++;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   336
      if (numSubstitutions >= arguments.length)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   337
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   338
        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
   339
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   340
      var param = arguments[numSubstitutions];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   341
      var pad = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   342
             if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   343
        else if (pPad) pad = pPad;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   344
      var justifyRight = true;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   345
             if (pJustify && pJustify === "-") justifyRight = false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   346
      var minLength = -1;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   347
             if (pMinLength) minLength = parseInt(pMinLength);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   348
      var precision = -1;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   349
             if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   350
      var subst = param;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   351
             if (pType == 'b') subst = parseInt(param).toString(2);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   352
        else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   353
        else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   354
        else if (pType == 'u') subst = Math.abs(param);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   355
        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
   356
        else if (pType == 'o') subst = parseInt(param).toString(8);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   357
        else if (pType == 's') subst = param;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   358
        else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   359
        else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   360
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   361
    str = leftpart + subst + rightPart;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   362
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   363
  return str;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   364
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   365
74
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   366
/**
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   367
 * 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
   368
 * @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
   369
 * @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
   370
 * @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
   371
 */
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   372
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   373
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
   374
{
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   375
  try
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   376
  {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   377
    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
   378
      parent.appendChild(baby);
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   379
    else
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   380
      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
   381
  }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   382
  catch(e)
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   383
  {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   384
    alert(e.toString());
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   385
    if ( window.console )
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   386
    {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   387
      // Firebug support
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   388
      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
   389
    }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   390
  }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   391
}
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 60
diff changeset
   392
125
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   393
/**
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   394
 * 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
   395
 * @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
   396
 * @return bool
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   397
 */
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   398
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   399
function validateEmail(email)
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   400
{
295
f948557af068 Add warning in installer for PHP < 5.2.0; hopefully fix validation of e-mail addresses with dashes
Dan
parents: 281
diff changeset
   401
  return ( email.match(/^(?:[\w\d_-]+\.?)+@((?:(?:[\w\d_-]\-?)+\.)+\w{2,4}|localhost)$/) ) ? true : false;
125
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   402
}
fb31c951d3a2 Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents: 85
diff changeset
   403
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
   404
/**
348
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   405
 * 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
   406
 * @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
   407
 * @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
   408
 */
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   409
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   410
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
   411
{
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   412
  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
   413
  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
   414
}
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   415
87e08a6e4fec Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents: 340
diff changeset
   416
/**
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
   417
 * 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
   418
 * @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
   419
 */
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
   420
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
   421
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
   422
{
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
   423
  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
   424
}
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
   425
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   426
/*
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   427
 * Utility functions, moved from windows.js
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   428
 */
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   429
 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   430
// getElementWidth() and getElementHeight()
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   431
// 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
   432
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   433
function getElementHeight(Elem) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   434
  if (ns4) 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   435
  {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   436
    var elem = getObjNN4(document, Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   437
    return elem.clip.height;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   438
  } 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   439
  else
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   440
  {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   441
    if(document.getElementById) 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   442
    {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   443
      var elem = document.getElementById(Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   444
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   445
    else if (document.all)
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   446
    {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   447
      var elem = document.all[Elem];
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   448
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   449
    if (op5) 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   450
    { 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   451
      xPos = elem.style.pixelHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   452
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   453
    else
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   454
    {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   455
      xPos = elem.offsetHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   456
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   457
    return xPos;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   458
  } 
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   459
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   460
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   461
function getElementWidth(Elem) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   462
  if (ns4) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   463
    var elem = getObjNN4(document, Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   464
    return elem.clip.width;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   465
  } else {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   466
    if(document.getElementById) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   467
      var elem = document.getElementById(Elem);
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   468
    } else if (document.all){
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   469
      var elem = document.all[Elem];
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   470
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   471
    if (op5) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   472
      xPos = elem.style.pixelWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   473
    } else {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   474
      xPos = elem.offsetWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   475
    }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   476
    return xPos;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   477
  }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   478
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   479
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   480
function getHeight() {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   481
  var myHeight = 0;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   482
  if( typeof( window.innerWidth ) == 'number' ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   483
    myHeight = window.innerHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   484
  } else if( document.documentElement &&
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   485
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   486
    myHeight = document.documentElement.clientHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   487
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   488
    myHeight = document.body.clientHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   489
  }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   490
  return myHeight;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   491
}
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   492
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   493
function getWidth() {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   494
  var myWidth = 0;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   495
  if( typeof( window.innerWidth ) == 'number' ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   496
    myWidth = window.innerWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   497
  } else if( document.documentElement &&
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   498
      ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   499
    myWidth = document.documentElement.clientWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   500
  } else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   501
    myWidth = document.body.clientWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   502
  }
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   503
  return myWidth;
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 413
diff changeset
   504
}
426
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   505
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   506
/**
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   507
 * Sanitizes a page URL string so that it can safely be stored in the database.
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   508
 * @param string Page ID to sanitize
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   509
 * @return string Cleaned text
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   510
 */
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   511
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   512
function sanitize_page_id(page_id)
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   513
{
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   514
  // Remove character escapes
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   515
  page_id = dirtify_page_id(page_id);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   516
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   517
  var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   518
  pid_clean = page_id.replace(regex, 'X');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   519
  var pid_dirty = [];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   520
  for ( var i = 0; i < pid_clean.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   521
    pid_dirty[i] = pid_clean.substr(i, 1);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   522
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   523
  for ( var i = 0; i < pid_dirty.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   524
  {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   525
    var char = pid_dirty[i];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   526
    if ( char == 'X' )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   527
      continue;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   528
    var cid = char.charCodeAt(0);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   529
    cid = cid.toString(16).toUpperCase();
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   530
    if ( cid.length < 2 )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   531
    {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   532
      cid = '0' + cid;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   533
    }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   534
    pid_dirty[i] = "." + cid;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   535
  }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   536
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   537
  var pid_chars = [];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   538
  for ( var i = 0; i < page_id.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   539
    pid_chars[i] = page_id.substr(i, 1);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   540
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   541
  var page_id_cleaned = '';
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   542
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   543
  for ( var id in pid_chars )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   544
  {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   545
    var char = pid_chars[id];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   546
    if ( pid_dirty[id] == 'X' )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   547
      page_id_cleaned += char;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   548
    else
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   549
      page_id_cleaned += pid_dirty[id];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   550
  }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   551
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   552
  return page_id_cleaned;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   553
}
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   554
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   555
/**
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   556
 * Removes character escapes in a page ID string
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   557
 * @param string Page ID string to dirty up
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   558
 * @return string
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   559
 */
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   560
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   561
function dirtify_page_id(page_id)
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   562
{
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   563
  // First, replace spaces with underscores
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   564
  page_id = page_id.replace(/ /g, '_');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   565
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   566
  var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   567
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   568
  if ( matches != null )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   569
  {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   570
    for ( var i = 0; i < matches.length; i++ )
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   571
    {
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   572
      var match = matches[i];
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   573
      var byt = (match.substr(1)).toUpperCase();
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   574
      var code = eval("0x" + byt);
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   575
      var regex = new RegExp('\\.' + byt, 'g');
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   576
      page_id = page_id.replace(regex, String.fromCharCode(code));
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   577
    }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   578
  }
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   579
  
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   580
  return page_id;
f5718d7c2a6a Modernized Special:CreatePage.
Dan
parents: 420
diff changeset
   581
}