diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-12-29 15:57:16 +0000 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-12-29 15:57:16 +0000 |
commit | 2975f94d9effb4bf509945b60a7f7872098ede86 (patch) | |
tree | f07056ffb9f58ee024a977074333d4e05019eaa2 | |
parent | a9a045eefddcf6a0c1d759cf3b80c91832514ee7 (diff) | |
download | cheatdb-2975f94d9effb4bf509945b60a7f7872098ede86.tar.xz |
Add short description tips
-rw-r--r-- | app/public/static/package_edit.js | 32 | ||||
-rw-r--r-- | app/templates/packages/create_edit.html | 2 |
2 files changed, 33 insertions, 1 deletions
diff --git a/app/public/static/package_edit.js b/app/public/static/package_edit.js index 481e774..b997b83 100644 --- a/app/public/static/package_edit.js +++ b/app/public/static/package_edit.js @@ -22,6 +22,38 @@ $(function() { } }); + let hint = null; + function showHint(ele, text) { + if (hint) { + hint.remove(); + } + + hint = ele.parent() + .append(`<div class="alert alert-warning my-3">${text}</div>`) + .find(".alert"); + } + + let hint_mtmods = `Tip: + Don't include <i>Minetest</i>, <i>mod</i>, or <i>modpack</i> anywhere in the short description. + It is unnecessary and wastes characters.`; + + let hint_thegame = `Tip: + It's obvious that this adds something to Minetest, + there's no need to use phrases such as \"adds X to the game\".` + + $("#shortDesc").on("change paste keyup", function() { + var val = $(this).val().toLowerCase(); + if (val.indexOf("minetest") >= 0 || val.indexOf("mod") >= 0 || + val.indexOf("modpack") >= 0 || val.indexOf("mod pack") >= 0) { + showHint($(this), hint_mtmods); + } else if (val.indexOf("the game") >= 0) { + showHint($(this), hint_thegame); + } else if (hint) { + hint.remove(); + hint = null; + } + }) + var btn = $("#forums").parent().find("label").append("<a class='ml-3 btn btn-sm btn-primary'>Open</a>"); btn.click(function() { var id = $("#forums").val(); diff --git a/app/templates/packages/create_edit.html b/app/templates/packages/create_edit.html index 0953ce5..e6fe400 100644 --- a/app/templates/packages/create_edit.html +++ b/app/templates/packages/create_edit.html @@ -22,7 +22,7 @@ </div> </noscript> {% endif %} - <script src="/static/package_edit.js?v=2"></script> + <script src="/static/package_edit.js?v=3"></script> {% endblock %} {% block content %} |