Page MenuHomePhabricator

wikibits.js.diff

Authored By
bzimport
Nov 21 2014, 9:28 PM
Size
7 KB
Referenced Files
None
Subscribers
None

wikibits.js.diff

960a961,988
> var ts_month_map = {};
>
> ts_month_map["jan"] = "01";
> ts_month_map["feb"] = "02";
> ts_month_map["mar"] = "03";
> ts_month_map["apr"] = "04";
> ts_month_map["may"] = "05";
> ts_month_map["jun"] = "06";
> ts_month_map["jul"] = "07";
> ts_month_map["aug"] = "08";
> ts_month_map["sep"] = "09";
> ts_month_map["oct"] = "10";
> ts_month_map["nov"] = "11";
> ts_month_map["dec"] = "12";
>
> ts_month_map["january"] = "01";
> ts_month_map["february"] = "02";
> ts_month_map["march"] = "03";
> ts_month_map["april"] = "04";
> ts_month_map["may"] = "05";
> ts_month_map["june"] = "06";
> ts_month_map["july"] = "07";
> ts_month_map["august"] = "08";
> ts_month_map["september"] = "09";
> ts_month_map["october"] = "10";
> ts_month_map["november"] = "11";
> ts_month_map["december"] = "12";
>
998c1026
< if (typeof el == "string") return el;
---
> if (typeof el == "string") return el.replace(/^[\s]+|[\s]+$/g,"");
1000,1001c1028,1029
< if (el.textContent) return el.textContent; // not needed but it is faster
< if (el.innerText) return el.innerText; // IE doesn't have textContent
---
> if (el.textContent) return el.textContent.replace(/^[\s]+|[\s]+$/g,""); // not needed but it is faster
> if (el.innerText) return el.innerText.replace(/^[\s]+|[\s]+$/g,""); // IE doesn't have textContent
1016c1044
< return str;
---
> return str.replace(/^[\s]+|[\s]+$/g,""); // trim
1048c1076,1090
< if (itm.match(/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/))
---
> if (itm.match(/^\d{2}[\/. -][a-zA-Z]+?[\/. -]\d{4}$/)) // DD-[Jan|January]-YYYY
> sortfn = ts_sort_date;
> else if (itm.match(/^\d{4}[\/. -][a-zA-Z]+?[\/. -]\d{2}$/)) // YYYY-[Jan|January]-DD
> sortfn = ts_sort_date;
> else if (itm.match(/^\d{4}, \d{2} [a-zA-Z]+?$/)) // YYYY, DD [Jan|January]
> sortfn = ts_sort_date;
> else if (itm.match(/^[a-zA-Z]+? \d{2}, \d{4}$/)) // [Jan|January] DD, YYYY
> sortfn = ts_sort_date;
> else if (itm.match(/^\d{4}[\/. -]\d{2}[\/. -]\d{2}$/)) // YYYY-MM-DD
> sortfn = ts_sort_date;
> else if (itm.match(/^\d{2}[\/. -]\d{2}[\/. -]\d{4}$/)) // MM-DD-YYYY
> sortfn = ts_sort_date;
> else if (itm.match(/^\d{2}[\/. -]\d{2}[\/. -]\d{2}$/)) // MM-DD-YY
> sortfn = ts_sort_date;
> else if (itm.match(/^\d{2}:\d{2}, [a-zA-Z]+? \d{2}, \d{4}$/)) // hh:ss, January DD, YYYY
1050c1092
< if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/))
---
> else if (itm.match(/^\d{2}:\d{2}, \d{2} [a-zA-Z]+? \d{4}$/)) // hh:ss, DD January YYYY
1052c1094
< if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d$/))
---
> else if (itm.match(/^\d{2}:\d{2}, \d{4} [a-zA-Z]+? \d{2}$/)) // hh:ss, YYYY January DD
1054c1096,1098
< if (itm.match(/^[\u00a3$\u20ac]/)) // pound dollar euro
---
> else if (itm.match(/^\d{4}[\/.-]\d{2}[\/.-]\d{2}T\d{2}:\d{2}:\d{2}$/)) // YYYY-MM-DDTHH:mm:ss
> sortfn = ts_sort_date;
> else if (itm.match(/^[\u00a3$\u20ac]/)) // pound dollar euro
1056c1100
< if (itm.match(/^[\d.,]+\%?$/))
---
> else if (itm.match(/^[\d.,]+\%?$/))
1104c1148,1155
< function ts_dateToSortKey(date) {
---
> function ts_dateToSortKey(date) {
> var second = "00";
> var minute = "00";
> var hour = "00";
> var day = "00";
> var month = "00";
> var year = "0000";
> var matched = false;
1106,1142c1157,1211
< if (date.length == 11) {
< switch (date.substr(3,3).toLowerCase()) {
< case "jan": var month = "01"; break;
< case "feb": var month = "02"; break;
< case "mar": var month = "03"; break;
< case "apr": var month = "04"; break;
< case "may": var month = "05"; break;
< case "jun": var month = "06"; break;
< case "jul": var month = "07"; break;
< case "aug": var month = "08"; break;
< case "sep": var month = "09"; break;
< case "oct": var month = "10"; break;
< case "nov": var month = "11"; break;
< case "dec": var month = "12"; break;
< // default: var month = "00";
< }
< return date.substr(7,4)+month+date.substr(0,2);
< } else if (date.length == 10) {
< if (ts_europeandate == false) {
< return date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
< } else {
< return date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
< }
< } else if (date.length == 8) {
< yr = date.substr(6,2);
< if (parseInt(yr) < 50) {
< yr = '20'+yr;
< } else {
< yr = '19'+yr;
< }
< if (ts_europeandate == true) {
< return yr+date.substr(3,2)+date.substr(0,2);
< } else {
< return yr+date.substr(0,2)+date.substr(3,2);
< }
< }
< return "00000000";
---
> if (matched = date.match(/^(\d{2})[\/. -]([a-zA-Z]+?)[\/. -](\d{4})$/)) { // DD-[Jan|January]-YYYY
> day = matched[1];
> month = ts_month_map[matched[2].toLowerCase()] || "00";
> year = matched[3];
> } else if (matched = date.match(/^(\d{4})[\/. -]([a-zA-Z]+?)[\/. -](\d{2})$/)) { // YYYY-[Jan|January]-DD
> day = matched[3];
> month = ts_month_map[matched[2].toLowerCase()] || "00";
> year = matched[1];
> } else if (matched = date.match(/^(\d{4}), (\d{2}) ([a-zA-Z]+?)$/)) { // YYYY, DD [Jan|January]
> day = matched[2];
> month = ts_month_map[matched[3].toLowerCase()] || "00";
> year = matched[1];
> } else if (matched = date.match(/^([a-zA-Z]+?) (\d{2}), (\d{4})$/)) { // [Jan|January] DD, YYYY
> day = matched[2];
> month = ts_month_map[matched[1].toLowerCase()] || "00";
> year = matched[3];
> } else if (matched = date.match(/^(\d{2})[\/. -](\d{2})[\/. -](\d{4})$/)) { // MM-DD-YYYY
> day = matched[2];
> month = matched[1];
> year = matched[3];
> } else if (matched = date.match(/^(\d{4})[\/. -](\d{2})[\/. -](\d{2})$/)) { // YYYY-MM-DD
> day = matched[3];
> month = matched[2];
> year = matched[1];
> } else if (matched = date.match(/^(\d{2})[\/. -](\d{2})[\/. -](\d{2})$/)) { // MM-DD-YY
> day = matched[2];
> month = matched[1];
> year = (parseInt(matched[3]) < 50) ? '20'+matched[3] : '19'+matched[3];
> } else if (matched = date.match(/^(\d{2}):(\d{2}), ([a-zA-Z]+?) (\d{2}), (\d{4})$/)) { // hh:mm, January DD, YYYY
> minute = matched[2];
> hour = matched[1];
> day = matched[4];
> month = ts_month_map[matched[3].toLowerCase()] || "00";
> year = matched[5];
> } else if (matched = date.match(/^(\d{2}):(\d{2}), (\d{2}) ([a-zA-Z]+?) (\d{4})$/)) { // hh:mm, DD January YYYY
> minute = matched[2];
> hour = matched[1];
> day = matched[3];
> month = ts_month_map[matched[4].toLowerCase()] || "00";
> year = matched[5];
> } else if (matched = date.match(/^(\d{2}):(\d{2}), (\d{4}) ([a-zA-Z]+?) (\d{2})$/)) { // hh:mm, YYYY January DD
> minute = matched[2];
> hour = matched[1];
> day = matched[5];
> month = ts_month_map[matched[4].toLowerCase()] || "00";
> year = matched[3];
> } else if (matched = date.match(/^(\d{4})[\/.-](\d{2})[\/.-](\d{2})T(\d{2}):(\d{2}):(\d{2})$/)) { // YYYY-MM-DDTHH:mm:ss
> minute = matched[6];
> minute = matched[5];
> hour = matched[4];
> day = matched[3];
> month = matched[2];
> year = matched[1];
> }
> return year+month+day+hour+minute+second;

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2976
Default Alt Text
wikibits.js.diff (7 KB)

Event Timeline