This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript In-Depth | |
JavaScript 的 function 是 first-class 的意義: | |
* function 可以被指派到某個變數 | |
* function 可以當作另一個 function 的參數 | |
* function 可以作為另一個 function 的回傳值 | |
* function 具備和 Object 一樣的特質,包括:high order(?), assign 及 property | |
Higher-order function 的意義:1. function 可以將 1 或多個 function 作為參數 2. 輸出(回傳) function | |
// 如何呼叫 JS function // | |
========================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var zipcode = {"950":"台東市", "951":"綠島鄉", "952":"蘭嶼鄉", "953":"延平鄉", "954":"卑南鄉", "955":"鹿野鄉", "956":"關山鎮", "957":"海端鄉", "958":"池上鄉", "959":"東河鄉", "961":"成功鎮", "962":"長濱鄉", "963":"太麻里鄉", "964":"金峰鄉", "965":"大武鄉", "966":"達仁鄉"}; | |
var education = {"01":"博士", "02":"碩士", "03":"大學", "04":"專科", "05":"高中", "06":"國中", "07":"職校", "08":"小學", "09":"其他"}; | |
var occupation = {"01":"工商", "02":"公教", "03":"退休", "04":"家管", "05":"學生", "06":"服務業", "07":"其他"}; | |
var join_role = {"01":"一般志工", "02":"高中生", "03":"大學生", "04":"其他"}; | |
var service = {"01":"身心障礙者福利服務", "02":"老人福利服務", "03":"婦女福利服務", "04":"少年福利服務", "05":"兒童福利服務", "06":"諮商輔導服務", "07":"醫院社會服務", "08":"家庭福利服務", "09":"社區福利服務", "10":"綜合福利服務", "99":"其他(文化、環保)"}; | |
var specialty = {"01":"家電修理", "02":"機械", "03":"汽車修護", "04":"工藝", "05":"刻印", "06":"印刷", "07":"語文", "08":"文書處理", "09":"編輯", "10":"打字", "11":"美工", "12":"縫紉/編織", "13":"烹飪/烘焙", "14":"美容/美髮", "15":"家事服務", "16":"護理", "17":"手工藝", "18":"電腦", "19":"攝影", "20":"團康", "21":"管理", "22":"會計", "23":"作物栽培", "24":"農牧(藝)", "25":"音樂", "26": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showData( data ) { | |
var docs = data; | |
if ( Array.isArray( docs )) { | |
var tbl = document.createElement('table'); | |
var tr = document.createElement('tr'); | |
/* 表格標題列 */ | |
var titles = Object.keys(data[0]); | |
var tr = document.createElement('tr'); | |
for (var i in titles) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Following function find unique value in a sorted array */ | |
function get_unique_in_array( arr ) { | |
var ret = [arr[0]]; | |
for (var i=1; i<arr.length; i++) { | |
if ( ret.indexOf(arr[i]) < 0 ) { | |
ret.push(arr[i]); | |
} | |
} | |
return ret; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
台北市 = {"中正區":"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"}; | |
基隆市 = {"仁愛區":"200","信義區":"201","中正區":"202","中山區":"203","安樂區":"204","暖暖區":"205","七堵區":"206"}; | |
宜蘭縣 = {"宜蘭市":"260","頭城鎮":"261","礁溪鄉":"262","壯圍鄉":"263","員山鄉":"264","羅東鎮":"265","三星鄉":"266","大同鄉":"267","五結鄉":"268","冬山鄉":"269","蘇澳鎮":"270","南澳鄉":"272"}: | |
新竹市 = {"東區":"300", "北區":"300", "香山區":"300"}; | |
新竹縣 = {"湖口鄉":"303","新豐鄉":"304","新埔鎮":"305","關西鎮":"306","芎林鄉":"307","寶山鄉":"308","竹東鎮":"310","五峰鄉":"311","橫山鄉":"312","尖石鄉":"313","北埔鄉":"314","峨眉鄉":"315"}; | |
桃園市 = {"中壢區":"320","平鎮區":"324","龍潭區":"325","楊梅區":"326","新屋區":"327","觀音 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Following snippet is the basice to add a new shape to an SVG area | |
var svg = document.getElementById('svg'); | |
var rect = document.createElementNS('http://www.w3.org/2000/svg'); // Note: Using createElementNS() instead of createElement() | |
rect.setAttributeNS(null, 'x', xValue ); | |
rect.setAttributeNS(null, 'y', yValue ); | |
rect.setAttributeNS(null, 'width', widthValue ); | |
rect.setAttributeNS(null, 'height', heightValue ); | |
rect.setAttributeNS(null, 'style', 'fill: none; stroke: blue; stroke-width: 1px;'); | |
svg.appendChild( rect ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"> | |
<g id="handicap"> | |
<circle cx="32" cy="12" r="5" /> | |
<path d="m32,19 l0,14 14,0 9,14" style="stroke-width: 3; fill: none; stroke: black;" /> | |
<path d="M32,25 l12,0 4,-4" style="stroke-width: 3; fill: none; stroke: black;" /> | |
<path d="M28,28 A10 10 0 1 0 40 37" style="stroke-width: 3; fill: transparent; stroke: #000;" /> | |
</g> | |
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PHPWord 在 DocumentRoot 的上一層目錄 | |
$path = dirname(dirname(__FILE__))."/PHPWord/"; | |
require_once($path."PHPWord.php"); | |
$doc = new PHPWord(); | |
// 以 section 物件加入內容 | |
$sec = $doc->createSection(); | |
$sec->addText("ABC"); | |
$sec->addText("藉由 PHPWord 程式庫建立 .docx, .odt, .rtf 檔", array("name"=>"Arial", "size"=>14, "bold"=>true)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: application/vnd.ms-excel'); | |
header('Content-Disposition: attachment; filename="file.xlsx"'); | |
// PHPExcel 置於 DocumentRoot 的上一層目錄 | |
$path = dirname(dirname(__FILE__)).'/Classes/'; | |
require_once($path.'PHPExcel.php'); | |
require_once($path.'PHPExcel/Writer/Excel2007.php'); | |
$objPHPExcel = new PHPExcel(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var node_array = Array.prototype.slice.call( node_list ) |