게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
오유 댓글 추첨기 V1.0
게시물ID : programmer_5944짧은주소 복사하기
작성자 : S시온스S
추천 : 7
조회수 : 754회
댓글수 : 13개
등록시간 : 2014/10/13 20:56:46
가 내가 오유 추첨기를 들고 와쪄여!!!!!!!
http://www.todayhumor.co.kr/board/view.php?table=bestofbest&no=170073&s_no=170073&kind=bestofbest_sort&page=1&o_table=programmer



지난 베오베를 보다가

이사람이 추첨기를 만든걸 봤는데 공개를 안했길레 괘씸해서 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

이번엔 제가 만들어봤습니다!!!


Javascript로요 ㅋㅋ



우선 코드는 이렇습니다. 해보고 싶은 분은 Ctrl+C를 해보세요.


(function(){function getEmails(){var emailChecker=/[0-9a-zA-Z][_0-9a-zA-Z-]*@[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+){1,2}$/;var result=[];$(".memoContainerDiv").each(function(i,d){var items=$(d).find(".memoContentDiv").text().split(/(\n| )/);for(var j=0;j<items.length;j++)if(emailChecker.test(items[j]))result.push(setupInfomation(d))});return result}function getNormals(){var result=[];$(".memoContainerDiv").each(function(i,d){result.push(setupInfomation(d))});return result}function setupInfomation(elem){var obj=elem.obj={};elem=$(elem);var i=0;elem.find(".memoInfoDiv").children().each(function(a,d){if(d instanceof HTMLSpanElement){var text=$(d).text();switch(i++){case 0:obj.name=text.replace(/(\n| )/,"");obj.anony=!$(d).find("a").length;break;case 1:obj.update=new Date(/[0-9][-0-9]* [:0-9]*/.exec(text)[0]);break;case 2:if(obj.anony){obj.vote=parseInt(text.substr(text.indexOf("\ucd94\ucc9c:")+3));obj.unvote=parseInt(text.substr(text.indexOf("\ubc18\ub300:")+3))}else{obj.joindate=new Date(/[0-9][-0-9]*/.exec(text)[0]);obj.visit=parseInt(text.substr(text.indexOf("\ubc29\ubb38:")+3))}break;case 3:if(!obj.anony){obj.vote=parseInt(text.substr(text.indexOf("\ucd94\ucc9c:")+3));obj.unvote=parseInt(text.substr(text.indexOf("\ubc18\ub300:")+3))}break}}});return elem}function startCollect(){var lotteryCount=0,existEmail=false,filterType=0;do{lotteryCount=parseInt(prompt("\ucd94\ucca8\ud560 \uba85 \uc218\ub97c \uc785\ub825 \ud574 \uc8fc\uc138\uc694. (\uc22b\uc790\ub9cc\uc694!)"));if(isNaN(lotteryCount)){alert("\ucde8\uc18c\ub410\uc2b4\ub3e0");return}}while(!confirm(lotteryCount+"\uba85\uc774 \ub9de\ub098\uc694?"));existEmail=confirm("\uc774\uba54\uc77c \uc8fc\uc18c\uac00 \uc788\ub294 \ub300\uc0c1\ub9cc \ucd94\ucca8\ud560\uae4c\uc694?");if(confirm("\ub80c\ub364\uc73c\ub85c \ud560\uae4c\uc694?"))filterType="random";else if(confirm("\ucd94\ucc9c\uc218\uac00 \ub192\uc740 \uc21c\uc73c\ub85c \ud560\uae4c\uc694?"))filterType="vote";else if(confirm("\uac00\uc7a5 \ube68\ub9ac \uae00\uc744 \uc4f4 \uc0ac\ub78c\ubd80\ud130 \ud560\uae4c\uc694?"))filterType="newest";else{alert("\u3131- \uc6d0\ud558\ub294\uac8c \ubb61\ub2c8\uae4c.");return}var result=[];var target=existEmail?getEmails():getNormals();switch(filterType){case "random":for(var i=0;i<lotteryCount&&target.length>0;i++){var idx=parseInt(Math.random()*target.length);result.push(target[idx]);target.splice(idx,1)}break;case "vote":result=target.sort(function(a,b){return b[0].obj.vote-a[0].obj.vote});break;case "newest":result=target.sort(function(a,b){return+a[0].obj.update-+b[0].obj.update});break;case "join":}result.splice(lotteryCount,result.length-lotteryCount);$(".reports").remove();var dom=$("<div class='reports'>").css({position:"fixed",left:0,top:0,padding:10,background:"white",zIndex:1E12}).click(function(){$(this).remove()}).appendTo(document.body);var table=$("<table><tr><th>\uc774\ub984</th><th>\uc774\uba54\uc77c</th><th>\ucd94\ucc9c</th><th>\ubc29\ubb38</th></tr></table>");dom.append(table);if(result.length===0)table.append("<tr><td colspan='3'>\ub300\uc0c1\uc5c4\uc2b4\uc73c\ub85c \uc74c\uc2b4\uccb4</td></tr>");else $(result).each(function(i,d){var obj=d[0].obj;table.append("<tr><td>"+obj.name+"</td><td>"+obj.email+"</td><td>"+obj.vote+"</td><td>"+obj.visit+"</td></tr>")});console.log(result)}var intervalID=setInterval(function(){loadMoreReply()},100);var originNoMoreReplyPop=window.noMoreReplyPop;window.noMoreReplyPop=function(){console.log("\uc751?");if(intervalID){clearInterval(intervalID);intervalID=undefined;window.noMoreReplyPop=originNoMoreReplyPop;originNoMoreReplyPop();startCollect()}}})(); 



1.jpg

2.jpg

3.jpg

4.jpg

5.jpg



꼬릿말 보기
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호