8a2b7b1c998ceef02e8e9ec4da1353a4ba6c716b max Thu Jan 19 14:09:09 2012 -0800 crazy workaround for firefox bug not breaking long words in tables, rachel feedback diff --git src/hg/hgc/t2g.c src/hg/hgc/t2g.c index 7c77b04..4ba0e21 100644 --- src/hg/hgc/t2g.c +++ src/hg/hgc/t2g.c @@ -76,34 +76,54 @@ freeMem(seqIdCoordString); return seqIdHash; } void printSeqHeaders(bool showDesc, bool isClickedSection) { printf("<TABLE style=\"background-color: #%s\" WIDTH=\"100%%\" CELLPADDING=\"2\">\n", HG_COL_BORDER); printf("<TR style=\"background-color: #%s; color: #FFFFFF\">\n", HG_COL_TABLE_LABEL); if (showDesc) puts(" <TH style=\"width: 10%\">Article file</TH>\n"); puts(" <TH style=\"width: 70%\">One table row per sequence, with flanking text, sequence in bold</TH>\n"); if (t2gDebug) puts(" <TH style=\"width: 30%\">Identifiers</TH>\n"); if (!isClickedSection && !t2gDebug) - puts(" <TH style=\"width: 20%\">Matches</TH>\n"); + puts(" <TH style=\"width: 20%\">Feature that includes this match</TH>\n"); puts("</TR>\n"); } +void printAddWbr(char* text, int distance) +/* a crazy hack for firefox/mozilla that is unable to break long words in tables + * We need to add a <wbr> tag every x characters in the text to make text breakable. + */ +{ +int i; +i = 0; +char* c; +c = text; +while (*c!=0){ + { + if (i % distance == 0) + printf("<wbr>"); + printf("%c", *c); + c++; + i++; + } +} +} + bool printSeqSection(char* docId, char* title, bool showDesc, struct sqlConnection* conn, struct hash* clickedSeqs, bool isClickedSection, bool fasta) /* print a table of sequences, show only sequences with IDs in hash, * There are two sections, respective sequences are shown depending on isClickedSection and clickedSeqs * - seqs that were clicked on (isClickedSection=True) -> show only seqs in clickedSeqs * - other seqs (isClickedSection=False) -> show all other seqs * * */ { // get data from mysql char query[4096]; safef(query, sizeof(query), "SELECT fileDesc, snippet, locations, articleId,fileId, seqId, sequence FROM %s WHERE articleId='%s';", sequenceTable, docId); if (t2gDebug) puts(query); struct sqlResult *sr = sqlGetResult(conn, query); @@ -140,31 +160,33 @@ if (clickedSeqs!=NULL && ((hashLookup(clickedSeqs, annotId)!=0) != isClickedSection)) { foundSkippedRows = TRUE; continue; } if (fasta) { printf("<TT>>%s<BR>%s<BR></TT>", annotId, seq); } else { printf("<TR style=\"background-color: #%s\">\n", HG_COL_LOCAL_TABLE); if (showDesc) printf("<TD style=\"word-break: break-all\">%s\n", fileDesc); //printf("<TD><I>%s</I></TD>\n", snippet); - printf("<TD style=\"word-break: break-all\"><I>%s</I></TD>\n", snippet); + printf("<TD style=\"word-break:break-all;\"><I>"); + printAddWbr(snippet, 40); + printf("</I></TD>\n"); if (t2gDebug) { printf("<TD>article %s, file %s, seq %s, annotId %s", artId, fileId, seqId, annotId); } // print links to locations if (!isClickedSection && !t2gDebug) { struct slName *locs; // format: hg19/chr1:300-400,mm9/chr1:60006-23234 // split on "," then split on "/" locs = charSepToSlNames(locList, ','); printf("<TD>"); if (locs==NULL) printf("No matches"); for ( ; locs!=NULL; locs = locs->next)