アットウィキロゴ

cdfg2

var artist=new Array();
var title=new Array();
var number;
 
function sample(){
 
    var str;
var n=$("#te").val();
 
str=check(n);
 
$("#nc").text(str);
 
}
 
function check(w2){
 
var s;
var strx;
strx="moname";
for(s=0;s<number;s++){   
if(artist[s].indexOf(w2)>-1)strx=title[s];
}
return strx;
}
 
 
function readfile(){
 
    $.get("data.txt", function (data) {
 
        var s;
        var word = new Array();
        var str;
 
        word = data.split("</data>");
        for (s = 0; s < word.length; s++) {
            word[s] = word[s].replace("<data>", "");
        }
 
 
 
        for (s = 0; s < word.length; s++) {
            artist[s] = catchword(word[s], "artist");
        }
 
        for (s = 0; s < word.length; s++) {
            title[s] = catchword(word[s], "title");
        }
 
 
        number = word.length;
 
 
    });
 
    function catchword(str,wor){
        var strx,str1,str2;
        var p1, p2;
 
        str1 = "<" + wor + ">";
         str2 = "</" + wor + ">";
         p1 = str.indexOf(str1);
            p2 = str.indexOf(str2);
            strx = str.substring(p1, p2);
            strx = strx.replace(str1,"");
        return strx;
    }
}
 
 
 
 
 
<!DOCTYPE html>
 
<html lang="ja">
    <head>
        <meta charset="utf-8" />
        <title>rensyu</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="sample.js"></script>
</head>
<body onload="readfile()">
<input type="text" id="te" value="猫" size="20">
<input type="button" onclick="sample()" value="導入">
<p id="nc">表示</p>
</body>
</html>
 
最終更新:2013年09月22日 19:37