diff options
-rw-r--r-- | data/style.css | 4 | ||||
-rw-r--r-- | elm/iv.js | 28 | ||||
-rw-r--r-- | lib/VNWeb/VN/Page.pm | 6 |
3 files changed, 23 insertions, 15 deletions
diff --git a/data/style.css b/data/style.css index 560f8f35..cce9e6d8 100644 --- a/data/style.css +++ b/data/style.css @@ -1013,7 +1013,7 @@ div#iv_view { * 1 div -> loading * 2 div -> img * 3 a -> full - * 4 a -> close + * 4 a -> flagging * 5 a -> prev * 6 a -> next */ .ivview { position: fixed; background: $boxbg$; border: 2px solid $border$; padding: 5px; text-align: center } @@ -1021,7 +1021,7 @@ div#iv_view { .ivview img { cursor: pointer } .ivview > div:nth-child(1) { position: absolute; left: 48%; top: 48%; width: 30px; height: 30px } .ivview > a:nth-child(3) { float: left; padding-right: 10px } -.ivview > a:nth-child(4) { float: right; padding-left: 10px } +.ivview > a:nth-child(4) { float: right; padding-left: 10px; font-size: 11px; font-weight: normal; display: inline-block; width: 130px; text-align: right; white-space: nowrap } .ivview > a:nth-child(5) { padding-right: 5px } .ivview > a:nth-child(6) { padding-left: 5px } @@ -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); diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm index 3d95746d..c25c2f55 100644 --- a/lib/VNWeb/VN/Page.pm +++ b/lib/VNWeb/VN/Page.pm @@ -86,7 +86,7 @@ sub rev_ { a_ href => "/r$_->{rid}", "r$_->{rid}" if $_->{rid}; txt_ 'no release' if !$_->{rid}; txt_ '] '; - a_ href => tuwf->imgurl($_->{scr}{id}), 'data-iv' => "$_->{scr}{width}x$_->{scr}{height}", $_->{scr}{id}; + a_ href => tuwf->imgurl($_->{scr}{id}), 'data-iv' => "$_->{scr}{width}x$_->{scr}{height}::$_->{scr}{sexual}$_->{scr}{violence}$_->{scr}{votecount}", $_->{scr}{id}; txt_ ' (Not safe)' if $_->{nsfw}; }], [ image => 'Image', fmt => sub { image_ $_ } ], @@ -624,8 +624,6 @@ sub screenshots_ { my %rel; push $rel{$_->{rid}}->@*, $_ for grep $_->{rid}, @$s; - # TODO: Display image flagging status of each image, somehow. - input_ name => 'scrhide_s', id => "scrhide_s$_", type => 'radio', class => 'visuallyhidden', $sexp == $_ ? (checked => 'checked') : () for 0..2; input_ name => 'scrhide_v', id => "scrhide_v$_", type => 'radio', class => 'visuallyhidden', $viop == $_ ? (checked => 'checked') : () for 0..2; div_ class => 'mainbox', id => 'screenshots', sub { @@ -654,7 +652,7 @@ sub screenshots_ { }; div_ class => 'scr', sub { a_ href => tuwf->imgurl($_->{scr}{id}), - 'data-iv' => "$_->{scr}{width}x$_->{scr}{height}:scr", + 'data-iv' => "$_->{scr}{width}x$_->{scr}{height}:scr:$_->{scr}{sexual}$_->{scr}{violence}$_->{scr}{votecount}", mkclass( scrlnk => 1, scrlnk_s0 => $_->{scr}{sexual} <= 0, |