summaryrefslogtreecommitdiff
path: root/elm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-07-09 12:48:06 +0200
committerYorhel <git@yorhel.nl>2020-07-09 12:50:38 +0200
commit73eb6385240d82424d13235f02822920f51e974b (patch)
treee771c61f6a7a8bb66aac7cee497569b98d8955be /elm
parent5cba41839bc1059fa06904f7ebccd490f93b465e (diff)
VN::Page: Display screenshot flagging status in imageviewer thing
Replacing the 'close' button with something that does pretty much the opposite may not be the wisest thing to do, but that close button has always been a bit useless considering that clicking almost anywhere on the page will have the same effect. The right-bottom of the image is the natural place for the flagging status, as that's also where the status is displayed for other images on the site.
Diffstat (limited to 'elm')
-rw-r--r--elm/iv.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/elm/iv.js b/elm/iv.js
index 5892bef8..d81b6a19 100644
--- a/elm/iv.js
+++ b/elm/iv.js
@@ -1,12 +1,14 @@
//order:8 - After all regular JS, as other files may modify pageVars or modules in the Elm.* namespace.
/* Simple image viewer widget. Usage:
*
- * <a href="full_image.jpg" data-iv="{width}x{height}:{category}">..</a>
+ * <a href="full_image.jpg" data-iv="{width}x{height}:{category}:{flagging}">..</a>
*
* Clicking on the above link will cause the image viewer to open
* full_image.jpg. The {category} part can be empty or absent. If it is not
* empty, next/previous links will show up to point to the other images within
- * the same category.
+ * the same category. The {flagging} part can also be empty or absent,
+ * otherwise it should be a string in the format "svn", where s and v indicate
+ * the sexual/violence scores (0-2) and n the number of votes.
*
* ivInit() should be called when links with "data-iv" attributes are
* dynamically added or removed from the DOM.
@@ -23,7 +25,7 @@ var ivfull;
var ivnext;
var ivprev;
var ivload;
-var ivclose;
+var ivflag;
var imgw;
var imgh;
@@ -47,11 +49,8 @@ function create_div() {
ivfull = document.createElement('a');
ivparent.appendChild(ivfull);
- ivclose = document.createElement('a');
- ivclose.href = '#';
- ivclose.onclick = ivClose;
- ivclose.textContent = 'close';
- ivparent.appendChild(ivclose);
+ ivflag = document.createElement('a');
+ ivparent.appendChild(ivflag);
ivprev = document.createElement('a');
ivprev.onclick = show;
@@ -129,7 +128,7 @@ function resize() {
function show(ev) {
var u = this.href;
- var opt = this.getAttribute('data-iv').split(':');
+ var opt = this.getAttribute('data-iv').split(':'); // 0:reso, 1:category, 2:flagging
var idx = this.iv_i;
imgw = Math.floor(opt[0].split('x')[0]);
imgh = Math.floor(opt[0].split('x')[1]);
@@ -144,6 +143,17 @@ function show(ev) {
ivimg.textContent = '';
ivimg.appendChild(img);
+ let flag = opt[2] ? opt[2].match(/^([0-2])([0-2])([0-9]+)$/) : null;
+ var imgid = u.match(/\/([a-z]{2})\/[0-9]{2}\/([0-9]+)\./);
+ if(flag && imgid) {
+ ivflag.href = '/img/'+imgid[1]+imgid[2];
+ ivflag.textContent = flag[3] == 0 ? 'Not flagged' :
+ (flag[1] == 0 ? 'Safe' : flag[1] == 1 ? 'Suggestive' : 'Explicit') + ' / ' +
+ (flag[2] == 0 ? 'Tame' : flag[2] == 1 ? 'Violent' : 'Brutal' ) + ' (' + flag[3] + ')';
+ ivflag.style.visibility = 'visible';
+ } else
+ ivflag.style.visibility = 'hidden';
+
ivparent.style.display = 'block';
ivload.style.display = 'block';
fixnav(ivprev, opt[1], idx, -1);