Last active
August 29, 2015 13:56
-
-
Save treby/9182445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var CARD_COUNT_PER_PAGE = 25; | |
var page_limit = 3; | |
var total = 0; | |
var pointer = 0; | |
var card_list; | |
var idol_list = new Array(); | |
function action(num) { | |
if(typeof num !== 'number') { | |
num = 1; | |
$('<div/>').css({ | |
position: 'fixed', | |
left: 0, | |
top: 0, | |
width: '100%', | |
height: '100%', | |
zIndex: 1000, | |
backgroundColor: 'rgba(0,0,0,.7)', | |
color: '#fff', | |
fontSize: 30, | |
textAlign: 'center', | |
paddingTop: '5em' | |
}).attr('id', '___overlay').text('アルバム埋まってないのサーチ').appendTo('body'); | |
total = 0; | |
if (!confirm('集計を始めるの')) { | |
$('#___overlay').remove(); | |
return; | |
} | |
} | |
var progress = load(num); | |
$('#___overlay').text(num+'ページ目を集計中なの!'); | |
progress.done(function(page_total){ | |
total += page_total; | |
if (num < page_limit) { | |
action(num+1); | |
} else { | |
// 集計完了 | |
$('#___overlay').text('集計完了なの!'); | |
alert(unknown_list.length+'枚のカードが埋まってないの!'); | |
var txt = $('<textarea>').addClass('textarea'); | |
txt.attr({ | |
rows : '10', | |
style : 'width:280px;' | |
}); | |
var t = ''; | |
$.each(unknown_list, function(index){ | |
t += unknown_list[index] +'\r\n'; | |
}); | |
txt.val(t); | |
$('#wrapper').prepend(txt); | |
$('#___overlay').remove(); | |
} | |
}).fail(function(){ | |
alert('fail:' + total); | |
$('#___overlay').remove(); | |
}); | |
} | |
function load(num) { | |
var df = $.Deferred(); | |
var page = get(num); | |
page.done(function(data){ | |
var dom = $.parseHTML(data); | |
var _total = 0; | |
var hoge = $('.idol-prof ul', dom); | |
console.log(hoge); | |
// $(dom).find('.idol-prof ul').each(function(i){ | |
// idol_list.push($(this).html()); | |
// }); | |
if(_total === 0) df.reject(); | |
else df.resolve(_total); | |
}); | |
return df.promise(); | |
} | |
function get(num) { | |
var df = $.Deferred(); | |
$.ajax({ | |
url: 'http://imas.gree-apps.net/app/index.php/idol/detail/id/'+num, | |
success: function(data){ | |
console.log(data); | |
df.resolve(data); | |
} | |
}); | |
return df.promise(); | |
} | |
var d=document; | |
var jq=d.createElement('script'); | |
jq.src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'; | |
jq.onload=action; | |
d.body.appendChild(jq); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment