javascript 상하 롤링 v1.0

script 2010. 1. 31. 22:39
/**
* rolling js v1.0
* by junyong (http://junyong.pe.kr)
*/
function rolling(options) {
	var self = this;
	this.object = document.getElementById(options.rollId);
	this.object.onmouseover = function() { self.stop(); };
	this.object.onmouseout = function() { self.play(); };
	this.delay = options.delay || 1000;
	this.speed = options.speed || 50;
	this.step = options.step || 1;
	this.mover = options.mover || false;
	this.elChildHeight = options.childHeight;
	this.elHeight = this.object.offsetHeight;
	this.elPosition = 0;
	this.object.appendChild(this.object.cloneNode(true));
	this.control = setTimeout(function() {self.play()}, this.delay);
}
rolling.prototype = {
	play:function() {
		var self = this, time;
		this.elPosition = this.elPosition>(this.mover?this.elHeight:0) ? this.elPosition-this.elHeight : this.elPosition+1;
		this.object.style.top = (this.mover ? -this.elPosition : this.elPosition) + "px";
		this.control = setTimeout(function() {self.play()}, this.elPosition%(this.elChildHeight*this.step)==0?this.delay:this.speed);
	},
	stop:function() {
		clearTimeout(this.control);
	}
}

간단하게 사용할 수 있는 상하 롤링 스크립트 소스
사용은 아래와 같이
roll1 =  new rolling({rollId: "rollText1", delay: 1000, speed: 10, step: 2, mover: true, childHeight: 18});

간단 예제 파일첨부
다음버전은 좌우 롤링도..
:

Snow Leopard의 NTFS 활성화 시키기

mac 2010. 1. 25. 17:56

Link : http://forums.macrumors.com/showthread.php?t=785376

Mac os에서는 NTFS파티션을 읽기/쓰기위해서는 프로그램(NTFS-3G for Mac등)을 사용해야 했었는데
Snow Leopard에서는 기본적으로 NTFS파티션에 대해 읽기/쓰기를 지원을 한다고 하였는데
활성화 하기 위해서는 /etc/fstab파일을 수정해야 한다.

1. 기존 NTFS-3G 등 NTFS지원 프로그램을 삭제한다.
2. 터미널을 실행한다.(/응용 프로그램/유틸리티/터미널)
3. "diskutil info /Volumes/volume_name "(volume_name은 NTFS로 사용 할 볼륨이름)을 실행 후 결과화면에서 "Volumes UUID"값을 복사한다.
4. /etc/fstab 파일 백업. 기본적으로는 존재하지 않는 파일이다.
5. "sudo nano /etc/fstab " 실행
6. "UUID=paste_the_uuid_here none ntfs rw" (paste_the_uuid_here에는 아까 복사한 UUID값을 넣는다) 이나 "LABEL=volume_name none ntfs rw" (UUID값을 모를때 사용하는 명령어이며 volume_name에 볼륨이름을 넣는다)
두 명령어중 하나만 실행하면 된다.
7. ctrl-x 후 y
8 재부팅


:

jQuery 1.4 Released

script 2010. 1. 16. 22:25
javascript framework의 최고봉이라 할 수 있는 jQuery가 업데이트하여 1.4 버전을 발표했다.

자세한 내용은 jQuery 1.4 Released 페이지를 참조하고
대충 살펴보니 속도 개선을 한점과
setter함수(css(), val(), html() 등)에 function을 사용할 수 있는것
// find all ampersands in A's and wrap with a span
$('a').html(function(i,html){
  return html.replace(/&/gi,'&');
});
 
// Add some information to the title of the anchors
$('a[target]').attr("title", function(i,title){
  return title + " (Opens in External Window)";
});
core부분에서 element생성과 동시에 속성및 이벤트를 지정할 수 있는것
jQuery("
", { id: "foo", css: { height: "50px", width: "50px", color: "blue", backgroundColor: "#ccc" }, click: function() { $(this).css("backgroundColor", "red"); } }).appendTo("body");
이 외에도 추가되는 함수들이 더 있는데
jQuery 1.4 Released페이지와 API사이트를 참조하여 살펴봐야 할 듯

jQuery team이 무섭다 ㄷㄷ
점점 간단하게 개발할 수 있는데 속도까지 빨라지도 있다니 ㄷㄷ

:

jQuery - live()

script 2010. 1. 13. 00:09
Events 함수 중에 좀 멋진 live() !
HTML상의 있지도 않은 element에 대해 이벤트를 지정할 수 있다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            var index = 0;
            $("p.test").live("click", function() {
                alert($(this).text());
                $(this).after("<p class=\"test\">클릭" + ++index + "</p>");
            });
        });
    </script>
    <style type="text/css">
        p.test { background:#ccc; }
    </style>
</head>
<body>
    <p class="test">클릭</p>
</body>
</html>

live() 함수에 click 이벤트를 지정하여 앞으로 생길 p태그에 대해 이벤트를 지정할 수 있다.

Demo

클릭

: