From 4fcbb93cf90d420513856df128f13950909fb36f Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 15 May 2014 07:17:41 -0400 Subject: [PATCH] 100-point scores -> decimal scores. --- main.js | 20 ++++++++++---------- manifest.json | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/main.js b/main.js index d37b18d..091e46b 100644 --- a/main.js +++ b/main.js @@ -28,10 +28,10 @@ function get_edit_id_from_href(href) { } function get_scores_from_element(elem) { - var score_100 = parseInt(elem.val()); - var score_10 = Math.round(score_100 / 10.); - if (isNaN(score_100) || score_100 < 1 || score_100 > 100) { - alert("Invalid score: must be an integer between 1 and 100."); + var score_100 = Math.round(elem.val() * 10) / 10; + var score_10 = Math.round(elem.val()); + if (isNaN(score_100) || score_100 < 1 || score_100 > 10) { + alert("Invalid score: must be a decimal between 1.0 and 10.0."); return null; } return [score_100, score_10]; @@ -229,7 +229,7 @@ function hook_list() { else { var current = parseInt($(elem).text()); if (!isNaN(current)) - $(elem).text(current * 10); + $(elem).text(current + ".0"); } $("#scorediv" + anime_id) @@ -273,10 +273,10 @@ function hook_anime(anime_id) { if (!is_new && score === null) { var old_score = parseInt(old_input.val()); - score = old_score == 0 ? "" : old_score * 10; + score = old_score == 0 ? "" : old_score + ".0"; } - old_input.after($(" / 100")) + old_input.after($(" / 10.0")) .after($("") .attr("type", "text") .attr("id", "myinfo_score") @@ -302,7 +302,7 @@ function hook_add() { var old_input = $("select[name='score']"); var old_submit = $("input[type='button'][onclick='checkValidSubmit(1)']"); - old_input.after($(" / 100")) + old_input.after($(" / 10.0")) .after($("") .attr("type", "text") .attr("id", "score_input") @@ -329,10 +329,10 @@ function hook_edit(anime_id) { if (score === null) { var old_score = parseInt(old_input.val()); - score = old_score == 0 ? "" : old_score * 10; + score = old_score == 0 ? "" : old_score + ".0"; } - old_input.after($(" / 100")) + old_input.after($(" / 10.0")) .after($("") .attr("type", "text") .attr("id", "score_input") diff --git a/manifest.json b/manifest.json index 92f5f4e..efdc700 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 2, - "name": "100-Point Scores for MyAnimeList", + "name": "Decimal Scores for MyAnimeList", "version": "0.1", "description": "Gives you finer control over MyAnimeList.net scores.", - "short_name": "MAL 100", + "short_name": "MAL Decimal", "icons": {}, "content_scripts": [{