Attachment 'moinmoin_1.9.7_footnote_include_patch.diff'

Download

   1 --- FootNote.py.orig    2014-03-13 13:52:37.726570158 +0000
   2 +++ FootNote.py 2014-03-13 13:50:40.165168131 +0000
   3 @@ -50,7 +50,7 @@
   4 
   5          return "%s%s%s%s%s" % (
   6              formatter.sup(1),
   7 -            formatter.anchorlink(1, fwdlink_id, id=backlink_id),
   8 +            formatter.anchorlink(1, fwdlink_id, id=backlink_id, onclick="return gotoFootnote('{0}')".format(fwdlink_id)),
   9              formatter.text(str(showidx+1)),
  10              formatter.anchorlink(0),
  11              formatter.sup(0), )
  12 @@ -62,7 +62,21 @@
  13  def emit_footnotes(request, formatter):
  14      # emit collected footnotes
  15      if request.footnotes:
  16 -        result = []
  17 +        result = ['''<script type="text/javascript">
  18 +function gotoFootnote(name) {
  19 +  var search_term=new RegExp(name+'$');
  20 +  all_a=document.getElementsByTagName('a');
  21 +  for(var i=0; i<=all_a.length; i++) {
  22 +    cur_a=all_a[i];
  23 +    if (cur_a == undefined) continue;
  24 +    if (cur_a.id != '' && cur_a.id.match(search_term) != null) {
  25 +      cur_a.scrollIntoView(true);
  26 +      break;
  27 +    }
  28 +  }
  29 +  return false;
  30 +}
  31 +</script>''']
  32 
  33          result.append(formatter.div(1, css_class='footnotes'))
  34 
  35 @@ -90,7 +104,8 @@
  36                  item = formatter.anchorlink(1, backlink_id)
  37                  item += formatter.text(str(subidx+1))
  38                  item += formatter.anchorlink(0)
  39 -                items.append(item)
  40 +                #items.append(item)
  41 +                items.append('''<a href="#" onclick="return gotoFootnote('{0}')">{1}</a>'''.format(backlink_id, str(subidx+1)))
  42                  subidx += 1
  43 
  44              result.append(formatter.text(" ("))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2014-03-13 13:54:07, 1.6 KB) [[attachment:moinmoin_1.9.7_footnote_include_patch.diff]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.