회원가입∴아이디/비번찾기
홈으로


레이어 3 - 레이어 안에 1000 개의 글자중에 틀린 글자를 찾아내는 소스입니다
22년 전
레이어 쪼물딱거리기 - 이번얘기는 레이어안의 내용에 관한겁니다.
레이어 내용에 관한 속성은 innerHTML 이고 이 속성은 읽거나 쓰기가
가능합니다.
이 속성으로 레이어의 내용을 새로 정해주었을때 앞전 내용은 없어져버
리죠.

레이어 안에 1000 개의 글자중에 틀린 글자를 찾아내는 소스입니다.
틀린 글자의 갯수는 최대 열개 최소 한개 사이죠.

비슷한 글자끼리 하나의 배열을 형성하는 다중 배열을 정의해줍니다.
그리고 임의로 이 요소중 하나의 배열을 선택해 첫글자를 중심으로
레이어에 천개의 문자를 뿌려주고......
물론 틀린 글자를 적당히 섞고 또 맞는 글자를 클릭할때와 틀린 글자를
클릭할때 확인해줄 함수도 링크를 걸어줍니다.

제대로 클릭 했을땐 안내문 레이어에 적당한 멧세지를 띄워주며
엉뚱한 글자를 클릭 했거나 찾아낸 글자를 또 클릭했을땐 alert 창을 띄워주죠.
찾기 귀찮을땐 틀린 글자를 빨간 색으로 바꿔주는 함수도 만들어봤습니다.
틀린 글자가 빨간색으로 뜨더라도 기존의 기능은 달라지지 않습니다.


<html>
<title>
뽕뽕뽕뽕뽕뿅
</title>
<head>

<style type='text/css'>
   body
    A:link { text-decoration:none;font-size:12pt; color:  #ffffff;}
    A:visited { text-decoration:none;font-size:12pt; color: #ffffff;}
    A:active { text-decoration:none;font-size:12pt; color: #ffffff;}
    A:hover {color: ffffff;font-size:12pt; text-decoration:none;}  
    A  { cursor:crosshair  }

</style>

<script>

var strrr = new Array(
      new Array('뷁','붺','쀍','봵'),
      new Array('뽕','뿅','뿡','쁨','쁑'),
      new Array('탕','땅','텅'),
      new Array('가','거','갸','겨','개','걔')
      );
      
random_first = Math.floor(Math.random() * strrr.length);   //-- 다중 배열에서 하나의 배열을 임의로 찾아냄
str = strrr[random_first];

inner_html = '';               //-- 레이어에 뿌려질 문자열
str_length = 1000;      //-- 레이어에 뿌려질 문자열 길이
abc = new Array()     //-- 체크 함수를 위한 배열

  
int_random1 = Math.ceil(Math.random() * 10);   //-- 10 는 틀린 글자의 최대 갯수
int_array = new Array();         //-- 1000 개의 숫자를 요소로 하는 배열
int_array2 = new Array();
p = 0;                         //-- p 는 임의로 추출한 틀린글자 갯수까지.......

   for(m=0;m<int_random1;m++)  {
       push_int = Math.floor(Math.random() * str_length);
       if(in_array(push_int,int_array2))  m--;
       else int_array2.push(push_int);
       p = int_array2.length;
       //document.all.bbb.innerHTML = '총' + p + '개의 틀린글자가 있습니다';
       }

   for(n=0;n<str_length;n++)   {
       if(in_array(n,int_array2))  int_array[n] = Math.floor(Math.random() * (str.length - 1)) + 1;
       else int_array[n] = 0;
       }

function make_int1(flag)  {         //-- 레이어에 글자를 뿌려줌
   document.all.bbb.innerHTML = '\'' + str[0] + '\'이 아닌 글자가 총' + p + '개 있습니다';
    
   make_int2(flag);
   document.all.aaa.innerHTML = inner_html;
   }
    
function make_int2(ddd)   {          //-- 틀린 글자를 빨간 글자로 바꿔 레이어에 뿌려줌
   inner_html = '';
   if(!ddd)  {
           for(b=0;b<str_length;b++)  {
               if(int_array[b] == 0) inner_html += '<a href=\'javascript:click(' + b + ')\'>' + str[int_array[b]] + '</a>';
               else inner_html += '<a href=\'javascript:click(' + b + ')\' id=ccc>' + str[int_array[b]] + '</a>';  
               if(b % 40 == 39) inner_html += '<br>';
               }
          }
   else  {
       for(b=0;b<str_length;b++)  {
             if(int_array[b] == 0) inner_html += '<a href=\'javascript:click(' + b + ')\'>' + str[int_array[b]] + '</a>';
             else inner_html += '<a href=\'javascript:click(' + b + ')\'><font color=red><b>' + str[int_array[b]] + '</b></font></a>';  
             if(b % 40 == 39) inner_html += '<br>';
             }
       }
   }
    
function click(su)  {          //-- 글자를 클릭 했을때 실행 하는 함수
   if(in_array(su,int_array2))   {
       if(!check(su))  {
               abc.push(su);
               p -= 1;
               if(p != 0) document.all.bbb.innerHTML = p + '개 남았습니다';
               else  {
                   document.all.bbb.innerHTML =  '다 찾았습니다';
                   alert('다 찾으셨네요. \n\n근데 뭐할라고 찾으셨우??');
                   }
               }
       else  alert('아까 찾은 글자인데요');
       }
   else alert('아닌데요');
   }
  
function in_array(fu,array_name)   {    //-- 배열에 배열 요소가 있나 확인해주는 함수
   in_flag = false;
   //array_name = array_na;
   for(k=0;k<array_name.length;k++)  {
       if(fu == array_name[k]) in_flag = true;
       //break;                //-- 이 구문을 실행 시키니 원하는대로 결과가 나오질 않네.
       }
   return in_flag;
   }
  
function check(num)   {   //-- 클릭한 글자를 다시 클릭 했을때
  //abc = new Array();
  if(in_array(num,abc)) return true;
  else return false;
  }
  
</script>

<body onload='javascript:make_int1(0)' bgcolor=222222>

<input type=button value='게임 하기 또는 다시 시작하기 또는 매우매우 심심하기' onclick='javascript:location.reload()'>
<input type=button value='찾기 졸라 귀찮기' onclick='javascript:make_int1(1)'>


<div id=aaa style='position:absolute;left:100;top:150;width:700;height:500;background-color:555555;font:12pt;color:white;padding-left:30;padding-top:20;cursor:crosshair'>
</div>

<div id=bbb style='position:absolute;left:100;top:50;width:700;height:50;background-color:555555;font:12pt;color:white;padding-left:30;padding-top:20;cursor:crosshair'>
</div>
추천추천 : 430 추천 목록
번호 제목
2,891
입력 필드에서 특정단어(예:#err)가 포함되었을 때 실시간 감지 및 경고창 띄우기
2,890
데이터베이스 최적화와 쿼리 효율성을 높이 검색 성능을 개선하는 방법
2,889
간단한 게시판 만들기
2,888
PHP의 php.ini 파일에서 설정할 수 있는 주요 항목들을 카테고리별로 정리
2,887
유튜브 동영상의 썸네일 이미지를 체크하여 유효한 영상이아닐때 연결된 체크박스를 자동으로 체크
2,886
이미지 URL이 유효하지 않을 때, 해당 이미지와 연결된 체크박스를 자동으로 체크
2,885
HTTPS로 접속한 사용자를 강제로 HTTP로 리디렉션 하려면
2,884
PHP에서 MP3 파일을 직접 읽고 스트리밍 하기
2,883
현재 페이지가 location.reload()에 의해 새로고침되었는지
2,882
텍스트 파일을 읽고, 각 줄의 끝에서 6글자를 삭제한 후, 결과를 새로운 파일에 저장합니다.
2,881
cURL을 사용하여 리다이렉트를 따라가 최종 URL 가져오기
2,880
[PHP] $_SERVER 환경변수
2,879
10진수 <-> 16진수 변환기 PHP소스
2,878
텍스트에 직접 그라데이션 색상을 적용하려면?
2,877
CSS를 사용하여 요소의 내용물에 따라 width를 조정하는 방법
2,876
웹서버 ip 확인
2,875
웹호스팅의 절대경로를 확인
2,874
input 입력 필드 앞뒤 공백 실시간 제거
2,873
Placeholder 포커스시 감추기
2,872
MySQL 중복된 데이터를 삭제
2,871
MySQL 중복 데이터 확인
2,870
sessionStorage.getItem 와 sessionStorage.setItem
2,869
제이쿼리 랜덤으로 배경색 변경
2,868
preg match에 관한 정규식
2,867
Stream an audio file with MediaPlayer 오디오 파일 스트리밍 하기
2,866
Audio Streaming PHP Code
2,865
PHP $ SERVER 환경 변수 정리
2,864
Vimeo (비메오) API 를 사용하여 플레이어 컨트롤하기
2,863
iframe 사용시 하단에 발생하는 공백 제거방법
2,862
아이프레임(iframe) 전체화면 가능하게 하기
목록
뮤직트로트 부산광역시 부산진구 가야동 ㅣ 개인정보취급방침ㅣ모바일버전
Copyright ⓒ musictrot All rights reserved.