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년 전
오호~감사합니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8030 | 9년 전 | 415 | ||
| 8029 | 9년 전 | 339 | ||
| 8028 | 9년 전 | 296 | ||
| 8027 | 9년 전 | 308 | ||
| 8026 | 9년 전 | 380 | ||
| 8025 | 9년 전 | 410 | ||
| 8024 | 9년 전 | 398 | ||
| 8023 | 9년 전 | 424 | ||
| 8022 | 9년 전 | 339 | ||
| 8021 | 9년 전 | 362 | ||
| 8020 | 9년 전 | 363 | ||
| 8019 | 9년 전 | 376 | ||
| 8018 | 9년 전 | 478 | ||
| 8017 | 9년 전 | 559 | ||
| 8016 | 9년 전 | 384 | ||
| 8015 | 9년 전 | 418 | ||
| 8014 | 9년 전 | 347 | ||
| 8013 | 9년 전 | 269 | ||
| 8012 | 9년 전 | 270 | ||
| 8011 | 9년 전 | 478 | ||
| 8010 | 9년 전 | 333 | ||
| 8009 | 9년 전 | 349 | ||
| 8008 | 9년 전 | 317 | ||
| 8007 | 9년 전 | 466 | ||
| 8006 | 9년 전 | 502 | ||
| 8005 |
|
9년 전 | 995 | |
| 8004 | 9년 전 | 385 | ||
| 8003 | 9년 전 | 454 | ||
| 8002 | 9년 전 | 349 | ||
| 8001 |
|
9년 전 | 692 | |
| 8000 | 9년 전 | 457 | ||
| 7999 | 9년 전 | 408 | ||
| 7998 | 9년 전 | 466 | ||
| 7997 | 9년 전 | 336 | ||
| 7996 | 9년 전 | 565 | ||
| 7995 | 9년 전 | 512 | ||
| 7994 | 9년 전 | 401 | ||
| 7993 | 9년 전 | 471 | ||
| 7992 | 9년 전 | 542 | ||
| 7991 | 9년 전 | 290 | ||
| 7990 | 9년 전 | 325 | ||
| 7989 | 9년 전 | 331 | ||
| 7988 | 9년 전 | 758 | ||
| 7987 | 9년 전 | 463 | ||
| 7986 | 9년 전 | 464 | ||
| 7985 | 9년 전 | 543 | ||
| 7984 | 9년 전 | 461 | ||
| 7983 | 9년 전 | 698 | ||
| 7982 | 9년 전 | 558 | ||
| 7981 | 9년 전 | 516 | ||
| 7980 | 9년 전 | 537 | ||
| 7979 | 9년 전 | 528 | ||
| 7978 | 9년 전 | 491 | ||
| 7977 | 9년 전 | 432 | ||
| 7976 | 9년 전 | 892 | ||
| 7975 | 9년 전 | 406 | ||
| 7974 | 9년 전 | 450 | ||
| 7973 | 9년 전 | 631 | ||
| 7972 | 9년 전 | 423 | ||
| 7971 | 9년 전 | 499 | ||
| 7970 | 9년 전 | 341 | ||
| 7969 | 9년 전 | 582 | ||
| 7968 | 9년 전 | 428 | ||
| 7967 | 9년 전 | 412 | ||
| 7966 | 9년 전 | 416 | ||
| 7965 |
|
9년 전 | 1045 | |
| 7964 | 9년 전 | 435 | ||
| 7963 | 9년 전 | 444 | ||
| 7962 | 9년 전 | 444 | ||
| 7961 |
전갈자리남자
|
9년 전 | 537 | |
| 7960 | 9년 전 | 1004 | ||
| 7959 | 9년 전 | 585 | ||
| 7958 | 9년 전 | 436 | ||
| 7957 | 9년 전 | 393 | ||
| 7956 | 9년 전 | 390 | ||
| 7955 | 9년 전 | 494 | ||
| 7954 | 9년 전 | 429 | ||
| 7953 | 9년 전 | 477 | ||
| 7952 | 9년 전 | 399 | ||
| 7951 | 9년 전 | 531 | ||
| 7950 | 9년 전 | 427 | ||
| 7949 | 9년 전 | 420 | ||
| 7948 | 9년 전 | 356 | ||
| 7947 | 9년 전 | 974 | ||
| 7946 | 9년 전 | 489 | ||
| 7945 | 9년 전 | 434 | ||
| 7944 | 9년 전 | 494 | ||
| 7943 | 9년 전 | 423 | ||
| 7942 | 9년 전 | 439 | ||
| 7941 | 9년 전 | 428 | ||
| 7940 | 9년 전 | 928 | ||
| 7939 | 9년 전 | 421 | ||
| 7938 | 9년 전 | 436 | ||
| 7937 | 9년 전 | 325 | ||
| 7936 | 9년 전 | 908 | ||
| 7935 | 9년 전 | 512 | ||
| 7934 | 9년 전 | 491 | ||
| 7933 | 9년 전 | 617 | ||
| 7932 | 9년 전 | 559 | ||
| 7931 | 9년 전 | 614 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기