kuy / Wedata Manager

This greasemonkey script works on Wedata and provide various enhancement for editing database items from website.

Clone this repository (size: 24.1 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/kuy/wedata-manager/

Changed (Δ194 bytes):

raw changeset »

wedata_manager.user.js (12 lines added, 16 lines removed)

Up to file-list wedata_manager.user.js:

@@ -201,10 +201,10 @@ Wedata.prototype.getItem = function(id,
201
201
        if(xhr.readyState != 4) return;
202
202
        if(xhr.status == 200){
203
203
            var obj = eval('(' + xhr.responseText + ')');
204
            callback.call(thisObj, obj.data, obj);
204
            callback && callback.call(thisObj, obj.data, obj);
205
205
        }else{
206
206
            console.log('Wedata#getItem: failed to get item: ' + xhr.status + ', ' + xhr.responseText);
207
            callback.call(thisObj, null);
207
            callback && callback.call(thisObj, null);
208
208
        }
209
209
    }
210
210
    xhr.send(null);
@@ -220,10 +220,10 @@ Wedata.prototype.createItem = function(d
220
220
    xhr.onreadystatechange = function(){
221
221
        if(xhr.readyState != 4) return;
222
222
        if(xhr.status == 201)
223
            callback.call(thisObj, true);
223
            callback && callback.call(thisObj, true);
224
224
        else{
225
225
            console.log('Wedata#createItem: failed to create item: ' + xhr.status + ', ' + xhr.responseText);
226
            callback.call(thisObj, false);
226
            callback && callback.call(thisObj, false);
227
227
        }
228
228
    }
229
229
    var body = 'api_key=' + this.apikey + '&name=' + name;
@@ -243,10 +243,10 @@ Wedata.prototype.deleteItem = function(i
243
243
    xhr.onreadystatechange = function(){
244
244
        if(xhr.readyState != 4) return;
245
245
        if(xhr.status == 200)
246
            callback.call(thisObj, true);
246
            callback && callback.call(thisObj, true);
247
247
        else{
248
248
            console.log('Wedata#deleteItem: failed to delete item: ' + xhr.status + ', ' + xhr.responseText);
249
            callback.call(thisObj, false);
249
            callback && callback.call(thisObj, false);
250
250
        }
251
251
    }
252
252
    xhr.send('api_key=' + this.apikey);
@@ -264,11 +264,11 @@ Wedata.prototype.duplicateItem = functio
264
264
            console.log('Wedata#duplicateItem: ' + this.createItem(db,
265
265
                    'Copy of ' + info.name, res1, function(res2){
266
266
                console.log('Wedata#duplicateItem: ' + res2);
267
                callback.call(thisObj, res2);
267
                callback && callback.call(thisObj, res2);
268
268
            }, this));
269
269
        }else{
270
270
            console.log('Wedata#duplicateItem: failed to get item');
271
            callback.call(thisObj, false);
271
            callback && callback.call(thisObj, false);
272
272
        }
273
273
    }, this);
274
274
    return true;
@@ -283,11 +283,11 @@ Wedata.prototype._getUserURL = function(
283
283
    remain = remain || 10;
284
284
    var links = $x('id("menu")/li[3]/a');
285
285
    if(links && 0 < links.length)
286
        callback.call(thisObj, links[0].href);
286
        callback && callback.call(thisObj, links[0].href);
287
287
    else{
288
288
        console.log('Wedata#_getUserURL: failed to get user URL: remain: ' + remain);
289
289
        if(remain == 0)
290
            callback.call(thisObj, '');
290
            callback && callback.call(thisObj, '');
291
291
        else{
292
292
            var scope = this;
293
293
            var callee = arguments.callee;
@@ -333,16 +333,12 @@ ItemList.prototype.init = function(){
333
333
        var scope = this;
334
334
        unsafeWindow.wdmgr_delete = function(id){
335
335
            setTimeout(function(){
336
                console.log('ItemList#init: del: FN: ' + scope.wd.deleteItem(id, function(result){
337
                    console.log('ItemList#init: del: CB: ' + result);
338
                }, scope));
336
                scope.wd.deleteItem(id)
339
337
            }, 0);
340
338
        }
341
339
        unsafeWindow.wdmgr_duplicate = function(id){
342
340
            setTimeout(function(){
343
                console.log('ItemList#init: dup: FN: ' + scope.wd.duplicateItem(id, function(result){
344
                    console.log('ItemList#init: dup: CB: ' + result);
345
                }, scope));
341
                scope.wd.duplicateItem(id)
346
342
            }, 0);
347
343
        }
348
344