/[webpac2]/Webpacus/root/editor/editor.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

Contents of /Webpacus/root/editor/editor.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 170 - (show annotations)
Sun Nov 27 00:50:27 2005 UTC (18 years, 5 months ago) by dpavlin
File MIME type: application/javascript
File size: 4131 byte(s)
 r11176@llin:  dpavlin | 2005-11-27 01:07:46 +0100
 enter record number

1 /*
2 Webpacus template editor
3 */
4
5 var rec = null;
6 var url = null;
7 var template_filename = null;
8
9 var css_rnd = 0;
10
11 function update_status(text) {
12 var el = $('div_record_nr');
13 if (el) el.innerHTML = text;
14 }
15
16 function load_rec(nr) {
17 Logger.debug('load_rec '+nr);
18
19 if (loading.record) {
20 Logger.info('loading of record '+nr+' skipped, load in progress');
21 return;
22 }
23
24 show_working();
25 $('record_nr').disabled = 'true';
26
27 if (nr == 1) {
28 Element.addClassName('a_left_arr', 'nav_disable');
29 } else {
30 Element.removeClassName('a_left_arr', 'nav_disable');
31 }
32
33 var args = '?mfn='+nr+'&template_filename='+template_filename;
34
35 new Ajax.Updater( 'div_record', url+'record'+args, {
36 asynchronous: 1,
37 onLoading: function(request) {
38 loading.record = 1;
39 Logger.info('load_rec.onLoading: '+nr);
40 },
41 onLoaded: function(request) {
42 loading.record = 0;
43 hide_working();
44 $('record_nr').value = nr;
45 $('record_nr').disabled = '';
46 rec = nr;
47 Logger.info('load_rec.onLoaded: '+nr);
48 }
49 } ) ;
50
51 }
52
53 function inc_rec() {
54 show_working();
55 rec++;
56 load_rec(rec);
57 hide_working();
58 return false;
59 }
60
61 function dec_rec() {
62 if (rec > 1) {
63 show_working();
64 rec--;
65 load_rec(rec);
66 hide_working();
67 }
68 return false;
69 }
70
71 function reload_rec() {
72 show_working();
73 load_rec(rec);
74 hide_working();
75 return false;
76 }
77
78 var current_edit = '';
79
80 function edit_template() {
81 $('div_css').style.visibility = "hidden";
82 Element.removeClassName('a_css', 'tab_selected');
83 Element.addClassName('a_template', 'tab_selected');
84 $('div_template').style.visibility = "visible";
85 Logger.debug("switched to template editor");
86 var c = $('template_content');
87 if (c) c.focus();
88 return false;
89 }
90
91 function edit_css() {
92 $('div_template').style.visibility = "hidden";
93 Element.removeClassName('a_template', 'tab_selected');
94 Element.addClassName('a_css', 'tab_selected');
95 $('div_css').style.visibility = "visible";
96 Logger.debug("switched to CSS editor");
97 var c = $('css_content');
98 if (c) c.focus();
99 return false;
100 }
101
102 function switch_template(new_template_filename) {
103
104 Logger.info('switch_template to '+new_template_filename);
105 show_working();
106
107 Logger.debug('load template editor');
108 template_filename = new_template_filename;
109 load_template(new_template_filename);
110
111 Logger.debug('refresh record');
112 load_rec(rec);
113
114 hide_working();
115
116 return false;
117 }
118
119 var loading = {
120 template: 0,
121 css: 0,
122 record: 0
123 };
124
125 function load_template( template_filename ) {
126
127 if (loading.template) {
128 Logger.info('loading of template '+template_filename+' skipped, load in progress');
129 return;
130 }
131
132 var args = '?template_filename='+template_filename;
133
134 new Ajax.Updater( 'div_template', url+'template'+args, {
135 asynchronous: 1,
136 onLoading: function(request) {
137 loading.template = 1;
138 show_working();
139 Logger.info('load_template.onLoading: '+template_filename);
140 },
141 onLoaded: function(request) {
142 loading.template = 0;
143 Position.clone('div_template', 'div_css');
144 hide_working();
145 Logger.info('load_template.onLoaded: '+template_filename);
146 }
147 } ) ;
148 }
149
150 function load_css(css_filename) {
151
152 if (loading.css) {
153 Logger.info('loading of css '+css_filename+' skipped, load in progress');
154 return;
155 }
156
157 new Ajax.Updater( 'div_css', url+'css', {
158 asynchronous: 1,
159 onLoading: function(request) {
160 loading.css = 1;
161 show_working();
162 Logger.info('load_css.onLoading: '+css_filename);
163 },
164 onLoaded: function(request) {
165 loading.css = 0;
166 hide_working();
167 Logger.info('load_css.onLoaded: '+css_filename);
168 }
169 } ) ;
170 };
171
172 function reload_css() {
173 Logger.error('reload_css is not yet implemented!');
174 return false;
175 }
176
177 var working_count = 0;
178
179 function show_working() {
180 working_count++;
181 if (working_count > 1) Element.show('working');
182 Logger.debug('show_working, count = '+working_count);
183 }
184
185 function hide_working() {
186 working_count--;
187 if (working_count < 1) Element.hide('working');
188 Logger.debug('hide_working, count = '+working_count);
189 }
190
191 function init_page() {
192
193 show_working();
194
195 edit_template();
196
197 // load css editor
198 load_css();
199
200 // load template editor and record
201 switch_template(template_filename);
202
203 hide_working();
204
205 }
206

  ViewVC Help
Powered by ViewVC 1.1.26