tedshd's DevNote

Develop & Design Note by Ted

innerHeight & innerWidth

innerHeight & innerWidth

抓取瀏覽器目前顯示高度與寬度
一般都用

window.innerHeight

window.innerWidth

但唯獨IE6~IE8不行
Google了一下
發現用

window.document.documentElement.clientHeight

window.document.documentElement.clientWidth

便兼容所有瀏覽器

scrollHeight

如要抓 document 的高可用

document.body.scrollHeight

Refer

JavaScript function

function

function fun() {
    // do something

}
fun();
var fun = function () {
    // do something

};
fun();

立即函數(建立後立即執行,只執行此次)

var fun = (function () {
    // do something

}());

fileUpload by yui library

fileUpload by yui library

init upload button

JavaScript bind click event
in IE
use JavaScript move CSS position

  • uploader : Upload file
  • uploaderOut : handle not drag area

event


fileSelect

select file & render upload list
check file status
handle fileList
_upload

uploadprogress

upload file progress

uploadcomplete

upload complete
check ok or fail
_upload

uploaderror

cancel & upload next

_upload

check file status & upload status
upload
upload fileList[uploadfile]

_cancelUpload

Notice


Y.Uploader.TYPE
  • none(no flash)
  • html5
    • drag & drop
  • flash(IE)
if (Y.Uploader.TYPE === 'none') {
    console.log('no install flash player');
    return;
}
// init upload button

if (Y.Uploader.TYPE === 'html5') {
    // do something like drag & drop

} else if (Y.Uploader.TYPE === 'flash') {
    // do something

}
Free Space

check free space & show message
update free space

Drag & drop

only chrome can check isFile or isDirectory
drop area check(use setTimeOut & clearTimeout)

handle UI

when something behavior happen need check UI
like cancel, complete and error

upload list control

need update upload list status
like cancel, complete and error
control fileList

queue

It is easy to control upload only one file upload and other queue

If has total progress

need control & update total when something behavior happen
like cancel, error and upload more

Hello World

Hi, This a demo post of Logdown.

Logdown use Markdown as main syntax, you can find more example by reading this document on Wikipedia

Logdown also support drag & drop image uploading ( required Beta / Premium membership). The picture syntax is like this:

Bloging with code snippet:

inline code

Plain Code

puts "Hello World!"

Code with Language

puts "Hello World!"

Code with Title

hello_world.rb
puts "Hello World!"

MathJax Example

Mathjax

Inline Mathjax

The answser is .

Table Example

Tables Are Cool
col 1 Hello $1600
col 2 Hello $12
col 3 Hello $1

MarkDown