##漢語拼音 漢語拼音的好處:
- 祇要熟悉英文字母字鍵,不用額外學習音碼或型碼的按鍵位置
- 以「辭」為單位輸入,大幅減少選字時間
- 成語、常見辭句可直接輸入個別字元的首碼,大幅減少鍵入時間
- 不經切換鍵即可直接輸入標點符號
| -- using list in AppleScript | |
| -- define a list | |
| set emptyList to {} | |
| set d to {"c", "d"} | |
| set e to {"e", "f"} | |
| set ne to {"a", "b", 1, 3, d, e} | |
| -- count items in a list | |
| count ne | |
| --> 6 |
| (* Appliction "Dictionary" doesn't support AppleScript. However, we can control this application via UI elements | |
| of System Events. Following example show how to access various parts of "Dictionary" *) | |
| tell application "Dictionary" | |
| activate | |
| tell application "System Events" to tell process "Dictionary" | |
| UI elements of window 1 | |
| (* Access Spot light, enter searching word in the spotlight *) | |
| set value of text field 1 of group 3 of tool bar 1 of windows to "challenge" | |
| (* Get matched words/phrases list on the side bar of "Dictionary" *) | |
| value of text field 1 of row 2 of table 1 of scroll area 1 of splitter group 1 of window 1 |
| // NOTE: ensure numString contains only validate value, e.g. only digits, comma and period allowed | |
| function toReal( numString ) { | |
| if ( numString.contains('.') ) { // deem as real number with period within, regardless if comma exists | |
| return parseFloat(numString.replace(/,/g, '')); | |
| } else { | |
| return parseInt( numSring ); // deem as integer, without period | |
| } | |
| } |
| // SIMPLE VARIABLE ASSIGNMENT | |
| // Using syntax: set ... to ... | |
| set a to 1 -- set a as an integer object with value 1 | |
| set PI to 3.14159 -- set PI as a real object with value 3.14159 | |
| set b to "A string" -- set b as a text object with value "A string" | |
| set c to {"Thomas", "Sally"} -- set c as a list object contains two items: "Thomas", "Sally" | |
| set d to {name: "Thomas", sex: "male"} -- set d as a record object with two properties with values | |
| // To get variable type, in AppleScript, we name variable type as "class" | |
| class of a -- return "integer" |
| <!-- This snippet demo how to HIDE partial of a division within some range (another division) | |
| If replace #d2 below with images can make parts of the image shown within #s1 range. | |
| Also some suggest to add "margin: 0 auto;" within #s1 CSS, don't know why? | |
| --> | |
| <!DOCTYPE html> | |
| <head> | |
| <style> | |
| #s1, #s2 { width: 300x; height: 200px; } | |
| #s1 { top: 50px; background-color: blue; overflow: hidden; } /* assume #s1 is the range */ | |
| #s2 { background-color: brown; left: 100px; position: relative; } |
| var birthday = '1962/7/25'; | |
| function date2JSON( dt ) { | |
| var dayArr = dt.split('/'); | |
| return JSON.parse( '{ "year":' + parseInt( dt[0] ) + ', "month:"' + parseInt( dt[1] ) + ', "day":' + parseInt( dt[3] ) + '}'); | |
| Usage Example: | |
| var myBirthday = date2JSON( birthday ); | |
| ==> {"year": 1962, "month": 7, "day": 25} |
##漢語拼音 漢語拼音的好處:
| $origin = '97.09.27'; | |
| $dt = preg_split('/\./', $origin); | |
| $mysqlDate = ((int)$dt[0] + 1911).'-'.$dt[1].'-'.dt[2]; | |
| 1. preg_split has at least 2 parameters: | |
| 1) '/\./' -- regular expression pattern | |
| 2) $origin -- the string to be splited | |
| it use regular expression pattern to separate the string into array | |
| 2. convert string to number (coersion) |
| /* Epoch used in Taiwan started since 1911 AD. For example, this year (2015 AD) in Taiwan epoch is 中華民國 104 年 | |
| Often we need to different epoch notation between system/languages */ | |
| /* From String to JavaScript | |
| Taiwan epoch notation -- '104.01.29' | |
| AD -- Thu Jan 29 2015 22:27:19 GMT+0800 (CST) */ | |
| var str2JSdate = function( str ) { | |
| var dt = new Date(); | |
| var date_arr = str.split('.'); | |
| dt.setFullYear( parseInt( date_arr[0] ) + 1911 ); |
| var script = document.createElement('script'); | |
| script.setAttribute('src', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'); | |
| document.getElementsByTagName('head')[0].appendChild( script ); |