
BStrauss3 at attbi
Dec 21, 2001, 11:38 PM
Post #1 of 1
(139 views)
Permalink
|
|
[PATCH-improvement] IMG ALT Tag
|
|
It's good practice in html to always use the ALT= option on IMG tags. Both for visually challenged individuals (the ALT is what a screen reader says) and because icons aren't always 100% clear - quick, what does the gear mean? With an ALT value, when the mouse hovers over the image, that's the "tooltip" text the user sees. Anyway, except for one in pbuf.c that I don't understand (yet), the following patch adds ALTs to the IMGs. For bar graphs, it shows the % value, for others - well, look over the patch. As usual, comments, additions, etc. welcomed... -----Burton ===================B E G I N======================== --- ntop-original/webInterface.c Tue Dec 18 17:05:24 2001 +++ ntop-current/webInterface.c Fri Dec 21 15:54:28 2001 @@ -301,17 +301,17 @@ if(isDHCPClient(el)) - dynIp = " <IMG SRC=/bulb.gif BORDER=0> "; + dynIp = " <IMG ALT=\"DHCP Client\" SRC=/bulb.gif BORDER=0> "; else { if(isDHCPServer(el)) - dynIp = " <IMG SRC=/wheel.gif BORDER=0> "; + dynIp = " <IMG ALT=\"DHCP Server\" SRC=/wheel.gif BORDER=0> "; else dynIp = ""; } - if(isMultihomed(el)) multihomed = " <IMG SRC=/multihomed.gif BORDER=0> "; else multihomed = ""; - if(gatewayHost(el)) gwStr = " <IMG SRC=/router.gif BORDER=0> "; else gwStr = ""; - if(nameServerHost(el)) dnsStr = " <IMG SRC=/dns.gif BORDER=0> "; else dnsStr = ""; - if(isPrinter(el)) printStr = " <IMG SRC=/printer.gif BORDER=0> "; else printStr = ""; - if(isSMTPhost(el)) smtpStr = " <IMG SRC=/mail.gif BORDER=0> "; else smtpStr = ""; + if(isMultihomed(el)) multihomed = " <IMG ALT=\"Multihomed host\" SRC=/multihomed.gif BORDER=0> "; else multihomed = ""; + if(gatewayHost(el)) gwStr = " <IMG ALT=Router SRC=/router.gif BORDER=0> "; else gwStr = ""; + if(nameServerHost(el)) dnsStr = " <IMG ALT=\"DNS Server\" SRC=/dns.gif BORDER=0> "; else dnsStr = ""; + if(isPrinter(el)) printStr = " <IMG ALT=Printer SRC=/printer.gif BORDER=0> "; else printStr = ""; + if(isSMTPhost(el)) smtpStr = " <IMG ALT=\"Mail Server (SMTP)\" SRC=/mail.gif BORDER=0> "; else smtpStr = ""; switch(isHostHealthy(el)) { @@ -320,8 +320,8 @@ break; case 1: /* Warning */ - healthStr = "<IMG SRC=/Risk_medium.gif BORDER=0>"; + healthStr = "<IMG ALT=\"Medium Risk\" SRC=/Risk_medium.gif BORDER=0>"; break; case 2: /* Error */ - healthStr = "<IMG SRC=/Risk_high.gif BORDER=0>"; + healthStr = "<IMG ALT=\"High Risk\" SRC=/Risk_high.gif BORDER=0>"; break; } @@ -433,5 +433,6 @@ if(snprintf(flagBuf, sizeof(flagBuf), - "<IMG ALIGN=MIDDLE SRC=/statsicons/flags/%s.gif BORDER=0>", + "<IMG ALT=\"Flag for domain %s\" ALIGN=MIDDLE SRC=/statsicons/flags/%s.gif BORDER=0>", + domainName, domainName) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); --- ntop-original/reportUtils.c Tue Dec 18 17:05:21 2001 +++ ntop-current/reportUtils.c Fri Dec 21 16:44:04 2001 @@ -111,5 +111,5 @@ if(snprintf(buf, bufLen, "<TR %s><TH WIDTH=100 "TH_BG" ALIGN=LEFT>%s</TH>" "<TD WIDTH=100 "TD_BG" ALIGN=RIGHT>%s</TD>" - "<TD WIDTH=100><IMG ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=100 HEIGHT=12></TD>\n", + "<TD WIDTH=100><IMG ALT=\"100\%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=100 HEIGHT=12></TD>\n", getRowColor(), label, formatKBytes(totalS)) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); @@ -119,8 +119,9 @@ "<TD WIDTH=100 "TD_BG" ALIGN=RIGHT>%s</TD>" "<TD WIDTH=100 "TD_BG"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100\">" - "<TR><TD><IMG ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12></TD>" + "<TR><TD><IMG ALT=\"%d\%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12></TD>" "<TD "TD_BG" ALIGN=CENTER WIDTH=\"%d\">" "<P> </TD></TR></TABLE></TD>\n", getRowColor(), label, formatKBytes(totalS), + int_perc, (100*int_perc)/100, (100*(100-int_perc))/100) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); @@ -153,5 +154,5 @@ case 100: if(snprintf(buf, bufLen, "<TD WIDTH=100 "TD_BG" ALIGN=RIGHT>%s</TD>" - "<TD WIDTH=100><IMG ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"100\" HEIGHT=12></TD></TR>\n", + "<TD WIDTH=100><IMG ALT=\"100\%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"100\" HEIGHT=12></TD></TR>\n", formatKBytes(totalR)) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); break; @@ -159,8 +160,9 @@ if(snprintf(buf, bufLen, "<TD WIDTH=100 "TD_BG" ALIGN=RIGHT>%s</TD>" "<TD WIDTH=100 "TD_BG"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100\">" - "<TR><TD><IMG ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12>" + "<TR><TD><IMG ALT=\"%d\%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12>" "</TD><TD "TD_BG" ALIGN=CENTER WIDTH=\"%d\">" "<P> </TD></TR></TABLE></TD></TR>\n", formatKBytes(totalR), + int_perc, (100*int_perc)/100, (100*(100-int_perc))/100) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); @@ -250,8 +252,8 @@ if(revertOrder) { sign = ""; - arrowGif = " <IMG SRC=arrow_up.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Ascending order, click to reverse\" SRC=arrow_up.gif BORDER=0>"; } else { sign = "-"; - arrowGif = " <IMG SRC=arrow_down.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Descending order, click to reverse\" SRC=arrow_down.gif BORDER=0>"; } @@ -554,27 +556,27 @@ if(strstr(osName, "Windows") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/windows.gif>"; + flagImg = "<IMG ALT=\"OS: Windows\" ALIGN=MIDDLE SRC=/statsicons/os/windows.gif>"; else if(strstr(osName, "IRIX") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/irix.gif>"; + flagImg = "<IMG ALT=\"OS: Irix\" ALIGN=MIDDLE SRC=/statsicons/os/irix.gif>"; else if(strstr(osName, "Linux") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/linux.gif>"; + flagImg = "<IMG ALT=\"OS: Linux\" ALIGN=MIDDLE SRC=/statsicons/os/linux.gif>"; else if(strstr(osName, "SunOS") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/sun.gif>"; + flagImg = "<IMG ALT=\"OS: SunOS\" ALIGN=MIDDLE SRC=/statsicons/os/sun.gif>"; else if(strstr(osName, "Solaris") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/sun.gif>"; + flagImg = "<IMG ALT=\"OS: Sun Solaris\" ALIGN=MIDDLE SRC=/statsicons/os/sun.gif>"; else if(strstr(osName, "HP/JETdirect") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/hp.gif>"; + flagImg = "<IMG ALT=\"HP JetDirect\" ALIGN=MIDDLE SRC=/statsicons/os/hp.gif>"; else if(strstr(osName, "Mac") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/mac.gif>"; + flagImg = "<IMG ALT=\"OS: Apple Mac\" ALIGN=MIDDLE SRC=/statsicons/os/mac.gif>"; else if(strstr(osName, "Novell") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/novell.gif>"; + flagImg = "<IMG ALT=\"OS: Novell\" ALIGN=MIDDLE SRC=/statsicons/os/novell.gif>"; else if((strstr(osName, "BSD") != NULL) || (strstr(osName, "Unix") != NULL)) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/bsd.gif>"; + flagImg = "<IMG ALT=\"OS: BSD Unix\" ALIGN=MIDDLE SRC=/statsicons/os/bsd.gif>"; else if(strstr(osName, "HP-UX") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/hp.gif>"; + flagImg = "<IMG ALT=\"OS: HP-UX\" ALIGN=MIDDLE SRC=/statsicons/os/hp.gif>"; else if(strstr(osName, "AIX") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/aix.gif>"; + flagImg = "<IMG ALT=\"OS: IBM AIX\" ALIGN=MIDDLE SRC=/statsicons/os/aix.gif>"; else if(strstr(osName, "Berkeley") != NULL) - flagImg = "<IMG ALIGN=MIDDLE SRC=/statsicons/os/bsd.gif>"; + flagImg = "<IMG ALT=\"OS: Berkeley Unix\" ALIGN=MIDDLE SRC=/statsicons/os/bsd.gif>"; else flagImg = NULL; @@ -2657,5 +2659,5 @@ ) { if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s " - "<IMG SRC=/Risk_high.gif> <IMG SRC=/Risk_medium.gif> <IMG SRC=/Risk_low.gif>" + "<IMG ALT=\"High Risk\" SRC=/Risk_high.gif> <IMG ALT=\"Medium Risk\" SRC=/Risk_medium.gif> <IMG ALT=\"Low Risk\" SRC=/Risk_low.gif>" "</TH><TD "TD_BG" ALIGN=RIGHT NOWRAP><OL>", getRowColor(), "Network Healthness") < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); @@ -2663,9 +2665,9 @@ if(hasWrongNetmask(el)) - sendString("<LI><IMG SRC=/Risk_medium.gif><A HREF=/help.html#1>" + sendString("<LI><IMG ALT=\"Medium Risk\" SRC=/Risk_medium.gif><A HREF=/help.html#1>" "Wrong network mask or bridging enabled</A>\n"); if(hasDuplicatedMac(el)) - sendString("<LI><IMG SRC=/Risk_high.gif><A HREF=/help.html#2>" + sendString("<LI><IMG ALT=\"High Risk\" SRC=/Risk_high.gif><A HREF=/help.html#2>" "Duplicated MAC found for this IP address (spoofing?)</A>\n"); @@ -2704,10 +2706,10 @@ if(isWorkstation(el)) sendString("Workstation<br>"); if(isMasterBrowser(el)) sendString("Master Browser<br>"); - if(isPrinter(el)) sendString("Printer <IMG SRC=printer.gif BORDER=0><br>"); + if(isPrinter(el)) sendString("Printer <IMG ALT=Printer SRC=printer.gif BORDER=0><br>"); if(isBridgeHost(el)) sendString("Bridge<br>"); - if(nameServerHost(el)) sendString(" <IMG SRC=/dns.gif BORDER=0> Name Server<br>"); - if(gatewayHost(el)) sendString("Gateway <IMG SRC=/router.gif BORDER=0> <br>"); - if(isSMTPhost(el)) sendString("SMTP Server <IMG SRC=/mail.gif BORDER=0> <br>"); + if(nameServerHost(el)) sendString(" <IMG ALT=\"DNS Server\" SRC=/dns.gif BORDER=0> Name Server<br>"); + if(gatewayHost(el)) sendString("Gateway <IMG ALT=Router SRC=/router.gif BORDER=0> <br>"); + if(isSMTPhost(el)) sendString("SMTP Server <IMG ALT=\"Mail Server (SMTP)\" SRC=/mail.gif BORDER=0> <br>"); if(isPOPhost(el)) sendString("POP Server<br>"); if(isIMAPhost(el)) sendString("IMAP Server<br>"); @@ -2724,6 +2726,6 @@ #endif - if(isDHCPClient(el)) sendString("BOOTP/DHCP Client <IMG SRC=/bulb.gif BORDER=0><br>"); - if(isDHCPServer(el)) sendString("BOOTP/DHCP Server <IMG SRC=/wheel.gif BORDER=0> <br>"); + if(isDHCPClient(el)) sendString("BOOTP/DHCP Client <IMG ALT=\"DHCP Client\" SRC=/bulb.gif BIORDER=0><br>"); + if(isDHCPServer(el)) sendString("BOOTP/DHCP Server <IMG ALT=\"DHCP Server\" SRC=/wheel.gif BORDER=0> <br>"); sendString("</TD></TR>"); } @@ -2803,5 +2805,5 @@ if(isMultihomed(el) && (!broadcastHost(el))) - multihomed = " - multihomed <IMG SRC=/multihomed.gif BORDER=0>"; + multihomed = " - multihomed <IMG ALT=\"Multihomed host\" SRC=/multihomed.gif BORDER=0>"; else multihomed = ""; @@ -3017,5 +3019,5 @@ if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG" ALIGN=RIGHT>" "%s%s</TD></TR>\n", - getRowColor(), "MAC Address <IMG SRC=/card.gif BORDER=0>", + getRowColor(), "MAC Address <IMG ALT=\"Network Interface Card (NIC)\" SRC=/card.gif BORDER=0>", el->ethAddressString, separator /* it avoids empty cells not to be rendered */) < 0) @@ -3055,5 +3057,5 @@ if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG" ALIGN=RIGHT>" "<A HREF=%s.html>%s</A>%s</TD></TR>\n", - getRowColor(), "Last MAC Address/Router <IMG SRC=/card.gif BORDER=0>", + getRowColor(), "Last MAC Address/Router <IMG ALT=\"Network Interface Card (NIC)/Router\" SRC=/card.gif BORDER=0>", symLink, symMacAddr, separator /* it avoids empty cells not to be rendered */) < 0) @@ -3577,5 +3579,5 @@ if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT WIDTH=150>%s</TH>" "<TD "TD_BG" ALIGN=RIGHT WIDTH=100>%s</TD>" - "<TD ALIGN=CENTER WIDTH=250><IMG ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"250\" HEIGHT=12>" + "<TD ALIGN=CENTER WIDTH=250><IMG ALT=\"100\%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"250\" HEIGHT=12>" "</TD></TR>\n", getRowColor(), label, formatKBytes(total)) < 0) @@ -3586,8 +3588,9 @@ "<TD "TD_BG" ALIGN=RIGHT WIDTH=100>%s</TD>" "<TD "TD_BG" WIDTH=250><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"250\">" - "<TR><TD><IMG ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12>" + "<TR><TD><IMG ALT=\"%d\%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12>" "</TD><TD "TD_BG" ALIGN=CENTER WIDTH=\"%d\" %s>" "<P> </TD></TR></TABLE></TD></TR>\n", getRowColor(), label, formatKBytes(total), + int_perc, (250*int_perc)/100, (250*(100-int_perc))/100, getActualRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); @@ -3738,5 +3741,5 @@ snprintf(buf, BUF_SIZE, "<CENTER>\n" - "<P><IMG SRC=/warning.gif>\n" + "<P><IMG ALT=Warning SRC=/warning.gif>\n" "<P><FONT COLOR=\"#FF0000\" SIZE=+1>%s</FONT>\n" "</CENTER>\n", text); --- ntop-original/report.c Sat Dec 15 17:05:20 2001 +++ ntop-current/report.c Sat Dec 22 00:25:57 2001 @@ -849,8 +849,8 @@ if(revertOrder) { sign = ""; - arrowGif = " <IMG SRC=arrow_up.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Descending order, click to reverse\" SRC=arrow_up.gif BORDER=0>"; } else { sign = "-"; - arrowGif = " <IMG SRC=arrow_down.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Ascending order, click to reverse\" SRC=arrow_down.gif BORDER=0>"; } @@ -993,8 +993,8 @@ if(revertOrder) { sign = ""; - arrowGif = " <IMG SRC=arrow_up.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Descending order, click to reverse\" SRC=arrow_up.gif BORDER=0>"; } else { sign = "-"; - arrowGif = " <IMG SRC=arrow_down.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Ascending order, click to reverse\" SRC=arrow_down.gif BORDER=0>"; } @@ -1615,8 +1615,8 @@ if(revertOrder) { sign = ""; - arrowGif = " <IMG SRC=arrow_up.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Descending order, click to reverse\" SRC=arrow_up.gif BORDER=0>"; } else { sign = "-"; - arrowGif = " <IMG SRC=arrow_down.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Ascending order, click to reverse\" SRC=arrow_down.gif BORDER=0>"; } @@ -2056,5 +2056,6 @@ default: if(snprintf(buf, bufLen, "<TD "TD_BG" ALIGN=LEFT><IMG ALIGN=ABSMIDDLE SRC=/gauge.jpg" - " WIDTH=%d HEIGHT=12> </TD>\n", + " ALT=\"%d\%\" WIDTH=%d HEIGHT=12> </TD>\n", + int_perc, ratio*int_perc) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); break; @@ -3289,8 +3290,8 @@ if(revertOrder) { sign = ""; - arrowGif = " <IMG SRC=arrow_up.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Decending order, click to reverse\" SRC=arrow_up.gif BORDER=0>"; } else { sign = "-"; - arrowGif = " <IMG SRC=arrow_down.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Ascending order, click to reverse\" SRC=arrow_down.gif BORDER=0>"; } @@ -3772,8 +3773,8 @@ if(revertOrder) { sign = ""; - arrowGif = " <IMG SRC=arrow_up.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Descending Order, click to reverse\" SRC=arrow_up.gif BORDER=0>"; } else { sign = "-"; - arrowGif = " <IMG SRC=arrow_down.gif BORDER=0>"; + arrowGif = " <IMG ALT=\"Ascending Order, click to reverse\" SRC=arrow_down.gif BORDER=0>"; } --- ntop-original/admin.c Thu Dec 6 17:05:05 2001 +++ ntop-current/admin.c Fri Dec 21 15:39:26 2001 @@ -64,5 +64,5 @@ if(snprintf(buf, BUF_SIZE, "<TR><TH "TH_BG" ALIGN=LEFT><IMG SRC=/user.gif>" " %s</TH><TD "TD_BG"><A HREF=/modifyUser?%s>" - "<IMG SRC=/modifyUser.gif BORDER=0 align=absmiddle></A>" + "<IMG ALT=\"Modify User\" SRC=/modifyUser.gif BORDER=0 align=absmiddle></A>" " </TD></TR></TH></TR>\n", &key_data.dptr[1], key_data.dptr) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); @@ -71,6 +71,6 @@ if(snprintf(buf, BUF_SIZE, "<TR><TH "TH_BG" ALIGN=LEFT><IMG SRC=/user.gif>" " %s</TH><TD "TD_BG"><A HREF=/modifyUser?%s>" - "<IMG SRC=/modifyUser.gif BORDER=0 align=absmiddle></A>" - " <A HREF=/deleteUser?%s><IMG SRC=/deleteUser.gif BORDER=0 align=absmiddle>" + "<IMG ALT=\"Modify User\" SRC=/modifyUser.gif BORDER=0 align=absmiddle></A>" + " <A HREF=/deleteUser?%s><IMG ALT=\"Delete User\" SRC=/deleteUser.gif BORDER=0 align=absmiddle>" "</A></TD></TR></TH></TR>\n", &key_data.dptr[1], ebuf, ebuf) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); @@ -305,6 +305,6 @@ if(snprintf(buf, BUF_SIZE, "<TR><TH "TH_BG" ALIGN=LEFT><IMG SRC=/user.gif>" " '%s*'</TH><TD "TD_BG"><A HREF=/modifyURL?%s>" - "<IMG SRC=/modifyUser.gif BORDER=0 align=absmiddle></A>" - " <A HREF=/deleteURL?%s><IMG SRC=/deleteUser.gif BORDER=0 align=absmiddle>" + "<IMG ALT=\"Modify URL\" SRC=/modifyUser.gif BORDER=0 align=absmiddle></A>" + " <A HREF=/deleteURL?%s><IMG ALT=\"Delete URL\" SRC=/deleteUser.gif BORDER=0 align=absmiddle>" "</A></TD></TR></TH></TR>\n", &key_data.dptr[1], ebuf, ebuf) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!"); =====================E N D==========================
|