This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 視窗延遲半秒才出現對我來說有點久,現設為350毫秒--之後應允許使用者自設為150毫秒以上的時間。 * * 發生「移動到子物件會觸發父元件的onMouseOver事件」狀況,在[Stack Overflow找到解答](http://stackoverflow.com/questions/4697758#4698240)。(詭異的是:之前沒有發生!?),僅套用最簡便但不適用於孫輩以下之後代的。 * [法源法律網](http://www.lawbank.com.tw/)部分,僅對法規查詢的頁面重新排版。 * * 基本上與全國法規資料庫相同,故另分離出`pre32.js`供這二者共用。印象中其他許多的政府機關自有法規資料庫亦是相同結構,應亦能套用。
- Loading branch information
Showing
7 changed files
with
172 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
body, | ||
#main, | ||
#tbLaw, | ||
#Law-Content1 { | ||
width: 100% !important; | ||
} | ||
|
||
#tbLaw { | ||
margin: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** 處理<pre />的斷行排版 | ||
* 嘗試排版成階層式表單(如`ly.js`) | ||
*/ | ||
var stratums = [ | ||
{ | ||
"name": "paragraphs", ///< 用於CSS | ||
"ordinal": /^(?! )/ ///< 此階層的序數文字,「不能」是global | ||
}, | ||
{ | ||
"name": "categories", | ||
"ordinal": /^第[一二三四五六七八九十]+類:/ | ||
}, | ||
{ | ||
"name": "subparagraphs", | ||
"ordinal": /^\s*[○一二三四五六七八九十]+(、| | )/ ///< 憲法裡的「款」有時是全形空格,有時是兩個半形空格 | ||
}, | ||
{ | ||
"name": "items", | ||
"ordinal": /^\s*[\((][一二三四五六七八九十]+[\))]/ ///< 有些括號是全形,有些是半形 | ||
}, | ||
{ | ||
"name": "subitems", | ||
"ordinal": /^\s+\d+\./ | ||
}, | ||
{ | ||
"name": "subsubitems", | ||
"ordinal": /^\s+(\d+)/ ///< 全形括號(與立法院不同)、半形數字 | ||
} | ||
]; | ||
var pres = document.getElementsByTagName("PRE"); | ||
for(var i = 0; i < pres.length;) { | ||
var row = pres[i].parentNode.parentNode; | ||
if(row.childElementCount != 3) { | ||
/** 只處理條文,不處理分區(編章節)的文字 | ||
* 因為 Node#replaceChild 會改變 NodeList,故 ++i 的位置與一般 for 迴圈不同 | ||
*/ | ||
++i; | ||
continue; | ||
} | ||
/// 增加左方的空間 | ||
row.children[0].setAttribute("width", ""); | ||
row.children[1].setAttribute("width", ""); | ||
row.children[2].setAttribute("width", "95%"); | ||
|
||
var lines = pres[i].innerText.split("\n"); ///< 記得最後一行是空字串喔 | ||
var html = "<li>"; | ||
var depthArr = []; | ||
for(var j = 0; j < lines.length; ++j) { | ||
var endDetect = /(:|。|(刪除))$/.exec(html); | ||
if(endDetect) { | ||
var stratum = -1; | ||
for(var k = stratums.length - 1; k >= 0; --k) { | ||
if(stratums[k].ordinal.test(lines[j])) { | ||
stratum = k; | ||
break; | ||
} | ||
} | ||
|
||
switch(endDetect[1]) { | ||
case "。": | ||
/// 處理所得稅法中,一個款/目中又分段的情形 | ||
if(stratum < 0) { | ||
html += "<br />"; | ||
break; | ||
} | ||
/// 警告可能的錯誤情形 | ||
if(!depthArr.length ///< 「項」 | ||
&& lines[j-1].length == 32 ///< 前一行有32字 | ||
&& !/\w/.test(lines[j-1]) ///< 且沒有英數 | ||
&& lines[j] ///< 而這行不是最後一行 | ||
) html += '<div class="LER-warning" title="此網頁是用「換行」的方式排版,因而【法規亦毒氣】沒能判斷這裡究竟是「換行」還是「分項」。">警告:這裡可能其實沒有分項</div>'; | ||
// no break! | ||
case "(刪除)": | ||
html += "</li>"; | ||
while(depthArr.length && depthArr[depthArr.length - 1] != stratum) { | ||
html += "</ol></li>"; | ||
depthArr.pop(); | ||
} | ||
break; | ||
case ":": | ||
if(lines[j][0] == "「") { ///< 憲法§48 | ||
stratum = -1; | ||
break; | ||
} | ||
html += '<ol class="LER-art-' + stratums[stratum].name + '">'; | ||
depthArr.push(stratum); | ||
break; | ||
default: | ||
console.log(endDetect); | ||
throw new SyntaxError("RegExp returns wrong match."); | ||
} | ||
if(lines[j] && stratum >= 0) html += "<li>"; ///< 如果是末行的空白就不用加了 | ||
} | ||
html += lines[j].replace(/^\s+/, ''); | ||
} | ||
var list = document.createElement("OL"); | ||
list.innerHTML = html; | ||
list.className = (list.childElementCount == 1) ? "LER-art-singlePara" : "LER-art-paragraphs"; | ||
pres[i].parentNode.replaceChild(list, pres[i]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
if(location.href.indexOf("http://law.moj.gov.tw/LawClass/Law") == 0) { | ||
/** 如果連結到全國法規資料庫中不存在的法條,會強制執行 | ||
* `alert('查無資料');history.go(-1);` // line #43 | ||
* 由於該處是寫在<script />裡,因而不能等DOMContenetLoaded才處理 | ||
* 但即使是在`document_start`時執行這個檔好像也沒幫助.... | ||
* 先放著。 | ||
*/ | ||
alert = function(str){ console.log(str); }; | ||
history.go = function(){}; | ||
} |