Ajax 線上詞典

來源:互聯網
上載者:User

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>
<!--
<textarea id="debug" style="width:500px;height:350px;">

</textarea>
-->
<b>Dict.cn</b><hr>
<input onKeyUp=if(event.keyCode==13)this.nextSibling.nextSibling.click()> <input type="button" value='search' onclick="if(tv = this.previousSibling.previousSibling.value)dict(tv)">
<div id="temptrans" style="display:block;"><br>
 The vocabulary is derived from <a href=http://dict.cn>dict.cn</a><p align=right style='padding-right:650px;color:green'>
 buglol</p>
</div>
<script>
var $=function(hook){return document.getElementById(hook);}
function unhtmlspecialchars(str){
 f = new Array(/&lt;/g, /&gt;/g, /"/g, /&/g);
 r = new Array('<', '>', '"', '&');
 for (var i = 0; i < f.length; i++){
  str = str.replace(f[i], r[i]);
 }
 return str.replace(/'/g,"'");
}
function htmlspecialchars(str){
 var f = new Array(new RegExp('&', 'g'),new RegExp('<', 'g'),new RegExp('>', 'g'),new RegExp('"', 'g'));
 var r = new Array('&','&lt;','&gt;','"');
 for (var i = 0; i < f.length; i++){
  str = str.replace(f[i], r[i]);
 }
 return str.replace("'",/'/g);
}
function dict(v,s)
{
 try
 {
  Ax.loadHttp("http://dict.cn/search/?q="+decodeURI(v)+(s?"&r="+s:""),true,function()
  {
   var retTxt = Ax.Bin2Str(arguments[0].responseBody);
   //$("debug").value = shiftRelevantInterpretation(shiftHref(stripIMG(getIWanted(Ax.Bin2Str(arguments[0].responseBody)))));
   if(!/dictAdd/gi.test(retTxt))
   {
    //$("temptrans").innerHTML = "對不起,這個單詞沒找到!";
    //divChangeText ('progressDiv', '<font size="2" face="Trebuchet MS">1. <a href=./?q=campaign&r=compaign>campaign</a></font><br><font size="2" face="Trebuchet MS">2. <a href=./?q=copain&r=compaign>copain</a></font><br><font size="2" face="Trebuchet MS">3. <a href=./?q=complain&r=compaign>complain</a></font><br><font size="2" face="Trebuchet MS">4. <a href=./?q=complin&r=compaign>complin</a></font><br><br>試試近音查詞<a href=./?q=%5Bcompaign%5D>[compaign]</a>?');
    if(!/divChangeText/gi.test(retTxt))
    {
     return false;
    }else{
     var pattern = /<a href=\.\/\?q=([^&]+)&r=([^>]+)>/gi;
     //while((result = pattern.exec(v)) != null)
    }
   };
   $("temptrans").innerHTML = shiftRelevantInterpretation(shiftHref(stripIMG(getIWanted(retTxt))));
  });
 }catch(e){$("temptrans").innerHTML = "<br><b>Error:</b><br></br>"+e.description;return false;}
}
function rndNO(e,s)
{
 switch (e)
 {
  case 0:return ((d = new Date()).getYear()) + (s?"-":"") + (d.getMonth()+1) + (s?"-":"") + (d.getDate()) + (s?"-":"") + (d.getHours()) + (s?"-":"") + (d.getMinutes()) + (s?"-":"") + (d.getSeconds()) + (s?"-":"") + (d.getMilliseconds());
  case 1:return ((d = new Date()).getMonth()+1) + (s?"-":"") + (d.getDate()) + (s?"-":"") + (d.getHours()) + (s?"-":"") + (d.getMinutes()) + (s?"-":"") + (d.getSeconds()) + (s?"-":"") + (d.getMilliseconds());
  case 2:return ((d = new Date()).getDate()) + (s?"-":"") + (d.getHours()) + (s?"-":"") + (d.getMinutes()) + (s?"-":"") + (d.getSeconds()) + (s?"-":"") + (d.getMilliseconds());
  case 3:return ((d = new Date()).getHours()) + (s?"-":"") + (d.getMinutes()) + (s?"-":"") + (d.getSeconds()) + (s?"-":"") + (d.getMilliseconds());
  case 4:return ((d = new Date()).getMinutes()) + (s?"-":"") + (d.getSeconds()) + (s?"-":"") + (d.getMilliseconds());
  case 5:return ((d = new Date()).getSeconds()) + (s?"-":"") + (d.getMilliseconds());
  case 6:return ((d = new Date()).getMilliseconds());
 }
}
function stripIMG(s)
{
 var pattern = /<img[^>]+>/gi;
 return s.replace(pattern,"");
}
function getIWanted(s)
{
 if(!/divChangeText/gi.test(s))
 {
  var pattern = /<td height=\"320\" width=\"566\">([\d\D]+)(?=<img src=\/img\/wordbook\.gif border=0 align=absmiddle>加入生詞本<\/a>)/ig;
  return pattern.exec(s)[1] + "<\/td><\/tr><\/table>";
 }else{
  //divChangeText ('progressDiv', '<font size="2" face="Trebuchet MS">1. <a href=./?q=testis&r=testds>testis</a></font><br><font size="2" face="Trebuchet MS">2. <a href=./?q=testes&r=testds>testes</a></font><br><font size="2" face="Trebuchet MS">3. <a href=./?q=testas&r=testds>testas</a></font><br><font size="2" face="Trebuchet MS">4. <a href=./?q=tess&r=testds>tess</a></font><br><font size="2" face="Trebuchet MS">5. <a href=./?q=tsts&r=testds>tsts</a></font><br><font size="2" face="Trebuchet MS">6. <a href=./?q=test&r=testds>test</a></font><br><font size="2" face="Trebuchet MS">7. <a href=./?q=testy&r=testds>testy</a></font><br><font size="2" face="Trebuchet MS">8. <a href=./?q=testa&r=testds>testa</a></font><br><br>試試近音查詞<a href=./?q=%5Btestds%5D>[testds]</a>?');
  var pattern = /divChangeText.*/gi;
  try
  {
   var bb = "對不起,這個單詞沒找到!<br>您要尋找的是不是:<br>";
   s = s.match(pattern)[1];
   s = s.match(/(<a[^>]*>.*?<\/a>)/gi);
   for(var i=0;i<s.length-1;++i)
   {
    bb += s[i] + "<br>";
   }
   return bb;
  }catch(e){$("temptrans").innerHTML = "<br><b>Error:</b><br></br>"+e.description;return false;}
 }
}
function shiftHref(s)
{
 var pattern = /<a href=\"index\.php\?q=(.+?)(?=\">)/gi;
 //var str = "同義字:<a href=\"index.php?q=quiz\">quiz</a></font><br><br>4. show a certain characteristic when tested<br><a href=\"index.php?q=test\">test</a><br>5. achieve a certain score or rating on a test<br><br>6. determine the presence or properties of (a substance)<br><br>7. undergo a test<br><br><br>";
 return s.replace(pattern,function(){return "<a style='cursor:pointer;color:blue' onclick=\"newSearch('"+arguments[1].replace(/'/g,"\\'")+"')"});
}
function newSearch(v)
{
 document.getElementsByTagName("input")[0].value = v;
 dict(v);
 return false;
}
function shiftRelevantInterpretation(s)
{
 var pattern = /<a href=\.\/\?q=([^&]+)&r=([^>]+)>/gi;
 return (s.replace(pattern,function(){return "<a style='cursor:pointer;color:blue' onclick=\"relevantSearch('"+arguments[1].replace(/'/g,"\\'")+"','"+arguments[2].replace(/'/g,"\\'")+"')\">"}));
}
function relevantSearch(s,r)
{
 document.getElementsByTagName("input")[0].value = s.replace(/\+/gi," ");
 dict(s,r);
 return false; 
}
Ajax = function ()
{
 var navName = (function ()
 {
  var u = navigator.userAgent.toLowerCase();
  if (/gecko/i.test(u)) return "moz";
  if (/msie/i.test(u)) return "ie";
  return "other";
 })();
 this.MODE = "GET";
 var ie = navName=="ie";
 var elem = $("__AjaxCall_Wait");
 if (!elem)
 {
  elem = document.createElement("div");
  elem.id = '__AjaxCall_Wait';
  elem.style.position = "absolute";
  elem.style.display = "none";
  elem.style.background = "#3C4040";
  elem.style.left= "40%";
  elem.style.top= "50%";
  elem.style.color = "#FF6600";
  elem.style.padding = "7px";
  elem.style.border = "1px solid #FF7700";
  document.body.insertBefore(elem,document.body.firstChild);
 }
 elem.style.width = 250;
 //elem.style.height = 35;
 elem.innerHTML = "";
 this.xmlHttp = function ()
 {
  
  if (ie)
  {
   for (var i=0; i<2; i++)
   try
   {
    var r = new ActiveXObject(["MSXML2.XMLHTTP", "Microsoft.XMLHTTP"][i]);
    return r;
   }
   catch (e) { return null;};
  }
  else return new XMLHttpRequest();
  
 }

 this.loadHttp = function (url, asy, fun ,agv)
 {

  this.enabled = false;
  var xmlHttp = this.xmlHttp();
  $("__AjaxCall_Wait").style.display = "block";
  $("__AjaxCall_Wait").innerHTML = "Processing your request...";
  xmlHttp.open(this.MODE, url, (asy ? true : false));
  if (asy)
  {
   xmlHttp.onreadystatechange = function()
   {
    if(xmlHttp.readyState==4)
    {
     fun (xmlHttp);
     $("__AjaxCall_Wait").innerHTML = "";
     $("__AjaxCall_Wait").style.display = "none";
    }
   };
   this.MODE == "POST"?(xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),xmlHttp.send(agv)):xmlHttp.send(null);
  }
  else
  {
   try
   {
    this.MODE == "POST"?(xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),xmlHttp.send(agv)):xmlHttp.send(null);
   }
   catch (e)
   {
    throw new Error("LoadHttp Error.");
    return;
   }
   return xmlHttp.responseText;
  }
 }
 this.Bin2Str = function (binary)
 {
  
  try
  {
   var rec = new ActiveXObject("ADODB.RecordSet");
   rec.Fields.Append("lol",201,1);
   rec.open();
   rec.addNew();
   rec(0).appendChunk(binary);
   rec.update();
   var result = rec(0).value;
   rec.Close();
   return result;
  }catch(e){
   var t = rsB(binary),glbEncode=new Array();
   t = escape(t).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
   t = t.split("@");
   var i=0,j=t.length,k;
   while(++i<j)
   {
    k=t[i].substring(0,4);
    if(!glbEncode[k])glbEncode[k]=escape(vbChar(eval("0x"+k))).substring(1,6);
    t[i]=glbEncode[k]+t[i].substring(4);
   }
   return unescape(t.join("%"));
  }
 }
};
var Ax = new Ajax;
window.onload = function()
{
 document.getElementsByTagName("input")[0].focus();
}
</script>
<script language=vbscript>
Function rsB(vIn)
rsB=MidB(vIn,1)
End Function
Function vbChar(ss)
vbChar = Chr(ss)
End Function
</script>
</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.