From 473b0007bddb1bcd9df1d95a00029b69fa7060e2 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Mon, 1 Dec 2014 18:32:21 +0100 Subject: Replace some 'onclick' attributes with JS-generated events I think this was the last piece of inline JS. --- data/script.js | 15 +++++++++++++++ lib/VNDB/Handler/Tags.pm | 6 +++--- lib/VNDB/Handler/Traits.pm | 6 +++--- lib/VNDB/Handler/Users.pm | 4 ++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/data/script.js b/data/script.js index 5aae0305..ce66bc02 100644 --- a/data/script.js +++ b/data/script.js @@ -2683,6 +2683,11 @@ if(byId('advselect')) { }; } +// Spoiler selection buttons on tag/trait browse pages +if(byId('tagspoil_0')) byId('tagspoil_0').onclick = function() { setCookie('tagspoil', 0); return true; }; +if(byId('tagspoil_1')) byId('tagspoil_1').onclick = function() { setCookie('tagspoil', 1); return true; }; +if(byId('tagspoil_2')) byId('tagspoil_2').onclick = function() { setCookie('tagspoil', 2); return true; }; + // NSFW VN image toggle (/v+) if(byId('nsfw_show')) { var msg = byId('nsfw_show'); @@ -2735,6 +2740,16 @@ if(byId('listsel')) { }; } +// Notification list onclick +if(byId('notifies')) { + var l = byClass(byId('notifies'), 'td', 'clickable'); + for(var i=0; i 'browseopts'; - a href => "/g$t->{id}?fil=$f->{fil};m=0", $f->{m} == 0 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 0);return true;", mt '_tagp_spoil0'; - a href => "/g$t->{id}?fil=$f->{fil};m=1", $f->{m} == 1 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 1);return true;", mt '_tagp_spoil1'; - a href => "/g$t->{id}?fil=$f->{fil};m=2", $f->{m} == 2 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 2);return true;", mt '_tagp_spoil2'; + a href => "/g$t->{id}?fil=$f->{fil};m=0", $f->{m} == 0 ? (class => 'optselected') : (), id => 'tagspoil_0', mt '_tagp_spoil0'; + a href => "/g$t->{id}?fil=$f->{fil};m=1", $f->{m} == 1 ? (class => 'optselected') : (), id => 'tagspoil_1', mt '_tagp_spoil1'; + a href => "/g$t->{id}?fil=$f->{fil};m=2", $f->{m} == 2 ? (class => 'optselected') : (), id => 'tagspoil_2', mt '_tagp_spoil2'; end; a id => 'filselect', href => '#v'; diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm index 6cad44a0..5fff855d 100644 --- a/lib/VNDB/Handler/Traits.pm +++ b/lib/VNDB/Handler/Traits.pm @@ -98,9 +98,9 @@ sub traitpage { p class => 'browseopts'; # Q: tagp!? A: lazyness >_> - a href => "/i$trait?m=0", $f->{m} == 0 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 0);return true;", mt '_tagp_spoil0'; - a href => "/i$trait?m=1", $f->{m} == 1 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 1);return true;", mt '_tagp_spoil1'; - a href => "/i$trait?m=2", $f->{m} == 2 ? (class => 'optselected') : (), onclick => "setCookie('tagspoil', 2);return true;", mt '_tagp_spoil2'; + a href => "/i$trait?m=0", $f->{m} == 0 ? (class => 'optselected') : (), id => 'tagspoil_0', mt '_tagp_spoil0'; + a href => "/i$trait?m=1", $f->{m} == 1 ? (class => 'optselected') : (), id => 'tagspoil_1', mt '_tagp_spoil1'; + a href => "/i$trait?m=2", $f->{m} == 2 ? (class => 'optselected') : (), id => 'tagspoil_2', mt '_tagp_spoil2'; end; a id => 'filselect', href => '#c'; diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index 09be3d34..cf55a605 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -673,7 +673,7 @@ sub notifies { my $code = $self->authGetCode("/u$uid/notifies"); if(@$list) { - form action => "/u$uid/notifies?r=$f->{r};formcode=$code", method => 'post'; + form action => "/u$uid/notifies?r=$f->{r};formcode=$code", method => 'post', id => 'notifies'; $self->htmlBrowse( items => $list, options => $f, @@ -698,7 +698,7 @@ sub notifies { td class => 'tc4'; a href => "/u$uid/notify/$l->{id}", "$l->{ltype}$l->{iid}".($l->{subid}?".$l->{subid}":''); end; - td class => 'tc5', onclick => qq|javascript:location.href="/u$uid/notify/$l->{id}"|; + td class => 'tc5 clickable', id => "notify_$l->{id}"; lit mt '_usern_n_'.( $l->{ltype} eq 't' ? ($l->{subid} == 1 ? 't_new' : 't_reply') : 'item_edit'), -- cgit v1.2.3