This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This 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; } |
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
// 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 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
// 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 | |
} | |
} |
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
(* 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 |
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
-- 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 |
NewerOlder