Widget:EditSandbox: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
(20 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
function execute(){ | function execute(){ | ||
addToQueue(); | addToQueue("Edit'd"); | ||
} | } | ||
function addToQueue(question){ | |||
function | |||
var api = new mw.Api(); | var api = new mw.Api(); | ||
var result; | |||
var pageString = "User:" + mw.user.name() + "/WBRQueue"; | |||
api.get( { | api.get( { | ||
action: 'query', | action: 'query', | ||
format: 'json', | format: 'json', | ||
titles: | titles: pageString, | ||
export: 'export', | export: 'export', | ||
} , { | } , { | ||
Line 24: | Line 22: | ||
$title = $xml.find( "text" ); | $title = $xml.find( "text" ); | ||
var pageContent = $title.text().split(','); | |||
pageContent.push(question); | |||
alert(pageContent.toString()); | |||
var token = getToken(pageContent.toString()); | |||
}}); | }}); | ||
return result; | |||
} | } | ||
function getToken(){ | function getToken(question){ | ||
var token; | var token; | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
Line 36: | Line 38: | ||
format: 'json', | format: 'json', | ||
intoken: 'edit', | intoken: 'edit', | ||
titles: | titles: "User:" + mw.user.name() + "/WBRQueue", | ||
async: false | async: false | ||
}, { | }, { | ||
Line 42: | Line 44: | ||
$.each(data.query.pages, function(index, value){ | $.each(data.query.pages, function(index, value){ | ||
var token = value.edittoken; | var token = value.edittoken; | ||
addNewSection( " | addNewSection( "User:" + mw.user.name() + "/WBRQueue",question, token ); | ||
})}}); | })}}); | ||
Line 72: | Line 74: | ||
}); | }); | ||
} | } | ||
</script> | </script> | ||
<form> | <form> |