PageRenderTime 141ms CodeModel.GetById 135ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/XInsert/xml/javascript.insert.xml

#
XML | 379 lines | 276 code | 80 blank | 23 comment | 0 complexity | ec89c7ed71edc1c702588c1b78866bd0 MD5 | raw file
  1<?xml version="1.0" encoding="ISO-8859-1"?>
  2<!--
  3 javascript.xinsert.xml
  4 Copyright (c) 2006 by Martin Raspe (hertzhaft@biblhertz.it)
  5 Bibliotheca Hertziana (Max Planck Institute for Art History), Rome, Italy
  6 $Id$
  7-->
  8
  9<!--
 10 License: German Free Software License (D-FSL)
 11 (see http://www.d-fsl.org)
 12
 13 This license conforms to the GNU General Public License and is 
 14 adapted to the particular requirements of German and European law. 
 15 It was inspired by the 'Berlin Declaration on Open Access to 
 16 Knowledge in the Sciences and Humanities' which was signed by the 
 17 'Max Planck Society for the Advancement of Science'.
 18-->
 19
 20<menu name="JavaScript">
 21
 22<menu name="Statements">
 23
 24<item name="break">break
 25</item>
 26
 27<item name="continue">continue
 28</item>
 29
 30<item name="return">return;
 31</item>
 32
 33<item name="var">var | = ;
 34</item>
 35
 36<item name="with">
 37	with (|) {
 38		}
 39</item>
 40
 41</menu>
 42
 43<!-- ############# -->
 44
 45<menu name="Common objects">
 46
 47<item name="Array"> = new Array()</item>
 48
 49<item name="Date">= new Date()</item>
 50
 51<item name="document">document</item>
 52
 53<item name="history">history</item>
 54
 55<item name="Math">Math.</item>
 56
 57<item name="window">window</item>
 58
 59</menu>
 60
 61<!-- ############# -->
 62
 63<menu name="Conditions">
 64
 65<item name="if (short)">
 66	if (|)
 67		;
 68</item>
 69
 70<item name="if (brackets)">
 71	if (|) {
 72		}
 73</item>
 74
 75<item name="else if (short)">
 76	else if (|)
 77		;
 78</item>
 79
 80<item name="else if (brackets)">
 81	else if (|) {
 82		}
 83</item>
 84
 85<item name="else (short)">
 86	else
 87		|;</item>
 88
 89<item name="else (brackets)">
 90	else {
 91		|
 92		};
 93</item>
 94<item name="switch">
 95	switch () {
 96		case |:
 97			break;
 98		default:
 99			break;
100		}
101</item>
102
103</menu>
104
105<!-- ############# -->
106
107<menu name="Loops">
108
109<item name="for (infinite)">
110	for (;;) {
111		|
112		}
113</item>
114
115<item name="for (var i)">
116	for (var i = 0; i&lt;|; i++) {
117		}
118</item>
119
120<item name="while">
121	while (|) {
122		}
123</item>
124
125<item name="do ... while">
126	do {
127		|
128		} while ();
129</item>
130
131</menu>
132
133<!-- ############# -->
134
135<menu name="HTML Links">
136
137<item name="void(0)">
138	&lt;a href=javascript:void(0) onClick="|"&gt;
139</item>
140
141<item name="back">
142	&lt;a href=javascript:history.go(-1)&gt;
143</item>
144
145<item name="forward">
146	&lt;a href=javascript:history.go(+1)&gt;
147</item>
148
149</menu>
150
151<!-- ############# -->
152
153<menu name="Misc">
154
155<item name="write">document.write("|")</item>
156
157<item name="writeln">document.writeln("|")</item>
158
159<item name="Function">function |()\n{\n\t\n}</item>
160
161<item name="alert">alert("|")</item>
162
163<item name="confirm">if(confirm("|")){\n\t\n}</item>
164
165<item name="prompt"> = prompt("|",)</item>
166
167<item name="userAgent">navigator.userAgent</item>
168
169<item name="appName">navigator.appName</item>
170
171<item name="appVersion">navigator.appVersion</item>
172
173<item name="function">
174function |(args) {
175	var i = 0;
176	return;
177	}
178
179</item>
180
181</menu>
182
183<!-- ############# -->
184
185<menu name="Snippets">
186
187<item name="No frames">
188&lt;script language="javascript"&gt;
189	&lt;!-- // Load me in a new window if caught in a frame
190	if (self != top)
191		top.location.href = self.location.href;
192	// --&gt;
193&lt;/script&gt;
194</item>
195
196<item name="Screen Resolution">
197&lt;script language="javascript"&gt;
198	&lt;!-- // Save screen width in x_res and screen height in y_res
199	var x_res = screen.width;
200	var y_res = screen.height;
201	// --&gt;
202&lt;/script&gt;
203</item>
204
205<item name="Image Preload" type="xinsert_script">
206	{%img "Enter image id:"}
207	var {$=img}_on = new Image();
208	{$=img}_on.src = "{$=img}_on.png";
209	var {$=img}_off = new Image();
210	{$=img}_off.src = "{$=img}_off.png";
211</item>
212
213<item name="Image Rollover">
214// register these functions as mouseover/mouseout handlers for the images
215function onMouseOver(evt){
216	img_file = this.id + '_on.png';
217	this.setAttribute('src', img_file);
218	}
219
220function onMouseOut(evt){
221	img_file = this.id + '_off.png';
222	this.setAttribute('src', img_file);
223	}
224</item>
225
226<item name="window.open (min)">
227	window.open("|","");
228</item>
229
230<item name="window.open (max)">
231window.open("|","","height=,width=,screenX=,screenY=,resizeable,scrollbars,dependent,hotkeys,location,menubar,toolbar,status,directories");
232</item>
233
234<item name="Statusbar messagee">
235function statusbar_message(content) {
236	status = content;
237	return true;
238	}
239</item>
240
241</menu>
242
243<!-- ############# -->
244
245<menu name="Advanced">
246
247<item name="constructor">
248Class = function(arg) {
249	this.arg = arg;
250	return this;
251	}
252</item>
253
254<item name="method">
255Class.method = function(args) {
256	}
257</item>
258
259<item name="method prototype">
260Class.prototype.method = function(args) {
261	}
262</item>
263
264<item name="getElement">
265function getElement(tagid, quiet) {
266    // returns the element object with the id tagid
267    var e;
268    if (document.getElementById) {
269        e = document.getElementById(tagid);
270    } else if (document.all) {
271        alert("document.all!");
272        e = document.all[tagid];
273    } else if (document.layers) {
274        e = document.layers[tagid];
275    } 
276    if (e) {
277        return e;
278    } else {
279        if (! quiet) {
280            alert("unable to find element: "+tagid);
281        }
282        return null;
283    }
284}
285</item>
286
287<item name="registerEvents">
288function registerEvent(type, elem, handler) {
289    // register the given event handler on the indicated element
290    if (elem.addEventListener) {
291        elem.addEventListener(type, handler, false);    // bubble
292        }
293    else if (elem.attachEvent) {
294        elem.attachEvent("on" + type, handler);
295        }
296    else if (elem.captureEvents) {
297        if (Event) { 
298            t = type.toUpperCase();
299            elem.captureEvents(Event[t]);
300            elem[ "on" + type ] = handler;
301            }
302        }
303    else {
304        alert("Could not register event of type " + type);
305        return false;
306        }
307    return true;
308    }
309</item>
310
311<item name="unregisterEvent">
312function unregisterEvent(type, elem, handler) {
313    // unregister the given event handler from the indicated element
314    if (elem.removeEventListener) {
315        elem.removeEventListener(type, handler, false);
316            }
317    else if (elem.detachEvent) {
318        elem.detachEvent("on" + type, handler);
319        }
320    else if (elem.releaseEvents) {
321        if (Event) { 
322            t = type.toUpperCase();
323            elem.releaseEvents(Event[t]);
324            elem[ "on" + type ] = null;
325            }
326        }
327    else {
328        alert("Could not unregister event of type " + type);
329        return false;
330        }
331    return true;
332}
333</item>
334
335<item name="stopEvent">
336function stopEvent(e) {
337    if (!e)
338		var e = window.event;
339    if (e.stopPropagation)
340		e.stopPropagation();
341    e.cancelBubble = true;
342    return false;
343}
344</item>
345
346<item name="getEventSource">
347function getEventSource(e) {
348    if (e.target)
349		return e.target;
350    if (e.srcElement)
351		return e.srcElement;
352}
353</item>
354
355<item name="onWindowLoad">
356// initialize everything here
357function init() {
358	}
359
360// onload registration for window
361registerEvent("load", window, init);
362</item>
363
364<item name="register object method as event handler">
365function registerHandler(event, element, obj, methodname) {
366    // make a closure
367	var handler = function(evt) {
368        return obj[methodname](evt, this)
369			// the method should be able to process two parameters
370			// "evt" is the event object,
371			// "this" is the HTML element on which the event was registered
372        };
373    return registerEvent(event, element, handler);
374	}
375</item>
376
377</menu>
378</menu>
379