Widget:UserExamQuery: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
function ensureLoggedIn() { | function ensureLoggedIn() { | ||
mw.loader. | mw.loader.using('mediaWiki.user', function() {; | ||
if ($.isEmptyObject(wgUserName)) { | if ($.isEmptyObject(wgUserName)) { | ||
alert("Please Log In To Continue."); | |||
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=UserExamQuery"); | |||
} else { | } else { | ||
runQuery(); | |||
} | |||
}) | |||
} | } | ||
function runQuery() { | |||
function runQuery(){ | var api = new mw.Api(); | ||
api.get({ | |||
action : 'ask', | |||
username : username, | |||
format : 'json' | |||
}) | |||
.always(function (data) { | |||
console.log(data); | |||
}); | |||
} | } | ||
$(document).ready(ensureLoggedIn); | $(document).ready(ensureLoggedIn); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |