Widget:WBRControlPanel: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) Created page with "<includeonly> <script type="text/javascript"> </script> </includeonly>" |
Matt Pijoan (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly> | <includeonly> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
$(document).ready(function(){ | |||
$.getScript("http://wikidoc.org/resources/mediawiki.api/mediawiki.api.js", function(){ | |||
if(!mw.user.name()){ | |||
alert("Please Log In To Continue."); | |||
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=WBRControlPanel"); | |||
} | |||
}); | |||
}); | |||
function getQues(){ | |||
var api = new mw.Api(); | |||
var QueryString = '[[ExamType::'+exam+']] [[MainCategory::'+MainCat[Math.floor(Math.random()*MainCat.length)]+']] [[SubCategory::'+SubCat[Math.floor(Math.random()*SubCat.length)]+']]'; | |||
api.get( { | |||
action: 'ask', | |||
query: QueryString, | |||
format: 'json', | |||
async: false | |||
}, { | |||
ok: function (data) { | |||
$.each(data.query.results, function(index, value){ | |||
Questions.push(index); | |||
}); | |||
} | |||
}) | |||
.error( function ( error ) { | |||
$.each(error, function(key, value) { | |||
alert(key + ': ' + value); | |||
}); | |||
} ); | |||
} | |||
</script> | </script> | ||
</includeonly> | </includeonly> |