mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 05:48:51 +00:00
[ticket/13887] Made unreadable code readable
PHPBB3-13887
This commit is contained in:
parent
143578ad09
commit
0fc6816be6
1 changed files with 12 additions and 14 deletions
|
@ -329,22 +329,20 @@ phpbb.plupload.updateBbcode = function(action, index) {
|
||||||
var searchRegexp = function(index) {
|
var searchRegexp = function(index) {
|
||||||
return new RegExp('\\[attachment=' + index + '\\](.*?)\\[\\/attachment\\]', 'g');
|
return new RegExp('\\[attachment=' + index + '\\](.*?)\\[\\/attachment\\]', 'g');
|
||||||
};
|
};
|
||||||
// The update order of the indices is based on the action taken to ensure that we don't corrupt
|
|
||||||
// the bbcode index by updating it several times as we move through the loop.
|
|
||||||
// Removal loop starts at the removed index and moves to the end of the array.
|
|
||||||
// Addition loop starts at the end of the array and moves to the added index at 0.
|
|
||||||
var searchLoop = function() {
|
|
||||||
if (typeof i === 'undefined') {
|
|
||||||
i = (removal) ? index : phpbb.plupload.ids.length - 1;
|
|
||||||
}
|
|
||||||
return (removal) ? (i < phpbb.plupload.ids.length): (i >= index);
|
|
||||||
};
|
|
||||||
var i;
|
|
||||||
|
|
||||||
while (searchLoop()) {
|
// Loop forwards when removing and backwards when adding ensures we don't
|
||||||
text = text.replace(searchRegexp(i), updateBbcode);
|
// corrupt the bbcode index.
|
||||||
i += (removal) ? 1 : -1;
|
var i;
|
||||||
|
if (removal) {
|
||||||
|
for (i = index; i < phpbb.plupload.ids.length; i++) {
|
||||||
|
text = text.replace(searchRegexp(i), updateBbcode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = phpbb.plupload.ids.length - 1; i >= index; i--) {
|
||||||
|
text = text.replace(searchRegexp(i), updateBbcode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea.val(text);
|
textarea.val(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue