chore: 首次簽入 Thinkyu ASP.NET 專案

- 加入 Visual Studio / ASP.NET .gitignore
- 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
2026-09-10 09:42:37 +08:00
commit 577060bc78
2496 changed files with 501389 additions and 0 deletions
+267
View File
@@ -0,0 +1,267 @@
// --------------------------------------------------------------------------
//
// 地址輸入用的 JavaScript
//
// 2012/08/28 1. 去除 eval 語法,改用直接 JSON
// 2. 去除 zipData 底下的 Data,將 Country 與 Township 提上來一層
// --------------------------------------------------------------------------
// 定義輔助輸入用的類別
function AddressEditorClass()
{
this.FillSelect1 = FillSelect1;
this.FillSelect2 = FillSelect2;
this.FillZipCode = FillZipCode;
this.ZipcodeChange = ZipcodeChange;
// 這是用 JSON 表示法表示的資料
var zipData =
{
"County":
["縣市", "基隆市", "台北市", "新北市", "桃園市", "新竹市", "新竹縣", "苗栗縣", "台中市",
"彰化縣", "南投縣", "雲林縣", "嘉義市", "嘉義縣", "台南市", "高雄市", "屏東縣", "宜蘭縣",
"花蓮縣", "台東縣", "澎湖縣", "金門縣", "連江縣"],
"Township":
[
// 未選擇縣市
[
["", "鄉鎮市區"]
],
// 基隆市
[
["200", "仁愛區"], ["201", "信義區"], ["202", "中正區"], ["203", "中山區"], ["204", "安樂區"], ["205", "暖暖區"], ["206", "七堵區"]
],
// 台北市
[
["100", "中正區"], ["103", "大同區"], ["104", "中山區"], ["105", "松山區"], ["106", "大安區"], ["108", "萬華區"], ["110", "信義區"],
["111", "士林區"], ["112", "北投區"], ["114", "內湖區"], ["115", "南港區"], ["116", "文山區"]
],
// 新北市
[
["207", "萬里區"], ["208", "金山區"], ["220", "板橋區"], ["221", "汐止區"], ["222", "深坑區"], ["223", "石碇區"], ["224", "瑞芳區"],
["226", "平溪區"], ["227", "雙溪區"], ["228", "貢寮區"], ["231", "新店區"], ["232", "坪林區"], ["233", "烏來區"], ["234", "永和區"],
["235", "中和區"], ["236", "土城區"], ["237", "三峽區"], ["238", "樹林區"], ["239", "鶯歌區"], ["241", "三重區"], ["242", "新莊區"],
["243", "泰山區"], ["244", "林口區"], ["247", "蘆洲區"], ["248", "五股區"], ["249", "八里區"], ["251", "淡水區"], ["252", "三芝區"],
["253", "石門區"]
],
// 桃園市
[
["320", "中壢區"], ["324", "平鎮區"], ["325", "龍潭區"], ["326", "楊梅區"], ["327", "新屋區"], ["328", "觀音區"], ["330", "桃園區"],
["333", "龜山區"], ["334", "八德區"], ["335", "大溪區"], ["336", "復興區"], ["337", "大園區"], ["338", "蘆竹區"]
],
// 新竹市
[
["300|1", "東區"], ["300|2", "北區"], ["300|3", "香山區"]
],
// 新竹縣
[
["302", "竹北市"], ["303", "湖口鄉"], ["304", "新豐鄉"], ["305", "新埔鄉"], ["306", "關西鎮"], ["307", "芎林鄉"],
["308", "寶山鄉"], ["310", "竹東鎮"], ["311", "五峰鄉"], ["312", "橫山鄉"], ["313", "尖石鄉"], ["314", "北埔鄉"], ["315", "峨眉鄉"]
],
// 苗栗縣
[
["350", "竹南鎮"], ["351", "頭份市"], ["352", "三灣鄉"], ["353", "南庄鄉"], ["354", "獅潭鄉"], ["356", "後龍鎮"], ["357", "通霄鎮"],
["358", "苑裡鎮"], ["360", "苗栗市"], ["361", "造橋鄉"], ["362", "頭屋鄉"], ["363", "公館鄉"], ["364", "大湖鄉"], ["365", "泰安鄉"],
["366", "銅鑼鄉"], ["367", "三義鄉"], ["368", "西湖鄉"], ["369", "卓蘭鎮"]
],
// 台中市
[
["400", "中區"], ["401", "東區"], ["402", "南區"], ["403", "西區"], ["404", "北區"], ["406", "北屯區"], ["407", "西屯區"],
["408", "南屯區"], ["411", "太平區"], ["412", "大里區"], ["413", "霧峰區"], ["414", "烏日區"], ["420", "豐原區"], ["421", "后里區"],
["422", "石岡區"], ["423", "東勢區"], ["424", "和平區"], ["426", "新社區"], ["427", "潭子區"], ["428", "大雅區"], ["429", "神岡區"],
["432", "大肚區"], ["433", "沙鹿區"], ["434", "龍井區"], ["435", "梧棲區"], ["436", "清水區"], ["437", "大甲區"], ["438", "外埔區"],
["439", "大安區"]
],
// 彰化縣
[
["500", "彰化市"], ["502", "芬園鄉"], ["503", "花壇鄉"], ["504", "秀水鄉"], ["505", "鹿港鎮"], ["506", "福興鄉"], ["507", "線西鄉"],
["508", "和美鎮"], ["509", "伸港鄉"], ["510", "員林鎮"], ["511", "社頭鄉"], ["512", "永靖鄉"], ["513", "埔心鄉"], ["514", "溪湖鎮"],
["515", "大村鄉"], ["516", "埔鹽鄉"], ["520", "田中鎮"], ["521", "北斗鎮"], ["522", "田尾鄉"], ["523", "埤頭鄉"], ["524", "溪洲鄉"],
["525", "竹塘鄉"], ["526", "二林鎮"], ["527", "大城鄉"], ["528", "芳苑鄉"], ["530", "二水鄉"]
],
// 南投縣
[
["540", "南投市"], ["541", "中寮鄉"], ["542", "草屯鎮"], ["544", "國姓鄉"], ["545", "埔里鎮"], ["546", "仁愛鄉"], ["551", "名間鄉"],
["552", "集集鎮"], ["553", "水里鄉"], ["555", "魚池鄉"], ["556", "信義鄉"], ["557", "竹山鎮"], ["558", "鹿谷鄉"]
],
// 雲林縣
[
["630", "斗南鎮"], ["631", "大埤鄉"], ["632", "虎尾鎮"], ["633", "土庫鎮"], ["634", "褒忠鄉"], ["635", "東勢鄉"], ["636", "台西鄉"],
["637", "崙背鄉"], ["638", "麥寮鄉"], ["640", "斗六市"], ["643", "林內鄉"], ["646", "古坑鄉"], ["647", "莿桐鄉"], ["648", "西螺鎮"],
["649", "二崙鄉"], ["651", "北港鎮"], ["652", "水林鄉"], ["653", "口湖鄉"], ["654", "四湖鄉"], ["655", "元長鄉"]
],
// 嘉義市
[
["600|1", "東區"], ["600|2", "西區"]
],
// 嘉義縣
[
["602", "番路鄉"], ["603", "梅山鄉"], ["604", "竹崎鄉"], ["605", "阿里山鄉"], ["606", "中埔鄉"], ["607", "大埔鄉"],
["608", "水上鄉"], ["611", "鹿草鄉"], ["612", "太保市"], ["613", "朴子市"], ["614", "東石鄉"], ["615", "六腳鄉"], ["616", "新港鄉"],
["621", "民雄鄉"], ["622", "大林鎮"], ["623", "溪口鄉"], ["624", "義竹鄉"], ["625", "布袋鎮"]
],
// 台南市
[
["700", "中西區"], ["701", "東區"], ["702", "南區"], ["704", "北區"], ["708", "安平區"], ["709", "安南區"],
["710", "永康區"], ["711", "歸仁區"], ["712", "新化區"], ["713", "左鎮區"], ["714", "玉井區"], ["715", "楠西區"], ["716", "南化區"],
["717", "仁德區"], ["718", "關廟區"], ["719", "龍崎區"], ["720", "官田區"], ["721", "麻豆區"], ["722", "佳里區"], ["723", "西港區"],
["724", "七股區"], ["725", "將軍區"], ["726", "學甲區"], ["727", "北門區"], ["730", "新營區"], ["731", "後壁區"], ["732", "白河區"],
["733", "東山區"], ["734", "六甲區"], ["735", "下營區"], ["736", "柳營區"], ["737", "鹽水區"], ["741", "善化區"], ["742", "大內區"],
["743", "山上區"], ["744", "新市區"], ["745", "安定區"]
],
// 高雄市
[
["800", "新興區"], ["801", "前金區"], ["802", "苓雅區"], ["803", "鹽埕區"], ["804", "鼓山區"], ["805", "旗津區"], ["806", "前鎮區"],
["807", "三民區"], ["811", "楠梓區"], ["812", "小港區"], ["813", "左營區"],
["814", "仁武區"], ["815", "大社區"], ["820", "岡山區"], ["821", "路竹區"], ["822", "阿蓮區"], ["823", "田寮區"], ["824", "燕巢區"],
["825", "橋頭區"], ["826", "梓官區"], ["827", "彌陀區"], ["828", "永安區"], ["829", "湖內區"], ["830", "鳳山區"], ["831", "大寮區"],
["832", "林園區"], ["833", "鳥松區"], ["840", "大樹區"], ["842", "旗山區"], ["843", "美濃區"], ["844", "六龜區"], ["845", "內門區"],
["846", "杉林區"], ["847", "甲仙區"], ["848", "桃源區"], ["849", "那瑪夏區"], ["851", "茂林區"], ["852", "茄萣區"], ["817", "東沙群島"], ["819", "南沙群島"]
],
// 屏東縣
[
["900", "屏東市"], ["901", "三地門"], ["902", "霧台鄉"], ["903", "瑪家鄉"], ["904", "九如鄉"], ["905", "里港鄉"], ["906", "高樹鄉"],
["907", "鹽埔鄉"], ["908", "長治鄉"], ["909", "麟洛鄉"], ["911", "竹田鄉"], ["912", "內埔鄉"], ["913", "萬丹鄉"], ["920", "潮州鎮"],
["921", "泰武鄉"], ["922", "來義鄉"], ["923", "萬巒鄉"], ["924", "崁頂鄉"], ["925", "新埤鄉"], ["926", "南州鄉"], ["927", "林邊鄉"],
["928", "東港鎮"], ["929", "琉球鄉"], ["931", "佳冬鄉"], ["932", "新園鄉"], ["940", "枋寮鄉"], ["941", "枋山鄉"], ["942", "春日鄉"],
["943", "獅子鄉"], ["944", "車城鄉"], ["945", "牡丹鄉"], ["946", "恆春鄉"], ["947", "滿州鄉"]
],
// 宜蘭縣
[
["260", "宜蘭市"], ["261", "頭城鎮"], ["262", "礁溪鄉"], ["263", "壯圍鄉"], ["264", "員山鄉"], ["265", "羅東鎮"], ["266", "三星鄉"],
["267", "大同鄉"], ["268", "五結鄉"], ["269", "冬山鄉"], ["270", "蘇澳鎮"], ["272", "南澳鄉"], ["290", "釣魚台"]
],
// 花蓮縣
[
["970", "花蓮市"], ["971", "新城鄉"], ["972", "秀林鄉"], ["973", "吉安鄉"], ["974", "壽豐鄉"], ["975", "鳳林鎮"], ["976", "光復鄉"],
["977", "豐濱鄉"], ["978", "瑞穗鄉"], ["979", "萬榮鄉"], ["981", "玉里鎮"], ["982", "卓溪鄉"], ["983", "富里鄉"]
],
// 台東縣
[
["950", "台東市"], ["951", "綠島鄉"], ["952", "蘭嶼鄉"], ["953", "延平鄉"], ["954", "卑南鄉"], ["955", "鹿野鄉"], ["956", "關山鎮"],
["957", "海端鄉"], ["958", "池上鄉"], ["959", "東河鄉"], ["961", "成功鎮"], ["962", "長濱鄉"], ["963", "太麻里"], ["964", "金峰鄉"],
["965", "大武鄉"], ["966", "達仁鄉"]
],
// 澎湖縣
[
["880", "馬公市"], ["881", "西嶼鄉"], ["882", "望安鄉"], ["883", "七美鄉"], ["884", "白沙鄉"], ["885", "湖西鄉"]
],
// 金門縣
[
["890", "金沙鎮"], ["891", "金湖鎮"], ["892", "金寧鄉"], ["893", "金城鎮"], ["894", "烈嶼鄉"], ["896", "烏坵鄉"]
],
// 連江縣
[
["209", "南竿鄉"], ["210", "北竿鄉"], ["211", "莒光鄉"], ["212", "東引鄉"]
],
]
};
// 填入縣市下拉清單
function FillSelect1(select1Id)
{
var select1 = document.getElementById(select1Id);
if (!select1)
return;
for (i = 0; i < zipData.County.length; i++)
{
newOption = new Option(zipData.County[i], i);
select1.options.add(newOption);
}
}
// 填入鄉鎮市區下拉清單
function FillSelect2(select1Id, select2Id, txtZipCodeId, hfCuntyId, hfTownId, isfill)
{
var select1 = document.getElementById(select1Id);
var hfselect1 = document.getElementById(hfCuntyId);
if (!select1)
return;
hfselect1.value = select1.selectedIndex;
FillSelect2ByIndex(select1.selectedIndex, select2Id, txtZipCodeId, hfTownId, isfill);
}
// 填入鄉鎮市區下拉清單
// 並將縣市代號填入 hidden 中
function FillSelect2ByIndex(select1Index, select2Id, txtZipCodeId, hfTownId, isfill)
{
var select2 = document.getElementById(select2Id);
var txtZipCode = document.getElementById(txtZipCodeId);
if (!select2 || !txtZipCode)
return;
select2.options.length = 0;
for (i = 0; i < zipData.Township[select1Index].length; i++)
{
if (typeof zipData.Township[select1Index][i] != "undefined")
{
newOption = new Option(zipData.Township[select1Index][i][1], zipData.Township[select1Index][i][0]);
select2.options.add(newOption);
}
}
if (isfill)
FillZipCode(select2Id, txtZipCodeId, hfTownId);
}
// 填入郵遞區號,並加鄉鎮市區代號填入 hidden 中
function FillZipCode(select2Id, txtZipCodeId, hfTownId)
{
var select2 = document.getElementById(select2Id);
var txtZipCode = document.getElementById(txtZipCodeId);
var hfselect2 = document.getElementById(hfTownId);
if (!select2 || !txtZipCode)
return;
txtZipCode.value = select2.value.split("|")[0];
hfselect2.value = select2.value;
}
// 郵遞區號改變,填入縣市、鄉鎮市區下拉清單,並將縣市代號、鄉鎮市區代號填入 hidden 中
function ZipcodeChange(select1Id, select2Id, txtZipCodeId, hfCuntyId, hfTownId)
{
return;
var select1 = document.getElementById(select1Id);
var select2 = document.getElementById(select2Id);
var txtZipCode = document.getElementById(txtZipCodeId);
var hfselect1 = document.getElementById(hfCuntyId);
var hfselect2 = document.getElementById(hfTownId);
if (!select1 || !select2 || !txtZipCode)
return;
select1.selectedIndex = 0;
select2.selectedIndex = 0;
hfselect1.value = "";
hfselect2.value = "";
for (i = 0; i < zipData.Township.length; i++)
{
for (j = 0; j < zipData.Township[i].length; j++)
{
if ((typeof zipData.Township[i][j] != "undefined") &&
(txtZipCode.value.substr(0, 3) == zipData.Township[i][j][0]))
{
select1.selectedIndex = i;
hfselect1.value = i;
FillSelect2ByIndex(i, select2Id, txtZipCodeId, false);
select2.selectedIndex = j;
hfselect2.value = select2.value;
return;
}
}
}
if (txtZipCode.value != "")
{
FillSelect2ByIndex(0, select2Id, txtZipCodeId, false);
txtZipCode.value = "";
txtZipCode.select();
}
}
}
// 建立一個新的執行個體
var AddressEditor = new AddressEditorClass();
@@ -0,0 +1,3 @@
/* Andrew Urquhart : Client-Side Request Object for javascript : http://andrewu.co.uk/tools/request/
COPYRIGHT:You are free to use this script for any use you wish if this comment is left intact. Feel free to enhance the script and send me the updated version. Please don't redistribute. This script is provided as is,with no warranty of any kind. Use it at your own risk. Copyright Andrew R Urquhart; VERSION:#1.3 2005-05-11 17:52 UTC*/
function RObj(ea){var LS="";var QS=new Object();var un="undefined";var x=null;var f="function";var n="number";var r="string";var e1="ERROR:Index out of range in\r\nRequest.QueryString";var e2="ERROR:Wrong number of arguments or invalid property assignment\r\nRequest.QueryString";var e3="ERROR:Object doesn't support this property or method\r\nRequest.QueryString.Key";function Err(arg){if(ea){alert("Request Object:\r\n"+arg)}};function URID(t){var d="";if(t){for(var i=0;i<t.length;++i){var c=t.charAt(i);d+=(c=="+"?" ":c)}};return unescape(d)};function OL(o){var l=0;for(var i in o){if(typeof o[i]!=f){l++}};return l};function AK(key){var auk=true;for(var u in QS){if(typeof QS[u]!=f&&u.toString().toLowerCase()==key.toLowerCase()){auk=false;return u}}if(auk){QS[key]=new Object();QS[key].toString=function(){return TS(QS[key])};QS[key].Count=function(){return OL(QS[key])};QS[key].Count.toString=function(){return OL(QS[key]).toString()};QS[key].Item=function(e){if(typeof e==un){return QS[key]}else {if(typeof e==n){var a=QS[key][Math.ceil(e)];if(typeof a==un){Err(e1+"(\""+key+"\").Item("+e+")")};return a}else {Err("ERROR:Expecting numeric input in\r\nRequest.QueryString(\""+key+"\").Item(\""+e+"\")")}}};QS[key].Item.toString=function(e){if(typeof e==un){return QS[key].toString()}else {var a=QS[key][e];if(typeof a==un){Err(e1+"(\""+key+"\").Item("+e+")")};return a.toString()}};QS[key].Key=function(e){var t=typeof e;if(t==r){var a=QS[key][e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e3+"("+(e?e:"")+")")}};QS[key].Key.toString=function(){return x}};return key};function AVTK(key,val){if(key!=""){var key=AK(key);var l=OL(QS[key]);QS[key][l+1]=val}};function TS(o){var s="";for(var i in o){var ty=typeof o[i];if(ty=="object"){s+=TS(o[i])}else if(ty!=f){s+=o[i]+", "}};var l=s.length;if(l>1){return(s.substring(0,l-2))}return(s==""?x:s)};function KM(k,o){var k=k.toLowerCase();for(var u in o){if(typeof o[u]!=f&&u.toString().toLowerCase()==k){return u}}}if(window.location&&window.location.search){LS=window.location.search;var l=LS.length;if(l>0){LS=LS.substring(1,l);var preAmpAt=0;var ampAt=-1;var eqAt=-1;var k=0;var skip=false;for(var i=0;i<l;++i){var c=LS.charAt(i);if(LS.charAt(preAmpAt)=="="||(preAmpAt==0&&i==0&&c=="=")){skip=true}if(c=="="&&eqAt==-1&&!skip){eqAt=i}if(c=="&"&&ampAt==-1){if(eqAt!=-1){ampAt=i}if(skip){preAmpAt=i+1};skip=false}if(ampAt>eqAt){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,ampAt)));preAmpAt=ampAt+1;eqAt=ampAt=-1;++k}}if(LS.charAt(preAmpAt)!="="&&(preAmpAt!=0||i!=0||c!="=")){if(preAmpAt!=l){if(eqAt!=-1){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,l)))}else if(preAmpAt!=l-1){AVTK(URID(LS.substring(preAmpAt,l)),"")}}if(l==1){AVTK(LS.substring(0,1),"")}}}};var TC=OL(QS);if(!TC){TC=0};QS.toString=function(){return LS.toString()};QS.Count=function(){return(TC?TC:0)};QS.Count.toString=function(){return(TC?TC.toString():"0")};QS.Item=function(e){if(typeof e==un){return LS}else {if(typeof e==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return QS[i]}};Err(e1+"().Item("+e+")")}else {return QS[KM(e,QS)]}};return x};QS.Item.toString=function(){return LS.toString()};QS.Key=function(e){var t=typeof e;if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return i}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e2+"().Key("+(e?e:"")+")")};Err(e1+"().Item("+e+")")};QS.Key.toString=function(){Err(e2+"().Key")};this.QueryString=function(k){if(typeof k==un){return QS}else {var k=KM(k,QS);if(typeof QS[k]==un){t=new Object();t.Count=function(){return 0};t.Count.toString=function(){return "0"};t.toString=function(){return x};t.Item=function(e){return x};t.Item.toString=function(){return x};t.Key=function(e){Err(e3+"("+(e?e:"")+")")};t.Key.toString=function(){return x};return t}if(typeof k==n){return QS.Item(k)}else {return QS[k]}}};this.QueryString.toString=function(){return LS.toString()};this.QueryString.Count=function(){return(TC?TC:0)};this.QueryString.Count.toString=function(){return(TC?TC.toString():"0")};this.QueryString.Item=function(e){if(typeof e==un){return LS.toString()}else {if(typeof e==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return QS[i]}};Err(e1+".Item("+e+")")}else {return QS[KM(e,QS)]}}if(typeof e==n){Err(e1+".Item("+e+")")};return x};this.QueryString.Item.toString=function(){return LS.toString()};this.QueryString.Key=function(e){var t=typeof e;if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]=="object"&&(++c==e)){return i}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e2+".Key("+(e?e:"")+")")};Err(e1+".Item("+e+")")};this.QueryString.Key.toString=function(){Err(e2+".Key")};this.Version=1.3;this.Author="Andrew Urquhart (www.andrewu.co.uk)"};var Request=new RObj(false);
+51
View File
@@ -0,0 +1,51 @@
function FixMenu(menuTable)
{
if (!menuTable) { return };
var tbody = menuTable.getElementsByTagName("TBODY")[0];
var tr = tbody.getElementsByTagName("TR")[0];
for (var i = 0; i < tr.childNodes.length; i++)
{
var td = tr.childNodes[i];
if (td.tagName && td.tagName.toLowerCase() == 'td')
{
var anchor = td.getElementsByTagName("A")[0];
if (anchor)
{
var onClick = td.onmouseover;
td.onclick = (function (e, method) { return function (evt) { method.call(e); if (window.event) { evt = window.event } evt.cancelBubble = true; RemoveRootHover(e); __disappearAfter = 3000; Menu_Collapse(e) } })(td, onClick);
td.onmouseover = (function (e) { return function () { HoverRootMenu(e) } })(td);
anchor.style.cursor = "pointer";
var submnu = WebForm_GetElementById(td.id + "Items");
if (submnu) { anchor.onclick = function () { return false } }
td.onmouseout = (function (e) { return function () { RemoveRootHover(e) } })(td);
}
}
}
}
function HoverRootMenu(item)
{
var node = (item.tagName.toLowerCase() == "td") ? item : item.cells[0];
var data = Menu_GetData(item);
if (!data) { return null; }
var nodeTable = WebForm_GetElementByTagName(node, "table");
if (data.staticHoverClass)
{
nodeTable.hoverClass = data.staticHoverClass;
WebForm_AppendToClassName(nodeTable, data.staticHoverClass);
}
node = nodeTable.rows[0].cells[0].childNodes[0];
if (data.staticHoverHyperLinkClass) { node.hoverHyperLinkClass = data.staticHoverHyperLinkClass; WebForm_AppendToClassName(node, data.staticHoverHyperLinkClass) }
return node;
}
function RemoveRootHover(item)
{
var node = (item.tagName.toLowerCase() == "td") ? item : item.cells[0];
var data = Menu_GetData(item);
if (!data) { return null; }
var nodeTable = WebForm_GetElementByTagName(node, "table");
if (nodeTable.hoverClass) { WebForm_RemoveClassName(nodeTable, nodeTable.hoverClass) }
node = nodeTable.rows[0].cells[0].childNodes[0];
if (node.hoverHyperLinkClass) { WebForm_RemoveClassName(node, node.hoverHyperLinkClass) }
}
+453
View File
@@ -0,0 +1,453 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DatePicker.aspx.cs"
Inherits="WEB.Utility.DatePicker" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>日期挑选</title>
<script type="text/JavaScript" src="./CSJSRequestObject.js"></script>
<script type="text/JavaScript">
//-- Script designed by Liming Weng (victorwon@netease.com)
//-- Download this script and many more at
//-- The Java Magician!! http://javamagic.hypermart.net
var gdCtrl = new Object();
var gcGray = "#808080";
var gcToggle = "#ffff00";
var gcBG = "#eeeeee";
var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth() + 1;
var giDay = gdCurDate.getDate();
var VicPopCal = new Object();
var separator = Request.QueryString("SEPARATOR");
var gMonths = new Array("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月");
function fPopCalendar(popCtrl, dateCtrl, popCal)
{
parent.event.cancelBubble = true;
VicPopCal = popCal;
gdCtrl = dateCtrl;
fSetYearMon(giYear, giMonth);
var point = fGetXY(popCtrl);
with (VicPopCal.style)
{
left = point.x;
top = point.y + popCtrl.offsetHeight + 1;
visibility = 'visible';
}
VicPopCal.focus();
}
function fSetDate(iYear, iMonth, iDay)
{
gdCtrl.value = iYear + separator
+ (("0" + iMonth).length == 2 ? ("0" + iMonth) : iMonth) + separator
+ (("0" + iDay).length == 2 ? ("0" + iDay) : iDay);
if (window.showModalDialog)
{
parent.document.getElementById(Request.QueryString("SENDER")).value = gdCtrl.value;
fCancel();
}
else
{
window.returnValue = gdCtrl.value;
if (Request.QueryString("SENDER"))
if (window.opener)
{
window.opener.document.getElementById(Request.QueryString("SENDER")).value = gdCtrl.value;
}
window.close();
}
}
function fSetSelected(aCell)
{
var iOffset = 0;
var iYear = parseInt(document.getElementById("tbSelYear").value);
var iMonth = parseInt(document.getElementById("tbSelMonth").value);
aCell.bgColor = gcBG;
with (aCell.childNodes[0])
{
var iDay = parseInt(innerHTML);
if (color == gcGray)
return;
iMonth += iOffset;
if (iMonth < 1)
{
iYear--;
iMonth = 12;
}
else if (iMonth > 12)
{
iYear++;
iMonth = 1;
}
}
fSetDate(iYear, iMonth, iDay);
}
function Point(iX, iY)
{
this.x = iX;
this.y = iY;
}
function fBuildCal(iYear, iMonth)
{
var aMonth = new Array();
for (i = 1; i < 7; i++)
aMonth[i] = new Array(i);
var dYearStartDate = new Date(iYear, 0, 1);
var dCalDate = new Date(iYear, iMonth - 1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = new Date(iYear, iMonth, 0).getDate();
var iOffsetLast = new Date(iYear, iMonth - 1, 0).getDate() - iDayOfFirst + 1;
var iDate = 1;
var iNext = 1;
var iJuilet = Math.floor((dCalDate.getTime() - dYearStartDate.getTime()) / 86400000);
/*
if (typeof BHRD != "undefined" && BHRD[iYear])
{
for (d = 0; d < 7; d++)
aMonth[1][d] = (d < iDayOfFirst) ? -(iOffsetLast+d) : (iDate++) + "," + BHRD[iYear].charAt(iJuilet + iDate - 2);
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate <= iDaysInMonth) ? (iDate++) + "," + BHRD[iYear].charAt(iJuilet + iDate - 2) : -(iNext++);
}
else
*/
{
for (d = 0; d < 7; d++)
//aMonth[1][d] = (d < iDayOfFirst) ? -(iOffsetLast + d) : (iDate++) + ",.";
aMonth[1][d] = (d < iDayOfFirst) ? -(iOffsetLast + d) : (iDate++);
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
//aMonth[w][d] = (iDate <= iDaysInMonth) ? (iDate++) + ",." : -(iNext++);
aMonth[w][d] = (iDate <= iDaysInMonth) ? (iDate++) : -(iNext++);
}
return aMonth;
}
function fDrawCal(iYear, iMonth, iCellWidth, iDateTextSize)
{
var WeekDay = new Array("日", "一", "二", "三", "四", "五", "六");
var styleTD = " bgcolor='" + gcBG + "' width='" + iCellWidth + "' bordercolor='" + gcBG + "' "
+ "style='font:bold " + iDateTextSize + "pt Arial; text-align:center; vertical-align:middle; cursor:pointer; color:#008800;'";
with (document)
{
write("<tr>");
for (i = 0; i < 7; i++)
write("<td " + styleTD + ">" + WeekDay[i] + "</td>");
write("</tr>");
for (w = 1; w < 7; w++)
{
write("<tr>");
for (d = 0; d < 7; d++)
{
write("<td id=calCell " + styleTD + "' name='calCell' "
+ "onmouseover=\"this.bgColor=gcToggle\" onmouseout=\"this.bgColor=gcBG\" "
+ "onclick='fSetSelected(this)'>");
write("<font name='cellText' id='cellText'></font>");
write("</td>")
}
write("</tr>");
}
}
}
function fUpdateCal(iYear, iMonth)
{
iYear = (iYear * 1) + CY11;
myMonth = fBuildCal(iYear, iMonth);
PrevYear.disabled = "disabled";
NextYear.disabled = "disabled";
PrevMonth.disabled = "disabled";
NextMonth.disabled = "disabled";
try
{
var i = 0;
for (w = 0; w < 6; w++)
for (d = 0; d < 7; d++)
{
if (document.charset)
{
with (cellText[(7 * w) + d])
{
Victor = i++;
// 上一個月或下一個月
if (myMonth[w + 1][d] < 0)
{
color = gcGray;
innerHTML = -myMonth[w + 1][d];
calCell[(7 * w) + d].style.cursor = "default";
}
// 本月
else
{
//var sDateData = myMonth[w + 1][d].split(",");
var sDateData = myMonth[w + 1][d];
var sType = sDateData.length > 1 ? sDateData[1] : "";
var sDate = sDateData[0];
/*
switch (sType)
{
case ".": // 無資料
color = ((d == 0) || (d == 6)) ? "red" : "black";
break;
case "-": // 上班日
color = "black";
break;
case "N": // 國定假日或民俗假
color = "magenta";
break;
case "H": // 例假日
color = "red";
break;
case "V": // 彈性休假
color = "blue";
break;
case "B": // 補班
color = "green";
break;
}
innerHTML = sDateData[0];
*/
color = ((d == 0) || (d == 6)) ? "red" : "black";
innerHTML = sDateData;
calCell[(7 * w) + d].style.cursor = "pointer";
}
}
}
else
{
with (document.getElementsByName("cellText")[(7 * w) + d])
{
Victor = i++;
if (myMonth[w + 1][d] < 0)
{
color = gcGray;
innerHTML = -myMonth[w + 1][d];
document.getElementsByName("calCell")[(7 * w) + d].style.cursor = "default";
}
else
{
color = ((d == 0) || (d == 6)) ? "red" : "black";
innerHTML = myMonth[w + 1][d];
}
}
}
}
}
finally
{
PrevYear.disabled = "";
NextYear.disabled = "";
PrevMonth.disabled = "";
NextMonth.disabled = "";
}
}
function fSetYearMon(iYear, iMon)
{
tbSelMonth.options[iMon - 1].selected = true;
tbSelYear.value = iYear;
fUpdateCal(iYear, iMon);
}
function fPrevYear()
{
var iYear = tbSelYear.value;
var iMon = tbSelMonth.value;
fSetYearMon(--iYear, iMon);
}
function fNextYear()
{
var iYear = tbSelYear.value;
var iMon = tbSelMonth.value;
fSetYearMon(++iYear, iMon);
}
function fPrevMonth()
{
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;
if (--iMon < 1)
{
iMon = 12;
iYear--;
}
fSetYearMon(iYear, iMon);
}
function fNextMonth()
{
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;
if (++iMon > 12)
{
iMon = 1;
iYear++;
}
fSetYearMon(iYear, iMon);
}
function fGetXY(aTag)
{
var oTmp = aTag;
var pt = new Point(0, 0);
do
{
pt.x += oTmp.offsetLeft;
pt.y += oTmp.offsetTop;
oTmp = oTmp.offsetParent;
}
while (oTmp.tagName != "BODY");
return pt;
}
function fCancel()
{
if (window.showModalDialog)
{
parent.document.getElementById(Request.QueryString("SENDER")).focus();
var datepicker = parent.document.getElementById("DatePicker");
datepicker.style.top = 0;
datepicker.style.left = 0;
datepicker.style.width = 0;
datepicker.style.height = 0;
}
else
{
window.opener.document.getElementById(Request.QueryString("SENDER")).focus();
window.returnValue = "";
window.close();
}
}
</script>
</head>
<body bgcolor="#6699cc" style="margin: 0px">
<form id="form1" runat="server">
<div id="content" align="center" style="vertical-align: middle; padding:8px">
<table id='popTable' border='0' bgcolor='#6699cc' cellpadding="0"
cellspacing="0">
<tr style="height:28px;">
<td valign='top' align='center'>
<!--年度輸入-->
<input type='button' value='<' name='PrevYear' id='PrevYear'
onclick='fPrevYear()' disabled="disabled" style='height: 24px;
width: 24px; font: 10pt Arial; cursor: pointer;' />
</td>
<td valign='top' align='center'>
<input type='text' name='tbSelYear' id='tbSelYear' onkeydown='fUpdateCal(tbSelYear.value, tbSelMonth.value);'
style='width: 40px; font: 10pt Arial; border-style: groove'
runat="server" />
</td>
<td valign='top' align='center'>
<input type='button' value='>' name='NextYear' id='NextYear'
onclick='fNextYear()' disabled="disabled" style='height: 24px;
width: 24px; font: 10pt Arial; cursor: pointer' />
<!-- 月份挑選 -->
</td>
<td valign='top' align='center'>
<input type='button' name='PrevMonth' id='PrevMonth' disabled="disabled"
value='<' style='height: 24px; width: 24px; font: 10pt Arial;
cursor: pointer' onclick='fPrevMonth()' />
</td>
<td valign='top' align='center'>
<select name='tbSelMonth' id='tbSelMonth' onchange='fUpdateCal(tbSelYear.value, tbSelMonth.value)'
style='width: 70px; height: 21px; font: 10pt Arial; border-style: groove'>
<script type="text/javascript">
for (i = 0; i < 12; i++)
document.write("<option value='" + (i + 1) + "'>" + gMonths[i] + "</option>");
</script>
</select>
</td>
<td valign='top' align='center'>
<input type='button' name='NextMonth' id='NextMonth' disabled="disabled"
value='>' style='height: 24px; width: 24px; font: 10pt Arial;
cursor: pointer' onclick='fNextMonth()' />
</td>
</tr>
<tr>
<td align='center' colspan="6">
<div style='background-color: teal;'>
<table width='100%' border='0' cellpadding='2'>
<script type="text/javascript">
fDrawCal(giYear, giMonth, 19, 11);
</script>
</table>
</div>
</td>
</tr>
<tr>
<td align='center' colspan="6">
<input type='button' name='Close' value='关闭' onclick='fCancel()'
style='height: 24px; width: 80px; font: 10pt Arial; cursor: pointer;' />
</td>
</tr>
</table>
<script type="text/javascript">
var CY11 = 0;
if (Request.QueryString("CY11"))
CY11 = parseInt(Request.QueryString("CY11"), 10);
if (Request.QueryString("SENDER"))
{
var oldDate = "";
if (window.showModalDialog)
oldDate = parent.document.getElementById(Request.QueryString("SENDER")).value;
else if (window.opener)
oldDate = window.opener.document.getElementById(Request.QueryString("SENDER")).value;
if (oldDate != "")
{
if (separator != "")
while (oldDate.indexOf(separator) != -1)
oldDate = oldDate.replace(separator, "");
giYear = (parseInt(oldDate.substr(0, oldDate.length - 4), 10) * 1) + CY11;
giMonth = parseInt(oldDate.substr(oldDate.length - 4, 2), 10);
giDay = parseInt(oldDate.substr(oldDate.length - 2, 2), 10);
}
}
var tbSelYear = document.getElementById("tbSelYear");
var tbSelMonth = document.getElementById("tbSelMonth");
var PrevYear = document.getElementById("PrevYear");
var NextYear = document.getElementById("NextYear");
var PrevMonth = document.getElementById("PrevMonth");
var NextMonth = document.getElementById("NextMonth");
tbSelYear.value = giYear - CY11;
tbSelMonth.value = giMonth;
fUpdateCal(tbSelYear.value, tbSelMonth.value);
window.returnValue = "";
</script>
</div>
</form>
</body>
</html>
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WEB.Utility
{
public partial class DatePicker : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
+35
View File
@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <自動產生>
// 這段程式碼是由工具產生的。
//
// 變更這個檔案可能會導致不正確的行為,而且如果已重新產生
// 程式碼,則會遺失變更。
// </自動產生>
//------------------------------------------------------------------------------
namespace WEB.Utility
{
public partial class DatePicker
{
/// <summary>
/// form1 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// tbSelYear 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlInputText tbSelYear;
}
}
+544
View File
@@ -0,0 +1,544 @@
//--------------------------------------------
// 開窗挑選日期
//--------------------------------------------
//--------------------------------------------
// 這裡是日期視窗要用的變數
//--------------------------------------------
var gdCtrl = new Object();
var gcGray = "#808080";
var gcToggle = "#ffff00";
var gcBG = "#eeeeee";
var gcTableBackgroundColor = "#eeeeee";
var cy11 = 0;
var separator = "/";
var dateOrder = "YMD";
var objValue;
var datePicker;
var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth() + 1;
var giDay = gdCurDate.getDate();
var VicPopCal = new Object();
// var separator = Request.QueryString("SEPARATOR");
// 中文
var gMonths = new Array("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月");
var gWeekDay = new Array("日", "一", "二", "三", "四", "五", "六");
var gCloseText = "關閉";
var gClearText = "清除";
// 英文
//var gMonths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
//var gWeekDay = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
//var gCloseText = "Close";
//var gClearText = "Clear";
var styleTD = " bgcolor='" + gcBG + "' width='19' bordercolor='" + gcBG + "' "
+ "style='font:bold 10pt Courier; text-align:center; vertical-align:middle; cursor:pointer; color:#008800;'";
var html1 =
"<div style='padding: 8px;'>"
+ "<table style='border:0; background-color:F0F0F0'>"
+ " <tr>"
+ " <td valign='middle' align='center'>"
+ " <table id='popTable' style='border:0; background-color:F0F0F0'>"
+ " <tr>"
+ " <td valign='middle' align='center'>"
+ " <!--年度輸入-->"
+ " <input type='button' value='<' name='PrevYear' id='PrevYear'"
+ " onclick='fPrevYear()' disabled=\"disabled\" style='height: 24px;"
+ " width: 24px; font: 10pt Arial; cursor: pointer;'>"
+ " <input type='text' name='tbSelYear' id='tbSelYear' onkeydown='fUpdateCal(tbSelYear.value, tbSelMonth.value);'"
+ " style='width: 4em; font: 11pt Arial;'>"
+ " <input type='button' value='>' name='NextYear' id='NextYear'"
+ " onclick='fNextYear()' disabled=\"disabled\" style='height: 24px;"
+ " width: 24px; font: 10pt Arial; cursor: pointer' />"
+ " <!-- 月份挑選 -->"
+ " <input type='button' name='PrevMonth' id='PrevMonth' disabled=\"disabled\""
+ " value='<' style='height: 24px; width: 24px; font: 10pt Arial;"
+ " cursor: pointer' onclick='fPrevMonth()' />"
+ " <select name='tbSelMonth' id='tbSelMonth' onchange='fUpdateCal(tbSelYear.value, tbSelMonth.value)'"
+ " style='width: 70; font: 11pt Arial; border-style: groove'>"
+ " <option value='1'>" + gMonths[0] + "</option>"
+ " <option value='2'>" + gMonths[1] + "</option>"
+ " <option value='3'>" + gMonths[2] + "</option>"
+ " <option value='4'>" + gMonths[3] + "</option>"
+ " <option value='5'>" + gMonths[4] + "</option>"
+ " <option value='6'>" + gMonths[5] + "</option>"
+ " <option value='7'>" + gMonths[6] + "</option>"
+ " <option value='8'>" + gMonths[7] + "</option>"
+ " <option value='9'>" + gMonths[8] + "</option>"
+ " <option value='10'>" + gMonths[9] + "</option>"
+ " <option value='11'>" + gMonths[10] + "</option>"
+ " <option value='12'>" + gMonths[11] + "</option>"
+ " </select>"
+ " <input type='button' name='NextMonth' id='NextMonth' disabled=\"disabled\""
+ " value='>' style='height: 24px; width: 24px; font: 10pt Arial;"
+ " cursor: pointer' onclick='fNextMonth()' />"
+ " </td>"
+ " </tr>"
+ " <tr>"
+ " <td align='center'>"
+ " <div style='background-color: " + gcTableBackgroundColor + ";'>"
+ " <table width='100%' border='0' cellpadding='2'>";
var html2 =
" </table>"
+ " </div>"
+ " </td>"
+ " </tr>"
+ " <tr>"
+ " <td align='center'>"
+ " <input type='button' name='Close' value='" + gCloseText + "' onclick='fCancel()'"
+ " style='height: 24px; width: 60px; font: 10pt Arial; cursor: pointer;' />"
+ " <input type='button' name='Close' value='" + gClearText + "' onclick='fClear()'"
+ " style='height: 24px; width: 60px; font: 10pt Arial; cursor: pointer;' />"
+ " </td>"
+ " </tr>"
+ " </table>"
+ " </td>"
+ " </tr>"
+ "</table>"
+ "<div>";
var tbSelYear;
var tbSelMonth;
var PrevYear;
var NextYear;
var PrevMonth;
var NextMonth;
/* --------- */
// 挑選日期
function PickDate(objid, Acy11, Aseparator, AdateOrder)
{
var aValue = "";
cy11 = Acy11;
separator = Aseparator;
dateOrder = AdateOrder;
// 畫月曆的框框
datePicker = document.getElementById("XX_SELECT_DIV");
//datePicker.style.width = "";
//datePicker.style.height = "";
datePicker.innerHTML = html1 + fDrawCal(giYear, giMonth, 19, 12) + html2;
// Parse 原先的值
objValue = document.getElementById(objid);
oldDate = objValue.value;
if (oldDate != "")
{
if (separator != "")
while (oldDate.indexOf(separator) != -1)
oldDate = oldDate.replace(separator, "");
switch (dateOrder)
{
case "DMY":
giYear = (parseInt(oldDate.substr(4, oldDate.length - 4), 10) * 1) + cy11;
giMonth = parseInt(oldDate.substr(2, 2), 10);
giDay = parseInt(oldDate.substr(0, 2), 10);
break;
case "MDY":
giYear = (parseInt(oldDate.substr(4, oldDate.length - 4), 10) * 1) + cy11;
giMonth = parseInt(oldDate.substr(0, 2), 10);
giDay = parseInt(oldDate.substr(2, 2), 10);
break;
default:
giYear = (parseInt(oldDate.substr(0, oldDate.length - 4), 10) * 1) + cy11;
giMonth = parseInt(oldDate.substr(oldDate.length - 4, 2), 10);
giDay = parseInt(oldDate.substr(oldDate.length - 2, 2), 10);
break;
}
}
//
tbSelYear = document.getElementById("tbSelYear");
tbSelMonth = document.getElementById("tbSelMonth");
PrevYear = document.getElementById("PrevYear");
NextYear = document.getElementById("NextYear");
PrevMonth = document.getElementById("PrevMonth");
NextMonth = document.getElementById("NextMonth");
tbSelYear.value = giYear - cy11;
tbSelMonth.value = giMonth;
fUpdateCal(tbSelYear.value, tbSelMonth.value);
datePicker.style.position = "absolute";
datePicker.style.display = "block";
datePicker.style.zIndex = "999";
datePicker.style.border = "solid 1px black";
datePicker.style.padding = "3px";
datePicker.style.backgroundColor = "#F0F0F0";
datePicker.style.left = offsetLeft(objValue) + "px";
datePicker.style.top = offsetTop(objValue) + objValue.offsetHeight + "px";
if (datePicker.offsetTop + datePicker.offsetHeight > document.body.clientHeight)
datePicker.style.top = document.body.clientHeight - datePicker.offsetHeight + "px";
if (datePicker.offsetLeft + datePicker.offsetWidth > document.body.clientWidth)
datePicker.style.left = document.body.clientWidth - datePicker.offsetWidth + "px";
}
// 跳出日期挑選
function fPopCalendar(popCtrl, dateCtrl, popCal)
{
parent.event.cancelBubble = true;
VicPopCal = popCal;
gdCtrl = dateCtrl;
fSetYearMon(giYear, giMonth);
var point = fGetXY(popCtrl);
with (VicPopCal.style)
{
left = point.x;
top = point.y + popCtrl.offsetHeight + 1;
visibility = 'visible';
}
VicPopCal.focus();
}
// 挑選日期之後,更新畫面上的值
function fSetDate(iYear, iMonth, iDay)
{
switch (dateOrder)
{
case "DMY":
gdCtrl.value = (("0" + iDay).length == 2 ? ("0" + iDay) : iDay) + separator
+ (("0" + iMonth).length == 2 ? ("0" + iMonth) : iMonth) + separator
+ iYear;
break;
case "MDY":
gdCtrl.value = (("0" + iMonth).length == 2 ? ("0" + iMonth) : iMonth) + separator
+ (("0" + iDay).length == 2 ? ("0" + iDay) : iDay) + separator
+ iYear;
break;
default:
gdCtrl.value = iYear + separator
+ (("0" + iMonth).length == 2 ? ("0" + iMonth) : iMonth) + separator
+ (("0" + iDay).length == 2 ? ("0" + iDay) : iDay);
break;
}
objValue.value = gdCtrl.value;
// objValue.onchange();
if ("createEvent" in document)
{
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
objValue.dispatchEvent(evt);
}
else
objValue.fireEvent("onchange");
fCancel();
}
// 畫面點選日期格子
function fSetSelected(aCell)
{
var iOffset = 0;
var iYear = parseInt(document.getElementById("tbSelYear").value);
var iMonth = parseInt(document.getElementById("tbSelMonth").value);
aCell.bgColor = gcBG;
with (aCell.childNodes[0])
{
var iDay = parseInt(innerHTML);
if (color == gcGray)
return;
iMonth += iOffset;
if (iMonth < 1)
{
iYear--;
iMonth = 12;
}
else if (iMonth > 12)
{
iYear++;
iMonth = 1;
}
}
fSetDate(iYear, iMonth, iDay);
}
function Point(iX, iY)
{
this.x = iX;
this.y = iY;
}
function fBuildCal(iYear, iMonth)
{
var aMonth = new Array();
for (i = 1; i < 7; i++)
aMonth[i] = new Array(i);
var dYearStartDate = new Date(iYear, 0, 1);
var dCalDate = new Date(iYear, iMonth - 1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = new Date(iYear, iMonth, 0).getDate();
var iOffsetLast = new Date(iYear, iMonth - 1, 0).getDate() - iDayOfFirst + 1;
var iDate = 1;
var iNext = 1;
var iJuilet = Math.floor((dCalDate.getTime() - dYearStartDate.getTime()) / 86400000);
if (typeof BHRD != "undefined" && BHRD[iYear])
{
for (d = 0; d < 7; d++)
aMonth[1][d] = (d < iDayOfFirst) ? -(iOffsetLast + d) : (iDate++) + "," + BHRD[iYear].charAt(iJuilet + iDate - 2);
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate <= iDaysInMonth) ? (iDate++) + "," + BHRD[iYear].charAt(iJuilet + iDate - 2) : -(iNext++);
}
else
{
for (d = 0; d < 7; d++)
aMonth[1][d] = (d < iDayOfFirst) ? -(iOffsetLast + d) : (iDate++) + ",.";
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate <= iDaysInMonth) ? (iDate++) + ",." : -(iNext++);
}
return aMonth;
}
// 畫月曆外框
function fDrawCal(iYear, iMonth, iCellWidth, iDateTextSize)
{
var styleTD = " bgcolor='" + gcBG + "' width='" + iCellWidth + "' bordercolor='" + gcBG + "' "
+ "style='font:bold " + iDateTextSize + "pt Courier; text-align:center; vertical-align:middle; cursor:pointer; color:#008800; padding:3px 0;'";
var result = "";
result += "<tr>";
for (i = 0; i < 7; i++)
result += "<td " + styleTD + ">" + gWeekDay[i] + "</td>";
result += "</tr>";
for (w = 1; w < 7; w++)
{
result += "<tr>";
for (d = 0; d < 7; d++)
{
result += "<td id=calCell " + styleTD + "' name='calCell' "
+ "onmouseover=\"this.bgColor=gcToggle\" onmouseout=\"this.bgColor=gcBG\" "
+ "onclick='fSetSelected(this)'>";
result += "<font name='cellText' id='cellText'></font>";
result += "</td>";
}
result += "</tr>";
}
return result;
}
// 畫月曆內容
function fUpdateCal(iYear, iMonth)
{
iYear = (iYear * 1) + cy11;
myMonth = fBuildCal(iYear, iMonth);
PrevYear.disabled = "disabled";
NextYear.disabled = "disabled";
PrevMonth.disabled = "disabled";
NextMonth.disabled = "disabled";
try
{
var i = 0;
for (w = 0; w < 6; w++)
for (d = 0; d < 7; d++)
{
//if (document.charset)
//{
// with (cellText[(7 * w) + d])
// {
// Victor = i++;
// // 上一個月或下一個月
// if (myMonth[w + 1][d] < 0)
// {
// color = gcGray;
// innerHTML = -myMonth[w + 1][d];
// calCell[(7 * w) + d].style.cursor = "default";
// calCell[(7 * w) + d].style["background-color"] = "";
// }
// // 本月
// else
// {
// var sDateData = myMonth[w + 1][d].split(",");
// var sType = sDateData.length > 1 ? sDateData[1] : "";
// var sDate = sDateData[0];
// switch (sType)
// {
// case ".": // 無資料
// color = ((d == 0) || (d == 6)) ? "red" : "black";
// break;
// case "-": // 上班日
// color = "black";
// break;
// case "N": // 國定假日或民俗假
// color = "magenta";
// break;
// case "H": // 例假日
// color = "red";
// break;
// case "V": // 彈性休假
// color = "blue";
// break;
// case "B": // 補班
// color = "green";
// break;
// }
// innerHTML = sDateData[0];
// // 選擇到的那一天塗底色
// if (iYear == giYear && iMonth == giMonth && sDate == giDay)
// calCell[(7 * w) + d].style["background-color"] = "#FFB0FF";
// else
// calCell[(7 * w) + d].style["background-color"] = "";
// calCell[(7 * w) + d].style.cursor = "pointer";
// }
// }
//}
//else
//{
with (document.getElementsByName("cellText")[(7 * w) + d])
{
var thisCell = document.getElementsByName("calCell")[(7 * w) + d];
Victor = i++;
if (myMonth[w + 1][d] < 0)
{
color = gcGray;
innerHTML = -myMonth[w + 1][d];
thisCell.style.cursor = "default";
}
else
{
var sDateData = myMonth[w + 1][d].split(",");
var sType = sDateData.length > 1 ? sDateData[1] : "";
var sDate = sDateData[0];
switch (sType)
{
case ".": // 無資料
color = ((d == 0) || (d == 6)) ? "red" : "black";
break;
case "-": // 上班日
color = "black";
break;
case "N": // 國定假日或民俗假
color = "magenta";
break;
case "H": // 例假日
color = "red";
break;
case "V": // 彈性休假
color = "blue";
break;
case "B": // 補班
color = "green";
break;
}
innerHTML = sDateData[0];
// 選擇到的那一天塗底色
if (iYear == giYear && iMonth == giMonth && sDate == giDay)
thisCell.style.backgroundColor = "#FFB0FF";
else
thisCell.style.backgroundColor = "";
thisCell.style.cursor = "pointer";
}
}
//}
}
}
finally
{
PrevYear.disabled = "";
NextYear.disabled = "";
PrevMonth.disabled = "";
NextMonth.disabled = "";
}
}
function fSetYearMon(iYear, iMon)
{
tbSelMonth.options[iMon - 1].selected = true;
tbSelYear.value = iYear;
fUpdateCal(iYear, iMon);
}
function fPrevYear()
{
var iYear = tbSelYear.value;
var iMon = tbSelMonth.value;
fSetYearMon(--iYear, iMon);
}
function fNextYear()
{
var iYear = tbSelYear.value;
var iMon = tbSelMonth.value;
fSetYearMon(++iYear, iMon);
}
function fPrevMonth()
{
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;
if (--iMon < 1)
{
iMon = 12;
iYear--;
}
fSetYearMon(iYear, iMon);
}
function fNextMonth()
{
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;
if (++iMon > 12)
{
iMon = 1;
iYear++;
}
fSetYearMon(iYear, iMon);
}
function fGetXY(aTag)
{
var oTmp = aTag;
var pt = new Point(0, 0);
do
{
pt.x += oTmp.offsetLeft;
pt.y += oTmp.offsetTop;
oTmp = oTmp.offsetParent;
}
while (oTmp.tagName != "BODY");
return pt;
}
function fCancel()
{
datePicker.style.display = "none";
}
function fClear()
{
objValue.value = "";
fCancel();
}
+442
View File
@@ -0,0 +1,442 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DatePicker1.aspx.cs"
Inherits="utility_DatePicker" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>日期挑选</title>
<script type="text/JavaScript" src="./CSJSRequestObject.js"></script>
</head>
<script type="text/JavaScript">
//-- Script designed by Liming Weng (victorwon@netease.com)
//-- Download this script and many more at
//-- The Java Magician!! http://javamagic.hypermart.net
var gdCtrl = new Object();
var gcGray = "#808080";
var gcToggle = "#ffff00";
var gcBG = "#eeeeee";
var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth() + 1;
var giDay = gdCurDate.getDate();
var VicPopCal = new Object();
var separator = Request.QueryString("SEPARATOR");
var gMonths = new Array("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月");
function fPopCalendar(popCtrl, dateCtrl, popCal)
{
parent.event.cancelBubble = true;
VicPopCal = popCal;
gdCtrl = dateCtrl;
fSetYearMon(giYear, giMonth);
var point = fGetXY(popCtrl);
with (VicPopCal.style)
{
left = point.x;
top = point.y + popCtrl.offsetHeight + 1;
visibility = 'visible';
}
VicPopCal.focus();
}
function fSetDate(iYear, iMonth, iDay)
{
gdCtrl.value = iYear + separator
+ (("0" + iMonth).length == 2 ? ("0" + iMonth) : iMonth) + separator
+ (("0" + iDay).length == 2 ? ("0" + iDay) : iDay);
if (window.showModalDialog)
{
parent.document.getElementById(Request.QueryString("SENDER")).value = gdCtrl.value;
fCancel();
}
else
{
window.returnValue = gdCtrl.value;
if (Request.QueryString("SENDER"))
if (window.opener)
{
window.opener.document.getElementById(Request.QueryString("SENDER")).value = gdCtrl.value;
}
window.close();
}
}
function fSetSelected(aCell)
{
var iOffset = 0;
var iYear = parseInt(document.getElementById("tbSelYear").value);
var iMonth = parseInt(document.getElementById("tbSelMonth").value);
aCell.bgColor = gcBG;
with (aCell.childNodes[0])
{
var iDay = parseInt(innerHTML);
if (color == gcGray)
return;
iMonth += iOffset;
if (iMonth < 1)
{
iYear--;
iMonth = 12;
}
else if (iMonth > 12)
{
iYear++;
iMonth = 1;
}
}
fSetDate(iYear, iMonth, iDay);
}
function Point(iX, iY)
{
this.x = iX;
this.y = iY;
}
function fBuildCal(iYear, iMonth)
{
var aMonth = new Array();
for (i = 1; i < 7; i++)
aMonth[i] = new Array(i);
var dYearStartDate = new Date(iYear, 0, 1);
var dCalDate = new Date(iYear, iMonth - 1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = new Date(iYear, iMonth, 0).getDate();
var iOffsetLast = new Date(iYear, iMonth - 1, 0).getDate() - iDayOfFirst + 1;
var iDate = 1;
var iNext = 1;
var iJuilet = Math.floor((dCalDate.getTime() - dYearStartDate.getTime()) / 86400000);
/*
if (typeof BHRD != "undefined" && BHRD[iYear])
{
for (d = 0; d < 7; d++)
aMonth[1][d] = (d < iDayOfFirst) ? -(iOffsetLast+d) : (iDate++) + "," + BHRD[iYear].charAt(iJuilet + iDate - 2);
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate <= iDaysInMonth) ? (iDate++) + "," + BHRD[iYear].charAt(iJuilet + iDate - 2) : -(iNext++);
}
else
*/
{
for (d = 0; d < 7; d++)
aMonth[1][d] = (d < iDayOfFirst) ? -(iOffsetLast + d) : (iDate++) + ",.";
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate <= iDaysInMonth) ? (iDate++) + ",." : -(iNext++);
}
return aMonth;
}
function fDrawCal(iYear, iMonth, iCellWidth, iDateTextSize)
{
var WeekDay = new Array("日", "一", "二", "三", "四", "五", "六");
var styleTD = " bgcolor='" + gcBG + "' width='" + iCellWidth + "' bordercolor='" + gcBG + "' "
+ "style='font:bold " + iDateTextSize + "pt Courier; text-align:center; vertical-align:middle; cursor:pointer; color:#008800;'";
with (document)
{
write("<tr>");
for (i = 0; i < 7; i++)
write("<td " + styleTD + ">" + WeekDay[i] + "</td>");
write("</tr>");
for (w = 1; w < 7; w++)
{
write("<tr>");
for (d = 0; d < 7; d++)
{
write("<td id=calCell " + styleTD + "' name='calCell' "
+ "onmouseover=\"this.bgColor=gcToggle\" onmouseout=\"this.bgColor=gcBG\" "
+ "onclick='fSetSelected(this)'>");
write("<font name='cellText' id='cellText'></font>");
write("</td>")
}
write("</tr>");
}
}
}
function fUpdateCal(iYear, iMonth)
{
iYear = (iYear * 1) + CY11;
myMonth = fBuildCal(iYear, iMonth);
PrevYear.disabled = "disabled";
NextYear.disabled = "disabled";
PrevMonth.disabled = "disabled";
NextMonth.disabled = "disabled";
try
{
var i = 0;
for (w = 0; w < 6; w++)
for (d = 0; d < 7; d++)
{
if (document.charset)
{
with (cellText[(7 * w) + d])
{
Victor = i++;
// 上一個月或下一個月
if (myMonth[w + 1][d] < 0)
{
color = gcGray;
innerHTML = -myMonth[w + 1][d];
calCell[(7 * w) + d].style.cursor = "default";
}
// 本月
else
{
var sDateData = myMonth[w + 1][d].split(",");
var sType = sDateData.length > 1 ? sDateData[1] : "";
var sDate = sDateData[0];
switch (sType)
{
case ".": // 無資料
color = ((d == 0) || (d == 6)) ? "red" : "black";
break;
case "-": // 上班日
color = "black";
break;
case "N": // 國定假日或民俗假
color = "magenta";
break;
case "H": // 例假日
color = "red";
break;
case "V": // 彈性休假
color = "blue";
break;
case "B": // 補班
color = "green";
break;
}
innerHTML = sDateData[0];
calCell[(7 * w) + d].style.cursor = "pointer";
}
}
}
else
{
with (document.getElementsByName("cellText")[(7 * w) + d])
{
Victor = i++;
if (myMonth[w + 1][d] < 0)
{
color = gcGray;
innerHTML = -myMonth[w + 1][d];
document.getElementsByName("calCell")[(7 * w) + d].style.cursor = "default";
}
else
{
color = ((d == 0) || (d == 6)) ? "red" : "black";
innerHTML = myMonth[w + 1][d];
}
}
}
}
}
finally
{
PrevYear.disabled = "";
NextYear.disabled = "";
PrevMonth.disabled = "";
NextMonth.disabled = "";
}
}
function fSetYearMon(iYear, iMon)
{
tbSelMonth.options[iMon - 1].selected = true;
tbSelYear.value = iYear;
fUpdateCal(iYear, iMon);
}
function fPrevYear()
{
var iYear = tbSelYear.value;
var iMon = tbSelMonth.value;
fSetYearMon(--iYear, iMon);
}
function fNextYear()
{
var iYear = tbSelYear.value;
var iMon = tbSelMonth.value;
fSetYearMon(++iYear, iMon);
}
function fPrevMonth()
{
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;
if (--iMon < 1)
{
iMon = 12;
iYear--;
}
fSetYearMon(iYear, iMon);
}
function fNextMonth()
{
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;
if (++iMon > 12)
{
iMon = 1;
iYear++;
}
fSetYearMon(iYear, iMon);
}
function fGetXY(aTag)
{
var oTmp = aTag;
var pt = new Point(0, 0);
do
{
pt.x += oTmp.offsetLeft;
pt.y += oTmp.offsetTop;
oTmp = oTmp.offsetParent;
}
while (oTmp.tagName != "BODY");
return pt;
}
function fCancel()
{
if (window.showModalDialog)
{
parent.document.getElementById(Request.QueryString("SENDER")).focus();
var datepicker = parent.document.getElementById("DatePicker");
datepicker.style.top = 0;
datepicker.style.left = 0;
datepicker.style.width = 0;
datepicker.style.height = 0;
}
else
{
window.opener.document.getElementById(Request.QueryString("SENDER")).focus();
window.returnValue = "";
window.close();
}
}
</script>
<body bgcolor="#6699cc" style="margin: 0px">
<form id="form1" runat="server">
<div id="content" align="center" style="vertical-align: middle">
<table border='0' bgcolor='#6699cc'>
<tr>
<td valign='middle' align='center'>
<table id='popTable' border='0' bgcolor='#6699cc'>
<tr>
<td valign='middle' align='center'>
<!--年度輸入-->
&nbsp;<input type='button' value='<' name='PrevYear' id='PrevYear'
onclick='fPrevYear()' disabled="disabled" style='height: 24px;
width: 24px; font: 11pt Arial; cursor: pointer;' />
<input type='text' name='tbSelYear' id='tbSelYear' onkeydown='fUpdateCal(tbSelYear.value, tbSelMonth.value);'
style='width: 40px; font: 11pt Arial; border-style: groove'
runat="server" />
<input type='button' value='>' name='NextYear' id='NextYear'
onclick='fNextYear()' disabled="disabled" style='height: 24px;
width: 24px; font: 11pt Arial; cursor: pointer' />&nbsp;
<!-- 月份挑選 -->
&nbsp;<input type='button' name='PrevMonth' id='PrevMonth' disabled="disabled"
value='<' style='height: 24px; width: 24px; font: 11pt Arial;
cursor: pointer' onclick='fPrevMonth()' />
<select name='tbSelMonth' id='tbSelMonth' onchange='fUpdateCal(tbSelYear.value, tbSelMonth.value)'
style='width: 70; height: 21; font: 11pt Arial; border-style: groove'>
<script type="text/javascript">
for (i = 0; i < 12; i++)
document.write("<option value='" + (i + 1) + "'>" + gMonths[i] + "</option>");
</script>
</select>
<input type='button' name='NextMonth' id='NextMonth' disabled="disabled"
value='>' style='height: 24px; width: 24px; font: 11pt Arial;
cursor: pointer' onclick='fNextMonth()' />
</td>
</tr>
<tr>
<td align='center'>
<div style='background-color: teal;'>
<table width='100%' border='0' cellpadding='2'>
<script type="text/javascript">
fDrawCal(giYear, giMonth, 19, 12);
</script>
</table>
</div>
</td>
</tr>
<tr>
<td align='center'>
<input type='button' name='Close' value='關閉' onclick='fCancel()'
style='height: 24; width: 60; font: 11pt Arial; cursor: pointer;' />
</td>
</tr>
</table>
</td>
</tr>
</table>
<script type="text/javascript">
var CY11 = 0;
if (Request.QueryString("CY11"))
CY11 = parseInt(Request.QueryString("CY11"), 10);
if (Request.QueryString("SENDER"))
{
var oldDate = "";
if (window.showModalDialog)
oldDate = parent.document.getElementById(Request.QueryString("SENDER")).value;
else if (window.opener)
oldDate = window.opener.document.getElementById(Request.QueryString("SENDER")).value;
if (oldDate != "")
{
if (separator != "")
while (oldDate.indexOf(separator) != -1)
oldDate = oldDate.replace(separator, "");
giYear = (parseInt(oldDate.substr(0, oldDate.length - 4), 10) * 1) + CY11;
giMonth = parseInt(oldDate.substr(oldDate.length - 4, 2), 10);
giDay = parseInt(oldDate.substr(oldDate.length - 2, 2), 10);
}
}
var tbSelYear = document.getElementById("tbSelYear");
var tbSelMonth = document.getElementById("tbSelMonth");
var PrevYear = document.getElementById("PrevYear");
var NextYear = document.getElementById("NextYear");
var PrevMonth = document.getElementById("PrevMonth");
var NextMonth = document.getElementById("NextMonth");
tbSelYear.value = giYear - CY11;
tbSelMonth.value = giMonth;
fUpdateCal(tbSelYear.value, tbSelMonth.value);
window.returnValue = "";
</script>
</div>
</form>
</body>
</html>
@@ -0,0 +1,30 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Common;
using System.Text;
public partial class utility_DatePicker : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
/*
BhrdDAC bhrddac = new BhrdDAC();
DataTable bhrd = bhrddac.GetAll();
StringBuilder sb = new StringBuilder();
foreach (DataRow row in bhrd.Rows)
{
sb.Append(String.Format("{0}:\"{1}\",", row["BHYER"], row["BHHRD"]));
}
sb.Append("\"\":\"\"");
Page.ClientScript.RegisterClientScriptBlock(typeof(String), "bhrd", WConstants.JavaScriptStart + "var BHRD={" + sb.ToString() + "}" + WConstants.JavaScriptEnd);
*/
}
}
+14
View File
@@ -0,0 +1,14 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetLookUp.aspx.cs" Inherits="Education.Utility.GetLookUp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
</form>
</body>
</html>
@@ -0,0 +1,69 @@
using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Web;
using System.Text;
using WebLib;
namespace Education.Utility
{
public partial class GetLookUp : FormBase
{
protected void Page_Load(object sender, EventArgs e)
{
DbCommand cmd = DAC.NewCommand();
DbDataAdapter da = DAC.NewDataAdapter();
cmd.Connection = conn;
da.SelectCommand = cmd;
// 從 Request 中取出參數
string lookupConfigName = Server.UrlDecode(DAC.GetString(Request["NAME"]));
string whereKey = DAC.GetString(Request["WHERE_KEY"]);
string langId = DAC.GetString(Request["LANGID"]);
string addWhere = DAC.GetString(Request["ADD_WHERE"]);
// 從設定檔中取得SQL
LookupList pickup = LookupList.GetInstance();
pickup.LookupConfigName = lookupConfigName;
string sql = pickup.GetLookupSQL();
string[] keyFields = pickup.GetKeyFields();
// 將傳入的KEY代入SQL
foreach (string keyField in keyFields)
{
if (addWhere.Length == 0)
cmd.CommandText = String.Format(sql, keyField, "");
else
cmd.CommandText = String.Format(sql, keyField, " AND " + addWhere);
cmd.Parameters.Clear();
cmd.Parameters.Add(DAC.NewParameter("VALUE", whereKey + "%"));
// 取回資料
DataTable table = new DataTable();
//conn.Open();
da.Fill(table);
//conn.Close();
// 若無資料,則找尋下一個 KEY
if (table.Rows.Count == 0)
{
continue;
}
else
{
// 輸出儲存下拉資料物件的 JSON 表示法字串
Response.Write(pickup.GetLookupJSON(table, langId));
Response.End();
return;
}
}
Response.End();
}
protected override bool IsSetMasterPage()
{
return false;
}
}
}
+26
View File
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <自動產生>
// 這段程式碼是由工具產生的。
//
// 變更這個檔案可能會導致不正確的行為,而且如果已重新產生
// 程式碼,則會遺失變更。
// </自動產生>
//------------------------------------------------------------------------------
namespace Education.Utility
{
public partial class GetLookUp
{
/// <summary>
/// form1 控制項。
/// </summary>
/// <remarks>
/// 自動產生的欄位。
/// 若要修改,請將欄位宣告從設計工具檔案移到程式碼後置檔案。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
}
}
@@ -0,0 +1,16 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetLookUpOld.aspx.cs" Inherits="utility_GetPickUp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
@@ -0,0 +1,66 @@
using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Web;
using System.Text;
using WebLib;
public partial class utility_GetPickUp : FormBase
{
protected void Page_Load(object sender, EventArgs e)
{
DbCommand cmd = DAC.NewCommand();
DbDataAdapter da = DAC.NewDataAdapter();
cmd.Connection = conn;
da.SelectCommand = cmd;
// 從 Request 中取出參數
string lookupConfigName = Request["NAME"];
string whereKey = Request["WHERE_KEY"];
string langId = Request["LANGID"];
string addWhere = Request["ADD_WHERE"];
// 從設定檔中取得SQL
LookupList pickup = LookupList.GetInstance();
pickup.LookupConfigName = lookupConfigName;
string sql = pickup.GetLookupSQL();
string[] keyFields = pickup.GetKeyFields();
// 將傳入的KEY代入SQL
foreach (string keyField in keyFields)
{
if (addWhere.Length == 0)
cmd.CommandText = String.Format(sql, keyField, "");
else
cmd.CommandText = String.Format(sql, keyField, " AND " + addWhere);
cmd.Parameters.Clear();
cmd.Parameters.Add(DAC.NewParameter("VALUE", whereKey + "%"));
// 取回資料
DataTable table = new DataTable();
conn.Open();
da.Fill(table);
conn.Close();
// 若無資料,則找尋下一個 KEY
if (table.Rows.Count == 0)
{
continue;
}
else
{
// 輸出儲存下拉資料物件的 JSON 表示法字串
Response.Write(pickup.GetLookupJSON(table, langId));
Response.End();
return;
}
}
Response.End();
}
protected override bool IsSetMasterPage()
{
return false;
}
}
+482
View File
@@ -0,0 +1,482 @@
//--------------------------------------------
// 要掛在回傳物件上的 method 程式碼
//--------------------------------------------
function JSON_Dataset_FieldValue_Method(index, fieldName)
{
var i = this.Cols[fieldName];
if (typeof i != "undefined")
{
if (typeof this.Rows[index] != "undefined")
return this.Rows[index][i];
else
return null;
}
}
//--------------------------------------------
// 取得 XMLHTTP 物件參考
//--------------------------------------------
function initRequest()
{
var A=null;
try
{
A = new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e)
{
try
{
A = new ActiveXObject("Microsoft.XMLHTTP")
}
catch(oc)
{
A = null
}
}
if (!A && typeof XMLHttpRequest != "undefined")
{
A = new XMLHttpRequest()
}
if (!A && window.createRequest)
{
try
{
A = window.createRequest();
} catch (e)
{
A = null;
}
}
return A
}
//--------------------------------------------
// 取得網頁上元件的 X 座標
//--------------------------------------------
function offsetLeft(obj)
{
x = obj.offsetLeft;
for (objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent)
x += objParent.offsetLeft;
return x;
}
//--------------------------------------------
// 取得網頁上元件的 Y 座標
//--------------------------------------------
function offsetTop(obj)
{
y = obj.offsetTop;
for(objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent)
y += objParent.offsetTop;
return y;
}
//--------------------------------------------
// 改顏色
//--------------------------------------------
function changeColor(obj, bgColor, txtColor)
{
obj.style.backgroundColor = bgColor;
obj.style.color = txtColor;
}
//--------------------------------------------
// 顯示下拉清單
//--------------------------------------------
function ShowPickup1()
{
XX_SELECT_DIV.style.display = "block";
XX_SELECT_DIV.style.border = "solid 1px black";
XX_SELECT_DIV.style.padding = "3px";
XX_SELECT_DIV.style.backgroundColor = "#FFF";
XX_SELECT_DIV.style.left = offsetLeft(objValue) + "px";
XX_SELECT_DIV.style.top = offsetTop(objValue) + objValue.offsetHeight + "px";
// 調整位置,不要超過螢幕的右邊與下邊
if (offsetLeft(objValue) + XX_SELECT_DIV.offsetWidth > document.body.clientWidth) {
XX_SELECT_DIV.style.left = document.body.clientWidth - XX_SELECT_DIV.offsetWidth + "px";
}
if (offsetTop(objValue) + objValue.offsetHeight + XX_SELECT_DIV.offsetHeight > document.body.clientHeight) {
XX_SELECT_DIV.style.top = document.body.clientHeight - XX_SELECT_DIV.offsetHeight + "px";
}
XX_SELECT_MASK.style.left = XX_SELECT_DIV.style.left;
XX_SELECT_MASK.style.top = XX_SELECT_DIV.style.top;
XX_SELECT_MASK.style.width = XX_SELECT_DIV.offsetWidth;
XX_SELECT_MASK.style.height = XX_SELECT_DIV.offsetHeight;
}
//--------------------------------------------
// XMLHTTP 的 onreadystatechange 事件處理程式
//--------------------------------------------
function ShowPickup()
{
if (XmlHttp.readyState==4 || XmlHttp.readyState=='complete')
{
XX_SELECT_DIV = document.getElementById('XX_SELECT_DIV');
XX_SELECT_DIV.innerHTML = xx_select_html;
XX_SELECT_PANEL = document.getElementById('XX_SELECT_PANEL');
XX_SELECT_TITLE = document.getElementById('XX_SELECT_TITLE');
XX_SELECT_MASK = document.getElementById('XX_SELECT_MASK');
XX_SELECT = document.getElementById('XX_SELECT');
RespText = XmlHttp.responseText;
// if no result, display "not found" message
if (RespText == "")
{
XX_SELECT_DIV.innerHTML = not_found_html1 + msgNotFound + not_found_html2;
ShowPickup1();
XX_SELECT_DIV.focus();
return;
}
// parse return data to object
try
{
XX_TEXT = JSON.parse(RespText);
XX_TEXT.ListData.Data.FieldValue = JSON_Dataset_FieldValue_Method;
// XX_TEXT = eval("(" + RespText + ")");
}
catch (err)
{
alert("解析回傳資料時發生錯誤:" + err.message + "\r\n回傳資料\r\n" + RespText);
return;
}
//
if (notShowOnlyOneRecord && (XX_TEXT.ListData.Data.Rows.length == 1))
{
Update(0);
return;
}
// generate table for display result
// draw title
newRow = XX_SELECT_TITLE.insertRow(-1);
newRow.bgColor = XX_TEXT.ListData.TitleBackgroundColor;
for (i in XX_TEXT.ListData.ListTitles)
{
newCell = newRow.insertCell(-1);
if ((typeof XX_TEXT.ListData.ListWidths[i] != "undefined") && (XX_TEXT.ListData.ListWidths[i] != ""))
newCell.width = XX_TEXT.ListData.ListWidths[i] + "px";
else
newCell.width = "100px";
newCell.innerHTML = "<div style='color:" + XX_TEXT.ListData.TitleTextColor
+ ";font-size:" + XX_TEXT.ListData.TitleTextSize
+ ";padding:3px"
+ ";margin:0"
+ ";white-space:normal;word-break:break-all;display:block;width:100%;height:100%;'>"
+ XX_TEXT.ListData.ListTitles[i]
+ "</div>";
}
// draw content
var n = 0;
for (i = XX_Init_RecNo; i < XX_TEXT.ListData.Data.Rows.length; i++)
{
n++;
newRow = XX_SELECT.insertRow(-1);
if ((i * 1) % 2 == 1)
newRow.bgColor = XX_TEXT.ListData.DataAltBackgroundColor;
else
newRow.bgColor = XX_TEXT.ListData.DataBackgroundColor;
for (j in XX_TEXT.ListData.ListFields)
{
newCell = newRow.insertCell(-1);
if ((typeof XX_TEXT.ListData.ListWidths[j] != "undefined") && (XX_TEXT.ListData.ListWidths[j] != ""))
newCell.width = XX_TEXT.ListData.ListWidths[j] + "px";
else
newCell.width = "100px";
newCell.style["padding"] = "0";
newCell.innerHTML = "<div onclick='Update(" + i + ")' "
+ "onmouseover='changeColor(this, &quot;#0000FF&quot;, &quot;#FFFFFF&quot;)' "
+ "onmouseout='changeColor(this, &quot;" + newRow.bgColor + "&quot;, &quot;" + XX_TEXT.ListData.DataTextColor + "&quot;)' "
+ "style='color:" + XX_TEXT.ListData.DataTextColor
+ ";font-size:" + XX_TEXT.ListData.DataTextSize
+ ";padding:3px"
+ ";white-space:normal;word-break:break-all;display:block;width:100%;height:100%;cursor:pointer;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;'>"
+ XX_TEXT.ListData.Data.FieldValue(i, XX_TEXT.ListData.ListFields[j])
+ "</div>";
}
// when record count is great then max_record setting, draw page-changing button
if ( (XX_Max_Records > 0 && n >= XX_Max_Records) || i == XX_TEXT.ListData.Data.Rows.length - 1)
{
XX_Next_RecNo = i + 1;
XX_Prev_RecNo = XX_Init_RecNo - XX_Max_Records;
newRow = XX_SELECT.insertRow(-1);
newCell = newRow.insertCell(-1);
newCell.colSpan = 99;
var s = "<input type='button' value='&nbsp;&lt;&nbsp;'"
+ (XX_Prev_RecNo >= 0 ? "" : " disabled ")
+ " onclick=\"SendPickupRequestCont("
+ "&quot;" + XX_Url + "&quot;,"
+ "&quot;" + XX_Name + "&quot;,"
+ "&quot;" + XX_Value_Id + "&quot;,"
+ XX_Text_Id + ","
+ "&quot;" + XX_Add_Where + "&quot;,"
+ (notShowOnlyOneRecord ? "true," : "false,")
+ XX_Max_Records + ","
+ XX_Prev_RecNo + ");\"/>"
+ "<input type='button' value='&nbsp;&gt;&nbsp;'"
+ (i < XX_TEXT.ListData.Data.Rows.length - 1 ? "" : " disabled ")
+ " onclick=\"SendPickupRequestCont("
+ "&quot;" + XX_Url + "&quot;,"
+ "&quot;" + XX_Name + "&quot;,"
+ "&quot;" + XX_Value_Id + "&quot;,"
+ XX_Text_Id + ","
+ "&quot;" + XX_Add_Where + "&quot;,"
+ (notShowOnlyOneRecord ? "true," : "false,")
+ XX_Max_Records + ","
+ XX_Next_RecNo + ");\"/>";
newCell.innerHTML = s;
break;
}
}
ShowPickup1();
XX_SELECT_DIV.focus();
}
}
//--------------------------------------------
// 使用 XMLHTTP 送出請求
//--------------------------------------------
function SendPickupRequestCont(url, name, AvalueId, AtextId, additionalWhere, notShowOnlyOne, maxRecords, initRecNo)
{
valueId = AvalueId;
textId = AtextId;
XX_Url = url;
XX_Name = name;
XX_Value_Id = AvalueId;
XX_Add_Where = additionalWhere;
XX_Max_Records = maxRecords;
XX_Init_RecNo = initRecNo;
notShowOnlyOneRecord = notShowOnlyOne;
// get value-input object
objValue = document.getElementById(valueId);
// get output object(s)
XX_Text_Id = "";
if (typeof textId[0] != "undefined")
{
objOutput = new Array(textId.length);
XX_Text_Id += "[";
for (i = 0; i < textId.length; i++)
{
objOutput[i] = document.getElementById(textId[i]);
XX_Text_Id += "&quot;" + textId[i] + "&quot;";
if (i < textId.length - 1)
XX_Text_Id += ","
}
XX_Text_Id += "]";
}
else
{
objOutput = document.getElementById(textId);
XX_Text_Id = textId;
}
// get a HttpRequest object and sumbit request
XmlHttp = initRequest();
XmlHttp.open("GET", url + "?NAME=" + name + "&LANGID=" + UserLangId
+ "&WHERE_KEY=" + escape(objValue.value)
+ "&ADD_WHERE=" + escape(additionalWhere)
+ "&TIME=" + new Date().getTime(), true);
XmlHttp.onreadystatechange = ShowPickup;
XmlHttp.send("");
}
function SendPickupRequest(url, name, AvalueId, AtextId, additionalWhere, notShowOnlyOne, maxRecords)
{
SendPickupRequestCont(url, name, AvalueId, AtextId, additionalWhere, notShowOnlyOne, maxRecords, 0);
}
//--------------------------------------------
// 下拉清單的鍵盤事件處理程式
//--------------------------------------------
function SelectKeydown(e)
{
if (!XX_SELECT || !XX_SELECT.selectedIndex || XX_SELECT.selectedIndex < 0)
return;
var keynum = 0;
if (window.event)
{
keynum = event.keyCode;
}
else if (e.which)
{
keynum = e.which;
}
switch (keynum)
{
// ESC key = close
case 27:
{
HidePickupList();
return false;
}
}
return true;
}
//--------------------------------------------
// 下拉清單的滑鼠雙擊處理程式
//--------------------------------------------
function SelectDblClicked()
{
if (XX_SELECT.selectedIndex < 0)
return;
Update();
}
//--------------------------------------------
// 更新頁面上的 HTML 元件中的值
//--------------------------------------------
function Update(value)
{
if (typeof objOutput[0] != "undefined")
{
for (i = 0; i < objOutput.length; i++)
{
if (typeof objOutput[i] != "undefined"
&& typeof XX_TEXT.ListData.OutputFields[i] != "undefined"
&& typeof XX_TEXT.ListData.Data.FieldValue(value, XX_TEXT.ListData.OutputFields[i]) != "undefined")
{
if (objOutput[i] != null)
{
if (objOutput[i].tagName == "INPUT")
objOutput[i].value = XX_TEXT.ListData.Data.FieldValue(value, XX_TEXT.ListData.OutputFields[i]);
else
objOutput[i].innerHTML = XX_TEXT.ListData.Data.FieldValue(value, XX_TEXT.ListData.OutputFields[i]);
}
}
}
}
else
{
if (typeof objOutput != "undefined"
&& typeof XX_TEXT.ListData.OutputFields[0] != "undefined"
&& typeof XX_TEXT.ListData.Data.FieldValue(value, XX_TEXT.ListData.OutputFields[0]) != "undefined")
{
if (objOutput != null)
{
if (objOutput.tagName == "INPUT")
objOutput.value = XX_TEXT.ListData.Data.FieldValue(value, XX_TEXT.ListData.OutputFields[i]);
else
objOutput.innerHTML = XX_TEXT.ListData.Data.FieldValue(value, XX_TEXT.ListData.OutputFields[i]);
}
}
}
HidePickupList();
}
// for debug
function Update1(obj)
{
alert(obj);
HidePickupList();
}
//--------------------------------------------
// 隱藏下拉清單, 並清除其中的資料
//--------------------------------------------
function HidePickupList()
{
XX_SELECT_DIV.style.display = "none";
XX_SELECT_DIV.innerHTML = xx_select_html;
XX_SELECT_MASK.style.left = "0";
XX_SELECT_MASK.style.top = "0";
XX_SELECT_MASK.style.width = "0";
XX_SELECT_MASK.style.height = "0";
objValue.focus();
}
//--------------------------------------------
// 變數與常數宣告
//--------------------------------------------
var XX_SELECT = null;
var XX_SELECT_DIV = null;
var XX_SELECT_PANEL = null;
var XX_SELECT_TITLE = null;
var XX_SELECT_MASK = null;
var XX_TEXT = null;
var objValue = null;
var objOutput = null;
var valueId = null;
var textId = null;
var notShowOnlyOneRecord = false;
var XX_SELECT_SelectedIndex = -1;
var XX_Url = "";
var XX_Name = "";
var XX_Value_Id = "";
var XX_Text_Id = "";
var XX_Add_Where = "";
var XX_Max_Records = 100;
var XX_Next_RecNo = 0;
var XX_Prev_RecNo = 0;
var XX_Init_RecNo = 0;
var not_found_html1 = "<table border=0 cellpadding=0 cellspacing=0><tr><td>"
+ "<table border=1 cellpadding=3 bgcolor=yellow>"
+ "<tr><td><b><font color=black>";
var not_found_html2 = "</font></b></td></tr></table></td><td valign='middle'>"
+ "<INPUT type='button' id='XX_CLOSE_BTN' value='&nbsp;X&nbsp;' class='PickupCloseButton' "
+ "onclick='javascript:HidePickupList();'></td></table>";
var xx_select_html = "<table border='0' cellpadding='0' cellspacing='0'>"
+ " <tr>"
+ " <td>"
+ " <table id='XX_SELECT_TITLE' border='1' cellpadding='0' cellspacing='0' "
+ " style='font-family:sans-serif; border-collapse:collapse;'>"
+ " </table>"
+ " </td>"
+ " <td>"
+ " <INPUT type='button' id='XX_CLOSE_BTN' value='&nbsp;X&nbsp;' "
+ " class='PickupCloseButton' onclick='javascript:HidePickupList();'>"
+ " </td>"
+ " </tr>"
+ " <tr>"
+ " <td colspan=2>"
+ " <div id='XX_SELECT_PANEL' style='display:block;overflow:auto'>"
+ " <table id='XX_SELECT' border='1' cellpadding='0' cellspacing='0' "
+ " style='font-family:sans-serif;border-collapse:collapse;'>"
+ " </table>"
+ " </div>"
+ " </td>"
+ " </tr>"
+ "</table>";
var outer_div_html = "<DIV id='XX_SELECT_DIV' "
+ "style='left:0;top:0;display:none;background-color:#FFFFFF;position:absolute;z-index:999;border:solid 1px #000000' "
+ "onkeydown='javascript:return SelectKeydown(event);'>";
var outer_iframe_html = "<iframe id='XX_SELECT_MASK' "
+ "style='display:block;border:0px none;position:absolute;left:0;top:0;width:0;height:0' "
+ "src='about:blank'></iframe>";
//--------------------------------------------
// 頁面開啟之後會執行的程式片段
// 這個 DIV 是用來放置下拉清單的
//--------------------------------------------
document.write(outer_div_html);
document.write(xx_select_html);
document.write("</DIV>");
document.write(outer_iframe_html);
+596
View File
@@ -0,0 +1,596 @@
//--------------------------------------------
// 取得網頁上元件的 X 座標
//--------------------------------------------
function offsetLeft(obj)
{
x = obj.offsetLeft;
for (objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent)
x += objParent.offsetLeft;
return x;
}
//--------------------------------------------
// 取得網頁上元件的 Y 座標
//--------------------------------------------
function offsetTop(obj)
{
y = obj.offsetTop;
for (objParent = obj.offsetParent; objParent; objParent = objParent.offsetParent)
y += objParent.offsetTop;
return y;
}
//--------------------------------------------
// 存檔前檢查
//--------------------------------------------
function CheckInput()
{
var i = 0;
// 檢查不可空白欄位
for (i in arNotEmpty)
{
obj = document.getElementById(arNotEmpty[i]);
if (!CheckEmpty(obj, arObjName[arNotEmpty[i]]))
return false;
}
// 檢查數值欄位
i = 0;
for (i in arIsNumber)
{
obj = document.getElementById(arIsNumber[i]);
if (!CheckNumber(obj, arObjName[arIsNumber[i]]))
return false;
}
// 檢查日期欄位
i = 0;
for (i in arIsDate)
{
obj = document.getElementById(arIsDate[i]);
if (!CheckDate(obj, arObjName[arIsDate[i]]))
return false;
}
return confirm(msgConfirmSave);
}
//--------------------------------------------
// 檢查是否空白
//--------------------------------------------
function CheckEmpty(obj, objCaption)
{
if (obj.value == "")
{
s = msgNotEmpty + " \"" + objCaption + "\".";
alert(s);
obj.focus();
return false;
}
return true;
}
//--------------------------------------------
// 檢查是否輸入為數值
//--------------------------------------------
function CheckNumber(obj, objCaption)
{
if (isNaN(parseFloat(obj.value)))
{
s = " \"" + objCaption + "\" " + msgMustNumber;
alert(s);
obj.focus();
return false;
}
return true;
}
//--------------------------------------------
// 檢查日期是否合理
//--------------------------------------------
function CheckDate(obj, objCaption)
{
if (parseDate(obj) != null)
{
s = " \"" + objCaption + "\" " + msgMustDate;
alert(s);
obj.focus();
return false;
}
return true;
}
//------------------------------------------------------------
// 取得按下按鍵相關資料
//------------------------------------------------------------
function GetKeyData(evt)
{
if (!evt)
{
// grab IE event object
evt = window.event
}
else if (!evt.keyCode)
{
// grab NN4 event info
evt.keyCode = evt.which;
evt.altKey = evt.modifiers & Event.ALT_MASK;
evt.ctrlKey = evt.modifiers & Event.CONTROL_MASK;
evt.shiftKey = evt.modifiers & Event.SHIFT_MASK;
}
return evt;
}
//------------------------------------------------------------
// 取得按下的按鍵,可在 onKeyDown, onKeyUp, onKeyPress 中使用
//------------------------------------------------------------
function GetKeyCode(evt)
{
return GetKeyData(evt).keyCode;
}
//------------------------------------------------------------
// 判斷按下的是否為某鍵
//------------------------------------------------------------
function IsKeyCode(evt, keyCode, altKey, ctrlKey, shiftKey)
{
var keyEvt = GetKeyData(evt);
return (keyEvt.keyCode == keyCode &&
((!altKey && !keyEvt.altKey) || (altKey && keyEvt.altKey)) &&
((!ctrlKey && !keyEvt.ctrlKey) || (ctrlKey && keyEvt.ctrlKey)) &&
((!shiftKey && !keyEvt.shiftKey) || (shiftKey && keyEvt.shiftKey)));
}
//------------------------------------------------------------
// 延遲若干毫秒後顯示 "處理中"
//------------------------------------------------------------
function ShowProcessing(delay)
{
if (typeof delay != "undefined")
window.setTimeout(ShowProcessing1, delay);
else
ShowProcessing1();
}
//------------------------------------------------------------
// 顯示 "處理中"
//------------------------------------------------------------
function ShowProcessing1()
{
var datePicker = document.getElementById("DatePicker");
datePicker.src="utility/Processing.htm";
datePicker.style.width = 340;
datePicker.style.height = 180;
datePicker.style.left = Math.round((document.body.clientWidth - datePicker.offsetWidth) / 2) + "px";
datePicker.style.top = Math.round((document.body.clientHeight - datePicker.offsetHeight) / 2) + "px";
datePicker.style.border = "none";
}
//------------------------------------------------------------
// 隱藏 "處理中"
//------------------------------------------------------------
function HideProcessing()
{
var datePicker = document.getElementById("DatePicker");
datePicker.style.width = 0;
datePicker.style.height = 0;
datePicker.style.left = 0;
datePicker.style.top = 0;
}
//------------------------------------------------------------
// 清理具名的 Vue 實例
//------------------------------------------------------------
function DestroyVue(key) {
var vm = window.__vms && window.__vms[key]
if (vm && !vm._isDestroyed) {
vm.$destroy()
delete window.__vms[key]
console.log(`DestroyVue - ${key} Destroied`);
return;
}
console.log('DestroyVue - nothing to destroy');
}
/**
* 用 jQuery dialog 開啟連結
* @param {string} url 要開啟的URL
* @param {string} title Dialog的標題文字
* @param {number} width Dialog的寬度(px)
* @param {number} height Dialog的高度(px)
* @param {boolean} refresh Dialog關閉時是否重新整理網頁
*/
function OpenDialog(url, title, width, height, refresh)
{
var horizontalPadding = 20;
var verticalPadding = 20;
if (width && width > window.innerWidth)
width = window.innerWidth - 20;
if (height && height > window.innerHeight - 120)
height = window.innerHeight - 120;
if (!width)
width = window.innerWidth - 100;
if (!height)
height = window.innerHeight - 150;
$('<iframe id="externalSite" class="externalSite" src="' + url + '" />').dialog({
title: title ? title : '對話視窗',
dialogClass: "no-close ui-dialog-topmost",
autoOpen: true,
width: width,
height: height,
modal: true,
resizable: true,
autoResize: true,
position: { my: "center center", at: "center center-45px", of: window },
show: {
effect: "none",
duration: 0
},
hide: {
effect: "none",
duration: 0
},
overlay: {
opacity: 0.3,
background: "black"
},
create: function (event, ui)
{
$(this).prop("refresh", refresh);
},
close: function (event, ui)
{
if ($(this).prop("refresh"))
__doPostBack("ctl00$__RefreshPage__", "");
},
buttons: [
{
text: "關閉",
class: "button red40",
style: "line-height: 25px; width: 80px;",
click: function ()
{
$(this).dialog("close");
// if ($(this).prop("refresh"))
// __doPostBack("ctl00$__RefreshPage__", "");
}
}]
}).width(width - horizontalPadding).height(height - verticalPadding);
}
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================
// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
// perfectly with SimpleDateFormat formats, but
// backwards-compatability was required.
// ------------------------------------------------------------------
// These functions use the same 'format' strings as the
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
//
// Field | Full Form | Short Form
// -------------+--------------------+-----------------------
// Year | yyyy (4 digits) | yy (2 digits), y (2 or 4 digits)
// Month | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
// | NNN (abbr.) |
// Day of Month | dd (2 digits) | d (1 or 2 digits)
// Day of Week | EE (name) | E (abbr)
// Hour (1-12) | hh (2 digits) | h (1 or 2 digits)
// Hour (0-23) | HH (2 digits) | H (1 or 2 digits)
// Hour (0-11) | KK (2 digits) | K (1 or 2 digits)
// Hour (1-24) | kk (2 digits) | k (1 or 2 digits)
// Minute | mm (2 digits) | m (1 or 2 digits)
// Second | ss (2 digits) | s (1 or 2 digits)
// AM/PM | a |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
// "MMM d, y" matches: January 01, 2000
// Dec 1, 1900
// Nov 20, 00
// "M/d/yy" matches: 01/20/00
// 9/2/00
// "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}
// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
var date=getDateFromFormat(val,format);
if (date==0) { return false; }
return true;
}
// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
// Compare two date strings to see which is greater.
// Returns:
// 1 if date1 is greater than date2
// 0 if date2 is greater than date1 of if they are the same
// -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
var d1=getDateFromFormat(date1,dateformat1);
var d2=getDateFromFormat(date2,dateformat2);
if (d1==0 || d2==0) {
return -1;
}
else if (d1 > d2) {
return 1;
}
return 0;
}
// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
format=format+"";
var result="";
var i_format=0;
var c="";
var token="";
var y=date.getYear()+"";
var M=date.getMonth()+1;
var d=date.getDate();
var E=date.getDay();
var H=date.getHours();
var m=date.getMinutes();
var s=date.getSeconds();
var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
// Convert real date parts into formatted versions
var value=new Object();
if (y.length < 4) {y=""+(y-0+1900);}
value["y"]=""+y;
value["yyyy"]=y;
value["yy"]=y.substring(2,4);
value["M"]=M;
value["MM"]=LZ(M);
value["MMM"]=MONTH_NAMES[M-1];
value["NNN"]=MONTH_NAMES[M+11];
value["d"]=d;
value["dd"]=LZ(d);
value["E"]=DAY_NAMES[E+7];
value["EE"]=DAY_NAMES[E];
value["H"]=H;
value["HH"]=LZ(H);
if (H==0){value["h"]=12;}
else if (H>12){value["h"]=H-12;}
else {value["h"]=H;}
value["hh"]=LZ(value["h"]);
if (H>11){value["K"]=H-12;} else {value["K"]=H;}
value["k"]=H+1;
value["KK"]=LZ(value["K"]);
value["kk"]=LZ(value["k"]);
if (H > 11) { value["a"]="PM"; }
else { value["a"]="AM"; }
value["m"]=m;
value["mm"]=LZ(m);
value["s"]=s;
value["ss"]=LZ(s);
while (i_format < format.length) {
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
if (value[token] != null) { result=result + value[token]; }
else { result=result + token; }
}
return result;
}
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
var digits="1234567890";
for (var i=0; i < val.length; i++) {
if (digits.indexOf(val.charAt(i))==-1) { return false; }
}
return true;
}
function _getInt(str,i,minlength,maxlength) {
for (var x=maxlength; x>=minlength; x--) {
var token=str.substring(i,i+x);
if (token.length < minlength) { return null; }
if (_isInteger(token)) { return token; }
}
return null;
}
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
val=val+"";
format=format+"";
var i_val=0;
var i_format=0;
var c="";
var token="";
var token2="";
var x,y;
var now=new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var date=1;
var hh=now.getHours();
var mm=now.getMinutes();
var ss=now.getSeconds();
var ampm="";
while (i_format < format.length) {
// Get next token from format string
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
// Extract contents of value based on format token
if (token=="yyyy" || token=="yy" || token=="y") {
if (token=="yyyy") { x=4;y=4; }
if (token=="yy") { x=2;y=2; }
if (token=="y") { x=2;y=4; }
year=_getInt(val,i_val,x,y);
if (year==null) { return 0; }
i_val += year.length;
if (year.length==2) {
if (year > 70) { year=1900+(year-0); }
else { year=2000+(year-0); }
}
}
else if (token=="MMM"||token=="NNN"){
month=0;
for (var i=0; i<MONTH_NAMES.length; i++) {
var month_name=MONTH_NAMES[i];
if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
if (token=="MMM"||(token=="NNN"&&i>11)) {
month=i+1;
if (month>12) { month -= 12; }
i_val += month_name.length;
break;
}
}
}
if ((month < 1)||(month>12)){return 0;}
}
else if (token=="EE"||token=="E"){
for (var i=0; i<DAY_NAMES.length; i++) {
var day_name=DAY_NAMES[i];
if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
i_val += day_name.length;
break;
}
}
}
else if (token=="MM"||token=="M") {
month=_getInt(val,i_val,token.length,2);
if(month==null||(month<1)||(month>12)){return 0;}
i_val+=month.length;}
else if (token=="dd"||token=="d") {
date=_getInt(val,i_val,token.length,2);
if(date==null||(date<1)||(date>31)){return 0;}
i_val+=date.length;}
else if (token=="hh"||token=="h") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>12)){return 0;}
i_val+=hh.length;}
else if (token=="HH"||token=="H") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>23)){return 0;}
i_val+=hh.length;}
else if (token=="KK"||token=="K") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>11)){return 0;}
i_val+=hh.length;}
else if (token=="kk"||token=="k") {
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>24)){return 0;}
i_val+=hh.length;hh--;}
else if (token=="mm"||token=="m") {
mm=_getInt(val,i_val,token.length,2);
if(mm==null||(mm<0)||(mm>59)){return 0;}
i_val+=mm.length;}
else if (token=="ss"||token=="s") {
ss=_getInt(val,i_val,token.length,2);
if(ss==null||(ss<0)||(ss>59)){return 0;}
i_val+=ss.length;}
else if (token=="a") {
if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
else {return 0;}
i_val+=2;}
else {
if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
else {i_val+=token.length;}
}
}
// If there are any trailing characters left in the value, it doesn't match
if (i_val != val.length) { return 0; }
// Is date valid for month?
if (month==2) {
// Check for leap year
if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
if (date > 29){ return 0; }
}
else { if (date > 28) { return 0; } }
}
if ((month==4)||(month==6)||(month==9)||(month==11)) {
if (date > 30) { return 0; }
}
// Correct hours value
if (hh<12 && ampm=="PM") { hh=hh-0+12; }
else if (hh>11 && ampm=="AM") { hh-=12; }
var newdate=new Date(year,month-1,date,hh,mm,ss);
return newdate.getTime();
}
// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d
// M/d/y M-d-y M.d.y MMM-d M/d M-d
// d/M/y d-M-y d.M.y d-MMM d/M d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
var preferEuro=(arguments.length==2)?arguments[1]:false;
generalFormats=new Array('y/M/d','yyyy/MM/dd','y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
var d=null;
for (var i=0; i<checkList.length; i++) {
var l=window[checkList[i]];
for (var j=0; j<l.length; j++) {
d=getDateFromFormat(val,l[j]);
if (d!=0) { return new Date(d); }
}
}
return null;
}
+44
View File
@@ -0,0 +1,44 @@
/*********************************************************************************
dw_cookies.js - cookie functions for www.dyn-web.com
Recycled from various sources
**********************************************************************************/
// Modified from Bill Dortch's Cookie Functions (hidaho.com)
// (found in JavaScript Bible)
function setCookie(name,value,days,path,domain,secure) {
var expires, date;
if (typeof days == "number") {
date = new Date();
date.setTime( date.getTime() + (days*24*60*60*1000) );
expires = date.toGMTString();
}
document.cookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
var nameq = name + "=";
var c_ar = document.cookie.split(';');
for (var i=0; i<c_ar.length; i++) {
var c = c_ar[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
}
return null;
}
// from Bill Dortch's Cookie Functions (hidaho.com)
function deleteCookie(name,path,domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
+486
View File
@@ -0,0 +1,486 @@
/*
json2.js
2013-05-26
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (typeof JSON !== 'object') {
JSON = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function () {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function () {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());
+14
View File
@@ -0,0 +1,14 @@
function FillMessage(id, msg) {
var control = $("#" + id);
if (control.val() !== "" && msg !== "")
control.val(control.val() + msg);
else if (msg !== "")
control.val(msg);
control.focus();
}
function togglePhrase(id) {
if ($("#" + id).hasClass("hide"))
$("#" + id).removeClass("hide");
else
$("#" + id).addClass("hide");
}