Floodlight.php
author Dan
Sun, 05 Jul 2009 01:02:47 -0400
changeset 3 45a2d33c0d1b
parent 2 8d081d3128a2
permissions -rw-r--r--
Added preload_js() support.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     1
<?php
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     2
/**!info**
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     3
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     4
  "Plugin Name"  : "Floodlight",
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     5
  "Plugin URI"   : "http://enanocms.org/plugin/floodlight",
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     6
  "Description"  : "A much broader search than Spotlight. Adds auto-completion to the Search sidebar block.",
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     7
  "Author"       : "Dan Fuhry",
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     8
  "Version"      : "1.1.5",
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
     9
  "Author URI"   : "http://enanocms.org/"
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    10
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    11
**!*/
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    12
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    13
$plugins->attachHook('sidebar_fetch_return', 'floodlight_inject_searchflags($return);');
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    14
$plugins->attachHook('autofill_json_request', 'floodlight_perform_search($dataset);');
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    15
$plugins->attachHook('session_started', 'floodlight_add_js_page();');
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    16
$plugins->attachHook('common_post', 'floodlight_intercept_search();');
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    17
$plugins->attachHook('compile_template', 'floodlight_add_js();');
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    18
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    19
function floodlight_inject_searchflags(&$return)
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    20
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    21
  if ( strstr($return[0], '<input name="q"') )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    22
  {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    23
    $hackme =& $return[0];
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    24
  }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    25
  else if ( strstr($return[1], '<input name="q"') )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    26
  {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    27
    $hackme =& $return[1];
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    28
  }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    29
  else
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    30
  {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    31
    return;
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    32
  }
2
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
    33
  $hackme = str_replace('<input name="q"', '<input name="q" autocomplete="off" onkeyup="this.setAttribute(\'autocomplete\', \'off\'); this.onkeyup = null; this.className = \'autofill floodlight\'; autofill_init_element(this, {});"', $hackme);
0
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    34
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    35
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    36
function floodlight_perform_search(&$dataset)
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    37
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    38
  global $db, $session, $paths, $template, $plugins; // Common objects
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    39
  if ( $_GET['type'] == 'floodlight' )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    40
  {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    41
    $results = perform_search($_GET['userinput'], $warnings, false, $word_list);
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    42
    if ( count($results) > 5 )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    43
    {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    44
      $results = array_slice($results, 0, 5);
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    45
    }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    46
    foreach ( $results as $result )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    47
    {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    48
      $dataset[] = array(
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    49
          0 => "go:{$paths->nslist[$result['namespace']]}{$result['page_id']}",
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    50
          'title' => str_replace(array('<highlight>', '</highlight>'), array('<b>', '</b>'), $result['page_name']),
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    51
          'score' => $result['score'],
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    52
          'type' => $result['page_note'],
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    53
          'size' => $result['page_length'],
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    54
        );
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    55
    }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    56
  }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    57
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    58
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    59
function floodlight_add_js_page()
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    60
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    61
  global $db, $session, $paths, $template, $plugins; // Common objects
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    62
  $paths->add_page(array(
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    63
      'name' => 'Floodlight Javascript',
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    64
      'urlname' => 'FloodlightJS',
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    65
      'namespace' => 'Special',
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    66
      'visible' => 0,
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    67
      'protected' => 0,
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    68
      'comments_on' => 0,
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    69
      'special' => 0
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    70
    ));
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    71
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    72
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    73
function floodlight_intercept_search()
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    74
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    75
  global $db, $session, $paths, $template, $plugins; // Common objects
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    76
  if ( $paths->page_id == 'Search' && $paths->namespace == 'Special' )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    77
  {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    78
    if ( isset($_GET['q']) && preg_match('/^go:/', $_GET['q']) )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    79
    {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    80
      redirect(makeUrl(preg_replace('/^go:/', '', $_GET['q'])), '', '', 0);
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    81
    }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    82
  }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    83
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    84
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    85
function floodlight_add_js()
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    86
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    87
  global $db, $session, $paths, $template, $plugins; // Common objects
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    88
  $template->add_header('<script type="text/javascript" src="' . makeUrlNS('Special', 'FloodlightJS', false, true) . '"></script>');
3
45a2d33c0d1b Added preload_js() support.
Dan
parents: 2
diff changeset
    89
  if ( method_exists($template, 'preload_js') )
45a2d33c0d1b Added preload_js() support.
Dan
parents: 2
diff changeset
    90
  {
45a2d33c0d1b Added preload_js() support.
Dan
parents: 2
diff changeset
    91
    $template->preload_js(array('l10n', 'jquery', 'jquery-ui', 'autofill'));
45a2d33c0d1b Added preload_js() support.
Dan
parents: 2
diff changeset
    92
  }
0
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    93
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    94
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    95
function page_Special_FloodlightJS()
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    96
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    97
  global $db, $session, $paths, $template, $plugins; // Common objects
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    98
  header('Content-type: text/javascript');
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
    99
  header('ETag: ' . sha1(__FILE__));
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   100
  
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   101
  global $aggressive_optimize_html;
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   102
  $aggressive_optimize_html = false;
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   103
  
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   104
  echo <<<EOF
1
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   105
var autofill_schemas = window.autofill_schemas || {};
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   106
autofill_schemas.floodlight = {
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   107
  init: function(element, fillclass, params)
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   108
  {
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   109
    params = params || {};
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   110
    $(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=' + fillclass) + '&userinput=', {
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   111
        minChars: 3,
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   112
        formatItem: function(row, _, __)
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   113
        {
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   114
          var type = ( typeof(row.type) == 'string' ) ? row.type : '';
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   115
          var html = '<big>' + row.title + '</big> <small>' + type + '</small>';
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   116
          html += '<br /><small>' + \$lang.get('floodlight_lbl_score') + row.score + '% | ' + row.size + '</small>';
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   117
          return html;
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   118
        },
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   119
        tableHeader: '<tr><th>' + \$lang.get('floodlight_table_heading') + '</th></tr>',
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   120
        showWhenNoResults: true,
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   121
        onItemSelect: function(li)
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   122
        {
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   123
          window.location = makeUrl(li.selectValue.replace(/^go:/, ''));
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   124
        },
2
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   125
        width: 180,
1
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   126
        noResultsHTML: '<tr><td class="row1" style="font-size: smaller;">' + \$lang.get('floodlight_msg_no_results') + '</td></tr>',
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   127
    });
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   128
  }
c9c49ce179e9 Minor change to JS code: runs as soon as available, not onload anymore
Dan
parents: 0
diff changeset
   129
};
2
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   130
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   131
function AutofillFloodlight(el, p)
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   132
{
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   133
  p = p || {};
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   134
  var cn_append = ( el.className ) ? ' ' + el.className : '';
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   135
  el.className = 'autofill floodlight' + cn_append;
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   136
  el.onkeyup = null;
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   137
  autofill_init_element(el, p);
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   138
}
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   139
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   140
addOnloadHook(function()
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   141
  {
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   142
    if ( document.forms[0] && document.forms[0].q )
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   143
    {
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   144
      document.forms[0].q.onkeyup = function() {
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   145
        new AutofillFloodlight(this);
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   146
      };
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   147
    }
8d081d3128a2 Some improvements for 1.1.6 compatibility
Dan
parents: 1
diff changeset
   148
  });
0
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   149
EOF;
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   150
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   151
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   152
/**!language**
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   153
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   154
The following text up to the closing comment tag is JSON language data.
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   155
It is not PHP code but your editor or IDE may highlight it as such. This
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   156
data is imported when the plugin is loaded for the first time; it provides
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   157
the strings displayed by this plugin's interface.
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   158
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   159
You should copy and paste this block when you create your own plugins so
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   160
that these comments and the basic structure of the language data is
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   161
preserved. All language data is in the same format as the Enano core
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   162
language files in the /language/* directories. See the Enano Localization
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   163
Guide and Enano API Documentation for further information on the format of
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   164
language files.
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   165
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   166
The exception in plugin language file format is that multiple languages
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   167
may be specified in the language block. This should be done by way of making
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   168
the top-level elements each a JSON language object, with elements named
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   169
according to the ISO-639-1 language they are representing. The path should be:
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   170
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   171
  root => language ID => categories array, ( strings object => category \
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   172
  objects => strings )
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   173
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   174
All text leading up to first curly brace is stripped by the parser; using
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   175
a code tag makes jEdit and other editors do automatic indentation and
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   176
syntax highlighting on the language data. The use of the code tag is not
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   177
necessary; it is only included as a tool for development.
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   178
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   179
<code>
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   180
{
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   181
  // english
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   182
  eng: {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   183
    categories: [ 'meta', 'floodlight' ],
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   184
    strings: {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   185
      meta: {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   186
        floodlight: 'Floodlight plugin'
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   187
      },
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   188
      floodlight: {
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   189
        table_heading: 'Search results',
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   190
        msg_no_results: 'No results',
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   191
        lbl_score: 'Relevance: ',
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   192
      }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   193
    }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   194
  }
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   195
}
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   196
</code>
4d19ad17b07c First revision, seems working. Yes, using a className of "autofill floodlight" will give your theme/whatever support for this plugin.
Dan
parents:
diff changeset
   197
**!*/