/[webpac2]/Webpacus/root/js/webpac.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Webpacus/root/js/webpac.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 136 by dpavlin, Thu Nov 24 22:29:34 2005 UTC revision 159 by dpavlin, Sat Nov 26 16:22:02 2005 UTC
# Line 3  Line 3 
3  // Documented in this code only, I'm afraid. Beware of dragons!  // Documented in this code only, I'm afraid. Beware of dragons!
4  // Dobrica Pavlinusic dpavlin(at)rot13(dot)org 2005-11-22  // Dobrica Pavlinusic dpavlin(at)rot13(dot)org 2005-11-22
5    
6    /*
7            load another template
8    */
9  function load_template(template_name) {  function load_template(template_name) {
10  //      alert('load_template '+template_name+' old template is '+$('template_name').value);  
11            var old_template = $('template_name').value;
12    
13            Logger.info('load_template: '+template_name+' (old: '+old_template+')');
14    
15            if (template_name == old_template) {
16                    Logger.error('why reload same template?');
17                    return false;
18            }
19    
20          $('template_name').value = template_name;          $('template_name').value = template_name;
21            submit_results_form();
22    }
23    
24    /*
25            pager
26    */
27    function load_results_page(page_nr) {
28    
29            var old_page = current_page_nr();
30    
31            Logger.info('load_results_page: '+page_nr+' (from page: '+old_page+')');
32    
33            if (page_nr == old_page) {
34                    Logger.error('why reload same page?');
35                    return false;
36            }
37    
38            $('page_nr').value = page_nr;
39            submit_results_form();
40    }
41    
42    function current_page_nr() {
43            var page_nr = parseInt( $('page_nr').value ) || 0;
44            return page_nr;
45    }
46    
47    function next_page() {
48            load_results_page( current_page_nr() + 1 );
49    }
50    
51    function prev_page() {
52            load_results_page( current_page_nr() - 1 );
53    }
54    
55    /*
56            submit results form using AJAX
57    */
58    function submit_results_form() {
59            var results_form = $('results_form');
60    
61            if (results_form) {
62                    Logger.debug('Ajax.Updater(results,/results)');
63    
64          new Ajax.Updater( 'results', '/results', {                  new Ajax.Updater( 'results', '/search/results', {
65                  parameters: Form.serialize( $('results_form') ),                          parameters: Form.serialize( results_form ),
66                  asynchronous: 1,                          asynchronous: 1,
67                  onLoading: function(request) {                          onLoading: function(request) {
68                          show_searching();                                  show_searching();
69                  },                          },
70                  onLoaded: function(request) {                          onLoaded: function(request) {
71                          Element.hide('searching');                                  hide_searching();
72  /*                      hide_searching(); */                          }
73                  }                  } ) ;
74          } ) ;                  return false;
75          return false;          } else {
76                    Logger.debug('no results_form element');
77                    return undef;
78            }
79  }  }
80    
81    /*
82            helper functions for submit_results_form()
83    */
84  function show_searching() {  function show_searching() {
85            Logger.debug('show_searching');
86          Element.show('searching');          Element.show('searching');
87          new Effect.Fade('results', { duration: 0.3 });          new Effect.Fade('results', { duration: 0.3 });
88  }  }
89    
90  function hide_searching() {  function hide_searching() {
91            Logger.debug('hide_searching');
92          Element.hide('searching');          Element.hide('searching');
93          //new Effect.Highlight('results');          //new Effect.Highlight('results');
94          new Effect.Appear('results', { duration: 0.3 });          new Effect.Appear('results', { duration: 0.3 });

Legend:
Removed from v.136  
changed lines
  Added in v.159

  ViewVC Help
Powered by ViewVC 1.1.26