forked from xiplus-mediawiki-programs/twinkle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwinkle-dev.js
81 lines (70 loc) · 2.3 KB
/
twinkle-dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// importScript User:Wetittwinkle/twinkle-dev.js,後果自負。
(function () {
var PREFIX = 'User:Wetittwinkle/';
var tests = [];
var ajax = function (title) {
return $.ajax({
url: 'https://zh.wikipedia.org/w/index.php?title=' + title + '&action=raw&ctype=text/javascript',
dataType: 'text',
});
};
var load = function (p) {
return ajax(PREFIX + p);
};
var message = function (text) {
console.log('[Wtwinkle]', text);
// $('#simpleSearch input[type="search"]').attr('placeHolder', text);
};
var scripts = ['morebits.js',
'twinkle.js',
'modules/twinklewarn.js',
'modules/friendlyshared.js',
'modules/friendlytag.js',
'modules/friendlytalkback.js',
'modules/twinklearv.js',
'modules/twinklebatchdelete.js',
'modules/twinklebatchundelete.js',
'modules/twinkleblock.js',
'modules/twinkleclose.js',
'modules/twinkleconfig.js',
'modules/twinklecopyvio.js',
'modules/twinklediff.js',
'modules/twinklefluff.js',
'modules/twinkleimage.js',
'modules/twinkleprotect.js',
'modules/twinklespeedy.js',
'modules/twinklestub.js',
'modules/twinkleunlink.js',
'modules/twinklexfd.js'
];
var styles = ['morebits.css',
'twinkle.css',
'modules/twinkleconfig.css'
];
var i=0;
mw.loader.using(['mediawiki.user', 'mediawiki.util', 'mediawiki.RegExp', 'mediawiki.Title', 'jquery.ui.dialog', 'jquery.tipsy']).done(function () {
for(i=0; i<styles.length; i++) {
mw.loader.load('https://zh.wikipedia.org/w/index.php?title=' + PREFIX + styles[i] + '&action=raw&ctype=text/css', 'text/css');
}
i=0;
var finished = 0;
var code = [];
// all
message('Loading WTW...');
var promises = [];
var done = function (x) {
return function (data) {
finished++;
//message('Loading WTW... (' + finished + '/' + tests.length + ')');
code[x] = data;
};
};
for (i=0; i<scripts.length; i++) {
promises[i] = load(scripts[i]).done(done(i));
}
$.when.apply($, promises).done(function () {
eval(code.join('\n;\n'));
message('Twinkle Done');
});
});
})();