1. Dan Connolly
  2. quacken

Commits

Dan Connolly  committed f75d28c

use appendChild etc. rather than document.write
- tried integrating with YUI from Mint
- Mint includes yui3.js but seems to do most of its work with YUI 2

  • Participants
  • Parent commits adcec9b
  • Branches default

Comments (0)

Files changed (1)

File mint_gdocs.js

View file
 
-function make_budget_window() {
+function make_budget_window(){
+    var categories = Mint.CategorySearch.getJson();
+
     //http://www.quirksmode.org/js/popup.html
     ugly_but_reportedly_necessary_global = window.open('', 'budget_window',
 						       'height=400, width=600');
     var d = ugly_but_reportedly_necessary_global.document;
-    d.write("hello world! bis");
-    var categories = Mint.CategorySearch.getJson();
-    d.write("<p>categories:" + categories.length + "</p>");
-    d.write("<ul>\n");
-    for (var i=0; i < categories.length; i++) {
-	d.write("<li>" + categories[i].value + "</li>\n");
+    var b = d.body;
+
+    var mk = function (p, n) {
+	var e = d.createElement(n);
+	p.appendChild(e);
+	return e;
     }
-    d.write("</ul>\n");
+
+    mk(b, 'h1').textContent = 'Budget';
+    var t = mk(b, 'table');
+    mk(mk(t, 'tr'), 'th').textContent = 'Category';
+    categories.forEach(function(cat) {
+	mk(mk(t, 'tr'), 'td').textContent = cat.value;
+    });
 }
 
 make_budget_window();