<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>overfloweblog &#187; javaScript</title>
	<atom:link href="http://overfloweb.com/blog/index.php/archives/category/web-development/javascriptajax/feed" rel="self" type="application/rss+xml" />
	<link>http://overfloweb.com/blog</link>
	<description>are you driving me crazy?</description>
	<lastBuildDate>Wed, 18 Jan 2012 09:11:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ext JS 워드프레스 테마</title>
		<link>http://overfloweb.com/blog/index.php/archives/86</link>
		<comments>http://overfloweb.com/blog/index.php/archives/86#comments</comments>
		<pubDate>Tue, 29 Jul 2008 02:52:17 +0000</pubDate>
		<dc:creator>overflow</dc:creator>
				<category><![CDATA[info]]></category>
		<category><![CDATA[javaScript]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[Ext Js]]></category>

		<guid isPermaLink="false">http://overfloweb.com/?p=86</guid>
		<description><![CDATA[워드프레스 K2 테마를 애용해 오다가, 평소 쓰지는 않고 흠모(?)만 해오던 Ext JS 프레임웤을 기반으로 제작된 워드프레스 테마가 있다고 해서 후다닥 구해와서 적용해봤습니다. 그동안 써온 K2 테마는 훌륭하긴 하지만 이곳저곳 알수없는 충돌이 나는 경우가 많았는데, Ext JS 테마는 그런 군더더기가 없는데다가 K2 와는 또다른 스타일의 많은 화려한 기능이 탑재해 있더군요. 디자인적인 취향이야 어쩔 수 없지만, 매력적인 [...]]]></description>
			<content:encoded><![CDATA[<p>워드프레스 K2 테마를 애용해 오다가, 평소 쓰지는 않고 흠모(?)만 해오던 Ext JS 프레임웤을 기반으로 제작된 워드프레스 테마가 있다고 해서 후다닥 구해와서 적용해봤습니다.</p>
<p>그동안 써온 K2 테마는 훌륭하긴 하지만 이곳저곳 알수없는 충돌이 나는 경우가 많았는데,<br />
Ext JS 테마는 그런 군더더기가 없는데다가  K2 와는 또다른 스타일의 많은 화려한 기능이 탑재해 있더군요.</p>
<p>디자인적인 취향이야 어쩔 수 없지만, 매력적인 테마임은 분명한것 같습니다.</p>
<p><a href="http://extjswordpress.net/">http://extjswordpress.net/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://overfloweb.com/blog/index.php/archives/86/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ext Js 2.0 &#8211; 최강 Javascript UI Library</title>
		<link>http://overfloweb.com/blog/index.php/archives/41</link>
		<comments>http://overfloweb.com/blog/index.php/archives/41#comments</comments>
		<pubDate>Thu, 10 Apr 2008 09:28:42 +0000</pubDate>
		<dc:creator>overflow</dc:creator>
				<category><![CDATA[javaScript]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[Ext Js]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://overfloweb.com/?p=41</guid>
		<description><![CDATA[야후의 YUI 가 공개되고 나서 확장판격인 YUI-EXT 1.0 이 나왔을때, 그 화려하고 다이내믹한 컴포넌트들에 열광했었습니다. 하지만 화려한 만큼 적용하기가 쉽지 않았고 여러가지 제약도 많아서 제대로 써보지도 못하고 감탄만 하고 말았었죠. 그렇게 그림의 떡 정도로 외면 당하기엔 아까운 화려한 인터페이스 라이브러리 Ext 가 안정적이고 최적화된 모습으로 Ext Js 2.0 을 공개했습니다. 그전에 ExtJs 2.0 과 Google [...]]]></description>
			<content:encoded><![CDATA[<p>야후의 <a href="http://developer.yahoo.com/yui/">YUI</a> 가 공개되고 나서 확장판격인 YUI-EXT 1.0 이 나왔을때, 그 화려하고 다이내믹한 컴포넌트들에 열광했었습니다.<br />
하지만 화려한 만큼 적용하기가 쉽지 않았고 여러가지 제약도 많아서 제대로 써보지도 못하고 감탄만 하고 말았었죠.<br />
그렇게 그림의 떡 정도로 외면 당하기엔 아까운 화려한 인터페이스 라이브러리 Ext 가 안정적이고 최적화된 모습으로 <a href="http://extjs.com">Ext Js 2.0</a> 을 공개했습니다.</p>
<p>그전에 ExtJs 2.0 과 Google Gears 가 통합했다는 소식을 접한 바 있었는데, 구글 기어즈가 safari 를 공식적으로 지원하지 않기 때문에 그다지 좋은 소식으로 들리진 않았지만 어떤 모습으로 더 강력해졌는지 자세히 살펴보고 싶어졌습니다.</p>
<p><a href="http://overfloweb.com/ext2/examples/">공개된 샘플</a> 에 있는 다양한 컴포넌트들 하나하나 들여다 보면 계속해서 놀라게 됩니다.<br />
그 중에서 <a href="http://overfloweb.com/ext2/examples/desktop/desktop.html">desktop</a> 을 보고 있자니 말이 안나옵니다. javascript 가 이렇게 까지도 표현이 가능하군요!</p>
<p><a href="http://extjs.com/deploy/dev/docs/">API</a> 는 물론 친절하게도 <a href="http://extjs.com/learn/Tutorial:Playing_With_Ext_The_Easy_Way_%28Korean%29">한국어 tutorial</a> 도 제공하고 있습니다.<br />
prototype.js 의 syntax 와 많이 비슷해서 쉽게 적응할 수 있을 듯 합니다.</p>
<p>자세한 기술적인 내용은 좀 더 다뤄보고 공부하면서 포스팅 할 생각 입니다.</p>
<p>지금까지 공개된 Ajax UI 컴포넌트 라이브러리 중에서 가장 강력한 기능을 가진놈이 아닐까 합니다.</p>
]]></content:encoded>
			<wfw:commentRss>http://overfloweb.com/blog/index.php/archives/41/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YDN이 권장하는 웹사이트의 최적화 지침</title>
		<link>http://overfloweb.com/blog/index.php/archives/39</link>
		<comments>http://overfloweb.com/blog/index.php/archives/39#comments</comments>
		<pubDate>Thu, 10 Apr 2008 02:21:50 +0000</pubDate>
		<dc:creator>overflow</dc:creator>
				<category><![CDATA[css/html]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[javaScript]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://overfloweb.com/?p=39</guid>
		<description><![CDATA[웹 사이트 성능 최적화 에반젤리스트(Evangelist)로 활동 중인 YDN(Yahoo! Developer Network)의 Steve Souders씨가 작성한 15개의 웹 사이트 성능 최적화 지침이다. &#8220;High Performance Web Sites&#8220;라는 이름으로 책이 출간되어 있으며, Firebug의 확장기능인 YSlow역시 이 규칙들에 기반하고 있다. 다음 예제들은 지침에 근거하여 작성한 실습 예제들로서 조금더 구체적인 성능향상 방법들을 제시한다. 규칙 1 &#8211; HTTP 요청을 줄여라 HTML에 속해있는 이미지, 스크립트, 플래시 등은 서버로 요청하고 응답받기까지의 시간을 필요로한다. 이러한 외부파일들이 [...]]]></description>
			<content:encoded><![CDATA[<p>웹 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%82%AC%EC%9D%B4%ED%8A%B8+', '사이트 ')">사이트</span> 성능 최적화 에반젤리스트(Evangelist)로 활동 중인 <a href="http://developer.yahoo.com/performance/rules.html">YDN(Yahoo! Developer <span class="key1" onclick="Keyword.open('/kview.php?kd=+Network', ' Network')">Network</span>)</a>의 <a href="http://stevesouders.com/hpws/">Steve Souders씨가 작성한 15개의 웹 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%82%AC%EC%9D%B4%ED%8A%B8+', '사이트 ')">사이트</span> 성능 최적화 지침</a>이다. &#8220;<a href="http://www.amazon.com/gp/product/0596529309?ie=UTF8&amp;tag=stevsoud-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596529309">High Performance Web <span class="key1" onclick="Keyword.open('/kview.php?kd=+Site', ' Site')">Site</span>s</a>&#8220;라는 이름으로 책이 출간되어 있으며, Firebug의 확장기능인 YSlow역시 이 규칙들에 기반하고 있다. 다음 예제들은 지침에 근거하여 작성한 실습 예제들로서 조금더 구체적인 성능향상 방법들을 제시한다.</p>
<h3>규칙 1 &#8211; HTTP 요청을 줄여라</h3>
<p>HTML에 속해있는 이미지, 스크립트, <span class="key1" onclick="Keyword.open('/kview.php?kd=%ED%94%8C%EB%9E%98%EC%8B%9C', '플래시')">플래시</span> 등은 서버로 요청하고 응답받기까지의 시간을 필요로한다. 이러한 외부파일들이 많으면 많을 수록 웹 사이트의 성능을 떨어트리기 마련이다. 다음은 예제들은 HTTP 요청을 줄이기 위한 방법을 제시하며 동일한 결과물을 놓고 직접 비교할 수 있다. 참고로 예제 6 ,7번에서 사용된 <a href="http://www.blankus.net/43">Data URI</a>는 IE7 이하에서 지원하지 않기 때문에 그림의 떡이나 마찬가지다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/imagemap-no.php">No Image Map</a> : 이미지맵을 사용하지 않았을 때</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/imagemap.php">Image Map</a> : 이미지맵을 사용했을 때</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/sprites.php">CSS Sprites</a> : CSS로 분할한 큰 이미지</li>
<li>예제 4 - <a href="http://stevesouders.com/hpws/combo-none.php">Separate <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span>s</a> : 분할 된 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span></li>
<li>예제 5 - <a href="http://stevesouders.com/hpws/combo.php">Combined <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span>s</a> : 합쳐진 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span></li>
<li>예제 6 - <a href="http://stevesouders.com/hpws/inline-images.php">Inline Images</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=+Data', ' Data')">Data</span> URI로 작성하여 출력한 이미지</li>
<li>예제 7 - <a href="http://stevesouders.com/hpws/inline-css-images.php">Inline CSS Images</a> : CSS에서 지정한 <span class="key1" onclick="Keyword.open('/kview.php?kd=+Data', ' Data')">Data</span> URI 이미지</li>
</ul>
<p> </p>
<h3>규칙 2 - <span class="key1" onclick="Keyword.open('/kview.php?kd=+CD', ' CD')">CD</span>N을 사용하라</h3>
<p><span class="key1" onclick="Keyword.open('/kview.php?kd=+CD', ' CD')">CD</span>N(Content Delivery <span class="key1" onclick="Keyword.open('/kview.php?kd=+Network', ' Network')">Network</span>)은 접속하는 사용자의 위치에 따라서 응답이 빠른 서버로 접속하여 필요한 파일들을 호출하는 것을 말한다. 글로벌라이제이션 서비스를 지향하는 서비스에 적절한 성능향상 방법으로 일반(특정 지역만을 대상으로 하는 서비스) 사이트에서는 만족스러운 향상효과를 기대하기 어렵다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/ex-cdn.php">CDN</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=+CD', ' CD')">CD</span>N 사용</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/ex-nocdn.php">No <span class="key1" onclick="Keyword.open('/kview.php?kd=+CD', ' CD')">CD</span>N</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=+CD', ' CD')">CD</span>N 미사용</li>
</ul>
<p> </p>
<h3>규칙 3 &#8211; Expires 헤더를 추가하라</h3>
<p><span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span>를 이용한 Ajax와 복잡한 UI 등이 널리 애용되면서 더욱 많은 외부파일(스크립트와 이미지, 스타일시트 등)들을 생산하게 됨에 따라 이를 효율적으로 처리하지 못할 경우 웹 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%82%AC%EC%9D%B4%ED%8A%B8+', '사이트 ')">사이트</span> 성능이 크게 저하되기도 한다. 외부파일들의 헤더에 Expires 정보를 추가하여 캐시하는 것 만으로도 웹 사이트의 성능을 끌어 올릴 수 있다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/expiresoff.php">No Expires</a> : Expires 헤더 미사용</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/expireson.php">Far Future Expires</a> : Expires 헤더 사용</li>
</ul>
<p> </p>
<h3>규칙 4 &#8211; Gzip 압축을 사용하라</h3>
<p>외부파일들을 압축하여 성능을 높일 수도 있다. 현존하는 대부분의 브라우저가 Gzip 압축전송을 지원하며, 이또한 헤더 정보를 수정하고 비교적 간단한 서버단 작업으로 구현할 수 있다. </p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/nogzip.html">Nothing Gzipped</a> : 압축전송 미사용</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/gzip-html.html">HTML Gzipped</a> : HTML만 압축전송</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/gzip-all.html">Everything Gzipped</a> : 모두 파일을 압축전송</li>
</ul>
<p> </p>
<h3>규칙 5 &#8211; 스타일시트(CSS)는 위에 선언하라</h3>
<p>스타일시트(CSS)는 HTML의 헤드(Head)태그의 최상단에 위치하는 것이 성능향상에 도움된다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/css-bottom.php">CSS at the Bottom</a> : CSS를 아래에 넣은 경우</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/css-top.php">CSS at the Top</a> : CSS를 위에 넣은 경우</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/css-top-import.php">CSS at the Top Using @import</a> : CSS <span class="key1" onclick="Keyword.open('/kview.php?kd=%ED%8C%8C%EC%9D%BC+', '파일 ')">파일</span> 호출에 @import를 사용한 경우</li>
<li>예제 4 - <a href="http://stevesouders.com/hpws/css-fouc.php">CSS <span class="key1" onclick="Keyword.open('/kview.php?kd=Flash+', 'Flash ')">Flash</span> of Unstyled <span class="key1" onclick="Keyword.open('/kview.php?kd=+Content', ' Content')">Content</span></a></li>
</ul>
<p> </p>
<h3>규칙 6 &#8211; 스크립트는 아래에 작성하라</h3>
<p><span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 파일들은 바디(Body)태그에서 호출하는 것으로 성능을 높일 수 있다. 다음 예제들은 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span> 위치에 따른 성능변화를 매우 직관적으로 표현하고 있다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/js-middle.php">Scripts in the Middle</a> : 스크립트를 중앙에서 호출</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/move-scripts.php">Scripts Top vs. Bottom</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 호출 위치의 상단과 하단 비교</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/js-top.php">Scripts at the Top</a> : 스크립트를 상단에서 호출</li>
<li>예제 4 - <a href="http://stevesouders.com/hpws/js-bottom.php">Scripts at the Bottom</a> : 스크립트를 하단에서 호출</li>
<li>예제 5 - <a href="http://stevesouders.com/hpws/js-blocking.php">Scripts Block Downloads</a> : 스크립트가 다운로드를 방해하는 사용</li>
<li>예제 6 - <a href="http://stevesouders.com/hpws/js-defer.php">Deferred <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span>s</a> : 로딩을 연장시키는 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 사용</li>
</ul>
<p> </p>
<h3>규칙 7 &#8211; CSS에서 Expressions 사용을 자제하라</h3>
<p>IE계열 브라우저에서만 작동하는 expression은 IE6 이하에서 표현하지 못하는 스타일링에 상습적으로 사용한다. 브라우저로 하여금 다소 무리한 연산을 요구하기 때문에 사용을 자제하는 것이 좋다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/expression-counter.php">Expression Counter</a> : Expression 복수 사용</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/no-expressions.php">No Expressions</a> : Expression 사용 안함</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/onetime-expressions.php">One-Time Expressions</a> : Expression 한번 사용</li>
<li>예제 4 - <a href="http://stevesouders.com/hpws/event-handler.php">Event Handler</a> : 이벤트 핸들러 사용</li>
</ul>
<p> </p>
<h3>규칙 8 - <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span>와 스타일시트는 외부파일로 분리하라</h3>
<p>너무나도 당연한 성능향상을 기대할 수 있다. 일단 브라우저에서 캐시효과를 누릴 수 있는 것 외에도 필요한 스크립트만을 호출할 수 있는 등 부가적으로 얻어지는 가치는 상당하다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/inlined.php">Inlined JS and CSS</a> : CSS와 JS를 외부파일로 분리하지 않음</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/external.php">External JS and CSS</a> : CSS와 JS를 외부파일로 분리함</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/external-cacheable.php">Cacheable External JS and CSS</a> : 외부파일로 분리한 CSS와 JS를 캐시함</li>
<li>예제 4 - <a href="http://stevesouders.com/hpws/post-onload.php">Post-Onload Download</a> : 페이지 로딩이 완료된 후(Onload) JS와 CSS 호출</li>
<li>예제 5 - <a href="http://stevesouders.com/hpws/dynamic-inlining.php">Dynamic Inlining</a> : 동적인 외부<span class="key1" onclick="Keyword.open('/kview.php?kd=%ED%8C%8C%EC%9D%BC+', '파일 ')">파일</span> 호출</li>
</ul>
<p> </p>
<h3>규칙 9 - <span class="key1" onclick="Keyword.open('/kview.php?kd=DNS', 'DNS')">DNS</span> 확인 시간을 줄여라</h3>
<p><span class="key1" onclick="Keyword.open('/kview.php?kd=DNS', 'DNS')">DNS</span>(Domain Name <span class="key1" onclick="Keyword.open('/kview.php?kd=+System', ' System')">System</span>)란 쉽게 말해 인터넷의 전화번호부라고 할 수 있다. 도메인이 사람이름이고 IP가 전화번호인 셈이다. 전화번호부에서 원하는 전화번호를 찾기위해 시간이 걸리는 것 처럼 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EB%B8%8C%EB%9D%BC%EC%9A%B0%EC%A0%80+', '브라우저 ')">브라우저</span> 또한 <span class="key1" onclick="Keyword.open('/kview.php?kd=DNS', 'DNS')">DNS</span> 확인을 위한 시간을 필요로한다. 여기에 들이는 시간을 줄여서 웹 사이트의 성능을 높일 수 있다. <span class="key1" onclick="Keyword.open('/kview.php?kd=DNS', 'DNS')">DNS</span>정보 역시 브라우저의 저장영역에 캐시되어 있기 때문에 같은 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EB%8F%84%EB%A9%94%EC%9D%B8+', '도메인 ')">도메인</span> 네임을 사용할 경우 <span class="key1" onclick="Keyword.open('/kview.php?kd=DNS', 'DNS')">DNS</span> 확인에 걸리는 시간을 최소화 할 수 있는 것이다. 도메인이 서로다른곳의 외부파일들을 불러올 때 고려해야 할 사항이다.</p>
<h3>규칙 10 - <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span>를 최소화 하라</h3>
<p>JS, CSS 파일을 압축(Minified) 또는 암호화(Obfuscated or Packed)하여 용량을 줄일 수 있다. Minify는 <span class="key1" onclick="Keyword.open('/kview.php?kd=%ED%8C%8C%EC%9D%BC+', '파일 ')">파일</span> 내부의 개행과 주석 그리고 인텐트(들여쓰기) 등, 시스템이 이해하기에 불표한 문자열을 제거하여 용량을 줄이는 방법이고 Packing은 여러가지 압축기법으로 문장을 암호화하여 브라우저의 인터프리터에 의존해 해석(Evaluate)하는 방식으로 Minified 파일보다 압축률이 훨씬 높다. 참고로, <a href="http://firejune.com/1299">매번 Packed하는 것이 꼭 좋지만은 않다.</a></p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/js-small-normal.php">Small <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span> Normal</a> : 작은 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 일반 호출</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/js-small-minify.php">Small <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span> Minified</a> : 작은 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 최소화 호출</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/js-small-obfuscate.php">Small <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span> Obfuscated</a> : 작은 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 암호화 호출</li>
<li>예제 4 - <a href="http://stevesouders.com/hpws/js-large-normal.php">Large <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span> Normal</a> : 큰 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 일반 호출</li>
<li>예제 5 - <a href="http://stevesouders.com/hpws/js-large-minify.php">Large <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span> Minified</a> : 큰 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 최소화 호출</li>
<li>예제 6 - <a href="http://stevesouders.com/hpws/js-large-obfuscate.php">Large <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span> Obfuscated</a> : 큰 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 암호화 호출</li>
</ul>
<p> </p>
<h3>규칙 11 &#8211; 리다이렉트는 피하라</h3>
<p>포워딩(Forwarding)과 달리 리다이렉트(Redirect)는 <a href="http://www.anfamily.net/mcsong/240">2차례에 걸쳐 통신</a>하게 된다. 그만큼 서버로부터의 응답이 완료되기까지 소요되는 시간이 길기 때문이다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/redir-beacon.php">Image Beacon</a></li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/xhr-beacon.php">XMLHttpRequest Beacon</a></li>
</ul>
<p> </p>
<h3>규칙 12 &#8211; 중복되는 스크립트는 제거하라</h3>
<p>때때로 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span> 파일을 복수로 불러야할 때가 있다. 이 때 캐시설정을 하지 않았다면, 동일한 파일이라 할지라도 브라우저는 지속적으로 요청을 하고 같은 수행을 반복 한다. 이와 같은 스크립팅은 가급적이면 피하는 것이 좋다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/dupe-scripts.php">Duplicate <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span>s &#8211; Not <span class="key1" onclick="Keyword.open('/kview.php?kd=+Cache', ' Cache')">Cache</span>d</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 중복 - <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%BA%90%EC%8B%9C+', '캐시 ')">캐시</span> 없음</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/dupe-scripts-cached.php">Duplicate <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span>s - <span class="key1" onclick="Keyword.open('/kview.php?kd=+Cache', ' Cache')">Cache</span>d</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 중복 &#8211; 캐시적용</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/dupe-scripts-cached10.php">Duplicate <span class="key1" onclick="Keyword.open('/kview.php?kd=+Script', ' Script')">Script</span>s &#8211; 10 <span class="key1" onclick="Keyword.open('/kview.php?kd=+Cache', ' Cache')">Cache</span>d</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8+', '스크립트 ')">스크립트</span> 중복 &#8211; 10개 <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%BA%90%EC%8B%9C+', '캐시 ')">캐시</span> 적용</li>
</ul>
<p> </p>
<h3>규칙 13 &#8211; ETag 헤더를 설정하라</h3>
<p>ETag는 HTTP/1.1에 기본으로 사용하도록 설정된 태그로서 파일<span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%BA%90%EC%8B%9C+', '캐시 ')">캐시</span> 및 갱신 진위여부를 가리는데 사용된다. 캐시와 밀접한 연관이 있으므로 외부파일의 헤더에는 ETag를 항상 설정하여 전송량을 최소화할 수 있다. 보다 자세한 내용은 &#8220;<a href="http://firejune.com/1151">응답헤더 설정으로 웹<span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%82%AC%EC%9D%B4%ED%8A%B8+', '사이트 ')">사이트</span> 성능 개선하기</a>&#8220;를 참고하자.</p>
<h3>규칙 14 &#8211; AJAX를 캐시하도록 하라</h3>
<p><span class="key1" onclick="Keyword.open('/kview.php?kd=+Ajax+', ' Ajax ')">Ajax</span>요청 역시 Expires 헤더를 설정하여 캐시효과를 누릴 수 있다.</p>
<h3>규칙 15 &#8211; 아이프레임을 현명하게 사용하라</h3>
<p>아이프레임역시 src 속성에 의해 브러우저로 하여금 HTTP 요청을 할당한다. 아이프레임을 다수 사용할 때 src 속성을 지정하지 않는 것으로 로딩속도를 향상시킬 수 있다.</p>
<ul class="square">
<li>예제 1 - <a href="http://stevesouders.com/hpws/iframes-none.php">No Iframes</a> : 아이프레임 없음</li>
<li>예제 2 - <a href="http://stevesouders.com/hpws/iframes-10.php">10 Iframes</a> : 10개의 아이프레임 src 없음</li>
<li>예제 3 - <a href="http://stevesouders.com/hpws/iframes-100.php">100 Iframes</a> : 100개의 아이프레임 src 없음</li>
<li>예제 4 - <a href="http://stevesouders.com/hpws/iframes-src.php">Iframe SRC Blocks</a> : src 지정으로 로딩속도 감속</li>
<li>예제 5 - <a href="http://stevesouders.com/hpws/iframes-src-js.php">Iframe SRC JS</a> : <span class="key1" onclick="Keyword.open('/kview.php?kd=%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8', '자바스크립트')">자바스크립트</span>에 의한 src 지정으로 로딩속도 확보</li>
<li>예제 6 - <a href="http://stevesouders.com/hpws/iframes-src-slow-components.php">Iframe SRC Slow Components</a></li>
<li>예제 7 - <a href="http://stevesouders.com/hpws/iframes-src-js-slow-components.php">Iframe SRC JS Slow Components</a></li>
<li>예제 8 - <a href="http://stevesouders.com/hpws/iframes-js-src-components.php">Iframe JS SRC and Components</a></li>
<li>예제 9 - <a href="http://stevesouders.com/hpws/iframes-many-components.php">Iframe Many Components</a></li>
</ul>
<div>출처 : <a href="http://firejune.com/1302">http://firejune.com/1302</a></div>
]]></content:encoded>
			<wfw:commentRss>http://overfloweb.com/blog/index.php/archives/39/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Script.aculo.us] dragdrop.js</title>
		<link>http://overfloweb.com/blog/index.php/archives/12</link>
		<comments>http://overfloweb.com/blog/index.php/archives/12#comments</comments>
		<pubDate>Tue, 01 Apr 2008 05:24:40 +0000</pubDate>
		<dc:creator>overflow</dc:creator>
				<category><![CDATA[javaScript]]></category>
		<category><![CDATA[script.aculo.us]]></category>

		<guid isPermaLink="false">http://overflow.ivyro.net/?p=12</guid>
		<description><![CDATA[  dragdrop.js script.aculo.us에서 Drag&#38;Drop 기능을 제공해주는 라이브러리입니다.   Droppables 드래그 대상이 되는 Draggable객체들을 Drop할 수 있는 element들을 관리하는 클래스입니다.   Attribute Droppables.drops: Array &#8211; Droppable 객체(실제로는 add()의 options 전체 항목이 저장됩니다.)들을 저장하는 배열입니다.   Method 1. Droppables.add(element, options) &#8211; Droppable 객체를 추가합니다. options로 다음 사항을 받을 수 있습니다. options 항목들 accept &#8211; Droppable에서 받아들일 Draggable [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="font-family: 'Times New Roman';">  dragdrop.js<br />
</span></strong>script.aculo.us에서 Drag&amp;Drop 기능을 제공해주는 라이브러리입니다.</p>
<p><span style="font-weight: bold; font-size: small;">  Droppables</span><br />
드래그 대상이 되는 Draggable객체들을 Drop할 수 있는 element들을 관리하는 클래스입니다.</p>
<div class="imageblock center" style="CLEAR: both; TEXT-ALIGN: center"><img src="http://cfs3.tistory.com/upload_control/download.blog?fhandle=YmxvZzk5NzVAZnMzLnRpc3RvcnkuY29tOi9hdHRhY2gvNS81NjkuUE5H" alt="사용자 삽입 이미지" width="334" height="224" /></div>
<p><span style="font-style: italic; font-size: small;">  Attribute</span><br />
<span style="COLOR: #8e8e8e">Droppables.</span>drops: Array &#8211; Droppable 객체(실제로는 add()의 options 전체 항목이 저장됩니다.)들을 저장하는 배열입니다.</p>
<p><span style="font-style: italic; font-size: small;">  Method</span><br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">1. </span>Droppables.</span>add(<span style="FONT-STYLE: italic">element</span>, <span style="FONT-STYLE: italic">options</span>) &#8211; Droppable 객체를 추가합니다. options로 다음 사항을 받을 수 있습니다.<br />
options 항목들</p>
<ul>
<li>accept &#8211; Droppable에서 받아들일 Draggable 객체의 클래스 스트링들을 설정합니다.</li>
<li>containment &#8211; Droppable에서 받아들일 Draggable객체의 element나 id를 설정합니다.</li>
<li>hoverclass<span style="COLOR: #8e8e8e">:boolean</span> &#8211; 받아들이기로 한 Draggable객체가 Droppable의 위에 있을 때 css를 설정하는 class를 설정합니다.</li>
<li>overlap &#8211; &#8216;<span style="COLOR: #993366">horizontal</span>&#8216; 또는 &#8216;<span style="COLOR: #993366">vertical</span>&#8216;을 인자로 받습니다. 수직/수평 방향으로 이동할 때 동작이 발생하도록 합니다.</li>
<li>greedy<span style="COLOR: #8e8e8e">:boolean</span> &#8211; true로 설정된 경우 hover와 관련된 처리를 수행하지 않습니다.</li>
</ul>
<p>options 항목들 중 내부사용 프로퍼티</p>
<ul>
<li><span style="COLOR: #8e8e8e">tree</span> &#8211; tree에서 사용하기 위한 코드로 보임</li>
<li><span style="COLOR: #8e8e8e">_continaers </span>- options.containment객체들이 저장됩니다.</li>
<li><span style="COLOR: #8e8e8e">element </span>- 실제 Droppable element가 저장됩니다. <span style="FONT-STYLE: italic"><br />
</span></li>
</ul>
<p>options 항목의 callback들</p>
<ul>
<li>onHover(<span style="COLOR: #8e8e8e; FONT-STYLE: italic">dragElement, dropElement, position</span>) &#8211; 받아들이기로 한 Draggable 객체가 Droppable의 위에 있에 있을 때 메소드를 onHover 인자로 받은 function을 호출합니다.</li>
<li>onDrop(<span style="COLOR: #8e8e8e; FONT-STYLE: italic">dragElement, dropElement, event</span>) &#8211; 받아들이기로 한 Drggable 객체가 Droppable의 위에서 릴리즈되었을 때 onDrop 인자로 받은 function을 호출합니다.</li>
</ul>
<p><span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">2. </span></span><span style="COLOR: #8e8e8e">Droppables.</span>remove(<span style="FONT-STYLE: italic">element</span>) &#8211; Droppable 객체를 삭제합니다.<br />
<span style="FONT-WEIGHT: bold"><br />
3.</span> <span style="COLOR: #8e8e8e">Droppables.</span>findDeepestChild(drops)<br />
- drops 루프를 돌면서 drops에서 가장 먼저 등록한 Droppable 객체들 중에서 가장 상위에 있는 Droppable 객체를 찾는 메소드입니다. (의도는?)<br />
<span style="FONT-WEIGHT: bold"><br />
4.</span> <span style="COLOR: #8e8e8e">Droppables.</span>isContained(element, drop)<br />
- 인자로 받는 element의 부모노드가 drop의 containment(받아들이기로 한 element) 목록에 있는 지 여부를 리턴합니다.</p>
<p><span style="FONT-WEIGHT: bold">5.</span> <span style="COLOR: #8e8e8e">Droppables.</span>isAffected(point, element, drop)<br />
- 인자로 받는 element가 인자로 받는 drop(Droppable)에 Drop이 된 것인지의 여부를 체크하는 메소드입니다.</p>
<ol>
<li>drop.element와 달라야하고,</li>
<li>drop._containers가 있는 경우 여기에 속해야하고,</li>
<li>drop.accept가 있는 경우 element의 className중 하나가 해당해야하고,</li>
<li>drop.element의 안에 인자로 받는 point의 위치가 속해야 합니다.</li>
</ol>
<p><span style="FONT-WEIGHT: bold">6.</span> <span style="COLOR: #8e8e8e">Droppables.</span>activate(drop) [<span style="COLOR: #8e8e8e">Droppables.</span>deactivate(drop)]<br />
- active[deactive]가 된 경우, drop.hoverclass가 있다면 drop.element에 hoverclass를 설정[제거]하고 last_activate 값을 설정[null로 설정]합니다.</p>
<p><span style="COLOR: #993366">※ show, fire, reset 메소드의 경우 Draggable에서 호출되는 메소드입니다. </span><br />
<span style="FONT-WEIGHT: bold">7. </span><span style="COLOR: #8e8e8e">Droppables.</span>show(point, element)<br />
- element의 Drop에 해당하는 Droppable이 있으면 hover 이펙트를 발생시킵니다.</p>
<ol>
<li>인자로 받은 element가 Drop되었는지를 체크(<span style="FONT-STYLE: italic">isAffected()</span>)하여 affected에 담습니다.</li>
<li>affected된 Droppable 중에서 가장 상위의 element(<span style="FONT-STYLE: italic">findDeepestChild()를 사용하여</span>)를 찾습니다.</li>
<li>해당하는 Droppable을 activate시킵니다.</li>
</ol>
<p><span style="FONT-WEIGHT: bold">8.</span> <span style="COLOR: #8e8e8e">Droppables.</span>fire(event, element) &#8211; onDrop 옵션을 가지고 있는 경우 onDrop 이벤트를 실행시킵니다.<br />
<span style="FONT-WEIGHT: bold">9.</span> <span style="COLOR: #8e8e8e">Droppables.</span>reset() &#8211; 초기화(deactivate) 시킵니다.</p>
<p><span style="font-weight: bold; font-size: small;">  Draggables</span><br />
Draggables객체들을 관리하는 클래스입니다.</p>
<div class="imageblock center" style="CLEAR: both; TEXT-ALIGN: center"><img src="http://cfs2.tistory.com/upload_control/download.blog?fhandle=YmxvZzk5NzVAZnMyLnRpc3RvcnkuY29tOi9hdHRhY2gvNS81NDMuUE5H" alt="사용자 삽입 이미지" width="390" height="340" /></div>
<p><span style="font-style: italic; font-size: small;">  Attribute</span><br />
<span style="COLOR: #8e8e8e">Draggables.</span>drags: Array &#8211; draggable을 저장합니다.<br />
<span style="COLOR: #8e8e8e">Draggables.</span>observers: Array -<br />
activeDraggable &#8211; 현재 활성화되어 있는 Draggable을 가르키는 변수입니다.</p>
<p><span style="font-style: italic; font-size: small;">  Method</span><br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">1. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>register(<span style="FONT-STYLE: italic">draggable</span>)<br />
- draggable을 인자로 받아서 drags에 추가합니다.<br />
- drggable이 처음 등록되는 경우 document의 mouseup/mousemove/keypress 이벤트 핸들러로 eventMoueUp/eventMouseMove/eventKeypress 메소드를 등록합니다.</p>
<p><span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">2. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>unregister(<span style="FONT-STYLE: italic">draggable</span>) -<br />
- 인자로 받는 draggable을 drags에서 삭제합니다.<br />
- 모든 draggable이 삭제되는 경우, document의 mouseup/mousemove/keypress 이벤트에 등록된 핸들러들을 모두 삭제합니다.</p>
<p><span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">3. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>activate(<span style="FONT-STYLE: italic">draggable</span>)<br />
- Draggable에서 호출되며, (delay 옵션이 있는 경우 dealy 옵션 뒤에) activeDraggable을 설정합니다.</p>
<p><span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">4. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>deactivate() &#8211; activeDraggable을 삭제합니다.(null처리)</p>
<p><span style="COLOR: #993366">※ 2에서 등록하였던 mouseup/mousemove/keypress 이벤트에 따라서, (activeDraggable이 있는 경우)activeDraggable에 해당하는 이벤트를 전달하는 역할을 합니다. </span><br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">5. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>updateDrag(<span style="FONT-STYLE: italic">event</span>)<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">6. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>endDrag(<span style="FONT-STYLE: italic">event</span>)<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">7. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>keyPress(<span style="FONT-STYLE: italic">event</span>) <br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000"><br />
</span><span style="COLOR: #993366">※ 8, 9, 10, 11은 Draggables.observers와 관련된 메소드들로 Draggable에서 onStart/End/Drag 이벤트가 발생됬을 때, 해당하는 이벤트를 듣기 위한 구조입니다. </span><span style="FONT-WEIGHT: bold; COLOR: #000000"><br />
8. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>addObserver(<span style="FONT-STYLE: italic">observer</span>)<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">9. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>removeObserver(<span style="FONT-STYLE: italic">element</span>)<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">10. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>notify(<span style="FONT-STYLE: italic">eventName, draggable, event</span>)<br />
- <span style="COLOR: #8e8e8e"><span style="COLOR: #000000">notify는 Draggable에서 호출되는 메소드로 onStart/onEnd/onDrag 이벤트가 발생한경우 observer에서 해당하는 이벤트를 관차하는 observer가 있는 경우 observer의 callback을 호출한 후 draggable의 등록된 callback을 호출합니다. </span></span><br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">11. </span></span><span style="COLOR: #8e8e8e">Draggables</span><span style="COLOR: #8e8e8e">.</span>_cacheObserverCallbacks()</p>
<p><span style="font-weight: bold; font-size: small;">  Draggable</span><br />
Drag되는 (Draggable)객체 입니다.</p>
<div class="imageblock center" style="CLEAR: both; TEXT-ALIGN: center"><img src="http://cfs3.tistory.com/upload_control/download.blog?fhandle=YmxvZzk5NzVAZnMzLnRpc3RvcnkuY29tOi9hdHRhY2gvNS81NzAuUE5H" alt="사용자 삽입 이미지" width="344" height="441" /></div>
<p><span style="font-style: italic; font-size: small;">Creation</span></p>
<blockquote><p><span style="COLOR: #993366">new </span>Draggable(<span style="FONT-STYLE: italic">&#8216;id_of_element&#8217;</span>, [<span style="FONT-STYLE: italic">options</span>]);</p></blockquote>
<p>options항목은 다음과 같습니다.</p>
<ul>
<li>handle &#8211; v1.0에서는 draggable할 element의 레퍼런스와 id를 인자로 받습니다. v1.5에서는 css 클래스 스트링으로 사용됩니다.</li>
<li>revert <span style="COLOR: #8e8e8e">:boolean</span> &#8211; true인 경우, 시작점으로 돌아갑니다. function이 들오올 수 있습니다.(since v1.5) 디폴트 값은 false입니다.</li>
<li>snap &#8211; true인 경우, snapping(달려들어 무는)이 발생합니다. 디폴트 값은 false입니다.</li>
<li>zindex &#8211; draggable할 item의 zindex를 정의합니다.</li>
<li>constraint &#8211; &#8216;horizontal&#8217; 또는 &#8216;vertical&#8217;이 설정되는 경우, 수평/수직으로만 이동하도록 설정됩니다.</li>
<li>ghosting <span style="COLOR: #8e8e8e">:boolean</span> &#8211; Drag~Drop이 진행되는 동안 자신의 위치에 clone object를 남겨둡니다.</li>
<li>starteffect &#8211; Drag가 시작될 때, 적용할 이펙트를 정의합니다. 디폴트로 투명 이펙트(Opacity)를 실행합니다.</li>
<li>reverteffect &#8211; Drag를 하다 되돌아가는 경우(Droppable영역이 아닌 지역에서 릴리즈했을 때)에 적용할 이펙트를 정의합니다. 디폴트 값으로는 시작점 포인트로 직선 이동하는 이펙트(Move)를 실행합니다.</li>
<li>endeffect &#8211; Drag가 종료될 때, 적용할 이펙트를 정의합니다. 디폴트로 투명 이펙트(Opacity)를 실행합니다.</li>
</ul>
<p>options에 설정되는 callback function입니다.</p>
<ul>
<li>change &#8211; Drag로 인하여 Draggable의 위치가 변경된 경우 발생합니다.</li>
</ul>
<p><span style="font-style: italic; font-size: small;">  Attribute</span><br />
<span style="COLOR: #8e8e8e">Draggable.</span>drags: Array &#8211; draggable을 저장합니다.<br />
<span style="COLOR: #8e8e8e">Draggable.</span>observers: Array &#8211; observer할 object들을 저장합니다.<br />
activeDraggable &#8211; 현재 활성화되어 있는 Draggable을 가르키는 변수입니다.<br />
dragging: <span style="COLOR: #8e8e8e">boolean </span>- dragging이 진행 중인지를 저장하는 변수입니다.</p>
<p><span style="font-style: italic; font-size: small;">  Method</span><br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">1. </span></span>destroy()<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">2. </span></span>currentDelta() &#8211; Draggable element의 left/top 위치를 리턴합니다.<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">3. </span></span>initDrag(<span style="FONT-STYLE: italic">event</span>)<br />
- Draggable에 mousedown 이벤트가 발생한 경우 호출됩니다.<br />
- draggable에 포함되는치, form element인지를 체크한 후, 현재의 마우스 위치와 실제 화면상의 위치 값을 저장한 후 Draggables.activate를 호출합니다.<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000"><br />
4. </span></span>startDrag(<span style="FONT-STYLE: italic">event</span>)<br />
- Draggable.updateDrag에서 호출됩니다.</p>
<ol>
<li>dragging 값을 true로 설정합니다.</li>
<li>zindex, ghosting, scroll과 관련된 option이 있는 경우 해당 option과 관련된 작업을 수행합니다.</li>
<li>Draggables에 onStart이벤트가 발생했음을 알립니다.</li>
<li>options에 starteffect가 있는 경우 starteffect를 수행합니다.</li>
</ol>
<p><span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">5. </span></span>updateDrag(<span style="FONT-STYLE: italic">event, pointer</span>)<br />
- Draggables.updateDrag에서 document의 mousemove 이벤트에 등록된 updateDrag에 의해서 호출됩니다.</p>
<ol>
<li>this.dragging이 설정되어 있지 않은 경우 startDrag를 호출합니다.</li>
<li>Droppables.show를 호출하여 현재 해당하는 Droppable이 있는 경우에 대한 처리를 수행합니다.</li>
<li>Draggable을 이동시킵니다.</li>
<li>options.scroll과 관련된 항목을 처리합니다.</li>
</ol>
<p><span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">6. </span></span>finishDrag(<span style="FONT-STYLE: italic">event, success</span>)<br />
- mouseup 또는 esc키가 눌린 경우 호출됩니다.</p>
<ol>
<li>this.dragging을 false로 설정합니다.</li>
<li>mouseup인 경우, Droppables.fire를 호출하여 Drop 이벤트에 대한 처리를 수행하게 합니다.</li>
<li>Draggables.notify를 호출해서 onEnd이벤트가 발생했음을 알립니다.</li>
<li>revert인 경우, startDrag시 저장하였던 시작점으로 복귀시킵니다.</li>
<li>drag가 완료되었으므로 zindex를 복원시킵니다.</li>
<li>endeffect설정이 되어있으면 이를 호출해줍니다.</li>
<li>Draggables.deactivate를 호출하여서 활성중인 Draggable이 없음을 설정합니다.</li>
</ol>
<p><span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">7. </span></span>keyProcess(<span style="FONT-STYLE: italic">event</span>) &#8211; esc키가 눌린 경우, finishDrag를 호출합니다.<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">8. </span></span>endDrag(<span style="FONT-STYLE: italic">event</span>) &#8211; mouseup이벤트가 발생한 경우, stopScrolling()과 finishDrag를 호출합니다.<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">9. </span></span>draw(<span style="FONT-STYLE: italic">point</span>)  &#8211; mouse 이동에 따른 draggable의 이동 처리를 수행합니다. (repaint코드라고 보시면 될 듯)<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">10. </span></span>stopScrolling()<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">11. </span></span>startScrolling(<span style="FONT-STYLE: italic">speed</span>)<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">12. </span></span>scroll()<br />
<span style="COLOR: #8e8e8e"><span style="FONT-WEIGHT: bold; COLOR: #000000">13. </span></span>_getWindowScroll(<span style="FONT-STYLE: italic">w</span>)</p>
<p>출처 : <a href="http://okjungsoo.tistory.com">http://okjungsoo.tistory.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://overfloweb.com/blog/index.php/archives/12/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How well do you know prototype (part II)</title>
		<link>http://overfloweb.com/blog/index.php/archives/11</link>
		<comments>http://overfloweb.com/blog/index.php/archives/11#comments</comments>
		<pubDate>Tue, 01 Apr 2008 04:29:00 +0000</pubDate>
		<dc:creator>overflow</dc:creator>
				<category><![CDATA[javaScript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://overflow.ivyro.net/?p=11</guid>
		<description><![CDATA[1) Detecting key events easily How do we detect which key was pressed? Prototype provides set of key event aliases so that we don’t have to remember that return is “13″ and escape is “27″. Almost all major keys are aliased: KEY_RETURN, KEY_ESC, KEY_TAB, KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN. See full list in API docs $('myInput').observe('keyup', [...]]]></description>
			<content:encoded><![CDATA[<div class="entry" style="font-family: verdana,arial,helvetica,sans-serif;">
<h3>1) Detecting key events easily</h3>
<p>How do we detect which key was pressed? Prototype provides set of<br />
key event aliases so that we don’t have to remember that return is “13″<br />
and escape is “27″. Almost all major keys are aliased: KEY_RETURN,<br />
KEY_ESC, KEY_TAB, KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN. See full list <a title="Event's KEY aliases" href="http://prototypejs.org/api/event">in API docs</a></p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;">$('myInput').observe('keyup', function(e){
if (e.keyCode == Event.KEY_TAB)
doSomethingCoolWhenTabIsPressed();
})</div>
</pre>
</div>
</div>
<h3>2) You won’t need event capturing (most likely)</h3>
<p>Sometimes I see capturing phase being explicitly set to false in<br />
Event’s observe method. The good thing is that it’s set to false by<br />
default and you would rarely need to use it. The following 2 lines are<br />
fully identical so we can just skip this last argument:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;">Event.observe('productInfo', 'click', displayProductInfo, false); // 'false' could be skipped
Event.observe('productInfo', 'click', displayProductInfo);</div>
</pre>
</div>
</div>
<p>or a short way:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;">$('productInfo').observe('click', displayProductInfo, false); // 'false' could be skipped
$('productInfo').observe('click', displayProductInfo);</div>
</pre>
</div>
</div>
<h3>3) insert() wisely</h3>
<p>Another one of those “it’s-there-by-default” values is a position<br />
argument of Element’s insert method. Surprisingly it’s not mentioned<br />
anywhere in the docs &#8211; I accidentally found it wondering through the<br />
source one day. insert accepts one of four position values: <strong>top</strong>, <strong>bottom</strong>, <strong>before</strong>, and <strong>after</strong>. If we omit this argument, it defaults to <strong>bottom</strong> (and luckily this happens to be the most common case). The following lines behave identically:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;"><strong>new Insertion.Bottom('blogEntry',
new Template('&lt;div&gt;&lt;h2&gt;#{name}&lt;/h2&gt;&lt;p&gt;#{content}&lt;/p&gt;&lt;/div&gt;')
.evaluate({
name: blogEntry.name,
content: blogEntry.content
}));
 
// Insertion class is deprecated - it's recommended to use Element's insert method:
 
$('blogEntry').insert(new Template('&lt;div&gt;&lt;h2&gt;#{name}&lt;/h2&gt;&lt;p&gt;#{content}&lt;/p&gt;&lt;/div&gt;')
.evaluate({
name: blogEntry.name,
content: blogEntry.content
}), 'bottom' ); // "bottom" can be skipped
 
$('blogEntry').insert(new Template('&lt;div&gt;&lt;h2&gt;#{name}&lt;/h2&gt;&lt;p&gt;#{content}&lt;/p&gt;&lt;/div&gt;')
.evaluate({
name: blogEntry.name,
content: blogEntry.content
}));
</strong></div>
</pre>
</div>
</div>
<h3>4) Forms gone wild</h3>
<p>Plain form submission is quite easy but what if we want to prevent<br />
certain elements from being serialized before submitting form via ajax?<br />
Let’s take a look at few ways to do this:</p>
<p>Plain form submission using .request</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;">$('register').observe('submit', function(e){
Event.stop(e);
$(this).request();
})</div>
</pre>
</div>
</div>
<p>Using .getInputs makes it easy to filter out elements based on type<br />
and name attributes. In this example we’re serializing elements with<br />
name ‘email’ and submitting result to the URI contained in form’s<br />
“action” attribute</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;">$('register').observe('submit', function(e){
Event.stop(e);
new Ajax.Request($(this).readAttribute('action'), {
parameters: Form.serializeElements($(this).getInputs('', 'email'))
})
})</div>
</pre>
</div>
</div>
<p>Using .getInputs could help most of the time but what if we want to<br />
exclude elements that have “multiple” attribute? We might try something<br />
like this:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;">$('register').observe('submit', function(e){
Event.stop(e);
new Ajax.Request(this.readAttribute('action'), {
parameters: Form.serializeElements($(this).getElements()
.reject(function(el){return el.hasAttribute('multiple')})
);
})
})</div>
</pre>
</div>
</div>
<p class="colored">Wow, what’s going on over here?!</p>
<p>When submit event occurs, we prevent default submit action <code>Event.stop(e)</code>, get all form’s elements <code>this.getElements()</code>, iterate over them REJECTING those that have “multiple” attribute <code>.reject(function(el){return el.hasAttribute('multiple')})</code>. The filtered collection is then serialized <code>Form.serializeElements()</code> and is submitted via ajax <code>new Ajax.Request()</code></p>
<p>This is all very cool but here’s the reason why learning CSS3<br />
selectors might be a good thing (the results from both &#8211; reject-based<br />
and selector-based filtering are the same):</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
<div style="padding: 10px; background-color: #c9edff;">$('register').observe('submit', function(e){
Event.stop(e);
new Ajax.Request($(this).readAttribute('action'), {
parameters: Form.serializeElements($$('#register input:not([multiple])'))
})
})</div>
</pre>
</div>
</div>
<h3>Enjoy prototyping!</h3>
<p><a href="http://thinkweb2.com/projects/prototype/?p=3" target="_blank">http://thinkweb2.com/projects/prototype/?p=3</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://overfloweb.com/blog/index.php/archives/11/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How well do you know prototype?</title>
		<link>http://overfloweb.com/blog/index.php/archives/7</link>
		<comments>http://overfloweb.com/blog/index.php/archives/7#comments</comments>
		<pubDate>Mon, 31 Mar 2008 15:14:40 +0000</pubDate>
		<dc:creator>overflow</dc:creator>
				<category><![CDATA[javaScript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://overflow.ivyro.net/?p=7</guid>
		<description><![CDATA[How well do you know prototypeor taking advantage of those extra 100 KB in your pageLet&#8217;s be honest &#8211; I&#8217;m tired of answering same questions over and over again. Prototype.js is a widely used javascript library with somewhat confusing online documentation. I personally find API reference to be a great resourse overall (with few glithes [...]]]></description>
			<content:encoded><![CDATA[<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-size: medium;"><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">How well do you know prototype</span></span><br style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold; color: #177fcd;">or taking advantage of those extra 100 KB in your page</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Let&#8217;s be honest &#8211; I&#8217;m tired of answering same questions over and over again. Prototype.js is a widely used javascript library with somewhat confusing online documentation. I personally find API reference to be a great resourse overall (with few glithes of course), but it&#8217;s far from being newbie-friendly. I&#8217;ve been developing with prototype for almost a year now and have been spending a lot of time on the IRC channel. It&#8217;s hard to explain what kind of nonsense people are asking sometimes. It seems to me that most of the time prototype is used at 15%, not more. I&#8217;m not surprised anymore to see Ajax.Request used with document.getElementById on one line</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Here, I&#8217;ve collected most common use cases that do NOT use all of prototype&#8217;s capabilities and their simple solutions. I hope this will be a basic checklist to go through when developing for your next project. So&#8230; Here we go:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">1</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">document.getElementById(&#8216;foo&#8217;)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">$(&#8216;foo&#8217;)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Surprisingly some people actually don&#8217;t know about this one ( including ~100KB file just to use Ajax.Request family )</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">2</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">var woot = document.getElementById(&#8216;bar&#8217;).value</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">var woot = $(&#8216;bar&#8217;).value</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">var woot = $F(&#8216;bar&#8217;)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Handy shortcut for reading a value of a form control</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">3</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:<br />
<br style="font-family: verdana,arial,helvetica,sans-serif;" /></span></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">$(&#8216;footer&#8217;).style.height = &#8217;100px&#8217;;<br />
</span><span style="font-family: verdana,arial,helvetica,sans-serif;">$(&#8216;footer&#8217;).style.background = &#8216;#ffc&#8217;; </span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">$(&#8216;footer&#8217;).setStyle({</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    height: &#8217;100px&#8217;,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    background: &#8216;#ffc&#8217;</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">})</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Dreaming about IE behaving W3C way? Not happenning! (but second construct will make you forget about cross-browser glitches)</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">4</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">$(&#8216;coolestWidgetEver&#8217;).innerHTML = &#8216;some nifty content&#8217;</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">$(&#8216;coolestWidgetEver&#8217;).update(&#8216;some nifty content&#8217;)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">One of those simple ones yet quite often forgotten. Yes, I know they are almost the same but I want to see you doing THIS with the first one</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">(isn&#8217;t chaining just cool?)</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">$(&#8216;coolestWidgetEver&#8217;).update(&#8216;some nifty content&#8217;).addClassName(&#8216;highlight&#8217;).next().hide()</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">5</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:<br />
<br style="font-family: verdana,arial,helvetica,sans-serif;" /></span></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">new Ajax.Request(&#8216;ninja.php?weapon1=foo&amp;weapon2=bar&#8217;)</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">new Ajax.Request(&#8216;ninja.php&#8217;, {</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    parameters: {</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">        weapon1: &#8216;foo&#8217;,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">        weapon2: &#8216;bar&#8217;</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    }</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">})</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Cleaner and better structured parameters definition</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">6</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">new Ajax.Request(&#8216;blah.php&#8217;, {</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    method: &#8216;POST&#8217;,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    asynchronous: true,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    contentType: &#8216;application/x-www-form-urlencoded&#8217;,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    encoding: &#8216;UTF-8&#8242;,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">})</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">new Ajax.Request(&#8216;blah.php&#8217;)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">All of these options are in Ajax.Request by default! &#8220;method: &#8216;POST&#8217;&#8221; happens to be on every second pastie page I&#8217;ve seen</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">(Still don&#8217;t believe in JS inheritance? You don&#8217;t have to. Just take advantage of it)</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">7</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">Event.observe(&#8216;myContainer&#8217;, &#8216;click&#8217;, doSomeMagic)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">$(&#8216;myContainer&#8217;).observe(&#8216;click&#8217;, doSomeMagic)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">This one is debatable but second way is more Object Oriented (well&#8230; sort of) and easier to chain (So decide for yourself)</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">8</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">$$(&#8216;div.hidden&#8217;).each(function(el){</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    el.show();</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">})</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">$$(&#8216;div.hidden&#8217;).invoke(&#8216;show&#8217;)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Here&#8217;s a typical &#8220;each overuse&#8221;. We have invoke for such things, folks! Sadly not many people know about it.</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">9</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">$$(&#8216;div.collapsed&#8217;).each(function(el){</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    el.observe(&#8216;click&#8217;, expand);</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">})</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;"></p>
<div style="padding: 10px; background-color: #c9edff;">$$(&#8216;div.collapsed&#8217;).invoke(&#8216;observe&#8217;, &#8216;click&#8217;, expand)</div>
<p></span></p>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Ha! Take this! Invoke can also be used for event handling when iterating over a collection of elements. It&#8217;s really easy, isn&#8217;t it?</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">10</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">$$(&#8216;input.date&#8217;).invoke(&#8216;observe&#8217;, &#8216;focus&#8217;, onFocus);</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">$$(&#8216;input.date&#8217;).invoke(&#8216;observe&#8217;, &#8216;blur&#8217;, onBlur);</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">$$(&#8216;input.date&#8217;)</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    .invoke(&#8216;observe&#8217;, &#8216;focus&#8217;, onFocus)</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">        .invoke(&#8216;observe&#8217;, &#8216;blur&#8217;, onBlur)</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Somehow people tend to forget about &#8220;chaining nirvana&#8221;. Don&#8217;t like the way it looks? Think about saving some time by NOT invoking $$ twice!</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif; font-weight: bold;">11</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The wrong way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">$(&#8216;productTable&#8217;).innerHTML = </span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    $(&#8216;productTable&#8217;).innerHTML + </span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    &#8217;&lt;tr&gt;&lt;td&gt;&#8217; + productId + &#8216; &#8216;</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    + productName + &#8216;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&#8217; </span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    + productId + &#8216; &#8216; + productPrice + </span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    &#8217;&lt;/td&gt;&lt;/tr&gt;&#8217;</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">The right way:</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
<div style="padding: 10px; background-color: #c9edff;"><span style="font-family: verdana,arial,helvetica,sans-serif;">var rowTemplate = new Template(&#8216;&lt;tr&gt;&lt;td&gt;#{id} #{name}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;#{id} #{price}&lt;/td&gt;&lt;/tr&gt;&#8217;);</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">$(&#8216;productTable&#8217;).insert(</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    rowTemplate.evaluate({</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">        id: productId,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">        name: productName,</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">        price: productPrice</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">    }))</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">)</span></div>
<p><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">No I&#8217;m not kidding. This has been posted to #prototype and something was wrong with it (hmm&#8230; I wonder what)</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Templates are great for those nasty HTML strings. Those humongous concatenated constructs make me feel slightly nauseous</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">evaluate takes care of all the parsing in a nice structured way</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">That&#8217;s all for now. Stay tuned as there is always a room for improvement!</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Created by kangax</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><span style="font-family: verdana,arial,helvetica,sans-serif;">Questions? Suggestions? Find me in #prototype [kangax] or shoot me an email [ kangax@gmail.com ]</span><br style="font-family: verdana,arial,helvetica,sans-serif;" /><br />
<a href="http://thinkweb2.com/projects/prototype-checklist/" target="_blank">http://thinkweb2.com/projects/prototype-checklist/</a><br style="font-family: verdana,arial,helvetica,sans-serif;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://overfloweb.com/blog/index.php/archives/7/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>prototype.js utility functions</title>
		<link>http://overfloweb.com/blog/index.php/archives/5</link>
		<comments>http://overfloweb.com/blog/index.php/archives/5#comments</comments>
		<pubDate>Mon, 31 Mar 2008 15:04:58 +0000</pubDate>
		<dc:creator>overflow</dc:creator>
				<category><![CDATA[javaScript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://overflow.ivyro.net/?p=5</guid>
		<description><![CDATA[$() 함수 사용하기 $()함수는 가장 많이 사용되는 DOM의 document.getElementById()함수에 대한 편리한 단축키이다. DOM함수처럼, 이것은 인자로 던져진 id를 가진 요소를 하나 반환한다. 하지만 DOM함수와는 달리, 이것은 여러개의 id를 사용할수 있고 $()는 요청된 요소를 가진 Array객체를 반환할것이다. 예제는 아래와 같다. &#60;HTML&#62; &#60;HEAD&#62; &#60;TITLE&#62; Test Page &#60;/TITLE&#62; &#60;script src="prototype-1.4.0.js"&#62;&#60;/script&#62; &#60;script&#62; function test1() { var d = $('myDiv'); alert(d.innerHTML); [...]]]></description>
			<content:encoded><![CDATA[<h4><span class="functionName">$()</span> 함수 사용하기</h4>
<p><span class="code">$()</span>함수는 가장 많이 사용되는 DOM의 <span class="code">document.getElementById()</span>함수에 대한 편리한 단축키이다. DOM함수처럼, 이것은 인자로 던져진 id를 가진 요소를 하나 반환한다.</p>
<p>하지만 DOM함수와는 달리, 이것은 여러개의 id를 사용할수 있고 <span class="code">$()</span>는 요청된 요소를 가진 <span class="code">Array</span>객체를 반환할것이다. 예제는 아래와 같다.</p>
<pre class="code">
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">
<pre class="code">&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt; Test Page &lt;/TITLE&gt;
&lt;script src="prototype-1.4.0.js"&gt;&lt;/script&gt;</pre>
<pre class="code">&lt;script&gt;
 function test1()
 {
  var d = $('myDiv');
  alert(d.innerHTML);
 }</pre>
<pre class="code"> function test2()
 {
  var divs = $('myDiv','myOtherDiv');
  for(i=0; i&lt;divs.length; i++)
  {
   alert(divs[i].innerHTML);
  }
 }
&lt;/script&gt;
&lt;/HEAD&gt;</pre>
<pre class="code">&lt;BODY&gt;
 &lt;div id="myDiv"&gt;
  &lt;p&gt;This is a paragraph&lt;/p&gt;
 &lt;/div&gt;
 &lt;div id="myOtherDiv"&gt;
  &lt;p&gt;This is another paragraph&lt;/p&gt;
 &lt;/div&gt;</pre>
<pre class="code"> &lt;input type="button" value=Test1 onclick="test1();"&gt;&lt;br&gt;
 &lt;input type="button" value=Test2 onclick="test2();"&gt;&lt;br&gt;</pre>
<pre class="code">&lt;/BODY&gt;
&lt;/HTML&gt;</pre>
</div>
</pre>
<p>이 함수의 다른 좋은 점은 이것은 인자형태를 가질수 있는 다른 함수를 생성할때 매우 유용하도록 만들어주는 id문자열이나 요소객체 자체를 던질수 있다는 것이다.</p>
<p><!-- ------------------------------------------------------------------------------------------- --></p>
<h4><span class="functionName">$F()</span> 함수 사용하기</h4>
<p><span class="code">$F()</span> 함수는 다른 단축키이다. 이것은 text박스나 드랍다운 list와 같은 어떤 필드의 입력 컨트롤의 값을 반환한다. 이 함수는 요소 id나 요소객체 자체를 인자로 가질수 있다.</p>
<pre class="code">
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;script&gt;
 function test3()
 {
  alert(  $F('userName')  );
 }
&lt;/script&gt;</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;input type="text" id="userName" value="Joe Doe"&gt;&lt;br&gt;
&lt;input type="button" value=Test3 onclick="test3();"&gt;&lt;br&gt;</div>
</pre>
<p><!-- ------------------------------------------------------------------------------------------- --></p>
<h4><span class="functionName">$A()</span> 함수 사용하기</h4>
<p><span class="code">$A()</span> 함수는 이것을 받아들이는 하나의 인자를 <span class="code">Array</span>객체로 변환한다.</p>
<p><a href="http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html#Reference.Array">Array 클래스를 위한 확장</a>과 조합된 이 함수는 이것을 더욱 쉽게 만든다. 예를 들면, 작성한 함수는 인자의 수를 유연하게 받아들인다.</p>
<pre class="code">
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;script&gt;</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4"> function showOptions(){
  var someNodeList = $('lstEmployees').getElementsByTagName('option');
  var nodes = $A(someNodeList);</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">  nodes.each(function(node){
    alert(node.nodeName + ': ' + node.innerHTML);
   });
 }
&lt;/script&gt;</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;select id="lstEmployees" size="10" &gt;
 &lt;option value="5"&gt;Buchanan, Steven&lt;/option&gt;
 &lt;option value="8"&gt;Callahan, Laura&lt;/option&gt;
 &lt;option value="1"&gt;Davolio, Nancy&lt;/option&gt;
&lt;/select&gt;</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;input type="button" value="Show the options" onclick="showOptions();" &gt;</div>
</pre>
<p><!-- ------------------------------------------------------------------------------------------- --></p>
<h4><span class="functionName">$H()</span> 함수 사용하기</h4>
<p><span class="code">$H()</span> 함수는 결합된 배열을 열거할수 있는 <a href="http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html#Reference.Hash">Hash</a>객체로 변환한다.</p>
<pre class="code">
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;script&gt;
 function testHash()
 {
  //let's create the object
  var a = {
   first: 10,
   second: 20,
   third: 30
   };</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">  //now transform it into a hash
  var h = $H(a);
  alert(h.toQueryString()); //displays: first=10&amp;second=20&amp;third=30
 }</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;/script&gt;</div>
</pre>
<p><!-- ------------------------------------------------------------------------------------------- --></p>
<h4><span class="functionName">$R()</span> 함수 사용하기</h4>
<p><span class="code">$R()</span> 함수는 <span class="code">new ObjectRange(lowerBound, upperBound, excludeBounds)</span>를 작성하기 위한 짧은 형태이다.</p>
<p>이 클래스의 완전한 설명을 보기 위해 <a href="http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html#Reference.ObjectRange">ObjectRange</a> 클래스 문서를 보라. <span class="code">each</span> 메소드를 통해 반복(iterators)의 사용법을 보여주는 간단한 예제를 보자. 더 많은 메소드는 <a href="http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html#Reference.Enumerable">Enumerable</a> 클래스 문서에서 볼수 있을것이다.</p>
<pre class="code">
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;script&gt;
 function demoDollar_R(){
  var range = $R(10, 20, false);
  range.each(function(value, index){
   alert(value);
  });
 }</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;/script&gt;</div>
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;input type="button" value="Sample Count" onclick="demoDollar_R();" &gt;</div>
</pre>
<p><!-- ------------------------------------------------------------------------------------------- --></p>
<h4><span class="functionName">Try.these()</span> 함수 사용하기</h4>
<p>이것은 인자처럼 많은 수의 함수를 가지고 그것들을 순서대로 차례차례 호출하도록 해준다. 이것은 함수중에 하나씩 수행하고 성공적인 함수호출의 결과를 반환할때까지 순차적으로 수행된다.</p>
<p>예제는 아래와 같다. <span class="code">xmlNode.text</span>는 몇몇 브라우저에서 작동하고 <span class="code">xmlNode.textContent</span>는 다른 브라우저에서 작동한다. <span class="code">Try.these()</span>함수를 사용하면 당신은 작동하는 것중 하나를 반환할수 있다.</p>
<pre class="code">
<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #e4e4e4">&lt;script&gt;
function getXmlNodeValue(xmlNode){
 return Try.these(
  function() {return xmlNode.text;},
  function() {return xmlNode.textContent;}
  );
}
&lt;/script&gt;</div>
</pre>
<p>예제 : <a href="http://overflow.berrybox.com/ajax/test/index.html">http://overflow.berrybox.com/ajax/test/index.html</a><br />
출처 : <a href="http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html">http://openframework.or.kr/framework_reference/prototype_js/1.4.0/prototype.js.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://overfloweb.com/blog/index.php/archives/5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

