note
ccn
Thank you [ig]. Here is my stuff: <readmore>
<code>
#!/usr/bin/perl --
use strict;
use warnings;
use LWP::Simple;
my $saints = get('http://perlmonks.org/?node=Saints%20in%20our%20Book')
or die "Can't get saints list\n";
# a hash of something like ( 'Cardinal (24)' => [9073, 381608], ... )
my %levels = (
'HighPriority (00)' => [ # users to be highlighted
116292, # mpeppler
679041, # oshalla
222593, # ccn
],
);
push @{$levels{$2}}, $1
while $saints =~ m{user-(\d+).+?<td>(\w+ \(\d+)\)</td>}g;
print <<'End_of_FreeNodelet_part_1';
[id://492700|Free Nodelet]
<!--
Highlight monk names accordingly their XP level
see http://perlmonks.org/?node_id=752253 for comments
-->
<style type="text/css">
.Pope { font-weight: bold; color: #01C2F3 !important; }
.Saint { font-weight: bold; color: #F400B1 !important; }
.Sage { font-weight: bold; color: #F400B1 !important; }
.Cardinal { font-weight: bold; color: #F400B1 !important; }
.Archbishop { font-weight: bold; color: #F400B1 !important; }
.Bishop { font-weight: bold; color: #F400B1 !important; }
.Chancellor { font-weight: bold; color: #FF8000 !important; }
.Canon { font-weight: bold; color: #FF8000 !important; }
.Abbot { font-weight: bold; color: #FF8000 !important; }
.Monsignor { font-weight: bold; color: #BA4D73 !important; }
.Prior { font-weight: bold; color: #BA4D73 !important; }
.Parson { font-weight: bold; color: #BA4D73 !important; }
.Vicar { font-weight: bold; color: #51AE5A !important; }
.Priest { font-weight: bold; color: #51AE5A !important; }
.Curate { font-weight: bold; color: #51AE5A !important; }
.HighPriority { font-weight: bold; background-color: #FFFF00 !important; }
</style>
<script type="text/javascript">
<!--
// "When a society has no colored pants to differentiate class...
// ...it's a society without purpose" -- Wef
// http://en.wikipedia.org/wiki/Kin-dza-dza!
var SaintsBook = new Object();
End_of_FreeNodelet_part_1
for my $ra (sort {$b->[2] cmp $a->[2]} map {[$_, split / /, $_]} keys %levels) {
# $ra looks like ['Cardinal (24)', 'Cardinal', '(24)']
print "var $ra->[1] = [", join(', ', @{$levels{$ra->[0]}}), "];\n";
print "for( var i=$ra->[1].length-1; i>=0; i--) SaintsBook[$ra->[1]\[i]] = '$ra->[1]';\n\n";
}
print <<'End_of_FreeNodelet_part_2';
function Colorize() {
var links = document.links;
for( var i=links.length-1; i>=0 ; --i )
if ( /node_id=(\d+)/.test(links[i].href) && SaintsBook[RegExp.$1] )
links[i].className = SaintsBook[RegExp.$1];
}
setTimeout('Colorize()', 600);
// -->
</script>
<!--
End of Highlight monk names accordingly their XP level
-->
End_of_FreeNodelet_part_2
__END__
</code>
</readmore>
I'd like to make a cgi version of that script but I have no suitable public site to publish it.
752253
765794