Project

General

Profile

1
/*
2
 * CodePress regular expressions for JavaScript syntax highlighting
3
 */
4
 
5
Language.syntax = [ // JavaScript
6
	{ 
7
	input : /\"(.*?)(\"|<br>|<\/P>)/g, 
8
	output : '<s>"$1$2</s>' // strings double quote
9
	},{ 
10
	input : /\'(.*?)(\'|<br>|<\/P>)/g,
11
	output : '<s>\'$1$2</s>' // strings single quote
12
	},{ 
13
	input : /\b(break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g,
14
	output : '<b>$1</b>' // reserved words
15
	},{ 
16
	input : /\b(alert|isNaN|parent|Array|parseFloat|parseInt|blur|clearTimeout|prompt|prototype|close|confirm|length|Date|location|Math|document|element|name|self|elements|setTimeout|navigator|status|String|escape|Number|submit|eval|Object|event|onblur|focus|onerror|onfocus|onclick|top|onload|toString|onunload|unescape|open|valueOf|window|onmouseover)\b/g,
17
	output : '<u>$1</u>' // special words
18
	},{
19
	input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g,
20
	output : '$1<i>//$2</i>$3' // comments //
21
	},{ 
22
	input : /\/\*(.*?)\*\//g,
23
	output : '<i>/*$1*/</i>' // comments /* */
24
	}
25
]
26

    
27
Language.snippets = [
28
	{ input : 'dw', output : 'document.write(\'$0\');' },
29
	{ input : 'getid', output : 'document.getElementById(\'$0\')' },
30
	{ input : 'fun', output : 'function $0(){\n\t\n}' },
31
	{ input : 'func', output : 'function $0(){\n\t\n}' }
32
];
33

    
34
Language.complete = [ // Auto complete only for 1 character
35
	{input : '\'',output : '\'$0\'' },
36
	{input : '"', output : '"$0"' },
37
	{input : '(', output : '\($0\)' },
38
	{input : '[', output : '\[$0\]' },
39
	{input : '{', output : '{\n\t$0\n}' }		
40
];
41

    
42
Language.shortcuts = [];
(10-10/20)