]> git.0d.be Git - empathy.git/blobdiff - data/empathy-log-window.html
account-settings: allow to change the service
[empathy.git] / data / empathy-log-window.html
index 987c07a2635a1e57698bf783bccc308b16c4080c..88159252082018df7f88c47483945413bd1b1ffb 100644 (file)
@@ -1,4 +1,7 @@
-<html>
+<?xml version="1.0">
+<html
+ xmlns="http://www.w3.org/TR/html4/"
+ xmlns:empathy="http://live.gnome.org/Empathy">
   <head>
     <style type="text/css">
 html, body, div, p {
@@ -41,6 +44,8 @@ img.icon {
 }
     </style>
     <script type="text/javascript">
+var EMPATHY_NS='http://live.gnome.org/Empathy';
+
 function filterNodes (node, tagName)
 {
   var out = new Array();
@@ -143,15 +148,14 @@ function insertRow (path, text, icon, date_)
   // insert the new node into the tree
   var nodes = getNodes(parentnode);
 
-  // console.log("path = " + path);
-  // console.log("i = " + i + ", path[i] = " + path[i] + ", nodes.length = " +
-  //    nodes.length);
-
   if (path[i] >= nodes.length)
     parentnode.appendChild(newnode);
   else
     parentnode.insertBefore(newnode, nodes[path[i]]);
 
+  // set the path
+  newnode.setAttributeNS(EMPATHY_NS, 'path', path.join(':'));
+
   // add an expander
   var toggle = document.createElement('span');
   newnode.appendChild(toggle);
@@ -169,7 +173,7 @@ function insertRow (path, text, icon, date_)
       else
         setExpander(newnode, false);
     };
-  
+
   toggle.onclick = toggleExpander;
   contents.ondblclick = toggleExpander;
 
@@ -183,8 +187,6 @@ function changeRow (path, text, icon, date_)
   var treeview = document.getElementById('treeview');
   var node = treeview;
 
-  // console.log("path = " + path + ", text = '" + text + "'");
-
   // walk the tree
   for (var i = 0; i < path.length; i++)
     node = getNodes(node)[path[i]];
@@ -225,6 +227,22 @@ function reorderRows (path, new_order)
   // For reference: new_order[new_pos] = old_pos
   for (var i = 0; i < nodes.length; i++)
     node.appendChild(nodes[new_order[i]]);
+
+  // recursively update the path
+  function updatePaths(path, node)
+    {
+      var nodes = getNodes(node);
+
+      for (var i = 0; i < nodes.length; i++)
+        {
+          var newpath = path.concat([i]);
+
+          nodes[i].setAttributeNS(EMPATHY_NS, 'path', newpath.join(':'));
+          updatePaths(newpath, nodes[i]);
+        }
+    }
+
+  updatePaths(path, node);
 }
 
 function hasChildRows (path, has_children)
@@ -243,6 +261,31 @@ function hasChildRows (path, has_children)
   else
     toggle.style.display = 'none';
 }
+
+function getOffset (node)
+{
+  var y = 0;
+
+  while (node != null && !isNaN(node.offsetTop))
+    {
+      y += node.offsetTop - node.scrollTop;
+      node = node.offsetParent;
+    }
+
+  return y;
+}
+
+function scrollToRow (path)
+{
+  var treeview = document.getElementById('treeview');
+  var node = treeview;
+
+  // walk the tree
+  for (var i = 0; i < path.length; i++)
+    node = getNodes(node)[path[i]];
+
+  window.scrollTo(0, getOffset(node));
+}
     </script>
   </head>