Commit 0d38bc9b authored by Matthias BUSSONNIER's avatar Matthias BUSSONNIER

Do not use potentially not unique id to collapse

generated html can be added many time in one page relying on line number
to collapse is dangerous.

Walking the dom to  get next children is more reliable
parent 85822df8
...@@ -66,11 +66,11 @@ class AnnotationCCodeWriter(CCodeWriter): ...@@ -66,11 +66,11 @@ class AnnotationCCodeWriter(CCodeWriter):
return css return css
_js = """ _js = """
function toggleDiv(id) { function toggleDiv(id) {
theDiv = document.getElementById(id); theDiv = id.nextElementSibling
if (theDiv.style.display != 'block') theDiv.style.display = 'block'; if (theDiv.style.display != 'block') theDiv.style.display = 'block';
else theDiv.style.display = 'none'; else theDiv.style.display = 'none';
} }
""" """
...@@ -99,7 +99,7 @@ body { font-family: courier; font-size: 12; } ...@@ -99,7 +99,7 @@ body { font-family: courier; font-size: 12; }
.cython.line { margin: 0em } .cython.line { margin: 0em }
""" """
def save_annotation(self, source_filename, target_filename): def save_annotation(self, source_filename, target_filename):
with closing(Utils.open_source_file(source_filename)) as f: with closing(Utils.open_source_file(source_filename)) as f:
...@@ -192,7 +192,7 @@ body { font-family: courier; font-size: 12; } ...@@ -192,7 +192,7 @@ body { font-family: courier; font-size: 12; }
score = (5 * calls['py_c_api'] + 2 * calls['pyx_c_api'] + score = (5 * calls['py_c_api'] + 2 * calls['pyx_c_api'] +
calls['py_macro_api'] + calls['pyx_macro_api']) calls['py_macro_api'] + calls['pyx_macro_api'])
#color = u"FFFF%02x" % int(255/(1+score/10.0)) #color = u"FFFF%02x" % int(255/(1+score/10.0))
outlist.append(u"<pre class='cython line score-%s' onclick='toggleDiv(\"line%s\")'>" % (score, k)) outlist.append(u"<pre class='cython line score-%s' onclick='toggleDiv(this)'>" % (score))
outlist.append(u" %d: " % k) outlist.append(u" %d: " % k)
for c, cc, html in special_chars: for c, cc, html in special_chars:
...@@ -200,7 +200,7 @@ body { font-family: courier; font-size: 12; } ...@@ -200,7 +200,7 @@ body { font-family: courier; font-size: 12; }
outlist.append(line.rstrip()) outlist.append(line.rstrip())
outlist.append(u'</pre>\n') outlist.append(u'</pre>\n')
outlist.append(u"<pre id='line%s' class='cython code score-%s' >%s</pre>" % (k, score, code)) outlist.append(u"<pre class='cython code score-%s' >%s</pre>" % (score, code))
return outlist return outlist
_parse_code = re.compile( _parse_code = re.compile(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment