changeset 36:e078e1500cc2 extractapp

config for localgazetteers-dev
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Fri, 06 Mar 2015 14:13:18 +0100
parents 04736430d961
children 893ed33c2bd4
files develop/views/Extractapp/.DS_Store develop/views/Extractapp/ConfigTagsInTopic.php develop/views/Extractapp/EditTaglist.php develop/views/Extractapp/EditWordlist.php develop/views/Extractapp/ExportTable.php develop/views/Extractapp/TaggingText.php develop/views/Extractapp/configtagsintopic.php develop/views/Extractapp/edittaglist.php develop/views/Extractapp/editwordlist.php develop/views/Extractapp/exporttable.php develop/views/Extractapp/index.php develop/views/Extractapp/taggingtext.php develop/views/Home/index.php develop/views/Home/test.php develop/views/maintemplate.php develop/views/maintemplate_local.php
diffstat 16 files changed, 1652 insertions(+), 1738 deletions(-) [+]
line wrap: on
line diff
Binary file develop/views/Extractapp/.DS_Store has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/develop/views/Extractapp/ConfigTagsInTopic.php	Fri Mar 06 14:13:18 2015 +0100
@@ -0,0 +1,139 @@
+<?php
+// --- initialize ---
+//$taglistArray = $viewmodel['taglistArray'];
+$topic = $viewmodel['topic'];
+$topic_name = $viewmodel['topic_name'];
+$tag_intopic = $viewmodel['tag_intopic'];
+$tag_others = $viewmodel['tag_others'];
+
+?>
+
+<html>
+<head>
+<title></title>
+</head>
+
+<body>
+<script type="text/javascript">
+function SelectMoveRows(s1, s2)
+{
+    var selId = '';
+    var selText = '';
+    // Move rows from s1 to s2 from bottom to top
+    for (i = s1.options.length - 1; i >= 0; i--)
+    {
+        if (s1.options[i].selected == true)
+        {
+            selId = s1.options[i].value;
+            selText = s1.options[i].text;
+            var newRow = new Option(selText,selId);
+            s2.options[s2.length] = newRow;
+            s1.options[i] = null;
+        }
+    }
+    SelectSort(s2);
+}
+function SelectSort(selList)
+{
+    var id = '';
+    var t = '';
+    for (x = 0; x < selList.length - 1; x++)
+    {
+        for (y = x+1; y < selList.length; y++)
+        {
+            if (selList[x].text > selList[y].text)
+            {
+                // Swap rows
+                id = selList[x].value;
+                t = selList[x].text;
+                selList[x].value = selList[y].value;
+                selList[x].text = selList[y].text;
+                selList[y].value = id;
+                selList[y].text = t;
+            }
+        }
+    }
+}
+
+function checkTopic(t) {
+	var ids = [];
+
+	for (var i = 0; i < t.options.length; i++) {
+		ids.push(t.options[i].value);
+		console.log(t.options[i].text);
+	}
+
+	console.log(ids);
+	var ids_json = JSON.stringify(ids);
+	var topic_id = JSON.parse('<?php echo json_encode($topic) ?>');
+
+	$.ajax({
+		url : './ConfigTagsInTopic',
+		async : false,
+		type : 'POST',
+		data : 'func=Update'+'&ids='+ids_json+'&topic_id='+topic_id,
+		error: function (e) {
+			console.log("error when update tags in topic"+ e );
+		},
+		success: function (e) {
+			alert("Updated!");
+		}
+	}).done(function(result) {
+	});
+
+}
+
+</script>
+
+<div class="container-fluid" style="margin-left:30%;">
+   
+		<form name="config" autocomplete='off' action="Javascript:checkTopic(document.config.InTopic)">
+			<h3>Topic: <?php echo $topic_name;?> </h3>
+			
+			<table class="table">
+				<thead>
+					<tr>
+						<td class="text-warning"> Selected tags </td>
+						<td></td>
+						<td class="text-warning"> Other tags </td>
+					</tr>
+				</thead>
+				<tbody>
+				<tr>
+					<td>
+						<select name="InTopic" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple>
+							<?php 
+								foreach ($tag_intopic as $taglistValue) {
+									echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
+								}
+							?>
+						</select>
+					</td>
+					<td align="center" valign="middle">
+			            <input type="button" value="<< Add" class="btn btn-primary" onClick="SelectMoveRows(document.config.Others, document.config.InTopic)"><br>
+			         	<br>
+			            <input type="button" value="Remove >>" class="btn btn-warning" onClick="SelectMoveRows(document.config.InTopic, document.config.Others)"><br>
+			        </td>
+					<td >
+						<select name="Others" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple>
+							<?php 
+								foreach ($tag_others as $taglistValue) {
+									echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
+								}
+							?>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td></td>
+					<td><input type="submit" value="Submit" class="btn btn-lg btn-success"></td>
+					<td></td>
+				</tr>
+				</tbody>
+			</table>
+			
+		</form>
+</div>
+
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/develop/views/Extractapp/EditTaglist.php	Fri Mar 06 14:13:18 2015 +0100
@@ -0,0 +1,357 @@
+<?php
+// --- initialize ---
+$taglistArray = $viewmodel['taglistArray'];
+$topic_id = $viewmodel['topic_id'];
+$largestId = $viewmodel['largest_id'];
+
+?>
+
+<html>
+<head>
+<title></title>
+<link rel="stylesheet" href="../css/colorpicker.css" type="text/css" />
+<script type="text/javascript" src="../js/colorpicker.js"></script>
+<script type="text/javascript" src="../js/eye.js"></script>
+<script type="text/javascript" src="../js/utils.js"></script>
+<script type="text/javascript" src="../js/layout.js?ver=1.0.2"></script>
+</head>
+
+<body>
+
+
+<table width="100%" border="1" id="tableMain"> </table>
+
+
+<script type="text/javascript">
+
+// var largestId = 0;
+var largestId = JSON.parse('<?php echo json_encode($largestId) ?>');
+
+function addTag( ) {
+	largestId++;
+	var row = tableMain.insertBefore(document.createElement("tr"), document.getElementById("trAddTag") );
+	row.setAttribute("height","50");
+	row.id = "tr"+largestId;
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.id = "tdId"+largestId;
+	newcolumn.setAttribute("width","150");
+	row.appendChild(newcolumn).innerHTML=largestId;
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","150");
+	newcolumn.id = "tdName"+largestId;
+	newcolumn.setAttribute("idnum",largestId);
+	newcolumn.setAttribute("name","tdName");
+	row.appendChild(newcolumn).innerHTML="";
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","150");
+	newcolumn.id = "tdTag"+largestId;
+	newcolumn.setAttribute("idnum",largestId);
+	newcolumn.setAttribute("name","tdTag");
+	row.appendChild(newcolumn).innerHTML="";
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","150");
+	row.appendChild(newcolumn).innerHTML="<div id=\"colorSelector"+largestId+"\"><div id=\"colorSelectorB"+largestId+"\"  style=\"background-color: #000000\"></div></div>";
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","50");
+	row.appendChild(newcolumn).innerHTML="<button onclick=\"newTag("+largestId+")\">Save</button>";
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","50");
+	row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+largestId+")\">Delete</button>";
+	
+	$('#colorSelector'+largestId).ColorPicker({
+		color: '#000000',
+		onShow: function (colpkr) {
+			$(colpkr).fadeIn(500);
+			return false;
+		},
+		onHide: function (colpkr) {
+			$(colpkr).fadeOut(500);
+			return false;
+		},
+		onChange: function (hsb, hex, rgb) {
+			$('#colorSelector'+largestId+' div').css('backgroundColor', '#' + hex);
+		}
+	});
+	/*
+	// addRule doesn't work in FF
+	document.styleSheets[0].addRule("#colorSelector"+largestId, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);")
+	document.styleSheets[0].addRule("#colorSelector"+largestId+" div", "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;")
+	*/
+
+	// insertRule works in IE9, FF, Saf, Chrome, Opera
+	var x = document.styleSheets[0];
+	var selector1 = "#colorSelector"+largestId;
+	var selector2 = "#colorSelector"+largestId+" div";
+
+	if (x.insertRule) {
+		x.insertRule(selector1+' {position:relative; width:36px; height:36px; background:url(../images/select.png);}', x.cssRules.length);
+		x.insertRule(selector2+' {position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background:url(../images/select.png) center;}', x.cssRules.length);
+	
+	} else if (x.addRule) {
+		x.addRule(selector1, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);");
+		x.addRule(selector2, "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;");
+	}
+	
+
+}	
+
+
+function addNode( id, name, tag, color ) {
+	// if ( parseInt(id) > largestId ) largestId=parseInt(id);
+	
+	var tableMain=document.getElementById("tableMain");
+	
+	if ( id == "AddTag" ) {
+		var row = tableMain.appendChild(document.createElement("tr"));
+		row.id = "trAddTag";
+		
+		var newcolumn = document.createElement("td");
+		newcolumn.setAttribute("width","150");
+		newcolumn.setAttribute("colspan","6");
+		newcolumn.setAttribute("align","center");
+		row.appendChild(newcolumn).innerHTML="<button onclick=\"addTag()\" style=\"height: 50px; width: 300px\">Add New Tag</button>";
+		
+		return 0;
+	}
+	var row = tableMain.appendChild(document.createElement("tr"));
+	row.setAttribute("height","50");
+	row.id = "tr"+id;
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.id = "tdId"+id;
+	newcolumn.setAttribute("width","150");
+	row.appendChild(newcolumn).innerHTML=id;
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","150");
+	newcolumn.id = "tdName"+id;
+	newcolumn.setAttribute("idnum",id);
+	newcolumn.setAttribute("name","tdName");
+	row.appendChild(newcolumn).innerHTML=name;
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","150");
+	newcolumn.id = "tdTag"+id;
+	newcolumn.setAttribute("idnum",id);
+	newcolumn.setAttribute("name","tdTag");
+	row.appendChild(newcolumn).innerHTML=tag;
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","150");
+	if ( color=="Color") {
+		row.appendChild(newcolumn).innerHTML="Color";
+	} else {
+		row.appendChild(newcolumn).innerHTML="<div id=\"colorSelector"+id+"\"><div id=\"colorSelectorB"+id+"\" style=\"background-color: "+color+"\"></div></div>";
+	}
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","50");
+	if ( color=="Color") {
+		row.appendChild(newcolumn).innerHTML="Save";
+	} else {
+		row.appendChild(newcolumn).innerHTML="<button onclick=\"saveTag("+id+", 'update')\">Save</button>";
+	}
+	
+	var newcolumn = document.createElement("td");
+	newcolumn.setAttribute("width","50");
+	if ( color=="Color") {
+		row.appendChild(newcolumn).innerHTML="Delete";
+	} else {
+		row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+id+")\">Delete</button>";
+	}
+	
+	$('#colorSelector'+id).ColorPicker({
+		color: color,
+		onShow: function (colpkr) {
+			$(colpkr).fadeIn(500);
+			return false;
+		},
+		onHide: function (colpkr) {
+			$(colpkr).fadeOut(500);
+			return false;
+		},
+		onChange: function (hsb, hex, rgb) {
+			$('#colorSelector'+id+' div').css('backgroundColor', '#' + hex);
+		}
+	});
+
+
+	/* 
+	// addRule doesn't work in FF
+	document.styleSheets[0].addRule("#colorSelector"+id, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);")
+	document.styleSheets[0].addRule("#colorSelector"+id+" div", "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;")
+
+	*/
+	// insertRule works in IE9, FF, Saf, Chrome, Opera
+	var x = document.styleSheets[0];
+	var selector1 = "#colorSelector"+id;
+	var selector2 = "#colorSelector"+id+" div";
+
+	if (x.insertRule) {
+		x.insertRule(selector1+' {position:relative; width:36px; height:36px; background:url(../images/select.png);}', x.cssRules.length);
+		x.insertRule(selector2+' {position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background:url(../images/select.png) center;}', x.cssRules.length);
+	
+	} else if (x.addRule) {
+		x.addRule(selector1, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);");
+		x.addRule(selector2, "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;");
+	}
+	
+
+}
+
+function newTag( id ) {
+	
+	var elid = document.getElementById("tdId"+id).textContent;
+	var elname = document.getElementById("tdName"+id).textContent;
+	var eltag = document.getElementById("tdTag"+id).textContent;
+	/*
+	var elid = document.getElementById("tdId"+id).innerHTML;
+	var elname = document.getElementById("tdName"+id).innerHTML;
+	var eltag = document.getElementById("tdTag"+id).innerHTML;
+	*/
+	var elcolor = $("#colorSelectorB"+id).css("background-color");
+
+	console.log("elid="+elid+', elname='+elname+', eltag='+eltag);
+
+	var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>');
+	
+	$.ajax({
+		url : './EditTaglist',
+		async : false,
+		type : 'POST',
+		data : 'func=NewTagElement'+'&id='+elid+'&name='+elname+'&tag='+eltag+'&color='+elcolor+'&topic_id='+topic_id,
+		error: function (e) {
+			console.log("error when newTag");
+		},
+		success: function (e) {
+			alert("Saved!");
+			document.location.reload(true);
+		}
+	}).done(function(result) {
+	});
+}
+
+function saveTag( id) {
+
+	var elid = document.getElementById("tdId"+id).textContent;
+	var elname = document.getElementById("tdName"+id).textContent;
+	var eltag = document.getElementById("tdTag"+id).textContent;
+	/*
+	var elid = document.getElementById("tdId"+id).innerHTML;
+	var elname = document.getElementById("tdName"+id).innerHTML;
+	var eltag = document.getElementById("tdTag"+id).innerHTML;
+	*/
+
+	var elcolor = $("#colorSelectorB"+id).css("background-color");
+	
+	console.log(elid+','+elname+','+eltag+','+elcolor);
+	
+	var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>');
+
+	$.ajax({
+		url : './EditTaglist',
+		async : false,
+		type : 'POST',
+		data : 'func=SaveTagElement'+'&id='+elid+'&name='+elname+'&tag='+eltag+'&color='+elcolor+'&topic_id='+topic_id,
+		error: function (e) {
+			console.log("error when saving Tag");
+		},
+		success: function (e) {
+			alert("Saved!");
+			document.location.reload(true);
+		}
+	}).done(function(result) {
+	});
+}
+
+function DeleteTag( id ) {	
+	$("#tr"+id).remove();
+	$.ajax({
+		url : './EditTaglist',
+		async : false,
+		type : 'POST',
+		data : 'func=DeleteTag'+'&id='+id+'&type=delete'
+	}).done(function(result) {
+		alert("Saved!");
+	});
+}
+
+
+$(document).on("click", "[name=tdName]", function () {
+	if ( $("#input"+this.id).length > 0 ) {
+		return;
+	}
+	//var startPageValue = this.innerHTML;
+	var startPageValue = this.textContent;
+	this.innerHTML="";
+	var newTextBox = document.createElement("input");
+	newTextBox.id = "input"+this.id;
+	newTextBox.setAttribute("name","inputName");
+	newTextBox.setAttribute("onfocus","this.select()");
+	newTextBox.setAttribute("size","20");
+	this.appendChild(newTextBox).value=startPageValue;
+	
+	$("#input"+this.id).focus();
+} );
+
+$(document).on("click", "[name=tdTag]", function () {
+	if ( $("#input"+this.id).length > 0 ) {
+		return;
+	}
+	//var startPageValue = this.innerHTML;
+	var startPageValue = this.textContent;
+	this.innerHTML="";
+	var newTextBox = document.createElement("input");
+	newTextBox.id = "input"+this.id;
+	newTextBox.setAttribute("name","inputTag");
+	newTextBox.setAttribute("onfocus","this.select()");
+	newTextBox.setAttribute("size","20");
+	this.appendChild(newTextBox).value=startPageValue;
+	
+	$("#input"+this.id).focus();
+} );
+
+$(document).on("keypress", "[name=tdName]", function () {
+	if (event.keyCode == 13) {
+		$(this).focusout();
+	}
+});
+
+$(document).on("keypress", "[name=tdTag]", function () {
+	if (event.keyCode == 13) {
+		$(this).focusout();
+	}
+});
+
+$(document).on("focusout", "[name=tdName]", function () {
+	var value=$("#input"+this.id).val();
+	$(this).html($(this).html() + value);
+	$("#input"+this.id).remove();
+});
+
+$(document).on("focusout", "[name=tdTag]", function () {
+	var value=$("#input"+this.id).val();
+	$(this).html($(this).html() + value);
+	$("#input"+this.id).remove();
+});
+
+addNode( "AddTag","","","" );
+addNode( "ID","Name","Tag","Color" );
+
+<?php 
+foreach ( $taglistArray as $tagId => $tagArray ) {
+
+	echo "addNode( \"".$tagId."\",\"".$tagArray[0]."\",\"".$tagArray[1]."\",\"".$tagArray[2]."\" );\n";
+}
+?>
+
+
+</script>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/develop/views/Extractapp/EditWordlist.php	Fri Mar 06 14:13:18 2015 +0100
@@ -0,0 +1,55 @@
+<?php
+// --- initialize ---
+$wordlistArray = $viewmodel['wordlistArray'];
+?>
+
+<html>
+<head>
+<title></title>
+<style>
+dynasty
+{
+	color:red;
+}
+nianhao
+{
+	color:blue;
+}
+name
+{
+	color:orange;
+}
+#editable-area {
+	line-height:160%;
+	letter-spacing:1.5px;
+	font-size:21px;
+}
+</style>
+</head>
+<body>
+
+<table width="98%" border="1">
+	<tr>
+		<td width="20%" valign="top">
+			<?php 
+			foreach ( $wordlistArray as $nameId => $nameValue ) {
+				echo "&nbsp;&nbsp;<a onclick=\"showListContent(".$nameId.")\" href=\"#\">".$nameValue."</a></br>";
+			}
+			?>
+			<form action="javascript:void(0);">				
+				<fieldset>
+					<legend>Add List:</legend>
+					List name: <input type="text" size="30" id="listNameText"><br>
+					<button onclick="addNewList()">Add</button>
+				</fieldset>
+			</form>
+		</td>
+		<td width="60%">
+			<div id="editable-area"></div>
+		</td>
+		<td width="20%" valign="top" id="button-area">&nbsp;</td>
+	</tr>
+</table>
+
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/develop/views/Extractapp/ExportTable.php	Fri Mar 06 14:13:18 2015 +0100
@@ -0,0 +1,85 @@
+<?php
+// --- initialize ---
+$outputTableArray = $viewmodel['outputTableArray'];
+$bookId = $viewmodel['bookId'];
+$sectionid = $viewmodel['section_id'];
+$bookName = $viewmodel['bookName'];
+$sectionName = $viewmodel['sectionName'];
+
+
+
+?>
+
+<html>
+<head>
+<title></title>
+
+</head>
+
+<body>
+<table width="100%" border="1" id="tableMain">
+	
+<?php
+$count=1;
+	foreach ( $outputTableArray as $trIndex =>$trValue ) {
+		echo "<tr>";
+		if ( $trIndex==0 ) {
+			echo "<td>#</td>";
+			echo "<td>Book ID</td>";
+			echo "<td>Section ID</td>";
+			echo "<td>方志</td>";
+			echo "<td>部</td>";
+		} else {
+			echo "<td>".$count++."</td>";
+			echo "<td>".$bookId."</td>";
+			echo "<td>".$sectionid."</td>";
+			echo "<td>".$bookName."</td>";
+			echo "<td>".$sectionName."</td>";
+		}
+		if ( isset( $trValue["page"] ) ) {
+			echo "<td>".$trValue["page"]."</td>";
+		} else {
+			echo "<td>&nbsp;</td>";
+		}
+		/*
+		foreach ( $outputTableArray[0][1] as $index => $value ) {
+			if ( isset( $trValue[1][$index] ) ) {
+				echo "<td>".$trValue[1][$index]."</td>";
+			} else {
+				echo "<td>&nbsp;</td>";
+			}
+		}
+		*/
+		foreach ( $outputTableArray[0][0] as $index => $value ) {
+			if ( $index == "time" ) {
+				if ( isset( $trValue[0][$index] ) ) {
+					echo "<td>".$trValue[0][$index]."</td>";
+					echo "<td>".$trValue[0][$index]."</td>";
+				} else {
+					echo "<td>&nbsp;</td>";
+					echo "<td>&nbsp;</td>";
+				}
+			} else {
+				if ( isset( $trValue[0][$index] ) ) {
+					echo "<td>".$trValue[0][$index]."</td>";
+				} else {
+					echo "<td>&nbsp;</td>";
+				}
+			}
+		}
+		if ( isset( $trValue["other"] ) ) {
+			echo "<td>".$trValue["other"]."</td>";
+		} else {
+			echo "<td>&nbsp;</td>";
+		}
+		if ( isset( $trValue["full"] ) ) {
+			echo "<td>".$trValue["full"]."</td>";
+		} else {
+			echo "<td>&nbsp;</td>";
+		}
+		echo "</tr>";
+	}
+?>
+</table>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/develop/views/Extractapp/TaggingText.php	Fri Mar 06 14:13:18 2015 +0100
@@ -0,0 +1,1016 @@
+<?php
+// --- initialize config file and input text ---
+$stringInput = $viewmodel['stringInput'];
+$wordlistArray = $viewmodel['wordlistArray'];
+$taglistArray = $viewmodel['taglistArray'];
+$section_id = $viewmodel['section_id'];
+$topiclistArray = $viewmodel['topiclistArray'];
+$default_topic_id = $viewmodel['default_topic_id'];
+$topic_name = $viewmodel['topic_name'];
+$topic_tag = $viewmodel['topic_tag'];
+$info = $viewmodel['info']; 
+$messages = $viewmodel['messages'];
+
+
+?>
+
+<html>
+<head>
+<title></title>
+
+<style>
+dynasty
+{
+	color:red;
+}
+nianhao
+{
+	color:blue;
+}
+name
+{
+	color:orange;
+}
+#editable-area {
+	line-height:160%;
+	letter-spacing:1.5px;
+	font-size:21px;
+}
+
+
+<?php
+// color on the tags
+foreach ( $taglistArray as $taglistValue ) {
+	echo $taglistValue[2]."\n{\ncolor:".$taglistValue[3]."\n}\n";
+	
+	echo ".span_".$taglistValue[2]."\n{\nbackground-color:".$taglistValue[3]."\n}\n";
+}
+
+?>
+</style>
+
+
+</head>
+
+<body>
+
+<script type="text/javascript">
+
+// === This is only for developing on local machine ====
+var _GET = JSON.parse('<?php echo json_encode($_GET) ?>');
+if (_GET['id']) {
+    
+    var info = JSON.parse('<?php echo json_encode($info) ?>');
+    var redirectUrl = "http://localhost:1080/localmonographs/develop/Extractapp/TaggingText";
+    var section_id = info['section_id'];
+
+    var form = $('<form action="' + redirectUrl + '" method="post">' +
+        '<input type="hidden" name="sectionId" value="'+section_id+'" />' +
+        '</form>');
+        $('body').append(form);
+        $(form).submit();
+}
+// ====
+
+
+
+// TODO: Popup to proceeding the saving situations
+function handleFileVersionConflict() {
+    var info = JSON.parse('<?php echo json_encode($info) ?>');
+    console.log("currentFileId="+info['current_fileId']);
+    
+    if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){
+        // -- there might be conflicts between different version
+        var retVal = confirm('There were something happened/someone editing in the between of time.\nDo you want to force saving? (There might be conflicts between two versions.)');
+        if( retVal == true ){
+            // TODO: force saving with currentFileId
+            alert("You do the force saving!");
+            //saveTextToLGService();
+
+        }else{
+            var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)");
+            
+            console.log("loadLastest="+loadLastest);
+            /*
+            var form = document.createElement("form");
+            form.setAttribute("method", "post");
+            form.setAttribute("action", "./TaggingText");  // hand to controller
+            form.setAttribute("target", "_blank");  
+
+            var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
+
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "topic");
+            hiddenField.setAttribute("value", topic_id);
+            form.appendChild(hiddenField);
+
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "func");
+            hiddenField.setAttribute("value", "Reload");  // reload
+            form.appendChild(hiddenField);
+
+            _postForContineTagging(form);
+
+            alert("You will reload the latest version.");   
+            */
+            /*
+            if (loadLastest == true) {
+                // TODO: reload page with the currentFileId
+                console.log('loadLastest is true');
+                $.ajax({
+                    type : 'POST',
+                    url : './TaggingText',
+                    async : false,
+                    data : 'func=Reload',
+                    success: function (result) {
+                        //var lastest_editing = jQuery.parseJSON(result); 
+                        console.log("lastest_editing string:"+result);
+                        // change text to the new one
+                        //var el = document.getElementById("editable-area");
+                        //el.innerHTML = lastest_editing;
+                        //alert("Reload the page!");
+                    },
+                    error: function (result) {
+                        alert("Reload Fails!");
+                    }
+                }).done(function(result) {
+                    // reload page
+                    //document.location.reload(true);
+
+                });
+
+            } else {
+                alert("Just a reminder, there is a new version for this branch.");
+            }
+            */
+            
+        }
+    }
+    return;
+    
+}
+
+<?php 
+foreach ( $taglistArray as $taglistValue ) {
+	echo '$(document).on("click", "'.$taglistValue[2].'", function (e) {'."\n";
+	echo "\t".'if ( $(this).prop("tagName").toLowerCase() != "'.$taglistValue[2].'" ) return 0;'."\n";
+	echo "\t".'if ( $("#editTextId").html() != "Edit the text" ) return 0;'."\n";
+	echo "\tremoveTagNewDiv( e, \"".$taglistValue[2]."\", $(this) );\n";
+	echo "});\n";
+}
+?>
+
+$(document).ready(function(){
+    
+    // --- for sidebar--- 
+    //run once
+    var el=$('#follow-scroll');
+    var originalelpos=el.offset().top; // take it where it originally is on the page
+    
+
+    //run on scroll
+    $(window).scroll(function(){
+        var el = $('#follow-scroll'); // important! (local)
+        var elpos = el.offset().top; // take current situation
+        var windowpos = $(window).scrollTop();
+        var finaldestination = windowpos+originalelpos;
+        //el.stop().animate({'top':finaldestination},500);
+        el.stop().animate({'top':finaldestination},0);
+    });
+
+    //--- for popups ---
+    //run once
+    var el=$('#popups');
+    var originalelpos=el.offset().top; // take it where it originally is on the page
+    
+    //run on scroll
+    $(window).scroll(function(){
+        var el = $('#popups'); // important! (local)
+        var elpos = el.offset().top; // take current situation
+        var windowpos = $(window).scrollTop();
+        var finaldestination = windowpos+originalelpos;
+        //el.stop().animate({'top':finaldestination},500);
+        el.stop().animate({'top':finaldestination},0);
+    });
+
+
+
+    handleFileVersionConflict();
+
+    
+
+    /*
+
+    // Popup choosing topic if first time to this section. without branchId
+    if (info['file_id'] == 0) {  // or info['branchId'] == 0, means new file
+        // ask to choose topic
+        $.ajax({
+
+        });
+        var popup = document.getElementById('popup-window');
+
+        // alert('choose topic!');
+    }
+    */
+
+});
+$(document).on("click", "name", function (e) {
+
+    if ( $("#editTextId").html() != "Edit the text" ) return 0;
+    if ( $(this).prop("tagName").toLowerCase() != "name" ) return 0;
+    
+    removeTagNewDiv( e, "name", $(this) );
+});
+
+$(document).on("mouseup", '#editable-area', function (e) {
+    $('.questionMarkClass').remove();
+    $('.tagItemDivClass').remove();
+   
+    if ( $("#editTextId").html() != "Edit the text" ) return 0;
+    var selection = getSelected();
+    range = getSelected().getRangeAt(0);
+    
+    container = document.createElement("div");
+    container.appendChild(selection.getRangeAt(0).cloneContents());
+
+    if(selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) {
+    
+    	var newdiv = document.createElement("div");
+        newdiv.id = "tagItemDivId";
+        newdiv.setAttribute("class", "tagItemDivClass");
+        newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px';
+        
+        newdiv.style.backgroundColor = "white";
+        newdiv.style.zIndex = 2;
+
+        //console.log(selection.getRangeAt(0).cloneContents());
+        if ( container.innerHTML.indexOf( "br" ) != -1 ) {
+            var newselect = document.createElement("select");
+            newselect.id = "TitletagType";
+            <?php 
+                foreach ( $taglistArray as $taglistValue ) {
+                    echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n";
+                }
+            ?>
+            newdiv.appendChild(newselect);
+            
+            //matchValue =  .match();
+            myRegexp = new RegExp("〈(.*?)〉", "g")
+            matchValue = myRegexp.exec(String(selection));
+            
+            if ( matchValue != null ) {
+                newdiv.innerHTML += "<input id=\"TitletagName\" value=\""+ matchValue[1] +"\"></br>";
+            } else {
+                newdiv.innerHTML += "<input id=\"TitletagName\" value=\"\"></br>";
+            }
+
+            console.log(" container innerHTML: "+ container.innerHTML );
+
+            newdiv.innerHTML += "<button onclick=\"addTagTitle( range, container )\">Add Title Tag To Each Line</button></br>";
+            
+            /*
+            newdiv.innerHTML += "<button onclick=\"exportTable( range, container )\">Export As A Table</button></br></br>";
+            */
+
+            var newselect = document.createElement("select");
+            newselect.id = "RemoveTitletagType";
+            <?php 
+                foreach ( $taglistArray as $taglistValue ) {
+                    echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n";
+                }
+            ?>
+            newdiv.appendChild(newselect);
+            
+            newdiv.innerHTML += "<input id=\"RemoveTitletagName\" value=\"\"></br>";
+            newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>";
+        } else {
+ 			// for pop up window on edit-area for tag list
+            newdiv.innerHTML = "Tag: "+String(selection)+"<br>";
+            
+            <?php 
+            foreach ( $taglistArray as $taglistValue ) {
+
+                if ($taglistValue[2] == $topic_tag) {
+                	echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">[TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)</button>\";\n";
+                    echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
+                    echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
+                    
+                    /*
+                    echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
+                    echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
+                    echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
+            		*/
+                    break;
+            	}
+            }
+            ?>
+
+            newdiv.innerHTML += "<button accesskey=\"2\" onclick=\"tagwithtitle( range, '"+String(selection)+"' )\">Tag As Title</button></br>";
+            
+            <?php 
+            	
+			    foreach ( $taglistArray as $taglistValue ) {
+                	/*
+                	if ( $taglistValue[2] == "person") {
+                        echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
+                        echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
+                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
+                	} else */
+                    if ($taglistValue[2] == $topic_tag) { 
+                		// pass
+                	} else if ($taglistValue[2] == "post_time") {
+                        echo "newdiv.innerHTML += \"<button accesskey=\\\"3\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
+                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
+                    } else if ($taglistValue[2] == "office") {
+                        echo "newdiv.innerHTML += \"<button accesskey=\\\"4\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
+                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
+                    } else {
+                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
+                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
+                    } 
+
+                }
+            ?>
+        }
+
+        //$('#tagItemDivId').addClass();  // tagItemDivId is newdiv's id
+        $('body').append(newdiv);
+        
+        $('#TitletagType').val(lastAddTag);
+
+    }
+    //e.stopPropagation();
+});
+
+
+// === for exporttable.php ===
+function exportTable( range, container ) {
+    //MsgBox("enter function");
+    var form = document.createElement("form");
+    form.setAttribute("method", "post");
+    form.setAttribute("action", "./ExportTable");
+    form.setAttribute("target", "_blank");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "content");
+    hiddenField.setAttribute("value", container.innerHTML);
+    form.appendChild(hiddenField);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "sectionid");
+    hiddenField.setAttribute("value", "<?php echo $section_id; ?>");
+    form.appendChild(hiddenField);
+    
+    var hiddenField2 = document.createElement("input");      
+    hiddenField2.setAttribute("name", "topic");
+    hiddenField2.setAttribute("value", topic_id);
+    form.appendChild(hiddenField2);
+
+    var info = JSON.parse( '<?php echo json_encode($info) ?>');
+
+    if (info) {
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "bookId");
+    hiddenField.setAttribute("value", info['book_id']);
+    form.appendChild(hiddenField);   
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "bookName");
+    hiddenField.setAttribute("value", info['book_name']);
+    form.appendChild(hiddenField);   
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "sectionName");
+    hiddenField.setAttribute("value", info['section_name']);
+    form.appendChild(hiddenField);
+
+    };
+
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+}
+
+function exportPage(topic_id) {
+    var startPage = $('#exportPageStart').val();
+    var endPage = $('#exportPageEnd').val();
+
+    var el = document.getElementById("editable-area");
+    var str="" + el.innerHTML;
+
+    var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】";
+    
+    var form = document.createElement("form");
+    form.setAttribute("method", "post");
+    form.setAttribute("action", "./ExportTable");
+    form.setAttribute("target", "_blank");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "content");
+    hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g")));
+    form.appendChild(hiddenField);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "topic");
+    hiddenField.setAttribute("value", topic_id);
+    form.appendChild(hiddenField);
+
+    _postForContineTagging(form);
+   
+
+    /*
+    var section_id = JSON.parse('<?php echo json_encode($section_id) ?>');
+    console.log("section_id: "+section_id+", topic_id: "+topic_id);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "sectionId");
+    hiddenField.setAttribute("value", section_id);
+    form.appendChild(hiddenField);   
+ 
+    var info = JSON.parse( '<?php echo json_encode($info) ?>');
+
+    if (info) {
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "bookId");
+        hiddenField.setAttribute("value", info['book_id']);
+        form.appendChild(hiddenField);   
+
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "bookName");
+        hiddenField.setAttribute("value", info['book_name']);
+        form.appendChild(hiddenField);   
+        
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "sectionName");
+        hiddenField.setAttribute("value", info['section_name']);
+        form.appendChild(hiddenField);
+
+    };
+
+
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+    */
+}
+
+
+
+
+function exportAll(topic_id) {
+    var el = document.getElementById("editable-area");
+    var str= "" + el.innerHTML;
+    var form = document.createElement("form");
+    form.setAttribute("method", "post");
+    form.setAttribute("action", "./ExportTable");//+section_id);  // hand to controller
+    form.setAttribute("target", "_blank");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "content");
+    hiddenField.setAttribute("value", str);
+    form.appendChild(hiddenField);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "topic");
+    hiddenField.setAttribute("value", topic_id);
+    form.appendChild(hiddenField);
+
+    _postForContineTagging(form);
+/*
+    var section_id = JSON.parse('<?php echo json_encode($section_id) ?>');
+    console.log("section_id: "+section_id+", topic_id: "+topic_id);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "sectionId");
+    hiddenField.setAttribute("value", section_id);
+    form.appendChild(hiddenField);   
+
+    var info = JSON.parse( '<?php echo json_encode($info) ?>');
+
+    if (info) {
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "bookId");
+    hiddenField.setAttribute("value", info['book_id']);
+    form.appendChild(hiddenField);   
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "bookName");
+    hiddenField.setAttribute("value", info['book_name']);
+    form.appendChild(hiddenField);   
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "sectionName");
+    hiddenField.setAttribute("value", info['section_name']);
+    form.appendChild(hiddenField);
+
+    };
+    
+
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+    */
+
+}
+// ===========
+
+
+function tagwithOnlytag( range, stringSelection, tag ) {
+    saveUndoText();
+    var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>');
+    var topic_tag2 = topic_tag+"2";
+
+    range.deleteContents();
+
+
+    if ( tag==topic_tag2) {
+        var newdiv = document.createElement(topic_tag);
+        newdiv.innerHTML = stringSelection;
+        range.insertNode(newdiv);
+        var newdiv = document.createElement("br");
+        range.insertNode(newdiv);
+
+    } else {
+        var newdiv = document.createElement(tag);
+        newdiv.innerHTML = stringSelection;
+        range.insertNode(newdiv);
+    }
+
+    /*
+    if ( tag=="person2") {
+        var newdiv = document.createElement("person");
+        newdiv.innerHTML = stringSelection;
+        range.insertNode(newdiv);
+        var newdiv = document.createElement("br");
+        range.insertNode(newdiv);
+    } else if (tag=="object2") {
+        var newdiv = document.createElement("object");
+        newdiv.innerHTML = stringSelection;
+        range.insertNode(newdiv);
+        var newdiv = document.createElement("br");
+        range.insertNode(newdiv);
+
+    } else {
+        var newdiv = document.createElement(tag);
+        newdiv.innerHTML = stringSelection;
+        range.insertNode(newdiv);
+    }
+    */
+
+    $('.tagItemDivClass').remove();
+}
+
+
+
+
+function replaceSmartRegex() {
+    saveUndoText();
+    var startPage = $('#regexPageStart2').val();
+    var endPage = $('#regexPageEnd2').val();
+    
+    var el = document.getElementById("editable-area");
+    var regexText=document.getElementById("regexText").value;
+    
+    <?php 
+    foreach ( $wordlistArray as $wordlistValue ) {
+        echo "\tvar regexText1=\"List ".$wordlistValue[1]."\";\n";
+        echo "\tregexText1 = preg_quote(regexText1);\n";
+        echo "\tvar replaceText1=\"".$wordlistValue[2]."\";\n";
+        echo "\tregexText = regexText.replace(new RegExp(regexText1, \"g\"), replaceText1);\n\n";
+    }
+    ?>
+    
+    var replaceText=document.getElementById("replaceText").value;
+    var str="" + el.innerHTML;
+    
+    if ( startPage == "" ) {
+        alert( "Tagged "+str.match(new RegExp(regexText, "g")).length+" entities!" );
+        el.innerHTML = str.replace(new RegExp(regexText, "g"), replaceText);
+    } else {
+        var regexText2="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】";
+        var partString = ""+str.match(new RegExp(regexText2, "g"));
+        alert(partString);
+        
+        alert( "Tagged "+partString.match(new RegExp(regexText, "g")).length+" entities!" );
+        var resultString = partString.replace(new RegExp(regexText, "g"), replaceText);
+        
+        str="" + el.innerHTML;
+        el.innerHTML = str.replace(new RegExp(regexText2, "g"), resultString);
+    }
+    //document.styleSheets[0].addRule("tag001", "color:green;")
+}
+
+
+
+function saveTextToLGService() {
+    var info = JSON.parse('<?php echo json_encode($info) ?>');
+    var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
+
+    // if this is a new branch, ask for label
+    if (info['branch_id'] == 0) {
+        var cnt = 0;
+        var label = prompt("Please enter your label for this new branch", "section"+info['section_id']);
+        while (label == null && cnt <= 3) {
+            cnt ++;
+            label = prompt("Please enter your label for this new branch (not empty)", "section"+info['section_id']);
+        }    
+    };
+    
+    
+
+    var form = document.createElement("form");
+    form.setAttribute("method", "post");
+    form.setAttribute("action", "./TaggingText");  // hand to controller
+    form.setAttribute("target", "_self");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "func");
+    hiddenField.setAttribute("value", "SaveFullTextToLGService");
+    form.appendChild(hiddenField); 
+    
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "label");
+    hiddenField.setAttribute("value", label);
+    form.appendChild(hiddenField);
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "topic_id");
+    hiddenField.setAttribute("value", topic_id);
+    form.appendChild(hiddenField); 
+
+    _postForContineTagging(form);
+
+    console.log("complete saving to LGService");
+
+    
+    /*
+
+    if (info) {
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "fileId");
+        hiddenField.setAttribute("value", info['file_id']);
+        form.appendChild(hiddenField);
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "branchId");
+        hiddenField.setAttribute("value", info['branch_id']);
+        form.appendChild(hiddenField);
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "userId");
+        hiddenField.setAttribute("value", info['user_id']);
+        form.appendChild(hiddenField);
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "sectionId");
+        hiddenField.setAttribute("value", info['section_id']);
+        form.appendChild(hiddenField);
+
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "bookId");
+        hiddenField.setAttribute("value", info['book_id']);
+        form.appendChild(hiddenField);
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "sectionName");
+        hiddenField.setAttribute("value", info['section_name']);
+        form.appendChild(hiddenField);
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "bookName");
+        hiddenField.setAttribute("value", info['book_name']);
+        form.appendChild(hiddenField);
+
+    }
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "text");
+    var el = document.getElementById("editable-area");
+    //var text = encodeURIComponent(el.innerHTML);
+    var text = el.innerHTML;
+    hiddenField.setAttribute("value", text);
+    form.appendChild(hiddenField);
+
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+    */
+}
+
+
+
+function chooseTopic(default_topic_id) {
+    var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' );
+    var info = JSON.parse('<?php echo json_encode($info) ?>');
+
+    $('#load_topic_div').html("");
+    $('#load_topic_div').css("display", "block");
+    
+    $('#load_topic_div').css("border", "1px solid black");
+    $('#load_topic_div').css("background-color", "White");
+    $('#load_topic_div').css("width", "150px");
+    $('#load_topic_div').css("height", "50px");
+    $('#load_topic_div').css("top", "20px");
+    $('#load_topic_div').css("left", "-150px");
+    
+
+    var topic_select = document.createElement("select");
+    topic_select.id = "loadTopiclist";
+    var selected_topic = t[0];
+    topic_select.onchange = function(){
+
+    	selected_topic = topic_select.options[topic_select.selectedIndex];
+    	console.log(selected_topic.text);
+
+    	var topic_id = selected_topic.value;
+
+		var form = document.createElement("form");
+        form.setAttribute("method", "post");
+        form.setAttribute("action", "./TaggingText");  // hand to controller
+        form.setAttribute("target", "_self");
+
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "topic");
+        hiddenField.setAttribute("value", topic_id);
+        form.appendChild(hiddenField);
+
+        var hiddenField = document.createElement("input");      
+        hiddenField.setAttribute("name", "func");
+        hiddenField.setAttribute("value", "ContinueTagging");
+        form.appendChild(hiddenField);
+    
+	    _postForContineTagging(form);
+           
+    };
+
+
+    //Create and append the options
+	for (var i = 0; i < t.length; i++) {
+		console.log(t[i]['id']+","+t[i]['name']);
+    	var option = document.createElement("option");
+    	option.value = t[i]['id'];
+	    option.text = t[i]['name'];
+	    if (option.value == default_topic_id) {
+	    	option.selected = true;
+	    };
+	    topic_select.appendChild(option);
+	}
+
+    $('#load_topic_div').append(topic_select);
+
+    var newbutton = document.createElement("button");
+    $(newbutton).html("Close");
+    $(newbutton).addClass("btn btn-xs btn-default");
+    $(newbutton).attr("onclick", "$('#load_topic_div').css(\"display\", \"none\");");
+    $('#load_topic_div').append(newbutton);
+  
+}
+
+// --- for config tags in topic ---
+function _postForContineTagging(form) {
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "text");
+    var el = document.getElementById("editable-area");
+    var text = el.innerHTML;
+    hiddenField.setAttribute("value", text);
+    form.appendChild(hiddenField);
+
+    var info = JSON.parse( '<?php echo json_encode($info) ?>');
+
+    if (info) {
+        // TODO: different field info array based on fileId(branchId) existing or not
+        if (info['file_id']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "fileId");
+            hiddenField.setAttribute("value", info['file_id']);
+            form.appendChild(hiddenField);
+        };
+        if (info['branch_id']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "branchId");
+            hiddenField.setAttribute("value", info['branch_id']);
+            form.appendChild(hiddenField);
+        };
+        if (info['user_id']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "userId");
+            hiddenField.setAttribute("value", info['user_id']);
+            form.appendChild(hiddenField);
+        };
+        if (info['section_id']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "sectionId");
+            hiddenField.setAttribute("value", info['section_id']);
+            form.appendChild(hiddenField);
+        };
+        if (info['book_id']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "bookId");
+            hiddenField.setAttribute("value", info['book_id']);
+            form.appendChild(hiddenField);
+        };
+        if (info['section_name']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "sectionName");
+            hiddenField.setAttribute("value", info['section_name']);
+            form.appendChild(hiddenField);
+        };
+        if (info['book_name']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "bookName");
+            hiddenField.setAttribute("value", info['book_name']);
+            form.appendChild(hiddenField);
+        };
+        if (info['current_fileId']) {
+            var hiddenField = document.createElement("input");      
+            hiddenField.setAttribute("name", "currentFileId");
+            hiddenField.setAttribute("value", info['current_fileId']);
+            form.appendChild(hiddenField);
+        };
+
+    }
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+
+}
+
+function configTagsInTopic(topic_id) {
+    var form = document.createElement("form");
+    
+    form.setAttribute("method", "post");
+    form.setAttribute("action", "./ConfigTagsInTopic");  // hand to controller
+    form.setAttribute("target", "_blank");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "topic");
+    hiddenField.setAttribute("value", topic_id);
+    form.appendChild(hiddenField);
+
+    _postForContineTagging(form);
+    
+    /*
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+    */
+        
+}
+
+
+
+$(document).on("change", '#smartRegexPopUpSelectWord', function (e) {
+
+<?php
+    foreach ( $wordlistArray as $wordlistValue ) {
+        echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {";
+        echo "$('#smartRegexPopUpText').val(\"".$wordlistValue[2]."\");";
+        echo "}";
+    }
+?>
+});
+
+
+
+</script>
+ 
+<div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; ">
+</div>
+
+
+<p class="bg-info" style="margin:10 30 10 30; max-width:1250"> <?php echo $messages; ?> </p>
+
+<table width="1270" border="1" style="margin:10 30 10 30;">
+    <tr>
+        <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;">
+            <div id="editable-area" class="area" style="max-width: 980"><?php echo $stringInput; ?></div>
+        </td>
+        <td width="290" valign="top">
+            <div id="popups" style="position:absolute; width:300px; ">
+                <div id="load_topic_div" style="position: absolute; display: none; z-index:2"></div>
+                <div id="load_regex_div" style="position: absolute; display: none; z-index:2;"></div>
+                <div id="smartRegexPopUpDiv" style="position: absolute; display: none; z-index:2">
+                    Name: <input id="smartRegexPopUpName"></input><br><br>
+                    Word List: 
+                    <select id="smartRegexPopUpSelectWord">
+                    <option value="NULL" selected>無</option>
+                    <?php
+                        foreach ( $wordlistArray as $wordlistValue ) {
+                            echo "<option value=\"".$wordlistValue[0]."\">".$wordlistValue[1]."</option>\n";
+                        }
+                    ?>
+                    </select>
+                    <br>
+                    OR (USE "|" TO SEPARATE WORDS):<br>
+                    <TEXTAREA id="smartRegexPopUpText" COLS=30 ROWS=4></TEXTAREA><br><br>
+                    Tag:
+                    <select id="smartRegexPopUpSelectTag">
+                    <?php
+                        foreach ( $taglistArray as $taglistValue ) {
+                            echo "<option value=\"".$taglistValue[2]."\">".$taglistValue[1]."</option>\n";
+                        }
+                        echo "<option value=\"title\">Title</option>\n";
+                    ?>
+                    <option value="NOTAG">不標記</option>
+                    </select><br>
+                    <button id="smartRegexPopUpAdd" onclick="replaceSmartAdd()" class="btn btn-info" style="">Add</button>
+                    <button id="smartRegexPopUpEdit" onclick="replaceSmartEdit()" class="btn btn-success" style="">Edit</button>
+                    <button id="smartRegexPopUpDel" onclick="replaceSmartDel()" class="btn btn-danger" style="">Delete</button>
+                    <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" class="btn btn-default" style=""><<</button>
+                    <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button>
+                    <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button>
+                </div>
+            </div>
+
+            <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 15 5; max-width:270px">
+                <form action="javascript:void(0);">   
+                    <fieldset>
+                        <legend><h5 class="text-success"> Config Topic: </h5></legend>
+                        <div> current topic is <?php echo $topic_name; ?> 
+                            <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button>
+                        </div>
+                        <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br>
+                    </fieldset>
+
+                    <fieldset>
+                        <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
+                        <div id="smartRegexShowDiv"></div><br>
+                        <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br>
+                        Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br>
+                        <button onclick="replaceSmartRun()" style="height: 30px; width: 100px">Run</button>
+                        <button onclick="replaceSmartRunWithBr()" style="height: 30px; width: 100px">Run(with Br)</button></br>
+                        <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br>
+                        <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button>
+                        <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button>
+                        <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br>
+                        <!--
+                        <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button>
+                        -->
+                    </fieldset>
+                    
+                    <fieldset>
+                        <legend><h5 class="text-success"> Tag by rule:</h5></legend>
+                        <button onclick="tagNameWithLastName()" style="height: 30px; width: 220px">Tag Word Begin With Surname</button></br>
+                        <button onclick="tagNameWithLastName2()" style="height: 30px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
+                        <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
+                        <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
+                        <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button>
+                    </fieldset>
+                
+                    <fieldset>
+                        <legend><h5 class="text-success"> Edit:</h5></legend>
+                        <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
+                    
+                        <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
+                        <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage -->
+                        <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
+                        <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br>
+                        </br>
+                        <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br>
+                        <!--
+                        <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>
+                        -->
+                        <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 220px">Manage Tag List</button></br>
+                    </fieldset>
+                    
+                    <fieldset>
+                        <legend><h5 class="text-success"> Export:</h5></legend>
+                        Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br>
+                        <button onclick="exportPage(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export</button></br>
+                        <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br>
+                    </fieldset>
+                
+                    <fieldset>
+                        <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend>
+                        Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br>
+                        Regex: <input type="text" size="23" id="regexText"></br>
+                        Replace: <input type="text" size="23" id="replaceText"><br>
+                        <button onclick="replaceSmartRegex()">Replace!</button>
+                    </fieldset>
+                </form>
+            </div>
+        </td>
+    </tr>
+
+</table>
+
+
+
+
+</body>
+
+</html>
--- a/develop/views/Extractapp/configtagsintopic.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-<?php
-// --- initialize ---
-//$taglistArray = $viewmodel['taglistArray'];
-$topic = $viewmodel['topic'];
-$topic_name = $viewmodel['topic_name'];
-$tag_intopic = $viewmodel['tag_intopic'];
-$tag_others = $viewmodel['tag_others'];
-
-?>
-
-<html>
-<head>
-<title></title>
-</head>
-
-<body>
-<script type="text/javascript">
-function SelectMoveRows(s1, s2)
-{
-    var selId = '';
-    var selText = '';
-    // Move rows from s1 to s2 from bottom to top
-    for (i = s1.options.length - 1; i >= 0; i--)
-    {
-        if (s1.options[i].selected == true)
-        {
-            selId = s1.options[i].value;
-            selText = s1.options[i].text;
-            var newRow = new Option(selText,selId);
-            s2.options[s2.length] = newRow;
-            s1.options[i] = null;
-        }
-    }
-    SelectSort(s2);
-}
-function SelectSort(selList)
-{
-    var id = '';
-    var t = '';
-    for (x = 0; x < selList.length - 1; x++)
-    {
-        for (y = x+1; y < selList.length; y++)
-        {
-            if (selList[x].text > selList[y].text)
-            {
-                // Swap rows
-                id = selList[x].value;
-                t = selList[x].text;
-                selList[x].value = selList[y].value;
-                selList[x].text = selList[y].text;
-                selList[y].value = id;
-                selList[y].text = t;
-            }
-        }
-    }
-}
-
-function checkTopic(t) {
-	var ids = [];
-
-	for (var i = 0; i < t.options.length; i++) {
-		ids.push(t.options[i].value);
-		console.log(t.options[i].text);
-	}
-
-	console.log(ids);
-	var ids_json = JSON.stringify(ids);
-	var topic_id = JSON.parse('<?php echo json_encode($topic) ?>');
-
-	$.ajax({
-		url : './ConfigTagsInTopic',
-		async : false,
-		type : 'POST',
-		data : 'func=Update'+'&ids='+ids_json+'&topic_id='+topic_id,
-		error: function (e) {
-			console.log("error when update tags in topic"+ e );
-		},
-		success: function (e) {
-			alert("Updated!");
-		}
-	}).done(function(result) {
-	});
-
-}
-
-</script>
-
-<div class="container-fluid" style="margin-left:30%;">
-   
-		<form name="config" autocomplete='off' action="Javascript:checkTopic(document.config.InTopic)">
-			<h3>Topic: <?php echo $topic_name;?> </h3>
-			
-			<table class="table">
-				<thead>
-					<tr>
-						<td class="text-warning"> Selected tags </td>
-						<td></td>
-						<td class="text-warning"> Other tags </td>
-					</tr>
-				</thead>
-				<tbody>
-				<tr>
-					<td>
-						<select name="InTopic" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple>
-							<?php 
-								foreach ($tag_intopic as $taglistValue) {
-									echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
-								}
-							?>
-						</select>
-					</td>
-					<td align="center" valign="middle">
-			            <input type="button" value="<< Add" class="btn btn-primary" onClick="SelectMoveRows(document.config.Others, document.config.InTopic)"><br>
-			         	<br>
-			            <input type="button" value="Remove >>" class="btn btn-warning" onClick="SelectMoveRows(document.config.InTopic, document.config.Others)"><br>
-			        </td>
-					<td >
-						<select name="Others" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple>
-							<?php 
-								foreach ($tag_others as $taglistValue) {
-									echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
-								}
-							?>
-						</select>
-					</td>
-				</tr>
-				<tr>
-					<td></td>
-					<td><input type="submit" value="Submit" class="btn btn-lg btn-success"></td>
-					<td></td>
-				</tr>
-				</tbody>
-			</table>
-			
-		</form>
-</div>
-
-</body>
-</html>
--- a/develop/views/Extractapp/edittaglist.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,357 +0,0 @@
-<?php
-// --- initialize ---
-$taglistArray = $viewmodel['taglistArray'];
-$topic_id = $viewmodel['topic_id'];
-$largestId = $viewmodel['largest_id'];
-
-?>
-
-<html>
-<head>
-<title></title>
-<link rel="stylesheet" href="../css/colorpicker.css" type="text/css" />
-<script type="text/javascript" src="../js/colorpicker.js"></script>
-<script type="text/javascript" src="../js/eye.js"></script>
-<script type="text/javascript" src="../js/utils.js"></script>
-<script type="text/javascript" src="../js/layout.js?ver=1.0.2"></script>
-</head>
-
-<body>
-
-
-<table width="100%" border="1" id="tableMain"> </table>
-
-
-<script type="text/javascript">
-
-// var largestId = 0;
-var largestId = JSON.parse('<?php echo json_encode($largestId) ?>');
-
-function addTag( ) {
-	largestId++;
-	var row = tableMain.insertBefore(document.createElement("tr"), document.getElementById("trAddTag") );
-	row.setAttribute("height","50");
-	row.id = "tr"+largestId;
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.id = "tdId"+largestId;
-	newcolumn.setAttribute("width","150");
-	row.appendChild(newcolumn).innerHTML=largestId;
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","150");
-	newcolumn.id = "tdName"+largestId;
-	newcolumn.setAttribute("idnum",largestId);
-	newcolumn.setAttribute("name","tdName");
-	row.appendChild(newcolumn).innerHTML="";
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","150");
-	newcolumn.id = "tdTag"+largestId;
-	newcolumn.setAttribute("idnum",largestId);
-	newcolumn.setAttribute("name","tdTag");
-	row.appendChild(newcolumn).innerHTML="";
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","150");
-	row.appendChild(newcolumn).innerHTML="<div id=\"colorSelector"+largestId+"\"><div id=\"colorSelectorB"+largestId+"\"  style=\"background-color: #000000\"></div></div>";
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","50");
-	row.appendChild(newcolumn).innerHTML="<button onclick=\"newTag("+largestId+")\">Save</button>";
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","50");
-	row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+largestId+")\">Delete</button>";
-	
-	$('#colorSelector'+largestId).ColorPicker({
-		color: '#000000',
-		onShow: function (colpkr) {
-			$(colpkr).fadeIn(500);
-			return false;
-		},
-		onHide: function (colpkr) {
-			$(colpkr).fadeOut(500);
-			return false;
-		},
-		onChange: function (hsb, hex, rgb) {
-			$('#colorSelector'+largestId+' div').css('backgroundColor', '#' + hex);
-		}
-	});
-	/*
-	// addRule doesn't work in FF
-	document.styleSheets[0].addRule("#colorSelector"+largestId, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);")
-	document.styleSheets[0].addRule("#colorSelector"+largestId+" div", "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;")
-	*/
-
-	// insertRule works in IE9, FF, Saf, Chrome, Opera
-	var x = document.styleSheets[0];
-	var selector1 = "#colorSelector"+largestId;
-	var selector2 = "#colorSelector"+largestId+" div";
-
-	if (x.insertRule) {
-		x.insertRule(selector1+' {position:relative; width:36px; height:36px; background:url(../images/select.png);}', x.cssRules.length);
-		x.insertRule(selector2+' {position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background:url(../images/select.png) center;}', x.cssRules.length);
-	
-	} else if (x.addRule) {
-		x.addRule(selector1, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);");
-		x.addRule(selector2, "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;");
-	}
-	
-
-}	
-
-
-function addNode( id, name, tag, color ) {
-	// if ( parseInt(id) > largestId ) largestId=parseInt(id);
-	
-	var tableMain=document.getElementById("tableMain");
-	
-	if ( id == "AddTag" ) {
-		var row = tableMain.appendChild(document.createElement("tr"));
-		row.id = "trAddTag";
-		
-		var newcolumn = document.createElement("td");
-		newcolumn.setAttribute("width","150");
-		newcolumn.setAttribute("colspan","6");
-		newcolumn.setAttribute("align","center");
-		row.appendChild(newcolumn).innerHTML="<button onclick=\"addTag()\" style=\"height: 50px; width: 300px\">Add New Tag</button>";
-		
-		return 0;
-	}
-	var row = tableMain.appendChild(document.createElement("tr"));
-	row.setAttribute("height","50");
-	row.id = "tr"+id;
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.id = "tdId"+id;
-	newcolumn.setAttribute("width","150");
-	row.appendChild(newcolumn).innerHTML=id;
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","150");
-	newcolumn.id = "tdName"+id;
-	newcolumn.setAttribute("idnum",id);
-	newcolumn.setAttribute("name","tdName");
-	row.appendChild(newcolumn).innerHTML=name;
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","150");
-	newcolumn.id = "tdTag"+id;
-	newcolumn.setAttribute("idnum",id);
-	newcolumn.setAttribute("name","tdTag");
-	row.appendChild(newcolumn).innerHTML=tag;
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","150");
-	if ( color=="Color") {
-		row.appendChild(newcolumn).innerHTML="Color";
-	} else {
-		row.appendChild(newcolumn).innerHTML="<div id=\"colorSelector"+id+"\"><div id=\"colorSelectorB"+id+"\" style=\"background-color: "+color+"\"></div></div>";
-	}
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","50");
-	if ( color=="Color") {
-		row.appendChild(newcolumn).innerHTML="Save";
-	} else {
-		row.appendChild(newcolumn).innerHTML="<button onclick=\"saveTag("+id+", 'update')\">Save</button>";
-	}
-	
-	var newcolumn = document.createElement("td");
-	newcolumn.setAttribute("width","50");
-	if ( color=="Color") {
-		row.appendChild(newcolumn).innerHTML="Delete";
-	} else {
-		row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+id+")\">Delete</button>";
-	}
-	
-	$('#colorSelector'+id).ColorPicker({
-		color: color,
-		onShow: function (colpkr) {
-			$(colpkr).fadeIn(500);
-			return false;
-		},
-		onHide: function (colpkr) {
-			$(colpkr).fadeOut(500);
-			return false;
-		},
-		onChange: function (hsb, hex, rgb) {
-			$('#colorSelector'+id+' div').css('backgroundColor', '#' + hex);
-		}
-	});
-
-
-	/* 
-	// addRule doesn't work in FF
-	document.styleSheets[0].addRule("#colorSelector"+id, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);")
-	document.styleSheets[0].addRule("#colorSelector"+id+" div", "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;")
-
-	*/
-	// insertRule works in IE9, FF, Saf, Chrome, Opera
-	var x = document.styleSheets[0];
-	var selector1 = "#colorSelector"+id;
-	var selector2 = "#colorSelector"+id+" div";
-
-	if (x.insertRule) {
-		x.insertRule(selector1+' {position:relative; width:36px; height:36px; background:url(../images/select.png);}', x.cssRules.length);
-		x.insertRule(selector2+' {position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background:url(../images/select.png) center;}', x.cssRules.length);
-	
-	} else if (x.addRule) {
-		x.addRule(selector1, "position: relative;	width: 36px;	height: 36px;	background: url(../images/select.png);");
-		x.addRule(selector2, "position: absolute;	top: 3px;	left: 3px;	width: 30px;	height: 30px;	background: url(../images/select.png) center;");
-	}
-	
-
-}
-
-function newTag( id ) {
-	
-	var elid = document.getElementById("tdId"+id).textContent;
-	var elname = document.getElementById("tdName"+id).textContent;
-	var eltag = document.getElementById("tdTag"+id).textContent;
-	/*
-	var elid = document.getElementById("tdId"+id).innerHTML;
-	var elname = document.getElementById("tdName"+id).innerHTML;
-	var eltag = document.getElementById("tdTag"+id).innerHTML;
-	*/
-	var elcolor = $("#colorSelectorB"+id).css("background-color");
-
-	console.log("elid="+elid+', elname='+elname+', eltag='+eltag);
-
-	var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>');
-	
-	$.ajax({
-		url : './EditTaglist',
-		async : false,
-		type : 'POST',
-		data : 'func=NewTagElement'+'&id='+elid+'&name='+elname+'&tag='+eltag+'&color='+elcolor+'&topic_id='+topic_id,
-		error: function (e) {
-			console.log("error when newTag");
-		},
-		success: function (e) {
-			alert("Saved!");
-			document.location.reload(true);
-		}
-	}).done(function(result) {
-	});
-}
-
-function saveTag( id) {
-
-	var elid = document.getElementById("tdId"+id).textContent;
-	var elname = document.getElementById("tdName"+id).textContent;
-	var eltag = document.getElementById("tdTag"+id).textContent;
-	/*
-	var elid = document.getElementById("tdId"+id).innerHTML;
-	var elname = document.getElementById("tdName"+id).innerHTML;
-	var eltag = document.getElementById("tdTag"+id).innerHTML;
-	*/
-
-	var elcolor = $("#colorSelectorB"+id).css("background-color");
-	
-	console.log(elid+','+elname+','+eltag+','+elcolor);
-	
-	var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>');
-
-	$.ajax({
-		url : './EditTaglist',
-		async : false,
-		type : 'POST',
-		data : 'func=SaveTagElement'+'&id='+elid+'&name='+elname+'&tag='+eltag+'&color='+elcolor+'&topic_id='+topic_id,
-		error: function (e) {
-			console.log("error when saving Tag");
-		},
-		success: function (e) {
-			alert("Saved!");
-			document.location.reload(true);
-		}
-	}).done(function(result) {
-	});
-}
-
-function DeleteTag( id ) {	
-	$("#tr"+id).remove();
-	$.ajax({
-		url : './EditTaglist',
-		async : false,
-		type : 'POST',
-		data : 'func=DeleteTag'+'&id='+id+'&type=delete'
-	}).done(function(result) {
-		alert("Saved!");
-	});
-}
-
-
-$(document).on("click", "[name=tdName]", function () {
-	if ( $("#input"+this.id).length > 0 ) {
-		return;
-	}
-	//var startPageValue = this.innerHTML;
-	var startPageValue = this.textContent;
-	this.innerHTML="";
-	var newTextBox = document.createElement("input");
-	newTextBox.id = "input"+this.id;
-	newTextBox.setAttribute("name","inputName");
-	newTextBox.setAttribute("onfocus","this.select()");
-	newTextBox.setAttribute("size","20");
-	this.appendChild(newTextBox).value=startPageValue;
-	
-	$("#input"+this.id).focus();
-} );
-
-$(document).on("click", "[name=tdTag]", function () {
-	if ( $("#input"+this.id).length > 0 ) {
-		return;
-	}
-	//var startPageValue = this.innerHTML;
-	var startPageValue = this.textContent;
-	this.innerHTML="";
-	var newTextBox = document.createElement("input");
-	newTextBox.id = "input"+this.id;
-	newTextBox.setAttribute("name","inputTag");
-	newTextBox.setAttribute("onfocus","this.select()");
-	newTextBox.setAttribute("size","20");
-	this.appendChild(newTextBox).value=startPageValue;
-	
-	$("#input"+this.id).focus();
-} );
-
-$(document).on("keypress", "[name=tdName]", function () {
-	if (event.keyCode == 13) {
-		$(this).focusout();
-	}
-});
-
-$(document).on("keypress", "[name=tdTag]", function () {
-	if (event.keyCode == 13) {
-		$(this).focusout();
-	}
-});
-
-$(document).on("focusout", "[name=tdName]", function () {
-	var value=$("#input"+this.id).val();
-	$(this).html($(this).html() + value);
-	$("#input"+this.id).remove();
-});
-
-$(document).on("focusout", "[name=tdTag]", function () {
-	var value=$("#input"+this.id).val();
-	$(this).html($(this).html() + value);
-	$("#input"+this.id).remove();
-});
-
-addNode( "AddTag","","","" );
-addNode( "ID","Name","Tag","Color" );
-
-<?php 
-foreach ( $taglistArray as $tagId => $tagArray ) {
-
-	echo "addNode( \"".$tagId."\",\"".$tagArray[0]."\",\"".$tagArray[1]."\",\"".$tagArray[2]."\" );\n";
-}
-?>
-
-
-</script>
-</body>
-</html>
--- a/develop/views/Extractapp/editwordlist.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-<?php
-// --- initialize ---
-$wordlistArray = $viewmodel['wordlistArray'];
-?>
-
-<html>
-<head>
-<title></title>
-<style>
-dynasty
-{
-	color:red;
-}
-nianhao
-{
-	color:blue;
-}
-name
-{
-	color:orange;
-}
-#editable-area {
-	line-height:160%;
-	letter-spacing:1.5px;
-	font-size:21px;
-}
-</style>
-</head>
-<body>
-
-<table width="98%" border="1">
-	<tr>
-		<td width="20%" valign="top">
-			<?php 
-			foreach ( $wordlistArray as $nameId => $nameValue ) {
-				echo "&nbsp;&nbsp;<a onclick=\"showListContent(".$nameId.")\" href=\"#\">".$nameValue."</a></br>";
-			}
-			?>
-			<form action="javascript:void(0);">				
-				<fieldset>
-					<legend>Add List:</legend>
-					List name: <input type="text" size="30" id="listNameText"><br>
-					<button onclick="addNewList()">Add</button>
-				</fieldset>
-			</form>
-		</td>
-		<td width="60%">
-			<div id="editable-area"></div>
-		</td>
-		<td width="20%" valign="top" id="button-area">&nbsp;</td>
-	</tr>
-</table>
-
-</body>
-</html>
--- a/develop/views/Extractapp/exporttable.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-<?php
-// --- initialize ---
-$outputTableArray = $viewmodel['outputTableArray'];
-$bookId = $viewmodel['bookId'];
-$sectionid = $viewmodel['section_id'];
-$bookName = $viewmodel['bookName'];
-$sectionName = $viewmodel['sectionName'];
-
-
-
-?>
-
-<html>
-<head>
-<title></title>
-
-</head>
-
-<body>
-<table width="100%" border="1" id="tableMain">
-	
-<?php
-$count=1;
-	foreach ( $outputTableArray as $trIndex =>$trValue ) {
-		echo "<tr>";
-		if ( $trIndex==0 ) {
-			echo "<td>#</td>";
-			echo "<td>Book ID</td>";
-			echo "<td>Section ID</td>";
-			echo "<td>方志</td>";
-			echo "<td>部</td>";
-		} else {
-			echo "<td>".$count++."</td>";
-			echo "<td>".$bookId."</td>";
-			echo "<td>".$sectionid."</td>";
-			echo "<td>".$bookName."</td>";
-			echo "<td>".$sectionName."</td>";
-		}
-		if ( isset( $trValue["page"] ) ) {
-			echo "<td>".$trValue["page"]."</td>";
-		} else {
-			echo "<td>&nbsp;</td>";
-		}
-		/*
-		foreach ( $outputTableArray[0][1] as $index => $value ) {
-			if ( isset( $trValue[1][$index] ) ) {
-				echo "<td>".$trValue[1][$index]."</td>";
-			} else {
-				echo "<td>&nbsp;</td>";
-			}
-		}
-		*/
-		foreach ( $outputTableArray[0][0] as $index => $value ) {
-			if ( $index == "time" ) {
-				if ( isset( $trValue[0][$index] ) ) {
-					echo "<td>".$trValue[0][$index]."</td>";
-					echo "<td>".$trValue[0][$index]."</td>";
-				} else {
-					echo "<td>&nbsp;</td>";
-					echo "<td>&nbsp;</td>";
-				}
-			} else {
-				if ( isset( $trValue[0][$index] ) ) {
-					echo "<td>".$trValue[0][$index]."</td>";
-				} else {
-					echo "<td>&nbsp;</td>";
-				}
-			}
-		}
-		if ( isset( $trValue["other"] ) ) {
-			echo "<td>".$trValue["other"]."</td>";
-		} else {
-			echo "<td>&nbsp;</td>";
-		}
-		if ( isset( $trValue["full"] ) ) {
-			echo "<td>".$trValue["full"]."</td>";
-		} else {
-			echo "<td>&nbsp;</td>";
-		}
-		echo "</tr>";
-	}
-?>
-</table>
-</body>
-</html>
--- a/develop/views/Extractapp/index.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-<html>
-<head>
-<title></title>
-
-<!-- 
-<script src="../../js/jquery-1.10.2.min.js"></script> 
-<script src="../../js/taggingtext.js"></script>
--->
-
-<!-- Bootstrap -->
-<!-- <link href="../../css/bootstrap.min.css" rel="stylesheet">
--->
-<!-- 
-<script src="../../js/bootstrap.min.js"></script>
--->
-
-
-</head>
-<body>
-
-
-<script src="<?php echo $system_root_url; ?>/js/jquery-1.10.2.min.js"></script>
-<script src="<?php echo $system_root_url; ?>/js/bootstrap.min.js"></script>
-<script src="<?php echo $system_root_url; ?>/js/taggingtext.js"></script>
-
-</body>
-
-</html>
\ No newline at end of file
--- a/develop/views/Extractapp/taggingtext.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1016 +0,0 @@
-<?php
-// --- initialize config file and input text ---
-$stringInput = $viewmodel['stringInput'];
-$wordlistArray = $viewmodel['wordlistArray'];
-$taglistArray = $viewmodel['taglistArray'];
-$section_id = $viewmodel['section_id'];
-$topiclistArray = $viewmodel['topiclistArray'];
-$default_topic_id = $viewmodel['default_topic_id'];
-$topic_name = $viewmodel['topic_name'];
-$topic_tag = $viewmodel['topic_tag'];
-$info = $viewmodel['info']; 
-$messages = $viewmodel['messages'];
-
-
-?>
-
-<html>
-<head>
-<title></title>
-
-<style>
-dynasty
-{
-	color:red;
-}
-nianhao
-{
-	color:blue;
-}
-name
-{
-	color:orange;
-}
-#editable-area {
-	line-height:160%;
-	letter-spacing:1.5px;
-	font-size:21px;
-}
-
-
-<?php
-// color on the tags
-foreach ( $taglistArray as $taglistValue ) {
-	echo $taglistValue[2]."\n{\ncolor:".$taglistValue[3]."\n}\n";
-	
-	echo ".span_".$taglistValue[2]."\n{\nbackground-color:".$taglistValue[3]."\n}\n";
-}
-
-?>
-</style>
-
-
-</head>
-
-<body>
-
-<script type="text/javascript">
-
-// === This is only for developing on local machine ====
-var _GET = JSON.parse('<?php echo json_encode($_GET) ?>');
-if (_GET['id']) {
-    
-    var info = JSON.parse('<?php echo json_encode($info) ?>');
-    var redirectUrl = "http://localhost:1080/localmonographs/develop/Extractapp/TaggingText";
-    var section_id = info['section_id'];
-
-    var form = $('<form action="' + redirectUrl + '" method="post">' +
-        '<input type="hidden" name="sectionId" value="'+section_id+'" />' +
-        '</form>');
-        $('body').append(form);
-        $(form).submit();
-}
-// ====
-
-
-
-// TODO: Popup to proceeding the saving situations
-function handleFileVersionConflict() {
-    var info = JSON.parse('<?php echo json_encode($info) ?>');
-    console.log("currentFileId="+info['current_fileId']);
-    
-    if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){
-        // -- there might be conflicts between different version
-        var retVal = confirm('There were something happened/someone editing in the between of time.\nDo you want to force saving? (There might be conflicts between two versions.)');
-        if( retVal == true ){
-            // TODO: force saving with currentFileId
-            alert("You do the force saving!");
-            //saveTextToLGService();
-
-        }else{
-            var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)");
-            
-            console.log("loadLastest="+loadLastest);
-            /*
-            var form = document.createElement("form");
-            form.setAttribute("method", "post");
-            form.setAttribute("action", "./TaggingText");  // hand to controller
-            form.setAttribute("target", "_blank");  
-
-            var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
-
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "topic");
-            hiddenField.setAttribute("value", topic_id);
-            form.appendChild(hiddenField);
-
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "func");
-            hiddenField.setAttribute("value", "Reload");  // reload
-            form.appendChild(hiddenField);
-
-            _postForContineTagging(form);
-
-            alert("You will reload the latest version.");   
-            */
-            /*
-            if (loadLastest == true) {
-                // TODO: reload page with the currentFileId
-                console.log('loadLastest is true');
-                $.ajax({
-                    type : 'POST',
-                    url : './TaggingText',
-                    async : false,
-                    data : 'func=Reload',
-                    success: function (result) {
-                        //var lastest_editing = jQuery.parseJSON(result); 
-                        console.log("lastest_editing string:"+result);
-                        // change text to the new one
-                        //var el = document.getElementById("editable-area");
-                        //el.innerHTML = lastest_editing;
-                        //alert("Reload the page!");
-                    },
-                    error: function (result) {
-                        alert("Reload Fails!");
-                    }
-                }).done(function(result) {
-                    // reload page
-                    //document.location.reload(true);
-
-                });
-
-            } else {
-                alert("Just a reminder, there is a new version for this branch.");
-            }
-            */
-            
-        }
-    }
-    return;
-    
-}
-
-<?php 
-foreach ( $taglistArray as $taglistValue ) {
-	echo '$(document).on("click", "'.$taglistValue[2].'", function (e) {'."\n";
-	echo "\t".'if ( $(this).prop("tagName").toLowerCase() != "'.$taglistValue[2].'" ) return 0;'."\n";
-	echo "\t".'if ( $("#editTextId").html() != "Edit the text" ) return 0;'."\n";
-	echo "\tremoveTagNewDiv( e, \"".$taglistValue[2]."\", $(this) );\n";
-	echo "});\n";
-}
-?>
-
-$(document).ready(function(){
-    
-    // --- for sidebar--- 
-    //run once
-    var el=$('#follow-scroll');
-    var originalelpos=el.offset().top; // take it where it originally is on the page
-    
-
-    //run on scroll
-    $(window).scroll(function(){
-        var el = $('#follow-scroll'); // important! (local)
-        var elpos = el.offset().top; // take current situation
-        var windowpos = $(window).scrollTop();
-        var finaldestination = windowpos+originalelpos;
-        //el.stop().animate({'top':finaldestination},500);
-        el.stop().animate({'top':finaldestination},0);
-    });
-
-    //--- for popups ---
-    //run once
-    var el=$('#popups');
-    var originalelpos=el.offset().top; // take it where it originally is on the page
-    
-    //run on scroll
-    $(window).scroll(function(){
-        var el = $('#popups'); // important! (local)
-        var elpos = el.offset().top; // take current situation
-        var windowpos = $(window).scrollTop();
-        var finaldestination = windowpos+originalelpos;
-        //el.stop().animate({'top':finaldestination},500);
-        el.stop().animate({'top':finaldestination},0);
-    });
-
-
-
-    handleFileVersionConflict();
-
-    
-
-    /*
-
-    // Popup choosing topic if first time to this section. without branchId
-    if (info['file_id'] == 0) {  // or info['branchId'] == 0, means new file
-        // ask to choose topic
-        $.ajax({
-
-        });
-        var popup = document.getElementById('popup-window');
-
-        // alert('choose topic!');
-    }
-    */
-
-});
-$(document).on("click", "name", function (e) {
-
-    if ( $("#editTextId").html() != "Edit the text" ) return 0;
-    if ( $(this).prop("tagName").toLowerCase() != "name" ) return 0;
-    
-    removeTagNewDiv( e, "name", $(this) );
-});
-
-$(document).on("mouseup", '#editable-area', function (e) {
-    $('.questionMarkClass').remove();
-    $('.tagItemDivClass').remove();
-   
-    if ( $("#editTextId").html() != "Edit the text" ) return 0;
-    var selection = getSelected();
-    range = getSelected().getRangeAt(0);
-    
-    container = document.createElement("div");
-    container.appendChild(selection.getRangeAt(0).cloneContents());
-
-    if(selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) {
-    
-    	var newdiv = document.createElement("div");
-        newdiv.id = "tagItemDivId";
-        newdiv.setAttribute("class", "tagItemDivClass");
-        newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px';
-        
-        newdiv.style.backgroundColor = "white";
-        newdiv.style.zIndex = 2;
-
-        //console.log(selection.getRangeAt(0).cloneContents());
-        if ( container.innerHTML.indexOf( "br" ) != -1 ) {
-            var newselect = document.createElement("select");
-            newselect.id = "TitletagType";
-            <?php 
-                foreach ( $taglistArray as $taglistValue ) {
-                    echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n";
-                }
-            ?>
-            newdiv.appendChild(newselect);
-            
-            //matchValue =  .match();
-            myRegexp = new RegExp("〈(.*?)〉", "g")
-            matchValue = myRegexp.exec(String(selection));
-            
-            if ( matchValue != null ) {
-                newdiv.innerHTML += "<input id=\"TitletagName\" value=\""+ matchValue[1] +"\"></br>";
-            } else {
-                newdiv.innerHTML += "<input id=\"TitletagName\" value=\"\"></br>";
-            }
-
-            console.log(" container innerHTML: "+ container.innerHTML );
-
-            newdiv.innerHTML += "<button onclick=\"addTagTitle( range, container )\">Add Title Tag To Each Line</button></br>";
-            
-            /*
-            newdiv.innerHTML += "<button onclick=\"exportTable( range, container )\">Export As A Table</button></br></br>";
-            */
-
-            var newselect = document.createElement("select");
-            newselect.id = "RemoveTitletagType";
-            <?php 
-                foreach ( $taglistArray as $taglistValue ) {
-                    echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n";
-                }
-            ?>
-            newdiv.appendChild(newselect);
-            
-            newdiv.innerHTML += "<input id=\"RemoveTitletagName\" value=\"\"></br>";
-            newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>";
-        } else {
- 			// for pop up window on edit-area for tag list
-            newdiv.innerHTML = "Tag: "+String(selection)+"<br>";
-            
-            <?php 
-            foreach ( $taglistArray as $taglistValue ) {
-
-                if ($taglistValue[2] == $topic_tag) {
-                	echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">[TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)</button>\";\n";
-                    echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
-                    echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
-                    
-                    /*
-                    echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
-                    echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
-                    echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
-            		*/
-                    break;
-            	}
-            }
-            ?>
-
-            newdiv.innerHTML += "<button accesskey=\"2\" onclick=\"tagwithtitle( range, '"+String(selection)+"' )\">Tag As Title</button></br>";
-            
-            <?php 
-            	
-			    foreach ( $taglistArray as $taglistValue ) {
-                	/*
-                	if ( $taglistValue[2] == "person") {
-                        echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
-                        echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
-                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
-                	} else */
-                    if ($taglistValue[2] == $topic_tag) { 
-                		// pass
-                	} else if ($taglistValue[2] == "post_time") {
-                        echo "newdiv.innerHTML += \"<button accesskey=\\\"3\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
-                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
-                    } else if ($taglistValue[2] == "office") {
-                        echo "newdiv.innerHTML += \"<button accesskey=\\\"4\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
-                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
-                    } else {
-                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
-                        echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
-                    } 
-
-                }
-            ?>
-        }
-
-        //$('#tagItemDivId').addClass();  // tagItemDivId is newdiv's id
-        $('body').append(newdiv);
-        
-        $('#TitletagType').val(lastAddTag);
-
-    }
-    //e.stopPropagation();
-});
-
-
-// === for exporttable.php ===
-function exportTable( range, container ) {
-    //MsgBox("enter function");
-    var form = document.createElement("form");
-    form.setAttribute("method", "post");
-    form.setAttribute("action", "./ExportTable");
-    form.setAttribute("target", "_blank");
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "content");
-    hiddenField.setAttribute("value", container.innerHTML);
-    form.appendChild(hiddenField);
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "sectionid");
-    hiddenField.setAttribute("value", "<?php echo $section_id; ?>");
-    form.appendChild(hiddenField);
-    
-    var hiddenField2 = document.createElement("input");      
-    hiddenField2.setAttribute("name", "topic");
-    hiddenField2.setAttribute("value", topic_id);
-    form.appendChild(hiddenField2);
-
-    var info = JSON.parse( '<?php echo json_encode($info) ?>');
-
-    if (info) {
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "bookId");
-    hiddenField.setAttribute("value", info['book_id']);
-    form.appendChild(hiddenField);   
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "bookName");
-    hiddenField.setAttribute("value", info['book_name']);
-    form.appendChild(hiddenField);   
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "sectionName");
-    hiddenField.setAttribute("value", info['section_name']);
-    form.appendChild(hiddenField);
-
-    };
-
-    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
-        document.body.appendChild(form);
-        form.submit();
-    } else {
-        form.submit(); // works under IE and Chrome, but not FF  
-    }
-}
-
-function exportPage(topic_id) {
-    var startPage = $('#exportPageStart').val();
-    var endPage = $('#exportPageEnd').val();
-
-    var el = document.getElementById("editable-area");
-    var str="" + el.innerHTML;
-
-    var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】";
-    
-    var form = document.createElement("form");
-    form.setAttribute("method", "post");
-    form.setAttribute("action", "./ExportTable");
-    form.setAttribute("target", "_blank");
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "content");
-    hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g")));
-    form.appendChild(hiddenField);
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "topic");
-    hiddenField.setAttribute("value", topic_id);
-    form.appendChild(hiddenField);
-
-    _postForContineTagging(form);
-   
-
-    /*
-    var section_id = JSON.parse('<?php echo json_encode($section_id) ?>');
-    console.log("section_id: "+section_id+", topic_id: "+topic_id);
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "sectionId");
-    hiddenField.setAttribute("value", section_id);
-    form.appendChild(hiddenField);   
- 
-    var info = JSON.parse( '<?php echo json_encode($info) ?>');
-
-    if (info) {
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "bookId");
-        hiddenField.setAttribute("value", info['book_id']);
-        form.appendChild(hiddenField);   
-
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "bookName");
-        hiddenField.setAttribute("value", info['book_name']);
-        form.appendChild(hiddenField);   
-        
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "sectionName");
-        hiddenField.setAttribute("value", info['section_name']);
-        form.appendChild(hiddenField);
-
-    };
-
-
-    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
-        document.body.appendChild(form);
-        form.submit();
-    } else {
-        form.submit(); // works under IE and Chrome, but not FF  
-    }
-    */
-}
-
-
-
-
-function exportAll(topic_id) {
-    var el = document.getElementById("editable-area");
-    var str= "" + el.innerHTML;
-    var form = document.createElement("form");
-    form.setAttribute("method", "post");
-    form.setAttribute("action", "./ExportTable");//+section_id);  // hand to controller
-    form.setAttribute("target", "_blank");
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "content");
-    hiddenField.setAttribute("value", str);
-    form.appendChild(hiddenField);
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "topic");
-    hiddenField.setAttribute("value", topic_id);
-    form.appendChild(hiddenField);
-
-    _postForContineTagging(form);
-/*
-    var section_id = JSON.parse('<?php echo json_encode($section_id) ?>');
-    console.log("section_id: "+section_id+", topic_id: "+topic_id);
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "sectionId");
-    hiddenField.setAttribute("value", section_id);
-    form.appendChild(hiddenField);   
-
-    var info = JSON.parse( '<?php echo json_encode($info) ?>');
-
-    if (info) {
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "bookId");
-    hiddenField.setAttribute("value", info['book_id']);
-    form.appendChild(hiddenField);   
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "bookName");
-    hiddenField.setAttribute("value", info['book_name']);
-    form.appendChild(hiddenField);   
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "sectionName");
-    hiddenField.setAttribute("value", info['section_name']);
-    form.appendChild(hiddenField);
-
-    };
-    
-
-    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
-        document.body.appendChild(form);
-        form.submit();
-    } else {
-        form.submit(); // works under IE and Chrome, but not FF  
-    }
-    */
-
-}
-// ===========
-
-
-function tagwithOnlytag( range, stringSelection, tag ) {
-    saveUndoText();
-    var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>');
-    var topic_tag2 = topic_tag+"2";
-
-    range.deleteContents();
-
-
-    if ( tag==topic_tag2) {
-        var newdiv = document.createElement(topic_tag);
-        newdiv.innerHTML = stringSelection;
-        range.insertNode(newdiv);
-        var newdiv = document.createElement("br");
-        range.insertNode(newdiv);
-
-    } else {
-        var newdiv = document.createElement(tag);
-        newdiv.innerHTML = stringSelection;
-        range.insertNode(newdiv);
-    }
-
-    /*
-    if ( tag=="person2") {
-        var newdiv = document.createElement("person");
-        newdiv.innerHTML = stringSelection;
-        range.insertNode(newdiv);
-        var newdiv = document.createElement("br");
-        range.insertNode(newdiv);
-    } else if (tag=="object2") {
-        var newdiv = document.createElement("object");
-        newdiv.innerHTML = stringSelection;
-        range.insertNode(newdiv);
-        var newdiv = document.createElement("br");
-        range.insertNode(newdiv);
-
-    } else {
-        var newdiv = document.createElement(tag);
-        newdiv.innerHTML = stringSelection;
-        range.insertNode(newdiv);
-    }
-    */
-
-    $('.tagItemDivClass').remove();
-}
-
-
-
-
-function replaceSmartRegex() {
-    saveUndoText();
-    var startPage = $('#regexPageStart2').val();
-    var endPage = $('#regexPageEnd2').val();
-    
-    var el = document.getElementById("editable-area");
-    var regexText=document.getElementById("regexText").value;
-    
-    <?php 
-    foreach ( $wordlistArray as $wordlistValue ) {
-        echo "\tvar regexText1=\"List ".$wordlistValue[1]."\";\n";
-        echo "\tregexText1 = preg_quote(regexText1);\n";
-        echo "\tvar replaceText1=\"".$wordlistValue[2]."\";\n";
-        echo "\tregexText = regexText.replace(new RegExp(regexText1, \"g\"), replaceText1);\n\n";
-    }
-    ?>
-    
-    var replaceText=document.getElementById("replaceText").value;
-    var str="" + el.innerHTML;
-    
-    if ( startPage == "" ) {
-        alert( "Tagged "+str.match(new RegExp(regexText, "g")).length+" entities!" );
-        el.innerHTML = str.replace(new RegExp(regexText, "g"), replaceText);
-    } else {
-        var regexText2="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】";
-        var partString = ""+str.match(new RegExp(regexText2, "g"));
-        alert(partString);
-        
-        alert( "Tagged "+partString.match(new RegExp(regexText, "g")).length+" entities!" );
-        var resultString = partString.replace(new RegExp(regexText, "g"), replaceText);
-        
-        str="" + el.innerHTML;
-        el.innerHTML = str.replace(new RegExp(regexText2, "g"), resultString);
-    }
-    //document.styleSheets[0].addRule("tag001", "color:green;")
-}
-
-
-
-function saveTextToLGService() {
-    var info = JSON.parse('<?php echo json_encode($info) ?>');
-    var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
-
-    // if this is a new branch, ask for label
-    if (info['branch_id'] == 0) {
-        var cnt = 0;
-        var label = prompt("Please enter your label for this new branch", "section"+info['section_id']);
-        while (label == null && cnt <= 3) {
-            cnt ++;
-            label = prompt("Please enter your label for this new branch (not empty)", "section"+info['section_id']);
-        }    
-    };
-    
-    
-
-    var form = document.createElement("form");
-    form.setAttribute("method", "post");
-    form.setAttribute("action", "./TaggingText");  // hand to controller
-    form.setAttribute("target", "_self");
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "func");
-    hiddenField.setAttribute("value", "SaveFullTextToLGService");
-    form.appendChild(hiddenField); 
-    
-
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "label");
-    hiddenField.setAttribute("value", label);
-    form.appendChild(hiddenField);
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "topic_id");
-    hiddenField.setAttribute("value", topic_id);
-    form.appendChild(hiddenField); 
-
-    _postForContineTagging(form);
-
-    console.log("complete saving to LGService");
-
-    
-    /*
-
-    if (info) {
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "fileId");
-        hiddenField.setAttribute("value", info['file_id']);
-        form.appendChild(hiddenField);
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "branchId");
-        hiddenField.setAttribute("value", info['branch_id']);
-        form.appendChild(hiddenField);
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "userId");
-        hiddenField.setAttribute("value", info['user_id']);
-        form.appendChild(hiddenField);
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "sectionId");
-        hiddenField.setAttribute("value", info['section_id']);
-        form.appendChild(hiddenField);
-
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "bookId");
-        hiddenField.setAttribute("value", info['book_id']);
-        form.appendChild(hiddenField);
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "sectionName");
-        hiddenField.setAttribute("value", info['section_name']);
-        form.appendChild(hiddenField);
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "bookName");
-        hiddenField.setAttribute("value", info['book_name']);
-        form.appendChild(hiddenField);
-
-    }
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "text");
-    var el = document.getElementById("editable-area");
-    //var text = encodeURIComponent(el.innerHTML);
-    var text = el.innerHTML;
-    hiddenField.setAttribute("value", text);
-    form.appendChild(hiddenField);
-
-    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
-        document.body.appendChild(form);
-        form.submit();
-    } else {
-        form.submit(); // works under IE and Chrome, but not FF  
-    }
-    */
-}
-
-
-
-function chooseTopic(default_topic_id) {
-    var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' );
-    var info = JSON.parse('<?php echo json_encode($info) ?>');
-
-    $('#load_topic_div').html("");
-    $('#load_topic_div').css("display", "block");
-    
-    $('#load_topic_div').css("border", "1px solid black");
-    $('#load_topic_div').css("background-color", "White");
-    $('#load_topic_div').css("width", "150px");
-    $('#load_topic_div').css("height", "50px");
-    $('#load_topic_div').css("top", "20px");
-    $('#load_topic_div').css("left", "-150px");
-    
-
-    var topic_select = document.createElement("select");
-    topic_select.id = "loadTopiclist";
-    var selected_topic = t[0];
-    topic_select.onchange = function(){
-
-    	selected_topic = topic_select.options[topic_select.selectedIndex];
-    	console.log(selected_topic.text);
-
-    	var topic_id = selected_topic.value;
-
-		var form = document.createElement("form");
-        form.setAttribute("method", "post");
-        form.setAttribute("action", "./TaggingText");  // hand to controller
-        form.setAttribute("target", "_self");
-
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "topic");
-        hiddenField.setAttribute("value", topic_id);
-        form.appendChild(hiddenField);
-
-        var hiddenField = document.createElement("input");      
-        hiddenField.setAttribute("name", "func");
-        hiddenField.setAttribute("value", "ContinueTagging");
-        form.appendChild(hiddenField);
-    
-	    _postForContineTagging(form);
-           
-    };
-
-
-    //Create and append the options
-	for (var i = 0; i < t.length; i++) {
-		console.log(t[i]['id']+","+t[i]['name']);
-    	var option = document.createElement("option");
-    	option.value = t[i]['id'];
-	    option.text = t[i]['name'];
-	    if (option.value == default_topic_id) {
-	    	option.selected = true;
-	    };
-	    topic_select.appendChild(option);
-	}
-
-    $('#load_topic_div').append(topic_select);
-
-    var newbutton = document.createElement("button");
-    $(newbutton).html("Close");
-    $(newbutton).addClass("btn btn-xs btn-default");
-    $(newbutton).attr("onclick", "$('#load_topic_div').css(\"display\", \"none\");");
-    $('#load_topic_div').append(newbutton);
-  
-}
-
-// --- for config tags in topic ---
-function _postForContineTagging(form) {
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "text");
-    var el = document.getElementById("editable-area");
-    var text = el.innerHTML;
-    hiddenField.setAttribute("value", text);
-    form.appendChild(hiddenField);
-
-    var info = JSON.parse( '<?php echo json_encode($info) ?>');
-
-    if (info) {
-        // TODO: different field info array based on fileId(branchId) existing or not
-        if (info['file_id']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "fileId");
-            hiddenField.setAttribute("value", info['file_id']);
-            form.appendChild(hiddenField);
-        };
-        if (info['branch_id']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "branchId");
-            hiddenField.setAttribute("value", info['branch_id']);
-            form.appendChild(hiddenField);
-        };
-        if (info['user_id']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "userId");
-            hiddenField.setAttribute("value", info['user_id']);
-            form.appendChild(hiddenField);
-        };
-        if (info['section_id']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "sectionId");
-            hiddenField.setAttribute("value", info['section_id']);
-            form.appendChild(hiddenField);
-        };
-        if (info['book_id']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "bookId");
-            hiddenField.setAttribute("value", info['book_id']);
-            form.appendChild(hiddenField);
-        };
-        if (info['section_name']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "sectionName");
-            hiddenField.setAttribute("value", info['section_name']);
-            form.appendChild(hiddenField);
-        };
-        if (info['book_name']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "bookName");
-            hiddenField.setAttribute("value", info['book_name']);
-            form.appendChild(hiddenField);
-        };
-        if (info['current_fileId']) {
-            var hiddenField = document.createElement("input");      
-            hiddenField.setAttribute("name", "currentFileId");
-            hiddenField.setAttribute("value", info['current_fileId']);
-            form.appendChild(hiddenField);
-        };
-
-    }
-    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
-        document.body.appendChild(form);
-        form.submit();
-    } else {
-        form.submit(); // works under IE and Chrome, but not FF  
-    }
-
-}
-
-function configTagsInTopic(topic_id) {
-    var form = document.createElement("form");
-    
-    form.setAttribute("method", "post");
-    form.setAttribute("action", "./ConfigTagsInTopic");  // hand to controller
-    form.setAttribute("target", "_blank");
-    
-    var hiddenField = document.createElement("input");      
-    hiddenField.setAttribute("name", "topic");
-    hiddenField.setAttribute("value", topic_id);
-    form.appendChild(hiddenField);
-
-    _postForContineTagging(form);
-    
-    /*
-    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
-        document.body.appendChild(form);
-        form.submit();
-    } else {
-        form.submit(); // works under IE and Chrome, but not FF  
-    }
-    */
-        
-}
-
-
-
-$(document).on("change", '#smartRegexPopUpSelectWord', function (e) {
-
-<?php
-    foreach ( $wordlistArray as $wordlistValue ) {
-        echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {";
-        echo "$('#smartRegexPopUpText').val(\"".$wordlistValue[2]."\");";
-        echo "}";
-    }
-?>
-});
-
-
-
-</script>
- 
-<div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; ">
-</div>
-
-
-<p class="bg-info" style="margin:10 30 10 30; max-width:1250"> <?php echo $messages; ?> </p>
-
-<table width="1270" border="1" style="margin:10 30 10 30;">
-    <tr>
-        <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;">
-            <div id="editable-area" class="area" style="max-width: 980"><?php echo $stringInput; ?></div>
-        </td>
-        <td width="290" valign="top">
-            <div id="popups" style="position:absolute; width:300px; ">
-                <div id="load_topic_div" style="position: absolute; display: none; z-index:2"></div>
-                <div id="load_regex_div" style="position: absolute; display: none; z-index:2;"></div>
-                <div id="smartRegexPopUpDiv" style="position: absolute; display: none; z-index:2">
-                    Name: <input id="smartRegexPopUpName"></input><br><br>
-                    Word List: 
-                    <select id="smartRegexPopUpSelectWord">
-                    <option value="NULL" selected>無</option>
-                    <?php
-                        foreach ( $wordlistArray as $wordlistValue ) {
-                            echo "<option value=\"".$wordlistValue[0]."\">".$wordlistValue[1]."</option>\n";
-                        }
-                    ?>
-                    </select>
-                    <br>
-                    OR (USE "|" TO SEPARATE WORDS):<br>
-                    <TEXTAREA id="smartRegexPopUpText" COLS=30 ROWS=4></TEXTAREA><br><br>
-                    Tag:
-                    <select id="smartRegexPopUpSelectTag">
-                    <?php
-                        foreach ( $taglistArray as $taglistValue ) {
-                            echo "<option value=\"".$taglistValue[2]."\">".$taglistValue[1]."</option>\n";
-                        }
-                        echo "<option value=\"title\">Title</option>\n";
-                    ?>
-                    <option value="NOTAG">不標記</option>
-                    </select><br>
-                    <button id="smartRegexPopUpAdd" onclick="replaceSmartAdd()" class="btn btn-info" style="">Add</button>
-                    <button id="smartRegexPopUpEdit" onclick="replaceSmartEdit()" class="btn btn-success" style="">Edit</button>
-                    <button id="smartRegexPopUpDel" onclick="replaceSmartDel()" class="btn btn-danger" style="">Delete</button>
-                    <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" class="btn btn-default" style=""><<</button>
-                    <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button>
-                    <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button>
-                </div>
-            </div>
-
-            <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 15 5; max-width:270px">
-                <form action="javascript:void(0);">   
-                    <fieldset>
-                        <legend><h5 class="text-success"> Config Topic: </h5></legend>
-                        <div> current topic is <?php echo $topic_name; ?> 
-                            <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button>
-                        </div>
-                        <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br>
-                    </fieldset>
-
-                    <fieldset>
-                        <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
-                        <div id="smartRegexShowDiv"></div><br>
-                        <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br>
-                        Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br>
-                        <button onclick="replaceSmartRun()" style="height: 30px; width: 100px">Run</button>
-                        <button onclick="replaceSmartRunWithBr()" style="height: 30px; width: 100px">Run(with Br)</button></br>
-                        <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br>
-                        <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button>
-                        <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button>
-                        <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br>
-                        <!--
-                        <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button>
-                        -->
-                    </fieldset>
-                    
-                    <fieldset>
-                        <legend><h5 class="text-success"> Tag by rule:</h5></legend>
-                        <button onclick="tagNameWithLastName()" style="height: 30px; width: 220px">Tag Word Begin With Surname</button></br>
-                        <button onclick="tagNameWithLastName2()" style="height: 30px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
-                        <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
-                        <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
-                        <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button>
-                    </fieldset>
-                
-                    <fieldset>
-                        <legend><h5 class="text-success"> Edit:</h5></legend>
-                        <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
-                    
-                        <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
-                        <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage -->
-                        <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
-                        <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br>
-                        </br>
-                        <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br>
-                        <!--
-                        <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>
-                        -->
-                        <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 220px">Manage Tag List</button></br>
-                    </fieldset>
-                    
-                    <fieldset>
-                        <legend><h5 class="text-success"> Export:</h5></legend>
-                        Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br>
-                        <button onclick="exportPage(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export</button></br>
-                        <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br>
-                    </fieldset>
-                
-                    <fieldset>
-                        <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend>
-                        Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br>
-                        Regex: <input type="text" size="23" id="regexText"></br>
-                        Replace: <input type="text" size="23" id="replaceText"><br>
-                        <button onclick="replaceSmartRegex()">Replace!</button>
-                    </fieldset>
-                </form>
-            </div>
-        </td>
-    </tr>
-
-</table>
-
-
-
-
-</body>
-
-</html>
--- a/develop/views/Home/index.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-<h1>Home/index.php</h1>
--- a/develop/views/Home/test.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-<h1>Home/test.php</h1>
-
-<?php
-// --- initialize config file and input text ---
-$name = $viewmodel['name'];
-
-
-?>
\ No newline at end of file
--- a/develop/views/maintemplate.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-<html>
-<head>
-<title></title>
-
-<script src="../js/jquery-1.10.2.min.js"></script>
-<script src="../js/jquery-ui.js"></script>
-<script src="../js/taggingtext.js"></script>
-
-<!-- Bootstrap -->
-<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
-<!--
-<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
-
-<link href="../css/bootstrap.min.css" rel="stylesheet">
-<script src="../js/bootstrap.min.js"></script>
-<script src="../js/bootstrap.js"></script>
--->
-
-</head>
-<body>
-
-
-</body>
-
-</html>
\ No newline at end of file
--- a/develop/views/maintemplate_local.php	Fri Mar 06 14:07:39 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-<html>
-<head>
-<title></title>
-
-
-<script src="../../js/jquery-1.10.2.min.js"></script>
-<script src="../../js/jquery-ui.js"></script>
-<script src="../../js/taggingtext.js"></script>
-
-<!-- Bootstrap -->
-<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
-<!--
-<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
-<link href="../../css/bootstrap.min.css" rel="stylesheet">
-<script src="../../js/bootstrap.min.js"></script>
-<script src="../../js/bootstrap.js"></script>
--->
-
-</head>
-<body>
-
-</body>
-
-</html>
\ No newline at end of file