Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3dc36cd

Browse files
committed
reformat code
1 parentd2324a7 commit3dc36cd

File tree

3 files changed

+2061
-1925
lines changed

3 files changed

+2061
-1925
lines changed

‎asset/js/common.js‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,33 @@ var migration_error = false;
66
varconnection_data;
77

88
functionwpsdb_call_next_hook(){
9-
if(!call_stack.length){
10-
call_stack=hooks;
11-
}
9+
if(!call_stack.length){
10+
call_stack=hooks;
11+
}
1212

13-
varfunc=call_stack[0];
14-
call_stack.shift();
15-
window[func]();// Uses the string from the array to call the function of the same name
13+
varfunc=call_stack[0];
14+
call_stack.shift();
15+
window[func]();// Uses the string from the array to call the function of the same name
1616
}
1717

18-
functionwpsdb_add_commas(number_string){
19-
number_string+='';
20-
x=number_string.split('.');
21-
x1=x[0];
22-
x2=x.length>1 ?'.'+x[1] :'';
23-
varrgx=/(\d+)(\d{3})/;
24-
while(rgx.test(x1)){
25-
x1=x1.replace(rgx,'$1'+','+'$2');
26-
}
27-
returnx1+x2;
18+
functionwpsdb_add_commas(number_string){
19+
number_string+='';
20+
x=number_string.split('.');
21+
x1=x[0];
22+
x2=x.length>1 ?'.'+x[1] :'';
23+
varrgx=/(\d+)(\d{3})/;
24+
while(rgx.test(x1)){
25+
x1=x1.replace(rgx,'$1'+','+'$2');
26+
}
27+
returnx1+x2;
2828
}
2929

30-
functionwpsdb_parse_json(maybe_json){
31-
try{
32-
varjson_object=jQuery.parseJSON(maybe_json);
33-
}
34-
catch(e){
35-
// we simply return false here because the json data itself will never just contain a value of "false"
36-
returnfalse;
37-
}
38-
returnjson_object;
30+
functionwpsdb_parse_json(maybe_json){
31+
try{
32+
varjson_object=jQuery.parseJSON(maybe_json);
33+
}catch(e){
34+
// we simply return false here because the json data itself will never just contain a value of "false"
35+
returnfalse;
36+
}
37+
returnjson_object;
3938
}

‎asset/js/hook.js‎

Lines changed: 66 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,68 @@
11
(function($){
2-
3-
$.wpsdb={
4-
/**
5-
* Implement a WordPress-link Hook System for Javascript
6-
* TODO: Change 'tag' to 'args', allow number (priority), string (tag), object (priority+tag)
7-
*/
8-
hooks:{action:{},filter:{}},
9-
add_action:function(action,callable,tag){
10-
jQuery.wpsdb.add_hook('action',action,callable,tag);
11-
},
12-
add_filter:function(action,callable,tag){
13-
jQuery.wpsdb.add_hook('filter',action,callable,tag);
14-
},
15-
do_action:function(action,args){
16-
jQuery.wpsdb.do_hook('action',action,null,args);
17-
},
18-
apply_filters:function(action,value,args){
19-
returnjQuery.wpsdb.do_hook('filter',action,value,args);
20-
},
21-
remove_action:function(action,tag){
22-
jQuery.wpsdb.remove_hook('action',action,tag);
23-
},
24-
remove_filter:function(action,tag){
25-
jQuery.wpsdb.remove_hook('filter',action,tag);
26-
},
27-
add_hook:function(hook_type,action,callable,tag){
28-
if(undefined==jQuery.wpsdb.hooks[hook_type][action]){
29-
jQuery.wpsdb.hooks[hook_type][action]=[];
30-
}
31-
varhooks=jQuery.wpsdb.hooks[hook_type][action];
32-
if(undefined==tag){
33-
tag=action+'_'+hooks.length;
34-
}
35-
jQuery.wpsdb.hooks[hook_type][action].push({tag:tag,callable:callable});
36-
},
37-
do_hook:function(hook_type,action,value,args){
38-
if(undefined!=jQuery.wpsdb.hooks[hook_type][action]){
39-
varhooks=jQuery.wpsdb.hooks[hook_type][action];
40-
for(vari=0;i<hooks.length;i++){
41-
if('action'==hook_type){
42-
hooks[i].callable(args);
43-
}else{
44-
value=hooks[i].callable(value,args);
45-
}
46-
}
47-
}
48-
if('filter'==hook_type){
49-
returnvalue;
50-
}
51-
},
52-
remove_hook:function(hook_type,action,tag){
53-
if(undefined!=jQuery.wpsdb.hooks[hook_type][action]){
54-
varhooks=jQuery.wpsdb.hooks[hook_type][action];
55-
for(vari=hooks.length-1;i>=0;i--){
56-
if(undefined==tag||tag==hooks[i].tag)
57-
hooks.splice(i,1);
58-
}
59-
}
60-
}
61-
}
62-
2+
$.wpsdb={
3+
/**
4+
* Implement a WordPress-link Hook System for Javascript
5+
* TODO: Change 'tag' to 'args', allow number (priority), string (tag),
6+
object (priority+tag)
7+
*/
8+
hooks:{
9+
action:{},
10+
filter:{}
11+
},
12+
add_action:function(action,callable,tag){
13+
jQuery.wpsdb.add_hook('action',action,callable,tag);
14+
},
15+
add_filter:function(action,callable,tag){
16+
jQuery.wpsdb.add_hook('filter',action,callable,tag);
17+
},
18+
do_action:function(action,args){
19+
jQuery.wpsdb.do_hook('action',action,null,args);
20+
},
21+
apply_filters:function(action,value,args){
22+
returnjQuery.wpsdb.do_hook('filter',action,value,args);
23+
},
24+
remove_action:function(action,tag){
25+
jQuery.wpsdb.remove_hook('action',action,tag);
26+
},
27+
remove_filter:function(action,tag){
28+
jQuery.wpsdb.remove_hook('filter',action,tag);
29+
},
30+
add_hook:function(hook_type,action,callable,tag){
31+
if(undefined==jQuery.wpsdb.hooks[hook_type][action]){
32+
jQuery.wpsdb.hooks[hook_type][action]=[];
33+
}
34+
varhooks=jQuery.wpsdb.hooks[hook_type][action];
35+
if(undefined==tag){
36+
tag=action+'_'+hooks.length;
37+
}
38+
jQuery.wpsdb.hooks[hook_type][action].push({
39+
tag:tag,
40+
callable:callable
41+
});
42+
},
43+
do_hook:function(hook_type,action,value,args){
44+
if(undefined!=jQuery.wpsdb.hooks[hook_type][action]){
45+
varhooks=jQuery.wpsdb.hooks[hook_type][action];
46+
for(vari=0;i<hooks.length;i++){
47+
if('action'==hook_type){
48+
hooks[i].callable(args);
49+
}else{
50+
value=hooks[i].callable(value,args);
51+
}
52+
}
53+
}
54+
if('filter'==hook_type){
55+
returnvalue;
56+
}
57+
},
58+
remove_hook:function(hook_type,action,tag){
59+
if(undefined!=jQuery.wpsdb.hooks[hook_type][action]){
60+
varhooks=jQuery.wpsdb.hooks[hook_type][action];
61+
for(vari=hooks.length-1;i>=0;i--){
62+
if(undefined==tag||tag==hooks[i].tag)
63+
hooks.splice(i,1);
64+
}
65+
}
66+
}
67+
};
6368
})(jQuery);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp