summary refs log tree commit diff
path: root/nixos/gui/chrome/content/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/gui/chrome/content/main.js')
-rw-r--r--nixos/gui/chrome/content/main.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/nixos/gui/chrome/content/main.js b/nixos/gui/chrome/content/main.js
new file mode 100644
index 000000000000..ecfc5a8c5c99
--- /dev/null
+++ b/nixos/gui/chrome/content/main.js
@@ -0,0 +1,70 @@
+// global variables.
+var gNixOS;
+var gOptionView;
+
+/*
+var gProgressBar;
+function setProgress(current, max)
+{
+  if (gProgressBar) {
+    gProgressBar.value = 100 * current / max;
+    log("progress: " + gProgressBar.value + "%");
+  }
+  else
+    log("unknow progress bar");
+}
+*/
+
+function updateTextbox(id, value)
+{
+  // setting the height cause an overflow which resize the textbox to its
+  // content due to its onoverflow attribute.
+  $(id).attr("value", value).attr("height", 1);
+};
+
+function updatePanel(options)
+{
+  log("updatePanel: " + options.length);
+  if (options.length == 0)
+    return;
+  // FIXME: ignore the rest of the selection for now.
+  var o = options[0];
+  $("#name").attr("label", o.path);
+
+  if (o.typename != null)
+    $("#typename").attr("label", o.typename);
+  else
+    $("#typename").attr("label", "");
+
+  $("#desc").text(o.description);
+
+  if (o.value != null)
+    updateTextbox("#val", o.value);
+  else
+    updateTextbox("#val", "");
+
+  if (o.defaultValue != null)
+    updateTextbox("#def", o.defaultValue);
+  else
+    updateTextbox("#def", "");
+
+  if (o.example != null)
+    updateTextbox("#exp", o.example);
+  else
+    updateTextbox("#exp", "");
+
+  updateTextbox("#decls", o.declarations.join("\n"));
+  updateTextbox("#defs", o.definitions.join("\n"));
+}
+
+
+function onload()
+{
+  var optionTree = document.getElementById("option-tree");
+  // gProgressBar = document.getElementById("progress-bar");
+  // setProgress(0, 1);
+
+  gNixOS = new NixOS();
+  gOptionView = new OptionView(gNixOS.option, updatePanel);
+  optionTree.view = gOptionView;
+}