r113627 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113626‎ | r113627 | r113628 >
Date:16:06, 12 March 2012
Author:ezachte
Status:new
Tags:
Comment:
more changes to get consistent formatting of counts via javascript
Modified paths:
  • /trunk/wikistats/squids/SquidReportArchive.pl (modified) (history)

Diff [purge]

Index: trunk/wikistats/squids/SquidReportArchive.pl
@@ -2836,9 +2836,9 @@
28372837 if ($mimetype2 =~ /image\/(?:png|jpeg|gif)/)
28382838 { $mimetype2 .= "<br><small>(img)</small> " ; }
28392839 if ($columns == 1)
2840 - { $mimetype2 = "<font color=#008000>$mimetype2</font" ; }
 2840+ { $mimetype2 = "<font color=#008000>$mimetype2</font>" ; }
28412841 if (($columns >= 2) && ($columns <= 4))
2842 - { $mimetype2 = "<font color=#900000>$mimetype2</font" ; }
 2842+ { $mimetype2 = "<font color=#900000>$mimetype2</font>" ; }
28432843 ($mime1,$mime2) = split ('\/', $mimetype2, 2) ;
28442844 $header2 .= "<th class=c>$mime1<br>$mime2</th>\n" ;
28452845 }
@@ -2856,10 +2856,8 @@
28572857 $total = &FormatCount ($total) ;
28582858 $total_images = $images_domain {$domain} ;
28592859 $total_images1 += $total_images ;
2860 - $total_images = &FormatCount ($total_images) ;
2861 - $total_images = "<font color=#900000>" . &FormatCount ($total_images) . "</font>" ;
28622860
2863 - $html .= &ShowCountBold ($total) . &ShowCountBold ($total_images) . "\n" ;
 2861+ $html .= &ShowCountBold ($total) . &ShowCountBold ($total_images,"#900000") . "\n" ;
28642862 $columns = 0 ;
28652863 foreach $mimetype (@mimetypes_sorted)
28662864 {
@@ -2869,12 +2867,11 @@
28702868
28712869 $count = &FormatCount ($counts_dm {"$domain,$mimetype"}) ;
28722870 if ($columns == 1)
2873 - { $count = "<font color=#008000>$count</font" ; }
2874 - if (($columns >= 2) && ($columns <= 4))
2875 - { $count = "<font color=#900000>$count</font" ; }
2876 - if ($count eq "")
2877 - { $count = "&nbsp;" ; }
2878 - $html .= &ShowCount ($count) . "\n" ;
 2871+ { $html .= &ShowCount ($count,"#008000") . "\n" ; }
 2872+ elsif (($columns >= 2) && ($columns <= 4))
 2873+ { $html .= &ShowCount ($count,"#900000") . "\n" ; }
 2874+ else
 2875+ { $html .= &ShowCount ($count) . "\n" ; }
28792876 }
28802877 $html .= "</tr>\n" ;
28812878 $rows++ ;
@@ -2888,8 +2885,7 @@
28892886
28902887 $total_mimes1 = &FormatCount ($total_mimes) ;
28912888 $total_images1 = &FormatCount ($total_images1) ;
2892 - $total_images1 = "<font color=#900000>" . &FormatCount ($total_images1) . "</font>" ;
2893 - $html .= "<tr><th colspan=2 class=l>Total</th>" . &ShowCountBold ($total_mimes1) . &ShowCountBold ($total_images1) . "\n" ;
 2889+ $html .= "<tr><th colspan=2 class=l>Total</th>" . &ShowCountBold ($total_mimes1) . &ShowCountBold ($total_images1,"#900000") . "\n" ;
28942890 $columns = 0 ;
28952891 foreach $mimetype (@mimetypes_sorted)
28962892 {
@@ -2899,10 +2895,11 @@
29002896
29012897 $count = &FormatCount ($mimetypes {$mimetype}) ;
29022898 if ($columns == 1)
2903 - { $count = "<font color=#008000>$count</font" ; }
 2899+ { $html .= &ShowCountBold ($count,"#008000") . "\n" ; }
29042900 if (($columns >= 2) && ($columns <= 4))
2905 - { $count = "<font color=#900000>$count</font" ; }
2906 - $html .= &ShowCountBold ($count) . "\n" ;
 2901+ { $html .= &ShowCountBold ($count,"#900000") . "\n" ; }
 2902+ else
 2903+ { $html .= &ShowCountBold ($count) . "\n" ; }
29072904 }
29082905 $html .= "</tr>\n" ;
29092906
@@ -2925,9 +2922,8 @@
29262923 $html .= "<tr><td class=l>" . ucfirst($domain) . "</td><td class=l>$language</td>\n" ;
29272924
29282925 $total = &FormatCount ($total) ;
2929 - $total_images = $images_project {$project} ;
2930 - $total_images = "<font color=#900000>" . &FormatCount ($total_images) . "</font>" ;
2931 - $html .= &ShowCountBold ($total) . &ShowCountBold ($total_images) . "\n" ;
 2926+ $total_images = &FormatCount ($images_project {$project}) ;
 2927+ $html .= &ShowCountBold ($total) . &ShowCountBold ($total_images,"#900000") . "\n" ;
29322928
29332929 $columns = 0 ;
29342930 foreach $mimetype (@mimetypes_sorted)
@@ -2938,12 +2934,11 @@
29392935
29402936 $count = &FormatCount ($counts_pm {"$project,$mimetype"}) ;
29412937 if ($columns == 1)
2942 - { $count = "<font color=#008000>$count</font" ; }
 2938+ { $html .= &ShowCount ($count,"#008000") ; }
29432939 if (($columns >= 2) && ($columns <= 4))
2944 - { $count = "<font color=#900000>$count</font" ; }
2945 -# if ($count eq "")
2946 -# { $count = "&nbsp;" ; }
2947 - $html .= &ShowCount ($count) . "\n" ;
 2940+ { $html .= &ShowCount ($count,"#900000") ; }
 2941+ else
 2942+ { $html .= &ShowCount ($count) . "\n" ; }
29482943 }
29492944 $html .= "</tr>\n" ;
29502945 $rows++ ;
@@ -4672,7 +4667,7 @@
46734668 # $html .= "<tr>" .
46744669 # # "<td class=hc><b>${MPVE}'s<br>Per<br>I U</b></td>" .
46754670 # "<td colspan=99 class=hc><b>Share in Global Monthly $views_edits</b><br><small><font color=#808080>red and blue bars have different scale</font></small></td></tr>\n" ;
4676 - $html .= "<tr><td class=hr><b>Country</b></td><td class=hc><b>Region</b><br><img src='http://stats.wikimedia.org/Location_of_Continents2.gif'></td><td class=hc><b>N/S</b></td><td class=hc colspan=2><small><font color=#404040>absolute count and edits per internet user</font></small></td><td class=hl colspan=2><small>share of global total<font color=#808080><p>note:blue and red bars have different scale</font></small></td></tr>\n" ;
 4671+ $html .= "<tr><td class=hr><b>Country</b></td><td class=hc><b>Region</b><br><img src='http://stats.wikimedia.org/Location_of_Continents2.gif'></td><td class=hc><b>N/S</b></td><td class=hc colspan=2><small><font color=#404040>absolute count and monthly ${views_edits}s per internet user</font></small></td><td class=hl colspan=2><small>share of global total<font color=#808080><p>note:blue and red bars have different scale</font></small></td></tr>\n" ;
46774672 $html .= "<tr><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th colspan=2>&nbsp;</th></tr>\n" ;
46784673 $html .= "</thead><tbody>\nTOTAL\nREGIONS\n" ;
46794674
@@ -5563,7 +5558,7 @@
55645559
55655560 $perc =~ s/(\.\d)0/$1/ ; # 0.10% -> 0.1%
55665561 if ($show_logcount && ($requests_this_language < 5 * $months_recently)) # show in grey to discuss threshold on foundation-l
5567 - { $perc = "<font color=#800000>$perc</font" ; }
 5562+ { $perc = "<font color=#800000>$perc</font>" ; }
55685563
55695564 $html .= "<tr><th class=l class=small nowrap>$language</th>" .
55705565 ($show_logcount ? "<td class=r>$requests_this_language</td>" : "") .
@@ -5777,7 +5772,7 @@
57785773 {
57795774 my $count = shift ;
57805775 if ($count eq "")
5781 - { return ("&nbsp;") ; }
 5776+ { return ("0") ; }
57825777 if ($count < 1)
57835778 { return ("1") ; }
57845779 $count =~ s/^(\d{1,3})(\d\d\d)$/$1,$2/ ;
@@ -5788,26 +5783,31 @@
57895784
57905785 sub ShowCount # qqq2
57915786 {
5792 - my ($num) = @_ ;
 5787+ my ($num,$color) = @_ ;
57935788 $num =~ s/,//g ;
57945789
5795 - if ($num eq '&nbsp;') # to do: remove &nbsp;'s from perl code, send 0 instead, formatting in javascript
5796 - { $num = 0 ; }
 5790+ if (($num eq '&nbsp;') || ($num == 0))# to do: remove &nbsp;'s from perl code, send 0 instead, formatting in javascript
 5791+ { $num = '-' ; }
 5792+ else
 5793+ {
 5794+ if ($num =~ /^[\d\.]+$/) # numeric string
 5795+ { $num *= 1000 ; }
57975796
5798 - if ($num =~ /^[\d\.]+$/) # numeric string
5799 - { $num *= 1000 ; }
 5797+ if ($num =~ /\D/) # contains non-digit ? enclose in double quotes
 5798+ { $num ="\"$num\"" ; }
58005799
5801 - if ($num =~ /\D/) # contains non-digit ? enclose in double quotes
5802 - { $num ="\"$num\"" ; }
5803 -
5804 - $num = "<script>showCount($num);</script>" ;
5805 - return ("<td class=r>$num</td>") ;
 5800+ $num = "<script>showCount($num);</script>" ;
 5801+ }
 5802+ if ($color eq '')
 5803+ { return ("<td class=r>$num</td>") ; }
 5804+ else
 5805+ { return ("<td class=r><font color=$color>$num</font></td>") ; }
58065806 }
58075807
58085808 sub ShowCountBold
58095809 {
5810 - my ($num) = @_ ;
5811 - $num = &ShowCount ($num) ;
 5810+ my ($num,$color) = @_ ;
 5811+ $num = &ShowCount ($num,$color) ;
58125812 $num =~ s/td/th/g ;
58135813 return ($num) ;
58145814 }

Status & tagging log