<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="__MSG_title__"
               description="__MSG_description__"
               screenshot="__MSG_screenshot__"
               thumbnail="__MSG_thumbnail__"
               author="Wenchao Tong (tongwenchao)"
               author_email="tongwenchao+yasc@google.com"
               author_affiliation="Google Inc."
               category="news"
               author_location="Shanghai, China">
    <Require feature="views" />
    <Require feature="dynamic-height" />
    <Locale messages="http://www.google.com/ig/modules/yasc/ALL_ALL.xml" />
    <Locale lang="zh-cn" messages="http://www.google.com/ig/modules/yasc/zh-CN_ALL.xml" />
  </ModulePrefs>
  <UserPref name="new_query_interval"
            display_name="__MSG_num_queries__"
            default_value="20"
            datatype="enum">
    <EnumValue value="10" display_value="__MSG_very_many__" />
    <EnumValue value="15" display_value="__MSG_many__" />
    <EnumValue value="20" display_value="__MSG_few__" />
  </UserPref>
  <UserPref name="interval_time"
            display_name="__MSG_animation_quality__"
            default_value="50"
            datatype="enum">
    <EnumValue value="30" display_value="__MSG_very_good__" />
    <EnumValue value="50" display_value="__MSG_good__" />
    <EnumValue value="70" display_value="__MSG_normal__" />
  </UserPref>
  <UserPref name="theme"
            display_name="__MSG_background_color__"
            default_value="__MSG_default_theme__"
            datatype="enum">
    <EnumValue value="0" display_value="__MSG_black__" />
    <EnumValue value="1" display_value="__MSG_white__" />
  </UserPref>
  <UserPref name="moving_mode"
            display_name="__MSG_moving_mode__"
            default_value="1"
            datatype="enum">
    <EnumValue value="1" display_value="__MSG_from_center_to_around__" />
    <EnumValue value="2" display_value="__MSG_random_moving__" />
    <EnumValue value="3" display_value="__MSG_from_top_to_bottom__" />
  </UserPref>
  <UserPref name="moving_speed"
            display_name="__MSG_moving_speed__"
            default_value="0"
            datatype="enum">
    <EnumValue value="-1" display_value="__MSG_slow__" />
    <EnumValue value="0" display_value="__MSG_normal__" />
    <EnumValue value="1" display_value="__MSG_fast__" />
  </UserPref>
  <UserPref name="height"
            display_name="__MSG_height__"
            default_value="350" />
  <Content type="html" view="home,canvas">
  <![CDATA[
<style>.yasc-outerdiv{width:100%;position:relative;overflow:hidden}.yasc-querybox{border:1px solid;position:absolute;white-space:nowrap;padding:2px 15px}a.yasc-querytext:link,a.yasc-querytext:active,a.yasc-querytext:visited{text-decoration:none;color:#fff}a.yasc-querytext:hover{font-weight:bold}</style>
<div id=bodyDiv>
<form action=# id=controlForm>
<input id=btStart onclick=yasc_onStart() type=button value="__MSG_start__" />
</form>
<div class=yasc-outerdiv id=outerDiv />
</div>
<div id=disclaimer></div>
<script>var yasc={};yasc.DEFAULT_HEIGHT=350;yasc.RANDOM_FACTOR=1E4;yasc.COUNTDOWN=10;yasc.LEFT_MARGIN=50;yasc.QUERYBOX_OPACITY=1;yasc.INTERVAL_TIME_BASE=70;yasc.MINIMIZE_INTERVAL_TIME=2E3;yasc.REBANG_URL_HEADER="http://www.google.com/m/services/trends/get?hl=zh-CN&gl=cn&category=web";yasc.START_BID=12E6;yasc.END_BID=12000040;yasc.BORDER_COLORS=[["White","Yellow","Thistle","Purple","GreenYellow","Lime","DarkMagenta"],["#00cc00","#ffcc33","#9966cc","#3399ff","#c4c4c4"]];yasc.BACKGROUND_COLORS=["Black","White"];
yasc.FONT_COLORS=["White","#00c"];yasc.BOX_BACKGROUND_COLORS=["#333333","#f4f4f4"];yasc.CENTER_TO_AROUND_MODE=1;yasc.RANDOM_MODE=2;yasc.TOP_TO_BOTTOM_MODE=3;yasc.intervalTime=50;yasc.newQueryInterval=20;yasc.mode=1;yasc.theme=0;yasc.stepLengthMin=2;yasc.stepLengthMax=7;yasc.queue=null;yasc.render=null;yasc.isIE=false;yasc.fetchedQueryset=yasc.START_BID-1;yasc.Point=function(top,left){this.top=top;this.left=left};
yasc.Query=function(){this.next=null;this.prev=null;var outerDiv=document.getElementById("outerDiv");this.countdown=yasc.COUNTDOWN;this.step=1;this.query="";this.link=document.createElement("a");this.link.className="yasc-querytext";this.link.setAttribute("target","_blank");this.queryDiv=document.createElement("div");this.queryDiv.className="yasc-querybox";this.queryDiv.style.backgroundColor=yasc.BOX_BACKGROUND_COLORS[yasc.theme];this.queryDiv.style.color=yasc.FONT_COLORS[yasc.theme];this.queryDiv.align=
"center";this.queryDiv.appendChild(document.createTextNode(this.query));this.queryDiv.style.zIndex=1;this.borderColor=yasc.BORDER_COLORS[yasc.theme][yasc.Query.getRandomInt(yasc.BORDER_COLORS[yasc.theme].length)];this.queryDiv.style.border="1px solid "+this.borderColor;var o=this;var onMouseOver=function(){o.onMouseOver()};var onMouseOut=function(){o.onMouseOut()};this.queryDiv.onmouseover=onMouseOver;this.queryDiv.onmouseout=onMouseOut;yasc.Query.setOpacity(this.queryDiv,0);this.link.appendChild(this.queryDiv);
outerDiv.appendChild(this.link);this.stepLength=yasc.Query.getRandomInt(yasc.stepLengthMax-yasc.stepLengthMin)+yasc.stepLengthMin;this.isMouseOver=false;if(yasc.Query.queryArray&&yasc.Query.queryArray.length>0)this.reset()};
yasc.Query.prototype.setStartEnd=function(){var outerDiv=document.getElementById("outerDiv");var canvasWidth=outerDiv.offsetWidth;var canvasHeight=outerDiv.offsetHeight;if(yasc.mode==yasc.CENTER_TO_AROUND_MODE){this.endPt=new yasc.Point(yasc.Query.getRandomInt(canvasHeight),yasc.Query.getRandomInt(canvasWidth-yasc.LEFT_MARGIN));this.queryDiv.style.top=(canvasHeight-this.queryDiv.offsetHeight)/2;this.queryDiv.style.left=(canvasWidth-this.queryDiv.offsetWidth)/2}else if(yasc.mode==yasc.RANDOM_MODE){this.endPt=
new yasc.Point(yasc.Query.getRandomInt(canvasHeight),yasc.Query.getRandomInt(canvasWidth-yasc.LEFT_MARGIN));this.queryDiv.style.top=yasc.Query.getRandomInt(canvasHeight);this.queryDiv.style.left=yasc.Query.getRandomInt(canvasWidth)}else if(yasc.mode==yasc.TOP_TO_BOTTOM_MODE){var left=yasc.Query.getRandomInt(canvasWidth-this.queryDiv.offsetWidth);this.queryDiv.style.top=-this.queryDiv.offsetHeight;this.queryDiv.style.left=left;this.endPt=new yasc.Point(canvasHeight,left)}};
yasc.Query.prototype.reset=function(){var queryIdx=yasc.Query.getRandomInt(yasc.Query.queryArray.length);var queryUrl=yasc.Query.queryArray[queryIdx];this.query=queryUrl[0];this.link.setAttribute("href",queryUrl[1]);this.queryDiv.childNodes[0].nodeValue=this.query;this.countdown=yasc.COUNTDOWN;this.step=1;this.queryDiv.style.zIndex=0;this.queryDiv.style.width=this.queryDiv.offsetWidth;this.setStartEnd()};
yasc.Query.prototype.onMouseOver=function(){this.queryDiv.style.border="2px solid "+this.borderColor;this.queryDiv.style.zIndex+=5;this.isMouseOver=true;this.normalOpacity=yasc.Query.getOpacity(this.queryDiv);yasc.Query.setOpacity(this.queryDiv,yasc.QUERYBOX_OPACITY)};yasc.Query.prototype.onMouseOut=function(){this.queryDiv.style.border="1px solid "+this.borderColor;this.queryDiv.style.zIndex-=5;this.isMouseOver=false;yasc.Query.setOpacity(this.queryDiv,this.normalOpacity)};
yasc.Query.prototype.fly=function(queue){if(queue!=null&&this.query==""){queue.removeQuery(this);return}if(this.isMouseOver)return;if(this.step==1){var new_opacity;var h_distance;var w_distance;var factor;new_opacity=yasc.Query.getOpacity(this.queryDiv)+0.1;if(new_opacity<=yasc.QUERYBOX_OPACITY)yasc.Query.setOpacity(this.queryDiv,new_opacity);h_distance=this.endPt.top-yasc.Query.stripPx(this.queryDiv.style.top);w_distance=this.endPt.left-yasc.Query.stripPx(this.queryDiv.style.left);factor=Math.sqrt(Math.pow(h_distance,
2)+Math.pow(w_distance,2))/this.stepLength;this.queryDiv.style.top=yasc.Query.stripPx(this.queryDiv.style.top)+h_distance/factor;this.queryDiv.style.left=yasc.Query.stripPx(this.queryDiv.style.left)+w_distance/factor;if(Math.abs(h_distance)<=this.stepLength&&Math.abs(w_distance)<=this.stepLength)this.step++}else if(this.step==2){this.countdown--;if(this.countdown<=0)this.step++}else if(this.step==3){new_opacity=yasc.Query.getOpacity(this.queryDiv)-0.1;yasc.Query.setOpacity(this.queryDiv,new_opacity);
if(new_opacity<=0)this.step++}else if(this.step==4){var outerDiv=document.getElementById("outerDiv");if(this.queryDiv!=null)if(this.queryDiv.childNodes.length==1)this.queryDiv.removeChild(this.queryDiv.childNodes[0]);if(this.link!=null){if(this.link.childNodes.length==1){this.link.removeChild(this.link.childNodes[0]);this.queryDiv=null}for(var i=0;i<outerDiv.childNodes.length;i++)if(outerDiv.childNodes[i]==this.link){outerDiv.removeChild(this.link);this.link=null;break}}if(queue!=null)queue.removeQuery(this)}};
yasc.Query.setOpacity=function(obj,value){obj.style.opacity=String(value);if(yasc.isIE)obj.style.filter="alpha(opacity="+value*100+")"};yasc.Query.getOpacity=function(obj){return parseFloat(obj.style.opacity)};yasc.Query.stripPx=function(value){if(typeof value!="string")return value;if(value=="")return 0;return parseFloat(value.substring(0,value.length-2))};yasc.Query.getRandomInt=function(max){return parseInt(Math.random()*yasc.RANDOM_FACTOR,10)%max};yasc.Query.queryArray=[];
yasc.Query.fetchQuerylog=function(){_IG_FetchXmlContent(yasc.REBANG_URL_HEADER,function(response){if(response==null||typeof response!="object"||response.firstChild==null)return;var itemList=response.getElementsByTagName("item");for(var j=0;j<itemList.length;j++){var query=itemList.item(j).getElementsByTagName("query")[0].firstChild.nodeValue;var url=itemList.item(j).getElementsByTagName("landing_page")[0].getAttribute("url");yasc.Query.queryArray.push([query,url])}var disclaimerText="";var disclaimerNode=
response.getElementsByTagName("disclaimer");if(disclaimerNode.length>0)var disclaimerText=disclaimerNode.item(0).firstChild.nodeValue;if(disclaimerText!=""){document.getElementById("disclaimer").innerHTML="<i>"+disclaimerText+"</i>";_IG_AdjustIFrameHeight()}});var interval=yasc.intervalTime*yasc.newQueryInterval*100;setTimeout(yasc.Query.fetchQuerylog,interval)};yasc.Query.getWindowHeight=function(){if(yasc.isIE)return document.body.offsetHeight;else return window.innerWidth};
yasc.QueryQueue=function(){this.head=null};yasc.QueryQueue.prototype.addQuery=function(query){if(this.head==null)this.head=query;else{this.head.prev=query;query.next=this.head;this.head=query}};yasc.QueryQueue.prototype.removeQuery=function(query){if(this.head==query)this.head=query.next;if(query.prev!=null)query.prev.next=query.next;if(query.next!=null)query.next.prev=query.prev};yasc.QueryQueue.prototype.isEmpty=function(){return this.head==null};
yasc.QueryQueue.prototype.clear=function(){var node=this.head;this.head=null;while(node!=null){node.step=4;node.fly(null);node=node.next}};yasc.Render=function(){this.isRunning=false;this.newQueryCountdown=0};
yasc.Render.prototype.render=function(){var outerDiv=document.getElementById("outerDiv");if(outerDiv.offsetHeight==0){yasc.queue.clear();var o=this;var f1=function(){o.render()};setTimeout(f1,yasc.MINIMIZE_INTERVAL_TIME);return}if(this.newQueryCountdown%yasc.newQueryInterval==0)if(this.isRunning){var newQuery=new yasc.Query;yasc.queue.addQuery(newQuery);this.newQueryCountdown=0}if(this.isRunning)this.newQueryCountdown++;var currentQuery=yasc.queue.head;while(currentQuery!=null){currentQuery.fly(yasc.queue);
currentQuery=currentQuery.next}if(this.isRunning||!yasc.queue.isEmpty()){var o=this;var f2=function(){o.render()};setTimeout(f2,yasc.intervalTime)}};yasc.Render.prototype.start=function(){this.isRunning=true;if(yasc.queue.isEmpty()){this.newQueryCountdown=0;this.render()}};yasc.Render.prototype.pause=function(){this.isRunning=false};
function yasc_onStart(){var startButton=document.getElementById("btStart");if(!yasc.render.isRunning){startButton.value="__MSG_stop__";yasc.render.start()}else{startButton.value="__MSG_start__";yasc.render.pause()}}function yasc_init_step(){if(yasc.intervalTime>=70)yasc.stepLengthMax=8;else if(yasc.intervalTime<=30)yasc.stepLengthMax=6;else yasc.stepLengthMax=7}
function yasc_init(){yasc.isIE=navigator.userAgent.toLowerCase().indexOf("msie")!=-1;var prefs=new _IG_Prefs;yasc.theme=prefs.getInt("theme");yasc.mode=prefs.getInt("moving_mode");yasc.intervalTime=prefs.getInt("interval_time");var ratio=yasc.intervalTime/yasc.INTERVAL_TIME_BASE;yasc.newQueryInterval=parseInt(prefs.getInt("new_query_interval")/ratio,10);yasc_init_step();var speed=prefs.getInt("moving_speed");yasc.stepLengthMin+=speed;yasc.stepLengthMax+=speed;var outerDiv=document.getElementById("outerDiv");
outerDiv.style.backgroundColor=yasc.BACKGROUND_COLORS[yasc.theme];document.getElementById("bodyDiv").style.backgroundColor=yasc.BACKGROUND_COLORS[yasc.theme];var disclaimer=document.getElementById("disclaimer");disclaimer.style.color=yasc.FONT_COLORS[yasc.theme];disclaimer.style.backgroundColor=yasc.BACKGROUND_COLORS[yasc.theme];yasc.Query.fetchQuerylog();yasc.queue=new yasc.QueryQueue;yasc.render=new yasc.Render;var height=prefs.getInt("height");if(height==0)height=yasc.DEFAULT_HEIGHT;outerDiv.style.height=
height;_IG_AdjustIFrameHeight();yasc_onStart()}_IG_RegisterOnloadHandler(yasc_init);</script>
]]>
  </Content>
</Module>
