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 |
||
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, evt) { | |||
submitRating("difficulty", score, event) | |||
} | |||
}); | }); | ||
$("#star2").raty({ | $("#star2").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/lib/img/', | |||
click : function (score, evt) { | |||
submitRating("yield", score, event) | |||
} | |||
}); | }); | ||
$("#star3").raty({ | $("#star3").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/lib/img/', | |||
click : function (score, evt) { | |||
submitRating("quality", score, event) | |||
} | |||
}); | }); | ||
function submitRating(type, score, page){ | function submitRating(type, score, page) { | ||
alert(score); | alert(score); | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get({ | api.get({ | ||
action : 'wbrinsertrating', | action : 'wbrinsertrating', | ||
username : mw.user.getName(), | username : mw.user.getName(), | ||
question : page, | question : page, | ||
type : score, | type : score, | ||
format : 'json' | format : 'json' | ||
}) | }) | ||
.done( function ( data ) { | .done(function (data) { | ||
console.log('API result:', data); | |||
}); | |||
}); | |||
} | } | ||
</script> | </script> | ||
</includeonly> | </includeonly> |