@@ -92,12 +92,17 @@ do ->
9292 testEquality(`[[]]==[[]]`, " ` [[]] ` " , " == " )
9393 testEquality(`[]==[]`, " ` [] ` " , " == " )
9494
95+ supportsCanvas = do ->
96+ el = document.createElement " canvas"
97+ !!(el.getContext && el.getContext(" 2d " ))
98+
9599@buildComparisonTable = (values, comparator)->
96100 comps = (new ForComparison(v) for v in values)
97101 $table = $(" <table >" , class: " comparisons" )
98102 $headRow = $(" <tr >" ).append(" <td >" ).appendTo($table)
99103 for comp in comps
100- $(" <td >" , class: " header col" ).html($(" <span >" , text: comp.asString)).appendTo($headRow)
104+ $el = if supportsCanvas then rotateText(comp.asString) else $(" <span >" , class: " rotate" , text: comp.asString)
105+ $(" <td >" , class: " header col" ).html($el).appendTo($headRow)
101106 for valX, x in comps
102107 $tr = $(" <tr >" ).appendTo($table)
103108 $(" <td >" , class: " row header" ).text(valX.asString).appendTo($tr)
@@ -113,12 +118,22 @@ do ->
113118 comps = (new ForComparison (v) for v in values)
114119 $table = $ (" <table>" , class : " comparisons" )
115120 for comp in comps
116- $tr = $ (" <tr>" ).html ($ (" <td>" , text : comp .asString )).appendTo ($table)
121+ $tr = $ (" <tr>" ).html ($ (" <td>" , class : " header row " , text : comp .asString )).appendTo ($table)
117122 $td = $ (" <td>" , class : " cell" ).html ($ (" <div>" , html : " " )).appendTo ($tr)
118123 val = (new Function (" if(#{ comp .asString } ){return true}else{return false}" ))()
119124 if val
120125 $td .addClass (" green" )
121126 expression = " if (#{ comp .asString } ) { /* #{ if val then ' executes' else ' does not execute' } */ } "
122127 $ (" <td>" , class : " expression" ).html (expression).appendTo ($tr)
128+ $table
123129
124- $table
130+ rotateText = (txt , cHeight = 80 )->
131+ canv = document .createElement (" canvas" )
132+ canv .width = " 25"
133+ canv .height = cHeight
134+ c = canv .getContext (" 2d" )
135+ c .rotate (Math .PI / 2 )
136+ c .font = " 15px Monospace"
137+ c .textAlign = " right"
138+ c .fillText (txt,cHeight,- 10 )
139+ canv
0 commit comments