<!DOCTYPE HTML>
<html ng-app="app" ng-controller="main">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title ng-bind="title">法規查詢</title>
		<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
		<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular-route.min.js"></script>
		<script src="scripts/ngController.js"></script>
		<link rel="stylesheet" href="styles/std.css">
		<link rel="stylesheet" href="styles/main.css">
	</head>
	<body>
		<header>
			<a id="brand" href="./#/">法規查詢</a>
			<div id="UpdateDate">
				法規整編資料截止日：
				<time ng-bind="UpdateDate || '讀取中…'"></time>
			</div>
		</header>
		<section ng-view>
<script type="text/ng-template" id="list">
	<div ng-if="!laws">讀取中…</div>
	<div ng-show="laws">
		<input ng-model="q" placeholder="搜尋名稱"
			ng-model-options="{debounce: 300}"
			ng-change="search()"
		>
		<p>{{q?'找到':'共有'}} {{filtered.length}} 個法規</p>
		<nav ng-show="filtered.length > itemsPerPage">
			分頁
			<select ng-model="skip" ng-options="value as (key-0+1) for (key, value) in pages()"></select>
		</nav>
		<article class="brief" ng-repeat="law in filtered=(laws |filter :q |orderBy :'-lastUpdate') |limitTo :itemsPerPage :skip track by law.PCode">
			<header class="table">
				<div class="tableCell">
					<div class="pcode">{{law.PCode}}</div>
					<div class="lastUpdate"><time title="最新異動日期">{{law.lastUpdate}}</time></div>
				</div>
				<div class="tableCell">
					<a class="name" href="./#/law/{{law.PCode}}">{{law.name}}</a>
				</div>
			</header>
			<p class="english" ng-if="law.english">{{law.english}}</p>
			<dl class="oldNames" ng-if="law.oldNames">
				<dt>舊名</dt>
				<dd>
					<ul class="inlineList">
						<li ng-repeat="name in law.oldNames track by $index">{{name}}</li>
					</ul>
				</dd>
			</dl>
			<dl class="updates" ng-if="law.updates">
				<dt>沿革</dt>
				<dd>
					<ul class="inlineList">
						<li ng-repeat="date in law.updates |orderBy :'-' track by $index"><time>{{date}}</time></li>
					</ul>
				</dd>
			</dl>
		</article>
	</div>
</script>
<script type="text/ng-template" id="law">
	<header>
		<span class="pcode">{{PCode}}</span>
		<h1>{{law['法規名稱']}}</h1>
	</header>
	<div ng-if="error">發生錯誤。</div>
	<div class="dlTable">
		<dl ng-repeat="(key, val) in law track by key"
			ng-if="['法規名稱', '法規內容', '附件'].indexOf(key) == -1"
		>
			<dt>{{key}}</dt>
			<dd class="rawdata">{{val}}</dd>
		</dl>
		<dl ng-if="law['附件']">
			<dt>附件</dt>
			<dd>
				<ol>
					<li ng-repeat="annex in law['附件'] track by $index">
						<a href="{{annex['下載網址']}}">{{annex['檔案名稱']}}</a>
					</li>
				</ol>
			</dd>
		</dl>
	</div>
	<div class="dlTable">
		<dl ng-repeat="article in law['法規內容'] track by $index">
			<dt>{{article['條號']}}</dt>
			<dd ng-if="!article['編章節']" class="rawdata">{{article['條文內容']}}</dd>
			<dd ng-if="article['編章節']"><h2>{{article['編章節']}}</h2></dd>
		</dl>
	</div>
</script>
		</section>
		<footer>
			<nav>
				<ul class="inlineList">
					<li><a href="https://www.facebook.com/kong.sex">Author</a></li>
					<li><a href="https://github.com/kong0107/mojLawSplitJSON">Source Codes</a></li>
				</ul>
			</nav>
		</footer>
	</body>
</html>
