jQuery.each break continue

Posted at 2009/05/11 09:45 // in 웹프로그래밍™/jQuery, Javascript // by 블루비

jQuery.each(callback)


each 메소드를 하는 하는 경우 for문과 같은 제어 문에서 사용되는 break , continue 의 쓰임이 필요 하다.
each에서는 return true(continue) 와 return false(break) 를 이용해서 break, continue와 같은 동작을 일으킬수 있다.

$('#loop').each(function(i){
if( i == 0 ) return true; //continue;
return false;//break;
});

2009/05/11 09:45 2009/05/11 09:45
  1. azki

    2009/05/11 16:39 [수정/삭제] [답글]

    아하. 그렇군요 기억해 두겠습니다

댓글을 남겨주세요.

[로그인][오픈아이디란?]

49가지 jQuery 플러그인

Posted at 2009/04/23 19:49 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
출처 : http://www.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/

JavaScipt libraries have made huge leaps and bounds in helping developers write code and develop products more quickly. jQuery is one of the most popular JavaScript frameworks, with powerful tools that improve the user’s interaction with Web applications. jQuery has an additional advantage in that it allows developers to select elements on a page using CSS-like syntax.

To help you take it up a notch, we share below some methods that can help you give visitors to your website an amazing user experience. Here are over 45 impressive jQuery plug-ins and techniques that have been recently created and that could make the development of your next website an easier and more interesting experience than the last.

You may want to take a look at the following related posts:

Dynamic Content

1. Build A Login Form With jQuery
In this tutorial, we’ll create a sliding panel, that slides in to reveal more content, using JQuery to animate the height of the panel. In this case, we will be creating a hypothetical login for the new tutsplus area that’s coming soon.

jQuery

2. Spoiler Revealer with jQuery
A simple technique that hides some content first and fades it in once a link is clicked.

jQuery

3. AJAX Upload
This AJAX file upload plug-in allows users to easily upload multiple files without having to refresh the page. In addition, you can use any element to trigger the file selection window. The plug-in creates a semi-transparent file input screen over the button you specify, so when a user clicks on the button, the normal file selection window is shown. After the user selects a file, the plug-in submits the form that contains the file input to an iFrame. So it isn’t true AJAX but provides the same user experience.

jQuery

4. FCBKcomplete
Give your users fancy Facebook-like dynamic inputs, with auto-complete and pre-added values.

jQuery

5. Create Accessible Charts Using Canvas and jQuery
This tool is proof that you can use the <canvas> element to illustrate HTML table data. The idea is a good one: putting the data in a table allows it to remain accessible, while the chart can be shown for visual enhancement.

jQuery


Form Manipulation

6. Radio Button and Check Box Replacement
This jQuery tool replaces radio buttons and check boxes with a more appealing display.

jQuery

7. Submit a Form without a Page Refresh

jQuery

8. jQuery AJAX Contact Form
Here is a quick and easy way to make a jQuery AJAX contact form with a “honeypot” to foil email bots, load success and error messages dynamically without leaving the page and provide descriptive error messages detailing why submitted values have failed validation.

jQuery

9. Simple jQuery Form Validation
This jQuery form shows live form-input validators both server-side and browser-side.

jQuery


Navigation Menus

10. jQuery Context Menu
A context menu plug-in for jQuery that features easy implementation, keyboard shortcuts, CSS styling and control methods.

jQuery

11. Kwicks for jQuery
Kwicks for jQuery started off as a port of the incredibly attractive MooTools framework, but has evolved into a highly customizable and versatile widget.

jQuery

12. jQuery iPod-style Drilldown Menu
“We created an iPod-style drilldown menu to help users traverse hierarchical data quickly and with control. It’s especially helpful when organizing large data structures that don’t translate well into traditional dropdown or fly-out menus.”

jQuery

13. jQuery File Tree
The jQuery File Tree is a configurable AJAX file-browser plug-in for jQuery. You can create a customized, fully-interactive file tree with as little as one line of JavaScript code.

jQuery

14. How to Create a MooTools Home Page-Inspired Navigation Effect
In this tutorial, you’ll recreate the same effect seen in MooTools’s menu, but in jQuery!

jQuery

15. CSS Sprites2
This tutorial demonstrates how to implement inline CSS Sprites2 using jQuery.

jQuery


Manipulating Content

16. jQuery books widget
With some custom JavaScript and jQuery magic you can create some interesting widgets. A good way to demonstrate this functionality is by building a browsable Amazon.com books widget.

jQuery

17. Text Size Slider
This tutorial explains how to use a slider to control the text size of an article on a page. This lets the user control exactly the size that suits them, and is also a pretty impressive feature to have on a site.

jQuery

18. Pagination
Create navigational elements: when you have a large number of items, you can group them into pages and present navigational elements that allow users to move from one page to another.

jQuery

19. Coda-Slider
As with the last tool, groups items together using navigational elements that allow users to move from one page to another.

jQuery

20. Creating a Slick Auto-Playing Featured-Content Slider
If you love the Coda-Slider plug-in for jQuery, then you will find this plug-in very useful for displaying lots of content in a small area. This nice plug-in adds some features not found in the original Coda-Slider, such as slowly cycling through panels, auto-playing different types of custom content. An arrow indicator serves as a visual indication of which panel you are currently viewing.

jQuery

  • Demo can be found here.
  • Download files here.

21. haccordion
A simple horizontal accordion plug-in for jQuery.

jQuery


Tabular Data and Grids

22. Table Row Checkbox Toggle
This tool generically adds a toggle function to any table row you specify based on a CSS class name. It will, by default, toggle on any check boxes within that table row.

jQuery

23. Tablesorter
Tablesorter is a jQuery plug-in that turns a standard HTML table with <th> and <td> tags into a sortable table without the need for page refreshes. Tablesorter can successfully parse and sort many types of data, including linked data, in a cell.

jQuery

24. TableEditor
TableEditor provides flexible in-place editing of HTML tables. User-defined handler functions can easily be dropped in to update, for example, a data source via an AJAX request.

jQuery

25. Scrollable HTML Table
This JavaScript code can be used to convert ordinary HTML tables into scrollable ones.

jQuery


Lightbox Techniques

26. Revealing Photo Slider
Learn how to create a thumbnail photo gallery, where clicking a button reveals the entire photo and more information about that photo.

jQuery

27. FancyBox
FancyBox was born to automatically scale large images to fit in windows, adding a nice drop-shadow under the zoomed item. It can be used to group related items and add navigation between them (using a pre-loading function). FancyBox is totally customizable through settings and CSS.

jQuery

28. Facebox Image and Content Viewer
Facebox is a lightweight Facebook-style Lightbox that can display images, divs, and even entirely remote pages (via AJAX) inline on a page and on demand. It uses the compact jQuery library as its engine, unlike Lightbox v2.0, which uses Prototype.

jQuery

29. jQuery.popeye
jQuery.popeye is a plug-in that transforms an unordered list of images into a simple image gallery. When an image is clicked, it enlarges Lightbox-style. The images are displayed in a box with “Previous” and “Next” controls, and information about the images can be included.

jQuery


Image Galleries and Viewers

30. Simple Controls Gallery
Simple Controls Gallery rotates and displays each image by fading it into view over the previous one, with navigation controls that pop up when the mouse hovers over the gallery. The controls allow the user to play, pause or jump to a specific image in the gallery.

jQuery

31. Agile Carousel
This jQuery plug-in allows you to easily create a custom carousel. Use the jQuery UI to enable many different types of transition. The plug-in uses PHP to call images from the folder you specify. Configure many different options including controls, slide timer length, easing type, transition type and more!

jQuery


Browser Tweaks

32. Setting Equal Heights with jQuery
A script to equalize the heights of boxes within the same container and create a tidy grid.

jQuery

33. jQuery IE6 PNG Transparency Fix
Another IE6 PNG fix that uses jQuery selectors to automatically fix all PNG images on a page.

34. BGI frame
This tool helps ease the pain of dealing with IE z-index issues. You can find a demo here.

35. Fix Overflow
IE puts scroll bars inside overflowing elements, and if an element is only one line, the scroll bar will cover it. This plug-in fixes that issue.

jQuery

36. Lazy Load
Lazy Load delays the loading of images below the fold on long pages. As the user scrolls down, the images are loaded as needed. Check out the demo here.

37. Maxlength
It’s a fairly common design practice to limit the number of characters a user can input in a field while giving feedback on how many spaces are left. This plug-in automates that task.

jQuery


Animation Effects

38. Scrollable
Scrollable is a flexible and lightweight (3.9 KB) jQuery plug-in for creating scrollable content. Scrollable items can contain any HTML, such as text, images, forms, video or any combination of them. You can make items scroll horizontally or vertically and decide how many items are visible at once.

jQuery

39. jQuery Fading Menu - Replacing Content
“Instead of thinking about CSS as page layout and a way to style your page when it loads, you can use in animation and change it on-the-fly to react to events that happen on your page. Take for example a menu. You can take the “click” event that happens when clicking on a menu to do lots of stuff.”

jQuery

40. Build an Animated Cartoon Robot with jQuery
This effect simulates a faux 3-D animated background reminiscent of old-school side-scrolling video games (and not unlike the parallax effect). This effect is created by layering several empty divs over each other, with transparent PNGs as background images. The backgrounds are animated at different speeds using jQuery.

jQuery

41. Flip
Flip is a plug-in for jQuery that “flips” page elements in four directions. Compatible with Firefox 2+, Internet Explorer 6+, Safari 3.1 (for Windows) and Google Chrome.

jQuery

  • Download files here.

42. Use jQuery for Background Image Animations
Animate your menu whenever a user hovers over an item with this effect.

jQuery


Image Manipulation

43. Jcrop
Jcrop is the quick and easy way to add image-cropping functionality to your Web application. It combines the ease of use of a typical jQuery plug-in with a powerful cross-platform DHTML cropping engine that is faithful to familiar desktop graphics applications.

jQuery

44. jQZoom
JQZoom is a JavaScript image magnifier that makes it really easy to magnify what you want. It is easy to customize and works on all modern browsers.

jQuery


Miscellaneous

45. Date Range Picker
A rich date-range widget that uses the jQuery UI’s date picker and some additional custom interaction.

jQuery

46. Sortable Lists
Unordered lists are commonly used to structure a website’s navigation. Having the ability to re-order such lists would be extremely useful. Here is a method to easily save and reload the list element order without getting lost as the page is refreshed.

jQuery

47. Amazing Music Player Using Mouse Gestures and Hotkeys
Learn how to create an amazing music player, coded in XHTML and jQuery, that makes use of mouse gestures and hotkeys. You can click and drag the mouse to interact with the music player’s interface or use directional keys and the space bar instead of the mouse.

jQuery

48. Script for Tracking Outbound Links in Google Analytics with jQuery
This code snippet uses Google Analytics and jQuery to automatically track outbound links. This interesting script enhances behavior by comparing the link’s domain to the current page’s domain and, if they are different, triggering the behavior. This is helpful when using a CMS or other tool that generates full URLs, including the “http://,” instead of relative ones.

  1. <script type="text/javascript">
  2. $('#content a:not(.popupwindow)').filter(function() {
  3. var theHref = this;
  4. if (theHref.hostname && theHref.hostname !== location.hostname) {
  5. $(theHref).not(".noAutoIcon").addClass("offSite");
  6. $(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) {
  7. var code=event.charCode || event.keyCode;
  8. if (!code || (code && code == 13)) {
  9. if(pageTracker){
  10. var fixedLink = this.href;
  11. fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
  12. fixedLink = '/outgoing/' fixedLink;
  13. pageTracker._trackPageview(fixedLink);
  14. };
  15. };
  16. });
  17. };
  18. });
  19. </script>
  1. <script type="text/javascript">
  2. $('#content a:not(.popupwindow)').filter(function() {
  3. var theHref = this;
  4. if (theHref.hostname && theHref.hostname !== location.hostname) {
  5. $(theHref).not(".noAutoIcon").addClass("offSite");
  6. $(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) {
  7. var code=event.charCode || event.keyCode;
  8. if (!code || (code && code == 13)) {
  9. if(pageTracker){
  10. var fixedLink = this.href;
  11. fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
  12. fixedLink = '/outgoing/' fixedLink;
  13. pageTracker._trackPageview(fixedLink);
  14. };
  15. };
  16. });
  17. };
  18. });
  19. </script>

49. jGrowl
jGrowl is a jQuery plug-in that delivers unobtrusive messages within the browser, similar to the way that OS X’s Growl Framework works.

jQuery

Related posts

You may want to take a look at the following related posts:

About the author

Noura Yehia is a Web designer and blogger who can be found at Noupe and Devsnippets. If you want to connect with the author, you can follow her on Twitter.

2009/04/23 19:49 2009/04/23 19:49

댓글을 남겨주세요.

[로그인][오픈아이디란?]

jQuery 1.3.2 Released

Posted at 2009/02/21 12:24 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
jQuery 1.3.2 버전으로 릴리즈 되었네요


  • Elements are now returned in document order.
    객체를 문서에 위치한 순서대로 반환
// jQuery 1.3.1 (and older)
$("h1, h2, h3")
=> [ h1, h1, h2, h2, h3, h3 ]
// jQuery 1.3.2
$("h1, h2, h3")
=> [ h1, h2, h3, h3, h1, h2 ]
  • .live() can now prevent bubbling.
<ul>
<li><b>Google</b></li>
<li><b>Yahoo</b></li>
</ul>
<script>
$("li").live("click", function(){
$(this).addClass("active");
});
$("li b").live("click", function(){
$(this).addClass("active");
return false;
});
</script>

  • :visible/:hidden are now significantly faster.
사용자 삽입 이미지

  • As are all the width/height methods.
사용자 삽입 이미지

  • Selectors are much faster in Internet Explorer.
사용자 삽입 이미지

  • appendTo/etc. have had a slight API tweak.
<div></div>
<div></div>
<script>
$("<p/>")
.appendTo("div")
.addClass("test");
</script>

jQuery 1.3.1 :

<div><p class="test"></p></div>
<div><p></p></div>
jQuery 1.3.2 :
<div><p class="test"></p></div>
<div><p class="test"></p></div>

jQuery 1.3.2 Released notes

Downloading

jQuery 1.3.2:


2009/02/21 12:24 2009/02/21 12:24

댓글을 남겨주세요.

[로그인][오픈아이디란?]

JavaScript Table Sorter

Posted at 2008/11/09 13:59 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
테이블 정렬용 자바스크립트 소스
크기 1.7KB 밖에 되지 않는 Table Sorter 는 간결한 코드에 상당히 빠른 성능을 발휘한다.

var sorter=new table.sorter("sorter");
sorter.init("sorter",1);

상세정보 here.

데모보기 here.

소스코드 다운로드 here.



사용자 삽입 이미지
2008/11/09 13:59 2008/11/09 13:59
  1. BoKi

    2008/11/11 10:44 [수정/삭제] [답글]

    script로 정렬하다니.. 대단하네요..

댓글을 남겨주세요.

[로그인][오픈아이디란?]

jQuery select box value

Posted at 2008/10/24 10:14 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
jQuery
select box의 내용 가져오기
$("#select_box > option:selected").val();

select box의 값 설정
$("#select_box > option[@value=지정값]").attr("selected", "true")

jQuery 바로가기
2008/10/24 10:14 2008/10/24 10:14

댓글을 남겨주세요.

[로그인][오픈아이디란?]

FCKEditor 사용자 컨텐츠 삽입 FCKeditorAPI

Posted at 2008/10/14 12:46 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 300 ;
oFCKeditor.Value = '<p>This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.<\/p>' ;

oFCKeditor.Create();

window.onload = function(){
oEditor = FCKeditorAPI.GetInstance(oFCKeditor.InstanceName) ;
}
* onload 이벤트 이후에 FCKeditorAPI 핸들러를 사용할 수 있음

사용자 삽입 이미지

Insert Content 버튼을 클릭하게 되면 에디터의 커서 영역에 컨텐츠가 삽입되는 이미지 입니다.



















<button onclick="oEditor.InsertHtml('Hello World!!')" style="font-size:9pt;">Insert Content</button>

oEditor 로 정의된 FCKeditorAPI를 이용하여 InsertHthml method를 호출하여 사용자 컨텐츠를 삽입한다.


2008/10/14 12:46 2008/10/14 12:46

댓글을 남겨주세요.

[로그인][오픈아이디란?]

JavaScript 슬라이드와 스크롤러을 이용한 웹사이트 15선

Posted at 2008/10/14 09:03 // in 웹프로그래밍™/jQuery, Javascript // by 블루비

출처 : http://dzineblog.com/2008/09/getting-creative-with-javascript.html

자바스크립트 프레임웍으로 다양한 슬라이드, 스크롤러를 적용한 이펙트한 웹사이트 들입니다.

1. YouLoveUs

사용자 삽입 이미지

2. Volll

사용자 삽입 이미지

3. Melissahie

사용자 삽입 이미지

4. SourceBits

사용자 삽입 이미지

5. ilFruttet

사용자 삽입 이미지

6. Danny Blackman

사용자 삽입 이미지

7. tatTAPtap

사용자 삽입 이미지

8. Coda ( Classic )

사용자 삽입 이미지

9. Lucuma

사용자 삽입 이미지

10. Komodo Media [ Don't Forget to Check the Foilage Meter ]

사용자 삽입 이미지

11. Viva Video

사용자 삽입 이미지

12. IJsfontein

사용자 삽입 이미지

13. Good Works Media

사용자 삽입 이미지

14. Viget Labs

사용자 삽입 이미지

15. Css Brigit

사용자 삽입 이미지

Tutorials + Scripts [ So you can Try this effects in your next Project ]

2008/10/14 09:03 2008/10/14 09:03
  1. 비밀방문자

    2009/02/06 17:45 [수정/삭제] [답글]

    관리자만 볼 수 있는 댓글입니다.

댓글을 남겨주세요.

[로그인][오픈아이디란?]

FCKEditor 기본 설정

Posted at 2008/09/29 14:51 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
사용자 삽입 이미지




filemanager PHP 설정

/fckeditor/ediotr/filemanager/connectors/php/config.php
$Config['Enabled'] = true ;//false를 true로 변경

$Config['UserFilesPath'] = '/upfiles/fckeditor/' ;//저장할 위치 퍼미션 777

$root = ( substr($_SERVER['DOCUMENT_ROOT'],-1) == "/" ) ? substr($_SERVER['DOCUMENT_ROOT'],0,-1):$_SERVER['DOCUMENT_ROOT'];
$Config['UserFilesAbsolutePath'] = $root.$Config['UserFilesPath'] ;

fckeditor.js 파일 설정

FCKeditor.BasePath = '/scripts/fckeditor/' ;

fckconfig.js 파일 설정

FCKConfig.EnterMode = 'br' ; // p | div | br - p 를 br로 수정
FCKConfig.ShiftEnterMode = 'p' ; // p | div | br - br 를 p로 수정

FCKConfig.ToolbarSets["Basic"] = [
['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']
] ;
//사용자 입맛에 맞게 툴바 추가
FCKConfig.ToolbarSets["Board"] = [
['Source','-','Bold','Italic','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','-','OrderedList','UnorderedList','-','Link','Unlink'],
['Outdent','Indent','Blockquote'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak']
] ;

2008/09/29 14:51 2008/09/29 14:51
  1. 궁금이

    2009/04/03 09:33 [수정/삭제] [답글]

    FCKeditor 2.6.4 버전을 어제 다운받아서 설치해서 사용하는 중입니다.

    그렇지만,

    페이지 내용을 한참 동안 적은 후에 IE의 뒤로가기나, 앞으로가기 버튼이나 다른 메뉴를 클릭을 하면, 현재 작성하고 있던 내용은 싸~~악 사라지고 그 페이지로 이동한다는 문제점을 발견하였습니다.
    설정에서 어떻게 해야할 지 찾지 못하여 이렇게 글을 남깁니다.
    최소한, 경고창을 띄워서 "저장하지 않았는데 이동하겠느냐" 라고 물어봐야 하지 않을까요? xquared에서는 그 기능이 있습니다만, FCKeditor에서는 어떻게 해야할지 모르겠네요.
    부탁드립니다.

댓글을 남겨주세요.

[로그인][오픈아이디란?]

FCKEditor focus & validate

Posted at 2008/09/29 13:57 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
사용자 삽입 이미지




처음 로드시 FCKEditor 생성
window.onload = fucntion()
{
oFCKeditor = new FCKeditor( 'content','100%',300) ;
oFCKeditor.ReplaceTextarea() ;
}

validate 체크 및 focus
var fck=FCKeditorAPI.GetInstance(oFCKeditor.InstanceName) ;
if( fck.GetXHTML(true) == "" ){
window.alert("내용을 입력해 주세요");
fck.Focus();
return;
}
2008/09/29 13:57 2008/09/29 13:57

댓글을 남겨주세요.

[로그인][오픈아이디란?]

[자바스크립트] 태그,스크립트,스타일,주석,한글 제거 정규식 표현

Posted at 2008/03/24 19:18 // in 웹프로그래밍™/jQuery, Javascript // by 블루비


var str = "한글  ";
str = str.replace(RegExpJS,"");
//result : 한글   

Hellow Blog

//스타일 제거 var RegExpCSS = "]*>(.*?)"; str = str.replace(RegExpCSS,""); //result : 한글

Hellow Blog

//한글 제거 var RegExpHG = "[ㄱ-ㅎ가-힣]"; str = str.replace(RegExpHG,""); //result :

Hellow Blog

//주석 제거 var RegExpDS = //g; str6 = str.replace(RegExpDS,""); //result : 한글

Hellow Blog

2008/03/24 19:18 2008/03/24 19:18

댓글을 남겨주세요.

[로그인][오픈아이디란?]

Javascript Key Event : Ctrl+Key shortcuts

Posted at 2008/02/22 21:02 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
Ctrl + Key(Ctrl + S) 형태의 조합키를 사용 할 수 있는 자바스크립트 코드 입니다.

원문에는 jQuery 를 이용한 코드도 포함 되어 있습니다.
http://www.scottklarr.com/topic/126/how-to-create-ctrl-key-shortcuts-in-javascript/

var isCtrl = false;
document.onkeyup=function(e){
	if(e.which == 17) isCtrl=false;
}
document.onkeydown=function(e){
	if(e.which == 17) isCtrl=true;
	if(e.which == 83 && isCtrl == true) {
		//run code for CTRL+S -- ie, save!
		return false;
	}
	if(e.which == 79 && isCtrl == true) {
		//run code for CTRL+O -- ie, open!
		return false;
	}
	if(e.which == 84 && isCtrl == true) {
		//run code for CTRL+T -- ie, new tab!
		return false;
	}
}


Javascript Key Codes

Key Pressed Key Code
backspace 8
tab 9
enter 13
shift 16
ctrl 17
alt 18
pause/break 19
caps lock 20
escape 27
page up 33
page down 34
end 35
home 36
left arrow 37
up arrow 38
right arrow 39
down arrow 40
insert 45
delete 46
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
a 65
b 66
c 67
d 68
e 69
f 70
g 71
h 72
i 73
j 74
k 75
l 76
m 77
n 78
o 79
p 80
q 81
r 82
s 83
t 84
u 85
v 86
w 87
x 88
y 89
z 90
left window key 91
right window key 92
select key 93
numpad 0 96
numpad 1 97
numpad 2 98
numpad 3 99
numpad 4 100
numpad 5 101
numpad 6 102
numpad 7 103
numpad 8 104
numpad 9 105
multiply 106
add 107
subtract 109
decimal point 110
divide 111
f1 112
f2 113
f3 114
f4 115
f5 116
f6 117
f7 118
f8 119
f9 120
f10 121
f11 122
f12 123
num lock 144
scroll lock 145
semi-colon 186
equal sign 187
comma 188
dash 189
period 190
forward slash 191
grave accent 192
open bracket 219
back slash 220
close braket 221
single quote 222

2008/02/22 21:02 2008/02/22 21:02

댓글을 남겨주세요.

[로그인][오픈아이디란?]

[Javascript] Override window.alert()

Posted at 2008/02/04 07:13 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
자바스크립트 함수 중 alert 이라는 함수를 override 하여 system modal window 가 아닌 layer 디자인을 통해 alert window를 만들어 사용할 수 있습니다. (window.confirm 도 바꿀 수 있겠죠.. ㅎㅎ )


Sample Link

<!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>
<title> Override Alert </title>
</head>
<body>
<script type='text/javascript'>
/***
 * Description : override alert
 * Author : blueb(xblueb@gmail.com)
 * Date : 2008-02-04
 */
	window['alert'] = function(msg){

		if( document.getElementById("alert") == null ){
		
			var cw = parseInt(document.documentElement.clientWidth);
			var ch = parseInt(document.documentElement.clientHeight);

			var _top = ch/2 - 50;
			var _left = cw/2 - 150;

			 var div = document.createElement('div');
			 div.id = "alert";
			 div.style.width = "300px";
			 div.style.height = "100px";
			 div.style.border = "5px solid #000";
			 div.style.fontSize = "9pt";
			 div.style.zIndex = "100";
			 div.style.position = "absolute";
			 div.style.top = _top +"px";
			 div.style.left = _left +"px";
			 var layout = "
" + msg + "
"; layout += ""; div.innerHTML = layout; document.body.appendChild(div); }else{ var cw = parseInt(document.documentElement.clientWidth); var ch = parseInt(document.documentElement.clientHeight); var _top = ch/2 - 50; var _left = cw/2 - 150; var div = document.getElementById("alert"); div.style.top = _top +"px"; div.style.left = _left +"px"; document.getElementById("alert-msg").innerHTML = msg; document.getElementById("alert").style.display = ""; } }; </script> <a href="javascript:window.alert('Hello world')">click</a> <p> </p> </body> </html>

system alert 과 같은 형태의 효과를 내기 위해서는 몇가지 더 추가 되어야 할 사항들이 있습니다. alert window가 발생된 시점에 content의 모든 영역에 click을 방지 하기 위해 투명 layer로 차단해줘야 겠죠 그외에도 몇가지 더 추가 해야 할 거 같습니다.
2008/02/04 07:13 2008/02/04 07:13
  1. azki

    2008/02/04 09:45 [수정/삭제] [답글]

    아이디어 괜찮은데요^^;;

    ps. 33,34 번째 라인의 " 가 중첩되어 에러가 나니 복사해 쓸때 조심해야될듯한

    • 블루비

      2008/02/04 10:16 [수정/삭제]

      확인해 보니 정말 그렇네요.. ㅎㅎ
      구문강조 스크립트로 인해서 코드가 변형이 되는 문제 인데 수정 해놨습니다.
      글 감사합니다. ^^

  2. 김주일

    2009/04/21 16:37 [수정/삭제] [답글]

    confirm은 같은 방법으로는 작동하지 않네요.
    CallBack형태로 작성되어야 될것 같습니다.

댓글을 남겨주세요.

[로그인][오픈아이디란?]

[JavaScript] beautyDate , beautyDate : function

Posted at 2008/01/30 09:30 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
John Resig's prettyDate()
- http://ejohn.org/blog/javascript-pretty-date/

Mixed's beautyDate()
- http://mixed.tistory.com/194


/**
 * JavaScript  beautyDate
 * 
 * @author mixed <mailto:i . nevalose (at) gmail . com>
 * @license GNU
 * @blog http://mixed.tistory.com/
 * 
 * @param {Date} date
 * @param {Object} customOption
 * 
 * @return {String} beautyDate
 */
function beautyDate(date,customOption){
	if(arguments.length<1||date.constructor != Date){
		return false;
	}
	var options = {
		format		:"{yyyy}/{mm}/{0d} {0h}:{0i}",
		monthFormat :["01","02","03","04","05","06","07","08","09","10","11","12"],
		weekFormat	:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],
		ampmFormat	:["am","pm"]
	}
	customOption = customOption||{};
	for(var i in customOption){
		options[i] = customOption[i];
	}
	options["rowData"] = [date.getFullYear()+"",
						  date.getMonth(),
						  date.getDate(),
						  date.getDay(),
						  date.getHours()<12?0:1,
						  date.getHours(),
						  date.getMinutes(),
						  date.getSeconds()];
	return options.format.replace(/\{([^{}]*)\}/g,function(type){
		var coptions = options;

		function addZero(num){
			return (num>=10)?num:"0"+num;
		}
		function twelveNotation(num){
			return (num>12)?num-12:num;
		}
		var rowData 	= coptions.rowData;
		var monthFormat = coptions.monthFormat;
		var weekFormat  = coptions.weekFormat;
		var ampmFormat  = coptions.ampmFormat;
		
		return type=="{yyyy}"&&rowData[0]||
			   type=="{yy}"&&rowData[0].slice(2,4)||
			   type=="{mm}"&&monthFormat[rowData[1]]||
			   type=="{dd}"&&rowData[2]||
			   type=="{0d}"&&addZero(rowData[2])||
			   type=="{ww}"&&weekFormat[rowData[3]-1]||
			   type=="{ap}"&&mFormat[rowData[4]]||
			   type=="{hh}"&&twelveNotation(rowData[5])||
			   type=="{HH}"&&rowData[5]||
			   type=="{0h}"&&addZero(twelveNotation(rowData[5]))||
			   type=="{0H}"&&addZero(rowData[5])||
			   type=="{ii}"&&addZero(rowData[6])||
			   type=="{0i}"&&addZero(rowData[6])||
			   type=="{ss}"&&rowData[7]||
			   type=="{0s}"&&addZero(rowData[7])||"'"+type+":undefined type'";

	});
}

2008/01/30 09:30 2008/01/30 09:30

댓글을 남겨주세요.

[로그인][오픈아이디란?]

Slider date-picker

Posted at 2008/01/22 10:27 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
사용자 삽입 이미지

시작과 종료 날짜를 Bar 타입의 Slider 를 통해 마우스 드레그로 원하는 날짜를 선택 할 수 있는 Slider date-picker 입니다.

사용자 입장에서 본다면 다소 접근 성이 조금은 결여 된 작품이지만...
개발자 입장에선 신선하다는 생각이 드는 군요...


Post : http://ajaxorized.com/introducing-the-sliding-date-picker/
Example : http://www.ajaxorized.com/dateslider/slider.html


Javascript Date Library







2008/01/22 10:27 2008/01/22 10:27

댓글을 남겨주세요.

[로그인][오픈아이디란?]

dojo 에서 만든 자바스크립트압축기 ShrinkSafe

Posted at 2007/12/07 02:10 // in 웹프로그래밍™/jQuery, Javascript // by 블루비
http://dojotoolkit.org/docs/shrinksafe

Mixed 블로그 포스팅에 의하면

1. 압축방식이 정규표현식으로 압축하지 않고 Rhino의 실제 파서를 이용하여 압축
2. 단점으로는 압축된 소스를 되돌릴 수 없음
3. 추후에는 Gzipping도 지원
4. 배포의 최적화 조건인 Minifying, Obfuscating, Gzipping 이 3가지 조건 만족


대세는 자바스크립트인 만큼 압축기를 사용하여 트래픽을 어느정도 줄여 줄 수 있을듯..
하지만 java 형태여서 윈도상에서 돌릴 수 있는 압축기가 있었으면 하는 바람..

전에 윈도우 버전용으로 나온거 있었던거 같은데.. 찾아봐야 겠군.


To run this example, you'll need a working install of Java (at least 1.4 is recommended). The latest version of the tool itself can be downloaded from Dojo Subversion at:
압축기 : http://svn.dojotoolkit.org/dojo/trunk/b ··· hino.jar
To demo our compression system, let's build an example that we want to compress. Here's the listing for infile.js:
function MyClass(){
this.foo = function(argument1, argument2){
var addedArgs = parseInt(argument1)+parseInt(argument2);
return addedArgs;
}
var anonymousInnerFunction = function(){
// do stuff here!
}
}
function MyFunc(){
// this is a top-level function
}
// we've got multiple lines of whitespace here
압출하는 방법은 아래 코드와 같이 실행하여 outfile.js 을 생성:
java -jar custom_rhino.jar -c infile.js > outfile.js 2>&1
아래와 같은 압축된 코드의 outfile.js 파일을 볼 수 있다.:
function MyClass(){
this.foo=function(_1,_2){
var _3=parseInt(_1)+parseInt(_2);
return _3;
};
var _4=function(){
};
}
function MyFunc(){

}
2007/12/07 02:10 2007/12/07 02:10

댓글을 남겨주세요.

[로그인][오픈아이디란?]