Jump to content


  • Posts

  • Joined

  • Last visited

caruga's Achievements


Newbie (1/7)



  1. Bleh, brilliant: I upgrade from FF 12 to FF 14 and install the latest firebug, and my whole browser crashed randomly on its third or so attempt to write to the console.
  2. Thanks. However, I'm getting nothing in the firefox error console when I use this. Tested with function _(mess, dlg) { alert(""+mess); console.log("" + mess); return mess;} I see alert but nothing in error console (filter is set to 'all'). Or is there another console I'm missing?
  3. I'm guessing not since I can't find anything on it. I find the 'alert' dialog box to be tedious.
  4. Okeydoke. Since writing my 1st post I discovered 'jquery'. This seems to do what I had in the back of my mind as a 'convenience' function. I wonder if it can express in much fewer lines of code what the code in my OP does... I gather from the code you wrote that all statements are also expressions (i.e. the variable declaration can be next to a comma operator), unlike C. Next thing I'm looking at is having all the ideas integrated into the visible tree structure (with ever-decreasing font-size, down to the microscopic), and being able to click on any chapter and having it zoom (and animate the zooming) in scale with the chapter depth clicked on...
  5. Knowing several languages but rusty with javascript, I know how there can be pitfalls in learning bad habits or coming up with convoluted, less than optimal solutions that would make more sense in other languages, almost abusing the language rather than working off of what it does best. So I am wondering if anything is unoptimal with the code below. The xml file is being read in; the code expects a 'featurelist' tag where 'ideas' and 'chapters' are organised under other chapters (except the top-level ones). Right now the code doesn't acknowledge the idea tags, it just tries to render the chapters in a html 'table of contents' in a tree-like organisation. The outputted html is correct, but I inserted some extra code to skip tags of the wrong id. This is the particular hot-spot where I'm wondering if better solutions are available, perhaps built-in rather than writing it 'by hand'. <script type="text/javascript">function processxml(xmldoc) { i = 0; root = xmldoc.getElementsByTagName("featurelist")[0]; el = root.getElementsByTagName("chapter")[0]; /* Initiate contents */ str = '<ul id="contents">'; while(el && el != root) { if(c=el.getAttributeNode("htmlclass")) str += '<div id="' + c.value + '">'; str += "<li>" + el.getAttribute("title") +"</li>"; if((els = el.getElementsByTagName("chapter")).length) { /* Has child chapters */ str += "<ul>"; el = els[0]; continue; } esc = 0; while(!esc) { save = el; while((el = el.nextSibling) && el.nodeName != "chapter") ; if(!el) { /* No next sibling */ str += "</ul>"; el = save; while((el = el.parentNode) && el.nodeName != "chapter") ; if(!el) /* No parent */ break; else /* Found parent, look again for sibling */ continue; } else { /* We have next sibling */ if(c) str += "</div>"; esc = 1; } } } /* Terminate contents */ str += "</ul>"; alert(str);// document.write(str); document.body.innerHTML = str;} Or have I done everything as well as it could be done?
  6. Hmm, looks like I will need js from what i've been reading. Right now I'm more bewildered about merely getting the counters to work. It seems you can't target specific instances of a counter that share the same identifier. If I have: .digest ol { counter-reset: n; } .digest li:before { counter-increment: n; content: counters(n,'.')'. '; } .digest li { display: block; } and: <ol class="digest"> <li>test 1</li> <li>test 2</li> <ol> <li>test 3</li> <li>test 4</li> </ol> <ol> <li>test 5</li> <li>test 6</li> </ol> I get:1. test 12. test 22.1. test 32.2. test 42.1. test 52.2. test 6 If I increment inside ol it skews all the numbers. What I want is: EDIT: seems i'm forced to nest within an ol within the li element.
  7. I'm wondering if css supports a solution to this problem, or whether I need something like javascript (and if I do need js, whether someone can point me to a link that will get me started on the solution I'm looking for). I'd like to automatically have the members of a list (table of contents) be links to a bookmark within the page, presumably using the number as the name of the anchor. This would mate together content and chapter headings. e.g. there would be a TOC like so: 1. blah2. blah2.1. blah blah2.2. blah blah2.2.1. blah blah blah And when I build the list with <ol> and <li> it would automatically insert the metadata around it: <a href="#2.1.">blah blah</a> and down below, a separate list under a separate class that also uses counters would exist, and would have <a name="2.1">blah blah</a>
  • Create New...