Widget:Raty: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
$("#star1").raty({ | $("#star1").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/lib/img/', | |||
click : function (score, event) { | |||
submitRating("difficulty", score, "Buh") | |||
} | |||
}); | }); | ||
$("#star2").raty({ | $("#star2").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/lib/img/', | |||
click : function (score, event) { | |||
submitRating("yield", score, "Buh") | |||
} | |||
}); | }); | ||
$("#star3").raty({ | $("#star3").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/lib/img/', | |||
click : function (score, event) { | |||
submitRating("quality", score, "Buh") | |||
} | |||
}); | }); | ||
function submitRating(type, score, page) { | |||
alert(score); | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'wbrinsertrating', | |||
username : mw.user.getName(), | |||
question : page, | |||
type : score, | |||
format : 'json' | |||
}) | |||
.done(function (data) { | |||
console.log('API result:', data); | |||
}); | |||
} | |||
</script> | </script> | ||
</includeonly> | </includeonly> |