Content deleted Content added
Bugfixes from Bobblewik |
Latest version from Bobblewik |
||
Line 2:
var txt = document.editform.wpTextbox1;
// century without AD,BC etc
txt.value = txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th))[ \-]century\]\]/gi, '$1 century');
txt.value = txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))[ \-]century\]\]/gi, '$1 century');
txt.value = txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))[ \-]centuries\]\]/gi, '$1 centuries');
// century with AD,BC etc▼
txt.value = txt.value.replace(/\[\[(\d{1,
txt.value = txt.value.replace(/\[\[\d{1,
txt.value = txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)[ \-]century\|(\d{1,2}(?:st|nd|rd|th))[ \-]centuries\s(AD|BC|CE|BCE)\]\]/gi, '$1 centuries $2');
// decades
txt.value = txt.value.replace(/\[\[(\d{1,4}'?s)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[(\d{1,4}s? (?:AD|BC|CE|BCE))\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[\d{1,4}s? (?:AD|BC|CE|BCE)\|(\d{1,4})\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[\d{1,4}s? (?:AD|BC|CE|BCE)\|(\d{1,4}s? (?:AD|BC|CE|BCE))\]\]/gi, '$1');
// months
Line 44 ⟶ 51:
txt.value = txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1');
// days of the week
txt.value = txt.value.replace(/\[\[(Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?)\]\]/gi, '$1');
// days of the week
txt.value = txt.value.replace(/\[\[(Mon|Tue|Tues|Wed|Thu|Thur|Thurs|Fri
txt.value = txt.value.replace(/\[\[(Sat)\]\]/g, '$1');
txt.value = txt.value.replace(/\[\[Mondays?\|(Mondays?)\]\]/gi, '$1');
txt.value = txt.value.replace(/\[\[Tuesdays?\|(Tuesdays?)\]\]/gi, '$1');
Line 56 ⟶ 64:
txt.value = txt.value.replace(/\[\[Sundays?\|(Sundays?)\]\]/gi, '$1');
▲ //BC etc
▲ txt.value = txt.value.replace(/\[\[(\d{1,4} (?:AD|BC|CE|BCE))\]\]/gi, '$1');
▲ txt.value = txt.value.replace(/\[\[\d{1,4} (?:AD|BC|CE|BCE)\|(\d{1,4})\]\]/gi, '$1');
//4 digit years piped into 2
txt.value = txt.value.replace(/\[\[\d{1,4}\|(\d{1,2})\]\]/gi, '$1');
//year: examine characters in link on left for date, examine characters in link on right for date
txt.value = txt.value.replace(/((?:[^yhletramub\s]..|[^rcianlse\d\s].|[^yhletr\d])\]\]\s?,?\-?\s?)\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^
//year pair: examine characters in link on left for date, examine characters in link on right for date
txt.value = txt.value.replace(/((?:[^yhletramub\s]..|[^rcianlse\d\s].|[^yhletr\d])\]\]\s?,?\-?\s?)\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^
//year: examine characters in link on left for date, avoid links on right
Line 71 ⟶ 76:
//year pair: examine characters in link on left for date, avoid links on right
txt.value = txt.value.replace(/((?:[^yhletramub\s]..|[^rcianlse\d\s].|[^yhletr\d])\]\]\s?,?\-?\s?)\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\]([^\[]{4})/gi, '$1$2$3$4$5');
//year: check for line-ends, text on left, avoid links on right. Run twice to deal better with lists.
Line 81 ⟶ 84:
//year: avoid links on left, examine characters in link on right for date
txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^
//year pair: avoid links on left, examine characters in link on right for date
txt.value = txt.value.replace(/([^\]]{4})\[\[(\d{1,4})\]\](.?.?.?.?.?.?)\[\[(\d{1,4})\]\](\s?,?\-?\s?\[\[(?:[^jfmasond\d]|.[^aepuco\d\s]|..[^
//year:avoid links on left, text on right
|