r63450 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63449‎ | r63450 | r63451 >
Date:00:56, 9 March 2010
Author:neilk
Status:deferred
Tags:
Comment:
make completed callbacks work properly
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.ApiUploadHandler.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.ApiUploadHandler.js
@@ -36,14 +36,14 @@
3737 },
3838
3939
40 - addCompletedCb: function(fn) {
 40+ addCompletedCb: function(f) {
4141 var _this = this;
42 - _this.completedCallbacks.push(function() { fn() });
 42+ _this.completedCallbacks.push(f);
4343 },
4444
45 - addErrorCb: function(fn) {
 45+ addErrorCb: function(f) {
4646 var _this = this;
47 - _this.errorCallbacks.push(function() { fn(error) });
 47+ _this.errorCallbacks.push(f);
4848 },
4949
5050 configureForm: function() {
@@ -71,6 +71,9 @@
7272 _this.addFormInputIfMissing('token', mw.getConfig('token'));
7373 _this.addFormInputIfMissing('action', 'upload');
7474 _this.addFormInputIfMissing('format', 'jsonfm');
 75+
 76+ // XXX only for testing, so it stops complaining about dupes
 77+ _this.addFormInputIfMissing('ignorewarnings', '1');
7578 },
7679
7780 addFormInputIfMissing: function(name, value) {
@@ -102,7 +105,6 @@
103106 var _this = this;
104107 _this.ui.progress(fraction);
105108 for (var i = 0; i < _this.progressCallbacks.length; i++) {
106 - debugger;
107109 _this.progressCallbacks[i](fraction);
108110 }
109111 },
@@ -113,9 +115,7 @@
114116 completed: function(result) {
115117 console.log("api: upload completed!")
116118 var _this = this;
117 -
118119 _this.ui.completed();
119 -
120120 for (var i = 0; i < _this.completedCallbacks.length; i++) {
121121 _this.completedCallbacks[i](result);
122122 }

Status & tagging log