클량 사게 뷰어(jquery mobile)
by Reiot
HTML
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css">
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
<script src="http://github.com/jamespadolsey/jQuery-Plugins/raw/master/cross-domain-ajax/jquery.xdomainajax.js"></script>
<!-- Start of first page -->
<div data-role="page" id="foo">
<div data-role="header" data-theme="b">
<h1>Clien Image Viewer</h1>
</div><!-- /header -->
<div data-role="content" data-theme="d">
<ul id="images" data-role="listview">
</ul>
</div><!-- /content -->
<div data-role="footer" class="ui-bar" data-theme="b">
<a href="#" id="more" data-role="button" data-icon="refresh">More</a>
</div><!-- /header -->
</div><!-- /page -->
JavaScript
var current_page=1;
function get_item(page) {
//alert(page);
var url = 'http://clien.career.co.kr/cs2/bbs/board.php?bo_table=image';
if (page) {
current_page = page; //remember this
url += '&page=' + page;
}
$.ajax({
url: url,
type: 'GET',
success: function(res) {
var board_main = $(res.responseText).find('div.board_main form table');
board_main.find('img').each(function() {
var src = $(this).attr('src');
$(this).attr('src', 'http://clien.career.co.kr/cs2/bbs/' + src);
});
board_main.find('tr').each(function() {
var $li = $('<li>');
if ($(this).find('.view_head').length) {
// header tr
var post_title = $(this).find('div.view_title h4 span'),
// text
post_info = $(this).find('p.post_info'),
// span or img
user_info = $(this).find('p.user_info');
var wr_id = /wr_id=(\d+)/g.exec(post_title.find('a').attr('href'))[1];
//alert(wr_id);
$li.attr({
'data-post-id': wr_id,
'data-role': 'list-divider'
}).append(post_title.text());
$li.appendTo('#images');
} else {
// content tr
var view_content = $(this).find('div.view_content');
$li.append(view_content);
$li.appendTo('#images');
}
});
$('#images').listview(); //is this safe to call for existing list?
}
});
}
$(function() {
get_item();
$('a#more').click(function() {
get_item(current_page + 1);
});
});