Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/162133
Change subject: Hygiene: Add recordOccupation method to WikiGrokApi
......................................................................
Hygiene: Add recordOccupation method to WikiGrokApi
Change-Id: I174f95597c1465f2a6677b1d83bbb704e10b03f6
---
M javascripts/modules/wikigrok/WikiGrokApi.js
M javascripts/modules/wikigrok/WikiGrokDialog.js
2 files changed, 29 insertions(+), 24 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/33/162133/1
diff --git a/javascripts/modules/wikigrok/WikiGrokApi.js
b/javascripts/modules/wikigrok/WikiGrokApi.js
index e9dfa61..deb5430 100644
--- a/javascripts/modules/wikigrok/WikiGrokApi.js
+++ b/javascripts/modules/wikigrok/WikiGrokApi.js
@@ -7,14 +7,32 @@
WikiGrokApi = Api.extend( {
apiUrl: 'https://tools.wmflabs.org/wikigrok/api.php',
- initialize: function() {
+ initialize: function( options ) {
+ this.itemId = options.itemId;
Api.prototype.initialize.apply( this, arguments );
},
- getPossibleOccupations: function( itemId ) {
+ recordOccupation: function( subject, occupationId, occupation,
claimIsCorrect ) {
+ return this.ajax( {
+ action: 'record_answer',
+ subject_id: this.itemId,
+ subject: subject,
+ occupation_id: occupationId,
+ occupation: occupation,
+ page_name: mw.config.get( 'wgPageName'
),
+ correct: claimIsCorrect,
+ user_id: mw.user.getId(),
+ source: 'mobile A'
+ },
+ {
+ url: this.apiUrl,
+ dataType: 'jsonp'
+ } );
+ },
+ getPossibleOccupations: function() {
return this.ajax( {
action: 'get_potential_occupations',
// Strip the Q out of the Wikibase item
ID
- item: itemId.replace( 'Q' , '' )
+ item: this.itemId.replace( 'Q' , '' )
},
{
url: this.apiUrl,
diff --git a/javascripts/modules/wikigrok/WikiGrokDialog.js
b/javascripts/modules/wikigrok/WikiGrokDialog.js
index fa601a7..136d460 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialog.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialog.js
@@ -35,8 +35,8 @@
},
template: M.template.get(
'modules/wikigrok/WikiGrokDialog.hogan' ),
- initialize: function() {
- this.apiWikiGrok = new WikiGrokApi();
+ initialize: function( options ) {
+ this.apiWikiGrok = new WikiGrokApi( { itemId:
options.itemId } );
this.apiWikiData = new WikiDataApi();
Panel.prototype.initialize.apply( this, arguments );
},
@@ -94,25 +94,12 @@
// Record answer in temporary database for analysis.
// Eventually answers will be recorded directly to Wikidata.
recordClaim: function( options ) {
- var self = this;
- $.ajax( {
- type: 'get',
- url:
'https://tools.wmflabs.org/wikigrok/api.php',
- data: {
- 'action': 'record_answer',
- 'subject_id': options.itemId,
- 'subject': options.name,
- 'occupation_id': options.occupationId,
- 'occupation': options.occupation,
- 'page_name': mw.config.get(
'wgPageName' ),
- 'correct': options.claimIsCorrect,
- 'user_id': mw.config.get( 'wgUserId' ),
- 'source': 'mobile A'
- },
- dataType: 'jsonp',
- success: function() {
- self.thankUser( options, true );
- }
+ var self = this,
+ args = [ options.name, options.occupationId,
+ options.occupation,
options.claimIsCorrect ];
+
+ this.apiWikiGrok.recordOccupation.apply(
this.apiWikiGrok, args ).done( function() {
+ self.thankUser( options, true );
} );
},
--
To view, visit https://gerrit.wikimedia.org/r/162133
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I174f95597c1465f2a6677b1d83bbb704e10b03f6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits