Skip to content

Commit 4f73da9

Browse files
committed
Fix some whitespace issues. Run 'make cleanup' to fix new ones
Squashed commit of the following: commit c35518a4125f4c1b95e75757f640257098e346aa Author: Kevin van Zonneveld <kevin@vanzonneveld.net> Date: Thu Jan 9 20:16:35 2014 +0100 Whitespace commit 2cc2ac3210aac5f5ae7f0f777de41e98e16d302d Author: Kevin van Zonneveld <kevin@vanzonneveld.net> Date: Thu Jan 9 20:15:27 2014 +0100 Applied make cleanup to workbench commit 3c335a9d587fcb000c57257f4c9294f238a39a95 Author: Kevin van Zonneveld <kevin@vanzonneveld.net> Date: Thu Jan 9 20:09:35 2014 +0100 Implement 'make cleanup' and applied it. Deleted legacy PHP_JS library commit ae6d5af Author: Kevin van Zonneveld <kevin@vanzonneveld.net> Date: Thu Jan 9 16:50:48 2014 +0100 Fix whitespace issues in experimental
1 parent fbf8f59 commit 4f73da9

File tree

793 files changed

+329946
-332795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

793 files changed

+329946
-332795
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHELL := /bin/bash
2+
13
setup:
24
git pull && \
35
cd _octopress && \
@@ -9,6 +11,18 @@ test:
911
cd tests && npm install
1012
node tests/cli.js --debug
1113

14+
# Apply code standards
15+
cleanup:
16+
@[ -x `which gjslint` ] || sudo easy_install http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz
17+
fixjsstyle \
18+
--recurse ./ \
19+
--exclude_directories _octopress,experimental,workbench,tests/node_modules,tools \
20+
--max_line_length 100 \
21+
--nojsdoc \
22+
--error_trace \
23+
--strict \
24+
--jslint_error all
25+
1226
hook:
1327
mkdir -p ~/.gittemplate/hooks
1428
curl https://raw.github.com/kvz/ochtra/master/pre-commit -o ~/.gittemplate/hooks/pre-commit

experimental/array/extract.js

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function extract (arr, type, prefix) {
1+
function extract(arr, type, prefix) {
22
// From: http://phpjs.org/functions
33
// + original by: Brett Zamir (http://brett-zamir.me)
44
// % note 1: Only works by extracting into global context (whether called in the global scope or
@@ -9,7 +9,7 @@ function extract (arr, type, prefix) {
99
// * example 1: color+'-'+size+'-'+shape+'-'+wddx_size;
1010
// * returns 1: 'blue-large-sphere-medium'
1111
if (Object.prototype.toString.call(arr) === '[object Array]' &&
12-
(type !== 'EXTR_PREFIX_ALL' && type !== 'EXTR_PREFIX_INVALID')) {
12+
(type !== 'EXTR_PREFIX_ALL' && type !== 'EXTR_PREFIX_INVALID')) {
1313
return 0;
1414
}
1515
var targetObj = this.window;
@@ -23,60 +23,60 @@ function extract (arr, type, prefix) {
2323
var prefixed = prefix + '_' + i;
2424
try {
2525
switch (type) {
26-
case 'EXTR_PREFIX_SAME' || 2:
27-
if (targetObj[i] !== undefined) {
26+
case 'EXTR_PREFIX_SAME' || 2:
27+
if (targetObj[i] !== undefined) {
28+
if (prefixed.match(validIdent) !== null) {
29+
targetObj[prefixed] = arr[i];
30+
++chng;
31+
}
32+
} else {
33+
targetObj[i] = arr[i];
34+
++chng;
35+
}
36+
break;
37+
case 'EXTR_SKIP' || 1:
38+
if (targetObj[i] === undefined) {
39+
targetObj[i] = arr[i];
40+
++chng;
41+
}
42+
break;
43+
case 'EXTR_PREFIX_ALL' || 3:
2844
if (prefixed.match(validIdent) !== null) {
2945
targetObj[prefixed] = arr[i];
3046
++chng;
3147
}
32-
} else {
33-
targetObj[i] = arr[i];
34-
++chng;
35-
}
36-
break;
37-
case 'EXTR_SKIP' || 1:
38-
if (targetObj[i] === undefined) {
39-
targetObj[i] = arr[i];
40-
++chng;
41-
}
42-
break;
43-
case 'EXTR_PREFIX_ALL' || 3:
44-
if (prefixed.match(validIdent) !== null) {
45-
targetObj[prefixed] = arr[i];
46-
++chng;
47-
}
48-
break;
49-
case 'EXTR_PREFIX_INVALID' || 4:
50-
if (i.match(validIdent) !== null) {
51-
if (prefixed.match(validIdent) !== null) {
48+
break;
49+
case 'EXTR_PREFIX_INVALID' || 4:
50+
if (i.match(validIdent) !== null) {
51+
if (prefixed.match(validIdent) !== null) {
52+
targetObj[prefixed] = arr[i];
53+
++chng;
54+
}
55+
} else {
56+
targetObj[i] = arr[i];
57+
++chng;
58+
}
59+
break;
60+
case 'EXTR_IF_EXISTS' || 6:
61+
if (targetObj[i] !== undefined) {
62+
targetObj[i] = arr[i];
63+
++chng;
64+
}
65+
break;
66+
case 'EXTR_PREFIX_IF_EXISTS' || 5:
67+
if (targetObj[i] !== undefined && prefixed.match(validIdent) !== null) {
5268
targetObj[prefixed] = arr[i];
5369
++chng;
5470
}
55-
} else {
56-
targetObj[i] = arr[i];
57-
++chng;
58-
}
59-
break;
60-
case 'EXTR_IF_EXISTS' || 6:
61-
if (targetObj[i] !== undefined) {
71+
break;
72+
case 'EXTR_REFS' || 256:
73+
throw 'The EXTR_REFS type will not work in JavaScript';
74+
case 'EXTR_OVERWRITE' || 0:
75+
// Fall-through
76+
default:
6277
targetObj[i] = arr[i];
6378
++chng;
64-
}
65-
break;
66-
case 'EXTR_PREFIX_IF_EXISTS' || 5:
67-
if (targetObj[i] !== undefined && prefixed.match(validIdent) !== null) {
68-
targetObj[prefixed] = arr[i];
69-
++chng;
70-
}
71-
break;
72-
case 'EXTR_REFS' || 256:
73-
throw 'The EXTR_REFS type will not work in JavaScript';
74-
case 'EXTR_OVERWRITE' || 0:
75-
// Fall-through
76-
default:
77-
targetObj[i] = arr[i];
78-
++chng;
79-
break;
79+
break;
8080
}
8181
} catch (e) { // Just won't increment for problem assignments
8282
}

experimental/array/list.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
function list () {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Brett Zamir (http://brett-zamir.me)
4-
// % note 1: Only works in global context and deviates (by necessity) from
5-
// % note 1: PHP version by adding the array (which in PHP is an rvalue
6-
// % note 1: separate from the list() lvalue) as the last argument
7-
// * example 1: var drink, color, power;
8-
// * example 1: list('drink', 'color', 'power', ['coffee', 'brown', 'caffeine']);
9-
// * example 1: drink +' is '+color+' and '+power+' makes it special.\n';
10-
// * returns 1: 'coffee is brown and caffeine makes it special.\n'
1+
function list() {
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Brett Zamir (http://brett-zamir.me)
4+
// % note 1: Only works in global context and deviates (by necessity) from
5+
// % note 1: PHP version by adding the array (which in PHP is an rvalue
6+
// % note 1: separate from the list() lvalue) as the last argument
7+
// * example 1: var drink, color, power;
8+
// * example 1: list('drink', 'color', 'power', ['coffee', 'brown', 'caffeine']);
9+
// * example 1: drink +' is '+color+' and '+power+' makes it special.\n';
10+
// * returns 1: 'coffee is brown and caffeine makes it special.\n'
1111

12-
var i = 0, arr = [];
12+
var i = 0, arr = [];
1313

14-
arr = arguments[arguments.length-1];
14+
arr = arguments[arguments.length - 1];
1515

16-
if (arr && typeof arr === 'object' && arr.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
17-
return arr.list.apply(arr, Array.prototype.slice.call(arguments, 0, -1));
16+
if (arr && typeof arr === 'object' && arr.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array
17+
return arr.list.apply(arr, Array.prototype.slice.call(arguments, 0, -1));
18+
}
19+
if (arr && typeof arr === 'object' && arr.length && !arr.propertyIsEnumerable('length')) {
20+
for (i = 0; i < arr.length; i++) {
21+
this.window[arguments[i]] = arr[i];
1822
}
19-
if (arr && typeof arr === 'object' && arr.length && !arr.propertyIsEnumerable('length')) {
20-
for (i = 0; i < arr.length; i++) {
21-
this.window[arguments[i]] = arr[i];
22-
}
23-
}
24-
else {
25-
for (i in arr) {
26-
if (i.length === parseInt(i).toString().length && parseInt(i) < arguments.length-1) {
27-
this.window[arguments[i]] = arr[i];
28-
}
29-
}
23+
}
24+
else {
25+
for (i in arr) {
26+
if (i.length === parseInt(i).toString().length && parseInt(i) < arguments.length - 1) {
27+
this.window[arguments[i]] = arr[i];
28+
}
3029
}
30+
}
3131

32-
return arr;
32+
return arr;
3333
}

experimental/classkit/classkit_import.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function classkit_import (file) {
1+
function classkit_import(file) {
22
// http://kevin.vanzonneveld.net
33
// + original by: Brett Zamir (http://brett-zamir.me)
44
// - depends on: file_get_contents

experimental/classkit/classkit_method_add.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function classkit_method_add (classname, methodname, args, code, flags) {
1+
function classkit_method_add(classname, methodname, args, code, flags) {
22
// http://kevin.vanzonneveld.net
33
// + original by: Brett Zamir (http://brett-zamir.me)
44
// * example 1: function a(){}
@@ -8,13 +8,13 @@ function classkit_method_add (classname, methodname, args, code, flags) {
88
var func, argmnts = [];
99

1010
switch (flags) {
11-
case 'CLASSKIT_ACC_PROTECTED':
12-
throw 'Protected not supported';
13-
case 'CLASSKIT_ACC_PRIVATE':
14-
throw 'Private not supported';
15-
case 'CLASSKIT_ACC_PUBLIC':
16-
default:
17-
break;
11+
case 'CLASSKIT_ACC_PROTECTED':
12+
throw 'Protected not supported';
13+
case 'CLASSKIT_ACC_PRIVATE':
14+
throw 'Private not supported';
15+
case 'CLASSKIT_ACC_PUBLIC':
16+
default:
17+
break;
1818
}
1919

2020
argmnts = args.split(/,\s*/);

experimental/classkit/classkit_method_copy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
function classkit_method_copy (dClass, dMethod, sClass, sMethod) {
1+
function classkit_method_copy(dClass, dMethod, sClass, sMethod) {
22
// http://kevin.vanzonneveld.net
33
// + original by: Brett Zamir (http://brett-zamir.me)
44
// * example 1: classkit_method_copy('newClass', 'newMethod', 'someClass', 'someMethod');
55
// * returns 1: true
66

7-
/*
7+
/*
88
function A(){}
99
function C(){}
1010
C.d = function () {alert('inside d');}

experimental/classkit/classkit_method_redefine.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function classkit_method_redefine (classname, methodname, args, code, flags) {
1+
function classkit_method_redefine(classname, methodname, args, code, flags) {
22
// http://kevin.vanzonneveld.net
33
// + original by: Brett Zamir (http://brett-zamir.me)
44
// * example 1: classkit_method_redefine('someClass', 'someMethod', 'a,b', 'return a+b');
@@ -7,16 +7,16 @@ function classkit_method_redefine (classname, methodname, args, code, flags) {
77
// In JavaScript, this is identical to classkit_method_add
88

99
var argmnts = [],
10-
func;
10+
func;
1111

1212
switch (flags) {
13-
case 'CLASSKIT_ACC_PROTECTED':
14-
throw 'Protected not supported';
15-
case 'CLASSKIT_ACC_PRIVATE':
16-
throw 'Private not supported';
17-
case 'CLASSKIT_ACC_PUBLIC':
18-
default:
19-
break;
13+
case 'CLASSKIT_ACC_PROTECTED':
14+
throw 'Protected not supported';
15+
case 'CLASSKIT_ACC_PRIVATE':
16+
throw 'Private not supported';
17+
case 'CLASSKIT_ACC_PUBLIC':
18+
default:
19+
break;
2020
}
2121

2222
argmnts = args.split(/,\s*/);

experimental/classkit/classkit_method_remove.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function classkit_method_remove (classname, methodname) {
1+
function classkit_method_remove(classname, methodname) {
22
// http://kevin.vanzonneveld.net
33
// + original by: Brett Zamir (http://brett-zamir.me)
44
// * example 1: classkit_method_remove('someClass', 'someMethod');

experimental/classkit/classkit_method_rename.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function classkit_method_rename (classname, methodname, newname) {
1+
function classkit_method_rename(classname, methodname, newname) {
22
// http://kevin.vanzonneveld.net
33
// + original by: Brett Zamir (http://brett-zamir.me)
44
// * example 1: classkit_method_rename('someClass', 'someMethod', 'newMethod');
@@ -8,7 +8,7 @@ function classkit_method_rename (classname, methodname, newname) {
88
classname = this.window[classname];
99
}
1010

11-
/*
11+
/*
1212
var method = classname[methodname]; // Static
1313
classname[newname] = method;
1414
delete classname[methodname];
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
function call_user_method(method, obj) {
2-
// http://kevin.vanzonneveld.net
3-
// + original by: Brett Zamir (http://brett-zamir.me)
4-
// + input by: dnukem
5-
// + improved by: Brett Zamir (http://brett-zamir.me)
6-
// - depends on: Exception
7-
// % note 1: Deprecated in PHP
8-
// * example 1: call_user_method('alert', this.window, 'Hello!');
9-
// * returns 1: 'Hello!'
10-
// * example 2: call_user_method([this.window, 'alert'], 'Hello!');
11-
// * returns 2: 'Hello!'
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Brett Zamir (http://brett-zamir.me)
4+
// + input by: dnukem
5+
// + improved by: Brett Zamir (http://brett-zamir.me)
6+
// - depends on: Exception
7+
// % note 1: Deprecated in PHP
8+
// * example 1: call_user_method('alert', this.window, 'Hello!');
9+
// * returns 1: 'Hello!'
10+
// * example 2: call_user_method([this.window, 'alert'], 'Hello!');
11+
// * returns 2: 'Hello!'
1212

13-
var func, object = obj, methodName = method, paramBegin = 2;
14-
if (method && typeof method === 'object' && method.length) {
15-
paramBegin = 1;
16-
object = method[0];
17-
object = typeof object === 'string' ? this.window[object] : object;
18-
methodName = method[1];
19-
}
20-
func = object[methodName];
13+
var func, object = obj, methodName = method, paramBegin = 2;
14+
if (method && typeof method === 'object' && method.length) {
15+
paramBegin = 1;
16+
object = method[0];
17+
object = typeof object === 'string' ? this.window[object] : object;
18+
methodName = method[1];
19+
}
20+
func = object[methodName];
2121

22-
if (typeof func !== 'function') {
23-
throw new this.Exception(func + ' is not a valid method');
24-
}
22+
if (typeof func !== 'function') {
23+
throw new this.Exception(func + ' is not a valid method');
24+
}
2525

26-
return func.apply(object, Array.prototype.slice.call(arguments, paramBegin));
26+
return func.apply(object, Array.prototype.slice.call(arguments, paramBegin));
2727
}

0 commit comments

Comments
 (0)