From 886b9108e04cb825adf0884a3a6b0d33c03f21b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= Date: Tue, 28 Aug 2018 16:43:09 +0200 Subject: [PATCH] Fix line endings. Fixes #105 --- example/array_test.d | 78 ++-- example/map_test.d | 78 ++-- html/candydoc/candy.ddoc | 104 +++--- html/candydoc/modules.ddoc | 16 +- html/candydoc/tree.js | 742 ++++++++++++++++++------------------- html/candydoc/util.js | 46 +-- 6 files changed, 532 insertions(+), 532 deletions(-) diff --git a/example/array_test.d b/example/array_test.d index ece0bf4..b2d19ac 100644 --- a/example/array_test.d +++ b/example/array_test.d @@ -1,39 +1,39 @@ -import std.conv; -import std.stdio; -import std.datetime; -import msgpack; - -struct A { - int x; -} - -struct Foo -{ - A[] a; -} - -void main() -{ - Foo foo; - foreach (a; 'a' .. 'z') - foreach (b; 'a' .. 'z') - foreach (c; 'a' .. 'z') - foo.a ~= A(); - - auto sw = StopWatch(AutoStart.yes); - ubyte[] data = msgpack.pack(foo); - writeln(sw.peek.usecs); - - auto sw2 = StopWatch(AutoStart.yes); - Foo foo1 = msgpack.unpack(data).as!(typeof(foo)); - writeln(sw2.peek.usecs); - - assert(foo == foo1); - - Foo foo2; - auto sw3 = StopWatch(AutoStart.yes); - msgpack.unpack(data, foo2); - writeln(sw3.peek.usecs); - - assert(foo == foo2); -} +import std.conv; +import std.stdio; +import std.datetime; +import msgpack; + +struct A { + int x; +} + +struct Foo +{ + A[] a; +} + +void main() +{ + Foo foo; + foreach (a; 'a' .. 'z') + foreach (b; 'a' .. 'z') + foreach (c; 'a' .. 'z') + foo.a ~= A(); + + auto sw = StopWatch(AutoStart.yes); + ubyte[] data = msgpack.pack(foo); + writeln(sw.peek.usecs); + + auto sw2 = StopWatch(AutoStart.yes); + Foo foo1 = msgpack.unpack(data).as!(typeof(foo)); + writeln(sw2.peek.usecs); + + assert(foo == foo1); + + Foo foo2; + auto sw3 = StopWatch(AutoStart.yes); + msgpack.unpack(data, foo2); + writeln(sw3.peek.usecs); + + assert(foo == foo2); +} diff --git a/example/map_test.d b/example/map_test.d index 807a89a..6107cf6 100644 --- a/example/map_test.d +++ b/example/map_test.d @@ -1,39 +1,39 @@ -import std.conv; -import std.stdio; -import std.datetime; -import msgpack; - -struct A { - int x; -} - -struct Foo -{ - A[string] a; -} - -void main() -{ - Foo foo; - foreach (a; 'a' .. 'z') - foreach (b; 'a' .. 'z') - foreach (c; 'a' .. 'z') - foo.a[to!string(a) ~ to!string(b) ~ to!string(c)] = A(); - - auto sw = StopWatch(AutoStart.yes); - ubyte[] data = msgpack.pack(foo); - writeln(sw.peek.usecs); - - auto sw2 = StopWatch(AutoStart.yes); - Foo foo1 = msgpack.unpack(data).as!(typeof(foo)); - writeln(sw2.peek.usecs); - - assert(foo == foo1); - - Foo foo2; - auto sw3 = StopWatch(AutoStart.yes); - msgpack.unpack(data, foo2); - writeln(sw3.peek.usecs); - - assert(foo == foo2); -} +import std.conv; +import std.stdio; +import std.datetime; +import msgpack; + +struct A { + int x; +} + +struct Foo +{ + A[string] a; +} + +void main() +{ + Foo foo; + foreach (a; 'a' .. 'z') + foreach (b; 'a' .. 'z') + foreach (c; 'a' .. 'z') + foo.a[to!string(a) ~ to!string(b) ~ to!string(c)] = A(); + + auto sw = StopWatch(AutoStart.yes); + ubyte[] data = msgpack.pack(foo); + writeln(sw.peek.usecs); + + auto sw2 = StopWatch(AutoStart.yes); + Foo foo1 = msgpack.unpack(data).as!(typeof(foo)); + writeln(sw2.peek.usecs); + + assert(foo == foo1); + + Foo foo2; + auto sw3 = StopWatch(AutoStart.yes); + msgpack.unpack(data, foo2); + writeln(sw3.peek.usecs); + + assert(foo == foo2); +} diff --git a/html/candydoc/candy.ddoc b/html/candydoc/candy.ddoc index c438b2e..a40ba4c 100644 --- a/html/candydoc/candy.ddoc +++ b/html/candydoc/candy.ddoc @@ -1,52 +1,52 @@ -D = $(B $0) - -DDOC = - - - -$(TITLE) - - - - - - -
-
- - - -

$(TITLE)

$(BODY)
- Page was generated with - - on $(DATETIME) -
-
-$(ADD_MODULES) - - - -DDOC_DECL = - -$(DT $0) - - - -DDOC_PSYMBOL = -$0 - - - -DDOC_MEMBERS = - -$(DL $0) - - - -DDOC_PARAM_ID = -$0 - - -DDOC_PARAM =$0 -ADD_MODULES = -MODULE =explorer.packageExplorer.addModule("$0"); +D = $(B $0) + +DDOC = + + + +$(TITLE) + + + + + + +
+
+ + + +

$(TITLE)

$(BODY)
+ Page was generated with + + on $(DATETIME) +
+
+$(ADD_MODULES) + + + +DDOC_DECL = + +$(DT $0) + + + +DDOC_PSYMBOL = +$0 + + + +DDOC_MEMBERS = + +$(DL $0) + + + +DDOC_PARAM_ID = +$0 + + +DDOC_PARAM =$0 +ADD_MODULES = +MODULE =explorer.packageExplorer.addModule("$0"); diff --git a/html/candydoc/modules.ddoc b/html/candydoc/modules.ddoc index 18a293d..f36692a 100644 --- a/html/candydoc/modules.ddoc +++ b/html/candydoc/modules.ddoc @@ -1,8 +1,8 @@ -MODULES = -$(MODULE msgpack.buffer) -$(MODULE msgpack.common) -$(MODULE msgpack.msgpack) -$(MODULE msgpack.object) -$(MODULE msgpack.packer) -$(MODULE msgpack.unpacker) -$(MODULE msgpack.util) +MODULES = +$(MODULE msgpack.buffer) +$(MODULE msgpack.common) +$(MODULE msgpack.msgpack) +$(MODULE msgpack.object) +$(MODULE msgpack.packer) +$(MODULE msgpack.unpacker) +$(MODULE msgpack.util) diff --git a/html/candydoc/tree.js b/html/candydoc/tree.js index 793250a..97996c0 100644 --- a/html/candydoc/tree.js +++ b/html/candydoc/tree.js @@ -1,374 +1,374 @@ /* This file is a part of CanDyDOC fileset. File is written by Victor Nakoryakov and placed into the public domain. - This file is javascript with classes that represents native style tree control. */ - -var pmNone = 0; -var pmPlus = 1; -var pmMinus = 2; - -var hlNone = 0; -var hlGrey = 1; -var hlSelected = 2; - -function TreeView(hrefMode) -{ - this.domEntry = document.createElement("div"); - this.children = new Array(); - this.selection = null; - this.hrefMode = hrefMode; - - this.createBranch = function(text, iconSrc) - { - var root = new TreeNode(text, iconSrc, this.hrefMode); - root.owner = this; - this.children[ this.children.length ] = root; - this.domEntry.appendChild( root.domEntry ); - return root; - } - - this.branch = function(text) - { - var ret = null; - for (var i = 0; i < this.children.length; ++i) - if (this.children[i].textElement.data == text) - { - ret = this.children[i]; - break; - } - - return ret; - } - - this.domEntry.style.fontSize = "10px"; - this.domEntry.style.cursor = "default"; - this.domEntry.style.whiteSpace = "nowrap"; -} - -var idCounter = 0; -function TreeNode(text, iconSrc, hrefMode) -{ - this.id = idCounter++; - this.parentNode = null; - this.children = new Array(); - this.domEntry = document.createElement("div"); - this.icon = document.createElement("img"); - this.textElement = document.createTextNode(text); - this.textSpan = document.createElement("span"); - this.lineDiv = document.createElement("div"); - this.hierarchyImgs = new Array(); - this.onclick = null; - - function createIcon() - { - var img = document.createElement("img"); - img.style.verticalAlign = "middle"; - img.style.position = "relative"; - img.style.top = "-1px"; - img.width = 16; - img.height = 16; - return img; - } - - function createHierarchyImage() - { - var img = createIcon(); - img.pointsTop = false; - img.pointsBottom = false; - img.pointsRight = false; - img.pmState = pmNone; - return img; - } - - function genHierarchyImageSrc(hierarchyImg) - { - var name = ""; - if (hierarchyImg.pointsTop) - name += "t"; - - if (hierarchyImg.pointsBottom) - name += "b"; - - if (hierarchyImg.pointsRight) - name += "r"; - - if (hierarchyImg.pmState == pmPlus) - name += "p"; - else if (hierarchyImg.pmState == pmMinus) - name += "m"; - - if (name == "") - name = "shim"; - - return "candydoc/img/tree/" + name + ".gif"; - } - - function setSrc(icon, src) - { - icon.src = src; - // After src change width and height are reseted in IE. - // Bug workaround: - icon.width = 16; - icon.height = 16; - } - - this.createChild = function(text, iconSrc) - { - var child = new TreeNode(text, iconSrc, this.owner.hrefMode); - this.children[ this.children.length ] = child; - this.domEntry.appendChild( child.domEntry ); - child.parentNode = this; - child.owner = this.owner; - - // insert hierarchy images according to deepness level - // of created child. - - if (this.children.length > 1) - { - // there were already added child before. So copy `level-1` - // hierarchy images from it. - - var prevAddedChild = this.children[ this.children.length - 2 ]; - - for (var i = 0; i < prevAddedChild.hierarchyImgs.length - 1; ++i) - { - var prevAddedChildImg = prevAddedChild.hierarchyImgs[i]; - var img = createHierarchyImage(); - setSrc(img, prevAddedChildImg.src); - img.pointsTop = prevAddedChildImg.pointsTop; - img.pointsBottom = prevAddedChildImg.pointsBottom; - img.pointsRight = prevAddedChildImg.pointsRight; - img.pmState = prevAddedChildImg.pmState; - - child.hierarchyImgs[ child.hierarchyImgs.length ] = img; - child.lineDiv.insertBefore(img, child.icon); - } - - // change last hierarchy image of prevAddedChild from |_ to |- - var lastHierarchyImg = prevAddedChild.hierarchyImgs[ prevAddedChild.hierarchyImgs.length - 1 ]; - lastHierarchyImg.pointsBottom = true; - setSrc(lastHierarchyImg, genHierarchyImageSrc(lastHierarchyImg)); - - // change hierarchy images of prevAddedChild's children on it's last - // level to | - prevAddedChild.addHierarchyTBLine(prevAddedChild.hierarchyImgs.length - 1); - } - else - { - // this is a first child. So copy `level-2` - // hierarchy images from parent, i.e. this. - - for (var i = 0; i < this.hierarchyImgs.length - 1; ++i) - { - var parentImg = this.hierarchyImgs[i]; - var img = createHierarchyImage(); - setSrc(img, parentImg.src); - img.pointsTop = parentImg.pointsTop; - img.pointsBottom = parentImg.pointsBottom; - img.pointsRight = parentImg.pointsRight; - img.pmState = parentImg.pmState; - - child.hierarchyImgs[ child.hierarchyImgs.length ] = img; - child.lineDiv.insertBefore(img, child.icon); - } - - if (this.hierarchyImgs.length > 0) // we are not root - { - // change last hierarchy image of parent (i.e. this): add minus to it - var lastHierarchyImg = this.hierarchyImgs[ this.hierarchyImgs.length - 1]; - lastHierarchyImg.pmState = pmMinus; - setSrc(lastHierarchyImg, genHierarchyImageSrc(lastHierarchyImg)); - lastHierarchyImg.owner = this; - lastHierarchyImg.onclick = new Function("e", "this.owner.processPMClick(e);"); - - // make decision on image on `level-1`. It depends on parent's (ie this) - // image on same level. - var parentL1HierarchyImg = lastHierarchyImg; - var l1HierarchyImg = createHierarchyImage(); - if (parentL1HierarchyImg.pointsBottom) - { - l1HierarchyImg.pointsTop = true; - l1HierarchyImg.pointsBottom = true; - } - setSrc(l1HierarchyImg, genHierarchyImageSrc(l1HierarchyImg)); - child.hierarchyImgs[ child.hierarchyImgs.length ] = l1HierarchyImg; - child.lineDiv.insertBefore(l1HierarchyImg, child.icon); - } - } - - // in any case on last level our child will have icon |_ - var img = createHierarchyImage(); - img.pointsTop = true; - img.pointsRight = true; - setSrc(img, genHierarchyImageSrc(img)); - - child.hierarchyImgs[ child.hierarchyImgs.length ] = img; - child.lineDiv.insertBefore(img, child.icon); - - return child; - } - - this.lastChild = function() - { - return this.children[ this.children.length - 1 ]; - } - - this.child = function(text) - { - var ret = null; - for (var i = 0; i < this.children.length; ++i) - if (this.children[i].textElement.data == text) - { - ret = this.children[i]; - break; - } - - return ret; - } - - this.addHierarchyTBLine = function(level) - { - for (var i = 0; i < this.children.length; ++i) - { - var img = this.children[i].hierarchyImgs[level]; - img.pointsTop = true; - img.pointsBottom = true; - setSrc(img, genHierarchyImageSrc(img)); - this.children[i].addHierarchyTBLine(level); - } - } - - this.expand = function() - { - var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ]; - - if (img.pmState == pmPlus) - { - img.pmState = pmMinus; - setSrc(img, genHierarchyImageSrc(img)); - - for (var i = 0; i < this.children.length; ++i) - this.children[i].domEntry.style.display = ""; - } - } - - this.collapse = function() - { - var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ]; - - if (img.pmState == pmMinus) - { - img.pmState = pmPlus; - setSrc(img, genHierarchyImageSrc(img)); - - for (var i = 0; i < this.children.length; ++i) - this.children[i].domEntry.style.display = "none"; - } - } - - this.toggle = function() - { - var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ]; - if (img.pmState == pmMinus) - this.collapse(); - else - this.expand(); - } - - this.select = function() - { - if (this.owner.selection != this) - { - if (this.owner.selection) - this.owner.selection.setHighlight(hlNone); - - this.owner.selection = this; - this.setHighlight(hlSelected); - } - } - - this.setHighlight = function(mode) - { - if (mode == hlNone) - { - this.textSpan.style.backgroundColor = ""; - this.textSpan.style.color = ""; - this.textSpan.style.border = ""; - } - else if (mode == hlGrey) - { - this.textSpan.style.backgroundColor = "#aaaaaa"; - this.textSpan.style.color = ""; - this.textSpan.style.border = ""; - } - else if (mode == hlSelected) - { - this.textSpan.style.backgroundColor = "3399cc"; - this.textSpan.style.color = "white"; - this.textSpan.style.border = "dotted 1px red"; - } - } - - this.setOnclick = function(proc) - { - this.onclick = proc; - } - - this.setRef = function(url) - { - if (this.anchor) - this.anchor.href = url; - } - - this.processPMClick = function(e) - { - this.toggle(); - - // prevent this line selection, stop bubbling - if (e) - e.stopPropagation(); // Mozilla way - if (window.event) - window.event.cancelBubble = true; // IE way - } - - this.processOnclick = function() - { - this.select(); - if (this.onclick instanceof Function) - this.onclick(); - } - - /////////////////////////////////////////////////////////////////////////// - if (iconSrc) - this.icon.src = iconSrc; - else - { - this.icon.width = 0; - this.icon.height = 0; - } - - this.icon.style.verticalAlign = "middle"; - this.icon.style.position = "relative"; - this.icon.style.top = "-1px"; - this.icon.style.paddingRight = "2px"; - - if (!hrefMode) - { - this.textSpan.appendChild( this.textElement ); - } - else - { - this.anchor = document.createElement("a"); - this.anchor.appendChild( this.textElement ); - this.textSpan.appendChild( this.anchor ); - } - - this.lineDiv.appendChild( this.icon ); - this.lineDiv.appendChild( this.textSpan ); - this.domEntry.appendChild( this.lineDiv ); - - this.lineDiv.owner = this; - - if (!hrefMode) - this.lineDiv.onclick = new Function("this.owner.processOnclick();"); -} + This file is javascript with classes that represents native style tree control. */ + +var pmNone = 0; +var pmPlus = 1; +var pmMinus = 2; + +var hlNone = 0; +var hlGrey = 1; +var hlSelected = 2; + +function TreeView(hrefMode) +{ + this.domEntry = document.createElement("div"); + this.children = new Array(); + this.selection = null; + this.hrefMode = hrefMode; + + this.createBranch = function(text, iconSrc) + { + var root = new TreeNode(text, iconSrc, this.hrefMode); + root.owner = this; + this.children[ this.children.length ] = root; + this.domEntry.appendChild( root.domEntry ); + return root; + } + + this.branch = function(text) + { + var ret = null; + for (var i = 0; i < this.children.length; ++i) + if (this.children[i].textElement.data == text) + { + ret = this.children[i]; + break; + } + + return ret; + } + + this.domEntry.style.fontSize = "10px"; + this.domEntry.style.cursor = "default"; + this.domEntry.style.whiteSpace = "nowrap"; +} + +var idCounter = 0; +function TreeNode(text, iconSrc, hrefMode) +{ + this.id = idCounter++; + this.parentNode = null; + this.children = new Array(); + this.domEntry = document.createElement("div"); + this.icon = document.createElement("img"); + this.textElement = document.createTextNode(text); + this.textSpan = document.createElement("span"); + this.lineDiv = document.createElement("div"); + this.hierarchyImgs = new Array(); + this.onclick = null; + + function createIcon() + { + var img = document.createElement("img"); + img.style.verticalAlign = "middle"; + img.style.position = "relative"; + img.style.top = "-1px"; + img.width = 16; + img.height = 16; + return img; + } + + function createHierarchyImage() + { + var img = createIcon(); + img.pointsTop = false; + img.pointsBottom = false; + img.pointsRight = false; + img.pmState = pmNone; + return img; + } + + function genHierarchyImageSrc(hierarchyImg) + { + var name = ""; + if (hierarchyImg.pointsTop) + name += "t"; + + if (hierarchyImg.pointsBottom) + name += "b"; + + if (hierarchyImg.pointsRight) + name += "r"; + + if (hierarchyImg.pmState == pmPlus) + name += "p"; + else if (hierarchyImg.pmState == pmMinus) + name += "m"; + + if (name == "") + name = "shim"; + + return "candydoc/img/tree/" + name + ".gif"; + } + + function setSrc(icon, src) + { + icon.src = src; + // After src change width and height are reseted in IE. + // Bug workaround: + icon.width = 16; + icon.height = 16; + } + + this.createChild = function(text, iconSrc) + { + var child = new TreeNode(text, iconSrc, this.owner.hrefMode); + this.children[ this.children.length ] = child; + this.domEntry.appendChild( child.domEntry ); + child.parentNode = this; + child.owner = this.owner; + + // insert hierarchy images according to deepness level + // of created child. + + if (this.children.length > 1) + { + // there were already added child before. So copy `level-1` + // hierarchy images from it. + + var prevAddedChild = this.children[ this.children.length - 2 ]; + + for (var i = 0; i < prevAddedChild.hierarchyImgs.length - 1; ++i) + { + var prevAddedChildImg = prevAddedChild.hierarchyImgs[i]; + var img = createHierarchyImage(); + setSrc(img, prevAddedChildImg.src); + img.pointsTop = prevAddedChildImg.pointsTop; + img.pointsBottom = prevAddedChildImg.pointsBottom; + img.pointsRight = prevAddedChildImg.pointsRight; + img.pmState = prevAddedChildImg.pmState; + + child.hierarchyImgs[ child.hierarchyImgs.length ] = img; + child.lineDiv.insertBefore(img, child.icon); + } + + // change last hierarchy image of prevAddedChild from |_ to |- + var lastHierarchyImg = prevAddedChild.hierarchyImgs[ prevAddedChild.hierarchyImgs.length - 1 ]; + lastHierarchyImg.pointsBottom = true; + setSrc(lastHierarchyImg, genHierarchyImageSrc(lastHierarchyImg)); + + // change hierarchy images of prevAddedChild's children on it's last + // level to | + prevAddedChild.addHierarchyTBLine(prevAddedChild.hierarchyImgs.length - 1); + } + else + { + // this is a first child. So copy `level-2` + // hierarchy images from parent, i.e. this. + + for (var i = 0; i < this.hierarchyImgs.length - 1; ++i) + { + var parentImg = this.hierarchyImgs[i]; + var img = createHierarchyImage(); + setSrc(img, parentImg.src); + img.pointsTop = parentImg.pointsTop; + img.pointsBottom = parentImg.pointsBottom; + img.pointsRight = parentImg.pointsRight; + img.pmState = parentImg.pmState; + + child.hierarchyImgs[ child.hierarchyImgs.length ] = img; + child.lineDiv.insertBefore(img, child.icon); + } + + if (this.hierarchyImgs.length > 0) // we are not root + { + // change last hierarchy image of parent (i.e. this): add minus to it + var lastHierarchyImg = this.hierarchyImgs[ this.hierarchyImgs.length - 1]; + lastHierarchyImg.pmState = pmMinus; + setSrc(lastHierarchyImg, genHierarchyImageSrc(lastHierarchyImg)); + lastHierarchyImg.owner = this; + lastHierarchyImg.onclick = new Function("e", "this.owner.processPMClick(e);"); + + // make decision on image on `level-1`. It depends on parent's (ie this) + // image on same level. + var parentL1HierarchyImg = lastHierarchyImg; + var l1HierarchyImg = createHierarchyImage(); + if (parentL1HierarchyImg.pointsBottom) + { + l1HierarchyImg.pointsTop = true; + l1HierarchyImg.pointsBottom = true; + } + setSrc(l1HierarchyImg, genHierarchyImageSrc(l1HierarchyImg)); + child.hierarchyImgs[ child.hierarchyImgs.length ] = l1HierarchyImg; + child.lineDiv.insertBefore(l1HierarchyImg, child.icon); + } + } + + // in any case on last level our child will have icon |_ + var img = createHierarchyImage(); + img.pointsTop = true; + img.pointsRight = true; + setSrc(img, genHierarchyImageSrc(img)); + + child.hierarchyImgs[ child.hierarchyImgs.length ] = img; + child.lineDiv.insertBefore(img, child.icon); + + return child; + } + + this.lastChild = function() + { + return this.children[ this.children.length - 1 ]; + } + + this.child = function(text) + { + var ret = null; + for (var i = 0; i < this.children.length; ++i) + if (this.children[i].textElement.data == text) + { + ret = this.children[i]; + break; + } + + return ret; + } + + this.addHierarchyTBLine = function(level) + { + for (var i = 0; i < this.children.length; ++i) + { + var img = this.children[i].hierarchyImgs[level]; + img.pointsTop = true; + img.pointsBottom = true; + setSrc(img, genHierarchyImageSrc(img)); + this.children[i].addHierarchyTBLine(level); + } + } + + this.expand = function() + { + var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ]; + + if (img.pmState == pmPlus) + { + img.pmState = pmMinus; + setSrc(img, genHierarchyImageSrc(img)); + + for (var i = 0; i < this.children.length; ++i) + this.children[i].domEntry.style.display = ""; + } + } + + this.collapse = function() + { + var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ]; + + if (img.pmState == pmMinus) + { + img.pmState = pmPlus; + setSrc(img, genHierarchyImageSrc(img)); + + for (var i = 0; i < this.children.length; ++i) + this.children[i].domEntry.style.display = "none"; + } + } + + this.toggle = function() + { + var img = this.hierarchyImgs[ this.hierarchyImgs.length - 1 ]; + if (img.pmState == pmMinus) + this.collapse(); + else + this.expand(); + } + + this.select = function() + { + if (this.owner.selection != this) + { + if (this.owner.selection) + this.owner.selection.setHighlight(hlNone); + + this.owner.selection = this; + this.setHighlight(hlSelected); + } + } + + this.setHighlight = function(mode) + { + if (mode == hlNone) + { + this.textSpan.style.backgroundColor = ""; + this.textSpan.style.color = ""; + this.textSpan.style.border = ""; + } + else if (mode == hlGrey) + { + this.textSpan.style.backgroundColor = "#aaaaaa"; + this.textSpan.style.color = ""; + this.textSpan.style.border = ""; + } + else if (mode == hlSelected) + { + this.textSpan.style.backgroundColor = "3399cc"; + this.textSpan.style.color = "white"; + this.textSpan.style.border = "dotted 1px red"; + } + } + + this.setOnclick = function(proc) + { + this.onclick = proc; + } + + this.setRef = function(url) + { + if (this.anchor) + this.anchor.href = url; + } + + this.processPMClick = function(e) + { + this.toggle(); + + // prevent this line selection, stop bubbling + if (e) + e.stopPropagation(); // Mozilla way + if (window.event) + window.event.cancelBubble = true; // IE way + } + + this.processOnclick = function() + { + this.select(); + if (this.onclick instanceof Function) + this.onclick(); + } + + /////////////////////////////////////////////////////////////////////////// + if (iconSrc) + this.icon.src = iconSrc; + else + { + this.icon.width = 0; + this.icon.height = 0; + } + + this.icon.style.verticalAlign = "middle"; + this.icon.style.position = "relative"; + this.icon.style.top = "-1px"; + this.icon.style.paddingRight = "2px"; + + if (!hrefMode) + { + this.textSpan.appendChild( this.textElement ); + } + else + { + this.anchor = document.createElement("a"); + this.anchor.appendChild( this.textElement ); + this.textSpan.appendChild( this.anchor ); + } + + this.lineDiv.appendChild( this.icon ); + this.lineDiv.appendChild( this.textSpan ); + this.domEntry.appendChild( this.lineDiv ); + + this.lineDiv.owner = this; + + if (!hrefMode) + this.lineDiv.onclick = new Function("this.owner.processOnclick();"); +} diff --git a/html/candydoc/util.js b/html/candydoc/util.js index 5cff63e..edb7165 100644 --- a/html/candydoc/util.js +++ b/html/candydoc/util.js @@ -5,37 +5,37 @@ function getLeft(elem) { - var ret = 0; - while (elem.offsetParent) - { - ret += elem.offsetLeft; - elem = elem.offsetParent; - } + var ret = 0; + while (elem.offsetParent) + { + ret += elem.offsetLeft; + elem = elem.offsetParent; + } return ret; } function getTop(elem) { - var ret = 0; - while (elem.offsetParent) - { - ret += elem.offsetTop; - elem = elem.offsetParent; - } + var ret = 0; + while (elem.offsetParent) + { + ret += elem.offsetTop; + elem = elem.offsetParent; + } return ret; } -function getWindowHeight() -{ - var ret = 0; - if (typeof(window.innerHeight) == "number") - ret = window.innerHeight; - else if (document.documentElement && document.documentElement.clientHeight) - ret = document.documentElement.clientHeight; - else if (document.body && document.body.clientHeight) - ret = document.body.clientHeight; - - return ret; +function getWindowHeight() +{ + var ret = 0; + if (typeof(window.innerHeight) == "number") + ret = window.innerHeight; + else if (document.documentElement && document.documentElement.clientHeight) + ret = document.documentElement.clientHeight; + else if (document.body && document.body.clientHeight) + ret = document.body.clientHeight; + + return ret; }