Saturday, 27. January 2018

If you make a div to have opacity from 0 to 1, everything within the div will be having the opacity including the text. To keep the text clear without affected by opacity, use the following style instead:

opacity: 0=transparent; 1=opaque;

background-color:rgb(255,0,0,0.1) /* 10% opaque red */
background-color:rgb(255,0,0,0.4) /* 40% opaque red */
background-color:rgb(255,0,0,0.7) /* 70% opaque red */
background-color:rgb(255,0,0, 1) /* full opaque red */

Styling is for the background and not the div.

source: https://stackoverflow.com/questions/5135019/css-opacity-only-to-background-color-not-the-text-on-it

single include script with variables to be use right after

Friday, 29. September 2017

To complement what is needed after the post “Include script files in one script file”, I found that some variables needed to be initialized cannot be done unless the loading of all scripts is completed. Looks like loading all scripts and other script initalizing variable are running in different thread. To solve the problem when error occurs identifying variable to be initialized, all variable initializing functions can be inserted as this:

This is how I altered the “loadScriptInOrder” and inserted the initializing scripts in it. Here is the inorder master.js file:
var scriptMap =["/jquery.js","/script1.js", "/script2.js", "/script3.js"];// list of to be loaded script in an array
var order = 0;
function loadScriptInOrder(){
if(order == scriptMap.length) {
initalize_variable1();initialize_variable2();//do this right after the loading
var JSLink = scriptMap[order];
var JSElement = document.createElement(’script’);
JSElement.src = JSLink;
JSElement.onload = callback;

function callback(){
loadScriptInOrder();//load the script in a recursive manner

This way I will not need to load jquery.js in HTML file and then inlude the master.js file. It will be one once and for all. That’s perfect!

single javascript file when having dependents

Sunday, 24. September 2017

Last post we discussed different ways to load javascripts into the header and now I discovered when some function is dependent on some script being loaded, the earlier solution did not cover that.

Here is the example of the masterscript:

var scriptMap =[... whatever scripts ...];// list of to be loaded script in an array
function include(file){
var script = document.createElement(’script’);
script.src = file;
/*basic include any js files here */
for(var i=0;i<scriptMap.length;i++) include(scriptMap[i]);

/* this helps */
function loadScript( url, callback ) {
var script = document.createElement( “script” )
script.type = “text/javascript”;
if(script.readyState) { //IE
script.onreadystatechange = function() {
if ( script.readyState === “loaded” || script.readyState === “complete” ) {
script.onreadystatechange = null;
} else { //Others
script.onload = function() {
script.src = url;
document.getElementsByTagName( “head” )[0].appendChild( script );
// call the function…
loadScript(script3.js’, function() {
alert(’script3 ready now!’);
loadScript(’script4.js’, function() {
//alert(’script4 ready now!’);
loadScript(‘/script5.js’, function() {
//alert(’script5 ready now!’);

function load_other_script(){
var imported = document.createElement(’script’);
imported = document.createElement(’script’);
imported.src = ‘/script7.js’;

In addition to make one script loaded one after another, this will make sure one script is loaded and ready for another script to be load as the later script is dependent on the first script to be loaded .

Chinese classic book translation

Friday, 22. September 2017

“Chinese classics (Daodejing 道德經; Sunzi bingfa 孫子兵法; Tang shi sanbai shou 唐詩三百首; Lunyu 論語; Zhongyong 中庸; Daxue 大學; and Xiaojing 孝經)”

I just find the translation of the these chinese classic books title funny. It is translated in sound which will be meaningless for western people. Ancient chinese characters is really based on context, the meaning of the book based on its title.

Take “Sunzi bingfa”, it has no meaning for people reading this but the meaning is obvious for people knowing the chinese characters even it is now in sound. To get western people understand the context of the book, some people translated the book to Sunzi as it means the person called Sunzi, but “bingfa” will better be translated as the “art of war”. It is even better be “war strategy” or the “war method”. The book tells you what are the ingredients of war and even how to have a successful war.

The other like “Daodejing 道德經” better be translated as “bible of ethics”.

“Tang shi sanbai shou 唐詩三百首” will be “The 300 poems of Tang Dynasty”.

“Lunyu 論語” is “word of discussion”.

“Zhongyong 中庸” is “The balance, stay away from extremes”.

“Daxue 大學” is “The big learning” or “The Knowledge”.

“Xiaojing 孝經” is “The bible for children” or “The bible of being nice to your parents”.


Thursday, 21. September 2017

http://pcwong.org/cantonese/syllables.html 係最新版本,用了常用字及加了遺漏了的字,有圓圈的就是改用了的常用字及加了遺漏了的字。

2017 syllable table update