CGI-Application-Search

 view release on metacpan or  search on metacpan

lib/CGI/Application/Search/Tutorial.pm  view on Meta::CPAN

mean you. Thanks.

=head2 Step 7: Rejoice

You've just completed the world's easiest search system setup!  Now go
setup that indexing cronjob.

=head1 AJAX USAGE

L<CGI::Application::Search> provides 2 features implemented in AJAX
(Asynchronous Javascript And XML). These are:

=over

=item Non-Refresh Search

Only the relevant portions of the page
are changed, not the entire page. This results in a faster search, especially
if the page is surrounded by other dynamic elements (navigation, side bars, etc).

=item Auto-Suggest

lib/CGI/Application/Search/Tutorial.pm  view on Meta::CPAN


    <div id="search_listing"></div>

    <script type="text/javascript">
    <!--
        new Ajax.Updater(
            'search_listing',
            url,
            {
                parameters: query,
                asynchronous: 1,
                onLoading: function(request) {
                    $('search_listing').innerHTML = "<strong>" + msg + " ...</strong>";
                }
            }
        );
    -->
    </script>


You can use the same template for both the inital request to view the full

templates/ajax_search_results.tmpl  view on Meta::CPAN

<!--
// search with a query string and a message to display
function ajax_search(query, msg) {
    if( Ajax.getTransport != false ) {
        query = query + '&ajax=1';
        new Ajax.Updater( 
            'search_listing',  
            url, 
            { 
                parameters: query,
                asynchronous: 1,
                onLoading: function(request) {
                    $('search_listing').innerHTML = "<strong>" + msg + " ...</strong>";
                } 
            } 
        );
    } else {
        location.href = location.protocol + '//' +  location.hostname + url + "?" + query;
    }
}

templates/ajax_search_results.tt  view on Meta::CPAN

<!--
// search with a query string and a message to display
function ajax_search(query, msg) {
     if( Ajax.getTransport != false ) {
         query = query + '&ajax=1';
         new Ajax.Updater( 
            'search_listing',  
            url,
            { 
                parameters: query,
                asynchronous: 1,
                onLoading: function(request) {
                    $('search_listing').innerHTML = "<strong>" + msg + " ...</strong>";
                } 
            } 
        );
    } else {
        location.href = location.protocol + '//' +  location.hostname + url + "?" + query;
    }
}

templates/prototype_javascript.tmpl  view on Meta::CPAN

      function() {return new XMLHttpRequest()}
    ) || false;
  }
}

Ajax.Base = function() {};
Ajax.Base.prototype = {
  setOptions: function(options) {
    this.options = {
      method:       'post',
      asynchronous: true,
      parameters:   ''
    }.extend(options || {});
  },

  responseIsSuccess: function() {
    return this.transport.status == undefined
        || this.transport.status == 0 
        || (this.transport.status >= 200 && this.transport.status < 300);
  },

templates/prototype_javascript.tmpl  view on Meta::CPAN


  request: function(url) {
    var parameters = this.options.parameters || '';
    if (parameters.length > 0) parameters += '&_=';

    try {
      if (this.options.method == 'get')
        url += '?' + parameters;

      this.transport.open(this.options.method, url,
        this.options.asynchronous);

      if (this.options.asynchronous) {
        this.transport.onreadystatechange = this.onStateChange.bind(this);
        setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
      }

      this.setRequestHeaders();

      var body = this.options.postBody ? this.options.postBody : parameters;
      this.transport.send(this.options.method == 'post' ? body : null);

    } catch (e) {

templates/prototype_javascript.tmpl  view on Meta::CPAN

    }
    return last_token_pos;
  }
}

Ajax.Autocompleter = Class.create();
Ajax.Autocompleter.prototype = Object.extend(new Autocompleter.Base(), 
Object.extend(new Ajax.Base(), {
  initialize: function(element, update, url, options) {
          this.base_initialize(element, update, options);
    this.options.asynchronous  = true;
    this.options.onComplete    = this.onComplete.bind(this)
    this.options.method        = 'post';
    this.options.defaultParams = this.options.parameters || null;
    this.url                   = url;
  },
  
  getUpdatedChoices: function() {
    entry = encodeURIComponent(this.element.name) + '=' + 
      encodeURIComponent(this.getEntry());
      



( run in 0.450 second using v1.01-cache-2.11-cpan-0d8aa00de5b )