מדיה ויקי:Gadget-Cat-a-lot.js: הבדלים בין גרסאות בדף

מ dirtily fixing selector bug; need to look into it later on
מ Keep reference to dom the whole time
שורה 51: שורה 51:
this.selectedLabels.each(function () {
this.selectedLabels.each(function () {
var file = $(this).find('a[title]');
var file = $(this).find('a[title]');
marked.push(file.attr('title'));
marked.push([file.attr('title'), $(this)]);
});
});
return marked;
return marked;
שורה 143: שורה 143:
},
},


getContent: function (filename, targetcat, mode) {
getContent: function (file, targetcat, mode) {


var data = {
var data = {
שורה 150: שורה 150:
rvprop: 'content|timestamp',
rvprop: 'content|timestamp',
intoken: 'edit',
intoken: 'edit',
titles: filename
titles: file[0]
};
};


this.doAPICall(data, function (result) {
this.doAPICall(data, function (result) {
catALot.editCategories(result, filename, targetcat, mode);
catALot.editCategories(result, file, targetcat, mode);
});
});
},
},


editCategories: function (result, filename, targetcat, mode) {
editCategories: function (result, file, targetcat, mode) {


if (result == null) {
if (result == null) {
//Happens on unstable wifi connections..
//Happens on unstable wifi connections..
this.connectionError.push(filename);
this.connectionError.push(file[0]);
this.updateCounter();
this.updateCounter();
return;
return;
שורה 186: שורה 186:
mode='remove';
mode='remove';
} else {
} else {
this.alreadyThere.push(filename);
this.alreadyThere.push(file[0]);
this.updateCounter();
this.updateCounter();
return;
return;
שורה 216: שורה 216:


if (text == otext) {
if (text == otext) {
this.notFound.push(filename);
this.notFound.push(file[0]);
this.updateCounter();
this.updateCounter();
return;
return;
שורה 224: שורה 224:
action: 'edit',
action: 'edit',
summary: comment,
summary: comment,
title: filename,
title: file[0],
token: this.edittoken,
token: this.edittoken,
starttimestamp: starttimestamp,
starttimestamp: starttimestamp,
שורה 232: שורה 232:
//TODO: Need to fix selectors later, wrapping in try...catch now, since we can do w/o it
//TODO: Need to fix selectors later, wrapping in try...catch now, since we can do w/o it
try {
try {
this.markAsDone(filename, mode, targetcat);
this.markAsDone(file[1], mode, targetcat);
} catch (e) { }
} catch (e) { }
this.doAPICall(data, function (ret) {
this.doAPICall(data, function (ret) {
שורה 238: שורה 238:
});
});
},
},
markAsDone: function (filename, mode, targetcat) {
markAsDone: function (label, mode, targetcat) {


var label = $('a[title=' + filename.replace(/([ #;&,.%+*~\':"!^$[\]()=>|\/])/g,'\\$1') + ']').parent();
label.addClass('cat_a_lot_markAsDone');
label.addClass('cat_a_lot_markAsDone');
switch (mode) {
switch (mode) {
שורה 408: שורה 407:
},
},
showProgress: function () {
showProgress: function () {
document.body.style.cursor = 'wait';
document.body.style.cursor = 'wait';