[Pkg-javascript-commits] [gitgraph.js] 01/06: New upstream version 0.0~git20170511.0.5fcc26b

Michael Lustfield mtecknology at debian.org
Sun Aug 27 04:09:30 UTC 2017


This is an automated email from the git hooks/post-receive script.

mtecknology pushed a commit to branch master
in repository gitgraph.js.

commit 5146a58d93b53d0f8c5dc28c42290f40db66d149
Author: Michael Lustfield <michael at lustfield.net>
Date:   Sat Aug 26 22:45:00 2017 -0500

    New upstream version 0.0~git20170511.0.5fcc26b
---
 LICENSE      |  24 ++++
 README.md    |  45 +++++++
 canvas.html  | 282 +++++++++++++++++++++++++++++++++++++++++
 draw.js      |  17 +++
 example.php  |  93 ++++++++++++++
 gitgraph.css |  14 +++
 gitgraph.js  | 399 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 jquery.js    |  18 +++
 8 files changed, 892 insertions(+)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..30cd6b7
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2011, Terrence Lee <kill889 at gmail.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of the fgdev nor the
+      names of its contributors may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6f4376d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,45 @@
+gitgraph.js
+=======
+gitgraph.js a tool for converting "git log --graph" from pure ascii characters graph to a canvas image.
+
+Quick Start (with PHP demo)
+-----
+1. Get a copy of this repo (clone or [download tarball](http://github.com/bluef/gitgraph.js/tarball/master))
+2. Put everything in the directory where PHP file can be excuted
+3. Edit example.php, change the value of GIT_REPO_PATH on line 2 to the path of your repo
+	
+	define("GIT_REPO_PATH", "/path/to/your/repo");
+	
+4. Go visit example.php in your browser
+
+Miscellaneous
+------------
+jQuery is only for parsing DOM
+
+License
+-------
+Copyright (c) 2011, Terrence Lee <kill889 at gmail.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+*	Redistributions of source code must retain the above copyright
+	notice, this list of conditions and the following disclaimer.
+*	Redistributions in binary form must reproduce the above copyright
+	notice, this list of conditions and the following disclaimer in the
+	documentation and/or other materials provided with the distribution.
+*	Neither the name of the fgdev nor the
+	names of its contributors may be used to endorse or promote products
+	derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/canvas.html b/canvas.html
new file mode 100644
index 0000000..a601202
--- /dev/null
+++ b/canvas.html
@@ -0,0 +1,282 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+		<title>canvas</title>
+		<script type="text/javascript" src="jquery.js"></script>
+		<script type="text/javascript" src="gitgraph.js"></script>
+		<script type="text/javascript" src="draw.js"></script>
+	</head>
+	
+	<body>
+		<canvas id="graph-canvas" width="110" height="600" style="float:left">
+		</canvas>
+		
+		<div>
+			<ul id="graph-raw-list" style="float:left">
+				<li>
+					<span class="node-relation">*  </span>
+				</li><li>
+					<span class="node-relation">|\  </span>
+				</li><li>
+					<span class="node-relation">* \  </span>
+				</li><li>
+					<span class="node-relation">|\ \  </span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">| | *  </span>
+				</li><li>
+					<span class="node-relation">| | |\  </span>
+				</li><li>
+					<span class="node-relation">| |_|/  </span>
+				</li><li>
+					<span class="node-relation">|/| |   </span>
+				</li><li>
+					<span class="node-relation">| | *</span>
+				</li><li>
+					<span class="node-relation">| * |</span>
+				</li><li>
+					<span class="node-relation">| * |  </span>
+				</li><li>
+					<span class="node-relation">| |\ \  </span>
+				</li><li>
+					<span class="node-relation">| |/ /  </span>
+				</li><li>
+					<span class="node-relation">|/| |   </span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \  </span>
+				</li><li>
+					<span class="node-relation">| |_|/  </span>
+				</li><li>
+					<span class="node-relation">|/| |   </span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">| | *</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">| |/  </span>
+				</li><li>
+					<span class="node-relation">|/|   </span>
+				</li><li>
+					<span class="node-relation">* |</span>
+				</li><li>
+					<span class="node-relation">| | *</span>
+				</li><li>
+					<span class="node-relation">| | *</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">| |/  </span>
+				</li><li>
+					<span class="node-relation">|/|   </span>
+				</li><li>
+					<span class="node-relation">| | *  </span>
+				</li><li>
+					<span class="node-relation">| | |\  </span>
+				</li><li>
+					<span class="node-relation">| |_|/  </span>
+				</li><li>
+					<span class="node-relation">|/| |   </span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \  </span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">* | | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \ \  </span>
+				</li><li>
+					<span class="node-relation">| |_|_|/  </span>
+				</li><li>
+					<span class="node-relation">|/| | |   </span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| | * |  </span>
+				</li><li>
+					<span class="node-relation">| | |\ \  </span>
+				</li><li>
+					<span class="node-relation">| | |/ /  </span>
+				</li><li>
+					<span class="node-relation">| |/| |   </span>
+				</li><li>
+					<span class="node-relation">| | * |</span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| | | *  </span>
+				</li><li>
+					<span class="node-relation">| | | |\  </span>
+				</li><li>
+					<span class="node-relation">| |_|_|/  </span>
+				</li><li>
+					<span class="node-relation">|/| | |   </span>
+				</li><li>
+					<span class="node-relation">* | | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \ \  </span>
+				</li><li>
+					<span class="node-relation">| |/ / /  </span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| |_|/  </span>
+				</li><li>
+					<span class="node-relation">|/| |   </span>
+				</li><li>
+					<span class="node-relation">| * |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \  </span>
+				</li><li>
+					<span class="node-relation">| |/ /  </span>
+				</li><li>
+					<span class="node-relation">* | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \  </span>
+				</li><li>
+					<span class="node-relation">| | | | *</span>
+				</li><li>
+					<span class="node-relation">| * | | |</span>
+				</li><li>
+					<span class="node-relation">|  / / /  </span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| * | |</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| | | *</span>
+				</li><li>
+					<span class="node-relation">| |_|/  </span>
+				</li><li>
+					<span class="node-relation">|/| |   </span>
+				</li><li>
+					<span class="node-relation">* | |</span>
+				</li><li>
+					<span class="node-relation">* | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \  </span>
+				</li><li>
+					<span class="node-relation">| | |/  </span>
+				</li><li>
+					<span class="node-relation">| |/|   </span>
+				</li><li>
+					<span class="node-relation">| * |  </span>
+				</li><li>
+					<span class="node-relation">| |\ \  </span>
+				</li><li>
+					<span class="node-relation">| | |/  </span>
+				</li><li>
+					<span class="node-relation">| | *</span>
+				</li><li>
+					<span class="node-relation">* | |  </span>
+				</li><li>
+					<span class="node-relation">|\ \ \  </span>
+				</li><li>
+					<span class="node-relation">| |/ /  </span>
+				</li><li>
+					<span class="node-relation">|/| /   </span>
+				</li><li>
+					<span class="node-relation">| |/    </span>
+				</li><li>
+					<span class="node-relation">* |</span>
+				</li><li>
+					<span class="node-relation">| *</span>
+				</li><li>
+					<span class="node-relation">| *</span>
+				</li><li>
+					<span class="node-relation">* |</span>
+				</li><li>
+					<span class="node-relation">* |</span>
+				</li><li>
+					<span class="node-relation">* |  </span>
+				</li><li>
+					<span class="node-relation">|\ \  </span>
+				</li><li>
+					<span class="node-relation">| |/  </span>
+				</li><li>
+					<span class="node-relation">| *</span>
+				</li><li>
+					<span class="node-relation">|/  </span>
+				</li><li>
+					<span class="node-relation">*</span>
+				</li><li>
+					<span class="node-relation">*</span>
+				</li>
+			</ul>
+		</div>
+	</body>
+	
+	<style type="text/css" media="screen">
+		ul {margin:0}
+		li {list-style-type:none; height:20px}
+		
+		li .node-relation {font-family:'Bitstream Vera Sans Mono', 'Courier', monospace;}
+	</style>
+</html>
\ No newline at end of file
diff --git a/draw.js b/draw.js
new file mode 100644
index 0000000..fadb333
--- /dev/null
+++ b/draw.js
@@ -0,0 +1,17 @@
+$(document).ready(function () {
+	var graphList = [];
+	
+	if (!document.getElementById('graph-canvas')) {
+		return;
+	}
+	
+	$("#graph-raw-list li span.node-relation").each(function () {
+		graphList.push($(this).text());
+	})
+	
+	gitGraph(document.getElementById('graph-canvas'), graphList);
+	
+	if ($("#rev-container")) {
+		$("#rev-container").css("width", document.body.clientWidth - document.getElementById('graph-canvas').width);
+	}
+})
diff --git a/example.php b/example.php
new file mode 100644
index 0000000..fa0d943
--- /dev/null
+++ b/example.php
@@ -0,0 +1,93 @@
+<?php
+
+	define("GIT_REPO_PATH", "/path/to/your/repo"); //set the path to your repo here
+
+	$repo_dir = getenv('GIT_DIR');
+	if (empty($repo_dir)) {
+		chdir(GIT_REPO_PATH);
+		$repo_dir = GIT_REPO_PATH;
+	}
+	$repo_name = basename($repo_dir);
+
+	$cmd = 'git log --graph --date-order --all -C -M -n 100 --date=iso --pretty=format:"B[%d] C[%H] D[%ad] A[%an] E[%ae] H[%h] S[%s]"';
+
+	@ob_clean();
+	ob_start();
+	passthru($cmd . ' 2>&1');
+	$o = ob_get_clean();
+
+	$rawRows = explode("\n", $o);
+	$graphItems = array();
+
+	foreach ($rawRows as $row) {
+		if (preg_match("/^(.+?)(\s(B\[(.*?)\])? C\[(.+?)\] D\[(.+?)\] A\[(.+?)\] E\[(.+?)\] H\[(.+?)\] S\[(.+?)\])?$/", $row, $output)) {
+			if (!isset($output[4])) {
+				$graphItems[] = array(
+					"relation"=>$output[1]
+				);
+				continue;
+			}
+			$graphItems[] = array(
+				"relation"=>$output[1],
+				"branch"=>$output[4],
+				"rev"=>$output[5],
+				"date"=>$output[6],
+				"author"=>$output[7],
+				"author_email"=>$output[8],
+				"short_rev"=>$output[9],
+				"subject"=>preg_replace('/(^|\s)(#[[:xdigit:]]+)(\s|$)/', '$1<a href="$2">$2</a>$3', $output[10])
+			);
+		}
+	}
+
+	$title = "Git Graph of " . $repo_name;
+?>
+
+<!DOCTYPE html>
+<html>
+	<head>
+		<title><?php echo $title; ?></title>
+		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+		<script type="text/javascript" src="jquery.js"></script>
+		<script type="text/javascript" src="gitgraph.js"></script>
+		<script type="text/javascript" src="draw.js"></script>
+		<link href="gitgraph.css" rel="stylesheet" type="text/css">
+	</head>
+
+	<body>
+		<div id="header">
+			<h2>
+				<?php echo $title; ?>
+			</h2>
+		</div>
+		<div id="git-graph-container">
+		<div id="rel-container">
+			<canvas id="graph-canvas" width="100px">
+				<ul id="graph-raw-list">
+					<?php
+						foreach ($graphItems as $graphItem) {
+							echo "<li><span class=\"node-relation\">" . $graphItem['relation'] . "</span></li>\n";
+						}
+					?>
+				</ul>
+			</canvas>
+		</div>
+
+		<div style="float:left;" id="rev-container">
+			<ul id="rev-list">
+				<?php
+					foreach ($graphItems as $graphItem) {
+						echo "<li>";
+						if (isset($graphItem['rev'])) {
+							echo "<code id='".$graphItem['short_rev']."'>".$graphItem['short_rev']."</code> <strong>" . $graphItem['branch'] . "</strong> <em>" . $graphItem['subject'] . "</em> by <span class=\"author\">" . $graphItem['author'] . " <" . $graphItem['author_email'] . "></span>  <span class=\"time\">" . $graphItem['date'] . "</span>";
+						} else {
+							echo "<span />";
+						}
+						echo "</li>";
+					}
+				?>
+			</ul>
+		</div>
+	</div>
+	</body>
+</html>
diff --git a/gitgraph.css b/gitgraph.css
new file mode 100644
index 0000000..4156457
--- /dev/null
+++ b/gitgraph.css
@@ -0,0 +1,14 @@
+body {font:13.34px/1.4 helvetica,arial,freesans,clean,sans-serif;}
+em {font-style:normal;}
+
+#git-graph-container, #rel-container {float:left;}
+#git-graph-container {}
+#git-graph-container li {list-style-type:none;height:20px;line-height:20px;overflow:hidden;}	
+#git-graph-container li .node-relation {font-family:'Bitstream Vera Sans Mono', 'Courier', monospace;}
+#git-graph-container li .author {color:#666666;}
+#git-graph-container li .time {color:#999999;font-size:80%}
+#git-graph-container li a {color:#000000;}
+#git-graph-container li a em {color:#BB0000;border-bottom:1px dotted #BBBBBB;text-decoration:none;font-style:normal;}
+
+#rev-list {margin:0;padding:0 5px 0 0;}
+#graph-raw-list {margin:0px;}
\ No newline at end of file
diff --git a/gitgraph.js b/gitgraph.js
new file mode 100644
index 0000000..e2f0026
--- /dev/null
+++ b/gitgraph.js
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2011, Terrence Lee <kill889 at gmail.com>
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the <organization> nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+var gitGraph = function (canvas, rawGraphList, config) {
+	if (!canvas.getContext) {
+		return;
+	}
+	
+	if (typeof config === "undefined") {
+		config = {
+			unitSize: 20,
+			lineWidth: 3,
+			nodeRadius: 4
+		};
+	}
+	
+	var flows = [];
+	var graphList = [];
+	
+	var ctx = canvas.getContext("2d");
+	
+	var init = function () {
+		var maxWidth = 0;
+		var i;
+		var l = rawGraphList.length;
+		var row;
+		var midStr;
+		
+		for (i = 0; i < l; i++) {
+			midStr = rawGraphList[i].replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "");
+			
+			maxWidth = Math.max(midStr.replace(/(\_|\s)/g, "").length, maxWidth);
+			
+			row = midStr.split("");
+			
+			graphList.unshift(row);
+		}
+		
+		canvas.width = maxWidth * config.unitSize;
+		canvas.height = graphList.length * config.unitSize;
+		
+		ctx.lineWidth = config.lineWidth;
+		ctx.lineJoin = "round";
+		ctx.lineCap = "round";
+	};
+	
+	var genRandomStr = function () {
+		var chars = "0123456789ABCDEF";
+		var stringLength = 6;
+		var randomString = '', rnum, i;
+		for (i = 0; i < stringLength; i++) {
+			rnum = Math.floor(Math.random() * chars.length);
+			randomString += chars.substring(rnum, rnum + 1);
+		}
+		
+		return randomString;
+	};
+	
+	var findFlow = function (id) {
+		var i = flows.length;
+		
+		while (i-- && flows[i].id !== id) {}
+		
+		return i;
+	};
+	
+	var findColomn = function (symbol, row) {
+		var i = row.length;
+		
+		while (i-- && row[i] !== symbol) {}
+		
+		return i;
+	};
+	
+	var findBranchOut = function (row) {
+		if (!row) {
+			return -1
+		}
+		
+		var i = row.length;
+		
+		while (i-- && 
+			!(row[i - 1] && row[i] === "/" && row[i - 1] === "|") &&
+			!(row[i - 2] && row[i] === "_" && row[i - 2] === "|")) {}
+		
+		return i;
+	}
+	
+	var genNewFlow = function () {
+		var newId;
+		
+		do {
+			newId = genRandomStr();
+		} while (findFlow(newId) !== -1);
+		
+		return {id:newId, color:"#" + newId};
+	};
+	
+	//draw method
+	var drawLineRight = function (x, y, color) {
+		ctx.strokeStyle = color;
+		ctx.beginPath();
+		ctx.moveTo(x, y + config.unitSize / 2);
+		ctx.lineTo(x + config.unitSize, y + config.unitSize / 2);
+		ctx.stroke();
+	};
+	
+	var drawLineUp = function (x, y, color) {
+		ctx.strokeStyle = color;
+		ctx.beginPath();
+		ctx.moveTo(x, y + config.unitSize / 2);
+		ctx.lineTo(x, y - config.unitSize / 2);
+		ctx.stroke();
+	};
+	
+	var drawNode = function (x, y, color) {
+		ctx.strokeStyle = color;
+		
+		drawLineUp(x, y, color);
+		
+		ctx.beginPath();
+		ctx.arc(x, y, config.nodeRadius, 0, Math.PI * 2, true);
+		ctx.fill();
+	};
+	
+	var drawLineIn = function (x, y, color) {
+		ctx.strokeStyle = color;
+		
+		ctx.beginPath();
+		ctx.moveTo(x + config.unitSize, y + config.unitSize / 2);
+		ctx.lineTo(x, y - config.unitSize / 2);
+		ctx.stroke();
+	};
+	
+	var drawLineOut = function (x, y, color) {
+		ctx.strokeStyle = color;
+		ctx.beginPath();
+		ctx.moveTo(x, y + config.unitSize / 2);
+		ctx.lineTo(x + config.unitSize, y - config.unitSize / 2);
+		ctx.stroke();
+	};
+	
+	var draw = function (graphList) {
+		var colomn, colomnIndex, prevColomn, condenseIndex;
+		var x, y;
+		var color;
+		var nodePos, outPos;
+		var tempFlow;
+		var prevRowLength = 0;
+		var flowSwapPos = -1;
+		var lastLinePos;
+		var i, k, l;
+		var condenseCurrentLength, condensePrevLength = 0, condenseNextLength = 0;
+		
+		var inlineIntersect = false;
+		
+		//initiate for first row
+		for (i = 0, l = graphList[0].length; i < l; i++) {
+			if (graphList[0][i] !== "_" && graphList[0][i] !== " ") {
+				flows.push(genNewFlow());
+			}
+		}
+		
+		y = canvas.height - config.unitSize * 0.5;
+		
+		//iterate
+		for (i = 0, l = graphList.length; i < l; i++) {
+			x = config.unitSize * 0.5;
+			
+			currentRow = graphList[i];
+			nextRow = graphList[i + 1];
+			prevRow = graphList[i - 1];
+			
+			flowSwapPos = -1;
+			
+			condenseCurrentLength = currentRow.filter(function (val) {
+				return (val !== " "  && val !== "_")
+			}).length;
+			
+			if (nextRow) {
+				condenseNextLength = nextRow.filter(function (val) {
+					return (val !== " "  && val !== "_")
+				}).length;
+			} else {
+				condenseNextLength = 0;
+			}
+			
+			//pre process begin
+			//use last row for analysing
+			if (prevRow) {
+				if (!inlineIntersect) {
+					//intersect might happen
+					for (colomnIndex = 0; colomnIndex < prevRowLength; colomnIndex++) {
+						if (prevRow[colomnIndex + 1] && 
+							(prevRow[colomnIndex] === "/" && prevRow[colomnIndex + 1] === "|") || 
+							((prevRow[colomnIndex] === "_" && prevRow[colomnIndex + 1] === "|") &&
+							(prevRow[colomnIndex + 2] === "/"))) {
+							
+							flowSwapPos = colomnIndex;
+							
+							//swap two flow
+							tempFlow = {id:flows[flowSwapPos].id, color:flows[flowSwapPos].color};
+							
+							flows[flowSwapPos].id = flows[flowSwapPos + 1].id;
+							flows[flowSwapPos].color = flows[flowSwapPos + 1].color;
+							
+							flows[flowSwapPos + 1].id = tempFlow.id;
+							flows[flowSwapPos + 1].color = tempFlow.color;
+						}
+					}
+				}
+				
+				if (condensePrevLength < condenseCurrentLength &&
+					((nodePos = findColomn("*", currentRow)) !== -1 &&
+					(findColomn("_", currentRow) === -1))) {
+					
+					flows.splice(nodePos - 1, 0, genNewFlow());
+				}
+				
+				if (prevRowLength > currentRow.length &&
+					(nodePos = findColomn("*", prevRow)) !== -1) {
+					
+					if (findColomn("_", currentRow) === -1 &&
+						findColomn("/", currentRow) === -1 && 
+						findColomn("\\", currentRow) === -1) {
+						
+						flows.splice(nodePos + 1, 1);
+					}
+				}
+			} //done with the previous row
+			
+			prevRowLength = currentRow.length; //store for next round
+			colomnIndex = 0; //reset index
+			condenseIndex = 0;
+			condensePrevLength = 0;
+			while (colomnIndex < currentRow.length) {
+				colomn = currentRow[colomnIndex];
+				
+				if (colomn !== " " && colomn !== "_") {
+					++condensePrevLength;
+				}
+				
+				if (colomn === " " && 
+					currentRow[colomnIndex + 1] &&
+					currentRow[colomnIndex + 1] === "_" &&
+					currentRow[colomnIndex - 1] && 
+					currentRow[colomnIndex - 1] === "|") {
+					
+					currentRow.splice(colomnIndex, 1);
+					
+					currentRow[colomnIndex] = "/";
+					colomn = "/";
+				}
+				
+				//create new flow only when no intersetc happened
+				if (flowSwapPos === -1 &&
+					colomn === "/" &&
+					currentRow[colomnIndex - 1] && 
+					currentRow[colomnIndex - 1] === "|") {
+					
+					flows.splice(condenseIndex, 0, genNewFlow());
+				}
+				
+				//change \ and / to | when it's in the last position of the whole row
+				if (colomn === "/" || colomn === "\\") {
+					if (!(colomn === "/" && findBranchOut(nextRow) === -1)) {
+						if ((lastLinePos = Math.max(findColomn("|", currentRow), 
+													findColomn("*", currentRow))) !== -1 &&
+							(lastLinePos < colomnIndex - 1)) {
+							
+							while (currentRow[++lastLinePos] === " ") {}
+							
+							if (lastLinePos === colomnIndex) {
+								currentRow[colomnIndex] = "|";
+							}
+						}
+					}
+				}
+				
+				if (colomn === "*" &&
+					prevRow && 
+					prevRow[condenseIndex + 1] === "\\") {
+					flows.splice(condenseIndex + 1, 1);
+				}
+				
+				if (colomn !== " ") {
+					++condenseIndex;
+				}
+				
+				++colomnIndex;
+			}
+			
+			condenseCurrentLength = currentRow.filter(function (val) {
+				return (val !== " "  && val !== "_")
+			}).length;
+			
+			//do some clean up
+			if (flows.length > condenseCurrentLength) {
+				flows.splice(condenseCurrentLength, flows.length - condenseCurrentLength);
+			}
+			
+			colomnIndex = 0;
+			
+			//a little inline analysis and draw process
+			while (colomnIndex < currentRow.length) {
+				colomn = currentRow[colomnIndex];
+				prevColomn = currentRow[colomnIndex - 1];
+				
+				if (currentRow[colomnIndex] === " ") {
+					currentRow.splice(colomnIndex, 1);
+					x += config.unitSize;
+					
+					continue;
+				}
+				
+				//inline interset
+				if ((colomn === "_" || colomn === "/") &&
+					currentRow[colomnIndex - 1] === "|" &&
+					currentRow[colomnIndex - 2] === "_") {
+					
+					inlineIntersect = true;
+					
+					tempFlow = flows.splice(colomnIndex - 2, 1)[0];
+					flows.splice(colomnIndex - 1, 0, tempFlow);
+					currentRow.splice(colomnIndex - 2, 1);
+					
+					colomnIndex = colomnIndex - 1;
+				} else {
+					inlineIntersect = false;
+				}
+				
+				color = flows[colomnIndex].color;
+				
+				switch (colomn) {
+					case "_" :
+						drawLineRight(x, y, color);
+						
+						x += config.unitSize;
+						break;
+						
+					case "*" :
+						drawNode(x, y, color);
+						break;
+						
+					case "|" :
+						drawLineUp(x, y, color);
+						break;
+						
+					case "/" :
+						if (prevColomn && 
+							(prevColomn === "/" || 
+							prevColomn === " ")) {
+							x -= config.unitSize;
+						}
+						
+						drawLineOut(x, y, color);
+						
+						x += config.unitSize;
+						break;
+						
+					case "\\" :
+						drawLineIn(x, y, color);
+						break;
+				}
+				
+				++colomnIndex;
+			}
+			
+			y -= config.unitSize;
+		}
+	};
+	
+	init();
+	draw(graphList);
+};
\ No newline at end of file
diff --git a/jquery.js b/jquery.js
new file mode 100644
index 0000000..8cdc80e
--- /dev/null
+++ b/jquery.js
@@ -0,0 +1,18 @@
+/*!
+ * jQuery JavaScript Library v1.6.2
+ * http://jquery.com/
+ *
+ * Copyright 2011, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2011, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Thu Jun 30 14:16:56 2011 -0400
+ */
+(function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),ci.close();d=ci.createElement( [...]
+shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.tar [...]
+)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bi(a,d),e=bj(a),g=bj(d);for(h=0;e[h];++h)bi(e[h],g[h])}if(b){bh(a,d);if(c){e=bj(a),g=bj(d);for(h=0;e[h];++h)bh(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(v [...]
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/gitgraph.js.git



More information about the Pkg-javascript-commits mailing list