http://sir.co.kr/bbs/board.php?bo_table=tiptech&wr_id=3569
이 글을 보고 간단히 만들어봤습니다.
index.html
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Real-time Rank</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="application.js" type="text/javascript"></script>
</head>
<body>
<div id="content">
<dl id="rank-list">
<dt>실시간 급상승 검색어</dt>
<dd>
<ol>
<li><a href="#">1 순위</a></li>
<li><a href="#">2 순위</a></li>
<li><a href="#">3 순위</a></li>
<li><a href="#">4 순위</a></li>
<li><a href="#">5 순위</a></li>
<li><a href="#">6 순위</a></li>
<li><a href="#">7 순위</a></li>
<li><a href="#">8 순위</a></li>
<li><a href="#">9 순위</a></li>
<li><a href="#">10 순위</a></li>
</ol>
</dd>
</dl>
</div>
</body>
</html>
stylesheet.css
body {
font-size: 12px;
background: #FFF;
color: #333;
margin: 0;
}
#content {
margin: 20px;
padding: 10px;
background: #393;
}
#rank-list a {
color: #FFF;
text-decoration: none;
}
#rank-list a:hover {
text-decoration: underline;
}
#rank-list {
overflow: hidden;
width: 160px;
height: 20px;
margin: 0;
}
#rank-list dt {
display: none;
}
#rank-list dd {
position: relative;
margin: 0;
}
#rank-list ol {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
list-style-type: none;
}
#rank-list li {
height: 20px;
line-height: 20px;
}
application.js
$(function() {
var count = $('#rank-list li').length;
var height = $('#rank-list li').height();
function step(index) {
$('#rank-list ol').delay(2000).animate({
top: -height * index,
}, 500, function() {
step((index + 1) % count);
});
}
step(1);
});
이 글을 보고 간단히 만들어봤습니다.
index.html
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Real-time Rank</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="application.js" type="text/javascript"></script>
</head>
<body>
<div id="content">
<dl id="rank-list">
<dt>실시간 급상승 검색어</dt>
<dd>
<ol>
<li><a href="#">1 순위</a></li>
<li><a href="#">2 순위</a></li>
<li><a href="#">3 순위</a></li>
<li><a href="#">4 순위</a></li>
<li><a href="#">5 순위</a></li>
<li><a href="#">6 순위</a></li>
<li><a href="#">7 순위</a></li>
<li><a href="#">8 순위</a></li>
<li><a href="#">9 순위</a></li>
<li><a href="#">10 순위</a></li>
</ol>
</dd>
</dl>
</div>
</body>
</html>
stylesheet.css
body {
font-size: 12px;
background: #FFF;
color: #333;
margin: 0;
}
#content {
margin: 20px;
padding: 10px;
background: #393;
}
#rank-list a {
color: #FFF;
text-decoration: none;
}
#rank-list a:hover {
text-decoration: underline;
}
#rank-list {
overflow: hidden;
width: 160px;
height: 20px;
margin: 0;
}
#rank-list dt {
display: none;
}
#rank-list dd {
position: relative;
margin: 0;
}
#rank-list ol {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
list-style-type: none;
}
#rank-list li {
height: 20px;
line-height: 20px;
}
application.js
$(function() {
var count = $('#rank-list li').length;
var height = $('#rank-list li').height();
function step(index) {
$('#rank-list ol').delay(2000).animate({
top: -height * index,
}, 500, function() {
step((index + 1) % count);
});
}
step(1);
});
댓글 8개
14년 전
올리고 보니 쓸데없는 재귀가 쓰였군요. 바보 같은 코드인데...
window.setInterval로 처리하시는 게 훨씬 안전할 것 같습니다.
window.setInterval로 처리하시는 게 훨씬 안전할 것 같습니다.
14년 전
생각해 보면 animate가 interval을 쓰기 때문에 그냥 저 코드 그대로 가도 되는군요.
혼자 뭐하는 거지 (...)
혼자 뭐하는 거지 (...)
14년 전
혹 네이버,다음,네이트 실시간 검색어 XML 필요하시면
http://bangabmoa.com/api/hitkeyword.php?type=xml
활용하세요.
http://bangabmoa.com/api/hitkeyword.php?type=xml
활용하세요.
14년 전
upcount 말고 downcount가 있는지는 모르겠지만, 일단 upcount가 항상 있다는 가정 하에 적용해봤습니다.
[application.js]
$(function() {
function animateRankList() {
var count = $('#rank-list li').length;
var height = $('#rank-list li').height();
function step(index) {
$('#rank-list ol').delay(2000).animate({
top: -height * index,
}, 500, function() {
step((index + 1) % count);
});
}
step(1);
}
window.yqlCallback = function(data) {
$(data.query.results.channel.data.naver.item).each(function(index, item) {
var text = item.rank + ' - ' + item.keyword + ' [' + item.upcount + ']';
$('#rank-list li a').eq(index).text(text);
});
animateRankList();
}
$('#rank-list li a').text('');
var url = 'http://bangabmoa.com/api/hitkeyword.php?type=xml';
var yql = 'SELECT * FROM xml WHERE url="' + url + '"';
$.ajax({
url: 'http://query.yahooapis.com/v1/public/yql?q=' + yql +
'&format=json&callback=yqlCallback',
dataType: 'script'
});
});
[application.js]
$(function() {
function animateRankList() {
var count = $('#rank-list li').length;
var height = $('#rank-list li').height();
function step(index) {
$('#rank-list ol').delay(2000).animate({
top: -height * index,
}, 500, function() {
step((index + 1) % count);
});
}
step(1);
}
window.yqlCallback = function(data) {
$(data.query.results.channel.data.naver.item).each(function(index, item) {
var text = item.rank + ' - ' + item.keyword + ' [' + item.upcount + ']';
$('#rank-list li a').eq(index).text(text);
});
animateRankList();
}
$('#rank-list li a').text('');
var url = 'http://bangabmoa.com/api/hitkeyword.php?type=xml';
var yql = 'SELECT * FROM xml WHERE url="' + url + '"';
$.ajax({
url: 'http://query.yahooapis.com/v1/public/yql?q=' + yql +
'&format=json&callback=yqlCallback',
dataType: 'script'
});
});
14년 전
댓글에선 들여쓰기가 하나도 적용 안 되네요.
http://www.google.co.kr/search?q=JavaScript+Beautifier
맘에 드시는 JavaScript Beautifier를 골라 잡아서 돌려주시면 들여쓰기가 깔끔히 적용된 코드를 보실 수 있을 겁니다.
http://www.google.co.kr/search?q=JavaScript+Beautifier
맘에 드시는 JavaScript Beautifier를 골라 잡아서 돌려주시면 들여쓰기가 깔끔히 적용된 코드를 보실 수 있을 겁니다.
행복한남자
14년 전
http://jsbeautifier.org/
좋네요~ㅋ 감사합니다.
좋네요~ㅋ 감사합니다.
14년 전
이거 여러 부분에서 유용하겠네요
나스디자인
14년 전
오호~감사합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3530 | 14년 전 | 913 | ||
| 3529 | 14년 전 | 1133 | ||
| 3528 |
|
14년 전 | 1340 | |
| 3527 | 14년 전 | 1190 | ||
| 3526 |
|
14년 전 | 891 | |
| 3525 | 14년 전 | 1182 | ||
| 3524 | 14년 전 | 1401 | ||
| 3523 | 14년 전 | 1371 | ||
| 3522 | 14년 전 | 920 | ||
| 3521 | 14년 전 | 2098 | ||
| 3520 |
|
14년 전 | 436 | |
| 3519 | 14년 전 | 1056 | ||
| 3518 | 14년 전 | 903 | ||
| 3517 |
다케미카코
|
14년 전 | 749 | |
| 3516 |
|
14년 전 | 1240 | |
| 3515 |
NS미디어
|
14년 전 | 1676 | |
| 3514 | 14년 전 | 1032 | ||
| 3513 |
FreeZone
|
14년 전 | 821 | |
| 3512 |
|
14년 전 | 826 | |
| 3511 | 14년 전 | 1086 | ||
| 3510 | 14년 전 | 1381 | ||
| 3509 | 14년 전 | 1477 | ||
| 3508 | 14년 전 | 550 | ||
| 3507 | 14년 전 | 1099 | ||
| 3506 |
|
14년 전 | 988 | |
| 3505 | 14년 전 | 1009 | ||
| 3504 | 14년 전 | 1734 | ||
| 3503 |
letsgolee
|
14년 전 | 1496 | |
| 3502 | 14년 전 | 1379 | ||
| 3501 | 14년 전 | 1137 | ||
| 3500 | 14년 전 | 1152 | ||
| 3499 | 14년 전 | 1766 | ||
| 3498 |
리눅스초보100
|
14년 전 | 797 | |
| 3497 |
네비플러스
|
14년 전 | 578 | |
| 3496 |
도와주세요
|
14년 전 | 840 | |
| 3495 | 14년 전 | 819 | ||
| 3494 | 14년 전 | 1320 | ||
| 3493 | 14년 전 | 1579 | ||
| 3492 | 14년 전 | 1336 | ||
| 3491 | 14년 전 | 950 | ||
| 3490 | 14년 전 | 1020 | ||
| 3489 | 14년 전 | 1106 | ||
| 3488 | 14년 전 | 2844 | ||
| 3487 |
JMoon
|
14년 전 | 1031 | |
| 3486 | 14년 전 | 1693 | ||
| 3485 | 14년 전 | 1311 | ||
| 3484 | 14년 전 | 954 | ||
| 3483 | 14년 전 | 2241 | ||
| 3482 |
photolate
|
14년 전 | 2660 | |
| 3481 | 14년 전 | 765 | ||
| 3480 | 14년 전 | 1005 | ||
| 3479 | 14년 전 | 1890 | ||
| 3478 |
|
14년 전 | 2276 | |
| 3477 | 14년 전 | 1337 | ||
| 3476 | 14년 전 | 1473 | ||
| 3475 | 14년 전 | 810 | ||
| 3474 | 14년 전 | 1122 | ||
| 3473 | 14년 전 | 1121 | ||
| 3472 | 14년 전 | 1884 | ||
| 3471 | 14년 전 | 1147 | ||
| 3470 | 14년 전 | 821 | ||
| 3469 | 14년 전 | 917 | ||
| 3468 | 14년 전 | 224 | ||
| 3467 | 14년 전 | 968 | ||
| 3466 | 14년 전 | 879 | ||
| 3465 | 14년 전 | 895 | ||
| 3464 |
스카이워커
|
14년 전 | 1430 | |
| 3463 | 14년 전 | 2310 | ||
| 3462 | 14년 전 | 1364 | ||
| 3461 | 14년 전 | 1142 | ||
| 3460 |
New악마
|
14년 전 | 1520 | |
| 3459 | 14년 전 | 774 | ||
| 3458 | 14년 전 | 777 | ||
| 3457 | 14년 전 | 1032 | ||
| 3456 | 14년 전 | 1261 | ||
| 3455 | 14년 전 | 891 | ||
| 3454 | 14년 전 | 1178 | ||
| 3453 | 14년 전 | 1807 | ||
| 3452 | 14년 전 | 789 | ||
| 3451 | 14년 전 | 1121 | ||
| 3450 | 14년 전 | 1142 | ||
| 3449 | 14년 전 | 846 | ||
| 3448 | 14년 전 | 858 | ||
| 3447 | 14년 전 | 1243 | ||
| 3446 | 14년 전 | 1728 | ||
| 3445 | 14년 전 | 1631 | ||
| 3444 | 14년 전 | 1539 | ||
| 3443 |
|
14년 전 | 920 | |
| 3442 | 14년 전 | 1108 | ||
| 3441 | 14년 전 | 943 | ||
| 3440 |
바인플러스
|
14년 전 | 826 | |
| 3439 | 14년 전 | 2020 | ||
| 3438 | 14년 전 | 1289 | ||
| 3437 |
New악마
|
14년 전 | 1230 | |
| 3436 |
카프카07
|
14년 전 | 1295 | |
| 3435 |
|
14년 전 | 1521 | |
| 3434 |
|
14년 전 | 881 | |
| 3433 | 14년 전 | 1659 | ||
| 3432 | 14년 전 | 3947 | ||
| 3431 | 14년 전 | 1884 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기