forked from FlominatorTM/WikiTree
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfileCleanup.js
More file actions
47 lines (42 loc) · 1.31 KB
/
Copy pathProfileCleanup.js
File metadata and controls
47 lines (42 loc) · 1.31 KB
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
javascript: moveCategories();
function moveCategories() {
var ta = document.getElementById("wpTextbox1");
var parts = ta.value.split("\n");
var oldValue = ta.value;
var top_ = "";
var bottom = "";
for (var i = 0; i < parts.length; i++) {
if (parts[i].trim() == "*") {
continue;
}
if (parts[i].indexOf("[[Category") > -1) {
top_ += "\n" + parts[i].replace("* [[Category", "[[Category");
} else {
bottom += "\n" + parts[i];
}
}
if (top_ != "") {
bottom = bottom.replace(/^\n+/, "");
var indexEndOfBioHeadline = bottom.indexOf("==\n") + "==\n".length;
var indexStartBioHeadline = bottom.indexOf("==");
if (indexStartBioHeadline > 1) {
/* template stuff */
var stuffBeforeBio = bottom.substring(0, indexStartBioHeadline);
var stuffAfterBio = bottom.substring(indexEndOfBioHeadline);
var bioHeadline = bottom.substring(
indexStartBioHeadline,
indexEndOfBioHeadline
);
bottom =
bioHeadline +
stuffBeforeBio.replace(/^\n+/, "").replace(/\n{2,}$/, "") +
"\n" +
stuffAfterBio.replace(/^\n+/, "").replace(/\n{2,}$/, "");
}
ta.value = top_.substring(1) + "\n" + bottom;
if (oldValue != ta.value) {
document.getElementById("wpSummary").value = "Formatting. ";
}
}
}
void 0;