מדיה ויקי:Gadget-HotCat.js: הבדלים בין גרסאות בדף
מ Some global configs factored out |
מ Minor fix for empty lines |
||
| שורה 322: | שורה 322: | ||
while (j < after.length && after.charAt (j) != '\n' && after.substr (j, 1).search (/\s/) >= 0) | while (j < after.length && after.charAt (j) != '\n' && after.substr (j, 1).search (/\s/) >= 0) | ||
j++; | j++; | ||
if (i >= 0 && before.charAt (i) == '\n' && j < after.length && after.charAt (j) == '\n') | if (i >= 0 && before.charAt (i) == '\n' && (after.length == 0 || j < after.length && after.charAt (j) == '\n')) | ||
i--; | i--; | ||
if (i >= 0) before = before.substring (0, i+1); else before = ""; | if (i >= 0) before = before.substring (0, i+1); else before = ""; | ||
| שורה 347: | שורה 347: | ||
if (cat_point < 0) | if (cat_point < 0) | ||
cat_point = find_insertionpoint (wikitext); | cat_point = find_insertionpoint (wikitext); | ||
var newcatstring = ' | var newcatstring = '[[' + nameSpace + ':' + toAdd + (key || "") + ']]'; | ||
if (cat_point >= 0) { | if (cat_point >= 0) { | ||
wikitext = wikitext.substring (0, cat_point) + newcatstring + wikitext.substring (cat_point); | wikitext = wikitext.substring (0, cat_point) + '\n' + newcatstring + wikitext.substring (cat_point); | ||
} else { | } else { | ||
if (wikitext.length > 0 && wikitext.substr (wikitext.length - 1, 1) != '\n') | |||
wikitext += '\n'; | |||
wikitext += newcatstring; | wikitext += newcatstring; | ||
} | } | ||