财经

[模仿][JS]微博经济7*二4直播

18 4月 , 2019  

应用微博财政和经济七*2四直播的数量

旗帜显然,学习壹门IT才能,最要紧的是实行,无论是软件开采依旧互连网调试,只要在真正环境下勤于动手和考虑,极快就能左右1门技艺,Silverlight也不例外。为了扶助越多朋友极快学习驾驭Silverlight应用开辟,笔者陈设以实例应用的点子,讲述Silverlight的逐条天性,从而

简轻巧单的做1个山寨品

  

在线地址:[惨痛啊,有GFW,却未曾vpn,往heroku上传浪费了过多岁月。。。]

显著,学习一门IT技艺,最要害的是进行,无论是软件开辟依然互联网调节和测试,只要在实事求是环境下勤于入手和思辨,非常快就能调控1门本事,Silverlight也不例外。为了匡助更多朋友飞速学习理解Silverlight应用开垦,小编安排以实例应用的章程,讲述Silverlight的依次性子,从而实今后上学理论的功底上,和实施相结合的目标。在各个阶段的实例教程中,将围绕2个Silverlight天性为着力核心开始展览扩充学习。

http://wangxinsheng.herokuapp.com/sinaFinLive

 

效果图:

自笔者的花费环境是:

图片 1

Windows 7 Ultimate 英文版


Visual Studio 2010 Premium 英文版

代码:

Expression Blend 4 Premium 英文版

css:直接使用今日头条的

Silverlight 4

index[代码轻便,不写注释了]:

 

  1 <html>
  2 <head>
  3 <title>新浪财经[7*24直播]</title>
  4 <link rel="stylesheet" href="live_fin_v1.css">
  5 <script src='jquery-1.11.1.min.js'></script>
  6 </head>
  7 <body>
  8 <style>
  9 .bd_topic{cursor:pointer;}
 10 </style>
 11 <div class="wrap clearfix">
 12     <div class="bd_weibo">
 13         <div class="bd_tt clearfix">
 14             <div class="bd_topics clearfix">
 15                 全部
 16                 <a  onclick='setTagAndGet(10,this);'>A股</a>
 17                 <a  onclick='setTagAndGet(1,this);'>宏观</a>
 18                 <a  onclick='setTagAndGet(2,this);'>行业</a>
 19                 <a  onclick='setTagAndGet(3,this);'>公司</a>
 20                 <a  onclick='setTagAndGet(4,this);'>数据</a>
 21                 <a  onclick='setTagAndGet(5,this);'>市场</a>
 22                 <a  onclick='setTagAndGet(6,this);'>观点</a>
 23                 <a  onclick='setTagAndGet(7,this);'>央行</a>
 24                 <a  onclick='setTagAndGet(8,this);'>其他</a>
 25             </div>
 26             <div class="bd_refresh clearfix">
 27                 <div class="refresh_ck">
 28                     <label class="autorefreshlb" for="autorefresh">X秒后刷新</label>
 29                 </div>
 30             </div>
 31         </div>
 32         <div class="bd_c">
 33             <div class="bd_c0" id="bd_c0">
 34                 <!-- data list -->
 35             </div>
 36         </div>
 37     </div>
 38 </div>
 39 <script>
 40 /*
 41 // 文字转16进制
 42 var toUnicode = function (s) { 
 43     var str = ""; 
 44     for (var i = 0; i < s.length; i++) { 
 45         str +="\\u"+s.charCodeAt(i).toString(16)+"\t"; 
 46     } 
 47     return str; 
 48 } 
 49 var a = '胜多负89%少'; 
 50 
 51 document.write(toUnicode(a));    // \u80dc    \u591a    \u8d1f    \u5c11 
 52 // 16进制转文字
 53 var toStr = function (n){ 
 54     var str = ""; 
 55     var s = n.split('\\u'); 
 56     for(var i = 0;i < s.length;i++){ 
 57         str += String.fromCharCode(parseInt(s[i],16))+"\t"; 
 58     } 
 59     return str; 
 60 } 
 61 var b = "\\u80dc    \\u591a    \\u8d1f    \\u5c11\\u3002\\u8fbe";
 62 b = "\\u53d1\\u6539\\u59d4\\u6279\\u51c6\\u5efa\\u8bbe\\u9999\\u683c\\u91cc\\u62c9\\u81f3\\u4e3d\\u6c5f\\u516c\\u8def\\uff0c\\u9879\\u76ee\\u9884\\u8ba1\\u6295\\u8d44203\\u4ebf\\u5143\\u4eba\\u6c11\\u5e01\\u3002    \\u65b0\\u6d6a\\u4e8b\\u4ef6\\u76f4\\u64ad";
 63 
 64 document.write(toStr(b));    // 胜    多    负    少
 65 */
 66 // 时间戳转日期
 67 function getDate(tm){ 
 68 var tt=new Date(parseInt(tm) * 1000);//.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " "); 
 69 return tt; 
 70 }
 71 // 数据取得或的callBack方法
 72 function t14222533(data){
 73     if(data.result.status.code==0){
 74         if(data.result.data.length>0){
 75             //append
 76             for(var i = data.result.data.length-1;i >=0;i--){
 77                 var item = data.result.data[i];
 78                 var day = getDate(item.created_at);
 79                 var dayName = day.getFullYear()+"年"+((day.getMonth()+1)<10?'0'+(day.getMonth()+1):(day.getMonth()+1))+"月"+(day.getDate()<10?'0'+day.getDate():day.getDate())+"日";
 80                 var timeName = ((''+day.getHours()).length<2?('0'+day.getHours()):day.getHours())+":"+((''+day.getMinutes()).length<2?('0'+day.getMinutes()):day.getMinutes())+":"+((''+day.getSeconds()).length<2?('0'+day.getSeconds()):day.getSeconds());
 81                 var tmpStr = oneData.replace(/\{\%today\%\}/g,dayName).replace(/\{\%id\%\}/g,item.id).replace(/\{\%day\%\}/g,dayName).replace(/\{\%time\%\}/g,timeName).replace(/\{\%tag\%\}/g,'').replace(/\{\%content\%\}/g,item.content);
 82                 var display = 'none';
 83                 tmpStr = tmpStr.replace(/\{\%display\%\}/g,display);
 84                 $("#bd_c0").prepend(tmpStr);
 85 
 86                 $("div[data-today='"+dayName+"']").find(".bd_date").hide();
 87                 $("div[data-today='"+dayName+"']").eq(0).find(".bd_date").show();
 88                 /* 隐藏当天日期
 89                 var toDay =    new Date();
 90                 todayName=toDay.getFullYear()+"年"+((toDay.getMonth()+1)<10?'0'+(toDay.getMonth()+1):(toDay.getMonth()+1))+"月"+(toDay.getDate()<10?'0'+toDay.getDate():toDay.getDate())+"日";
 91                 $("div[data-today='"+todayName+"']").find(".bd_date").hide();
 92                 */
 93                 id = item.id;
 94             }
 95         }
 96                 
 97         $(".autorefreshsecs").html(maxTime);
 98         clearTimeout(setTimeoutObj);
 99         setTimeoutObj = setTimeout(animate,1000);
100         //console.log('go');
101     }else{
102         console.log(data);
103     }
104 }
105 /*
106 http://live.sina.com.cn/zt/api/f/get/finance/globalnews1/index.htm?format=json&callback=t14222547&id=114975&tag=0&pagesize=15&dire=b&dpc=1
107 
108 http://live.sina.com.cn/zt/api/f/get/finance/globalnews1/index.htm?format=json&callback=t14222533&id=114986&tag=0&pagesize=45&dire=f&dpc=1
109 
110 t14222533({"result":{"status":{"code":0,"msg":"\u83b7\u53d6\u6210\u529f, succ"},"pageStr":{"totalPage":1,"pageSize":45,"prePage":1,"nextPage":1,"firstPage":1,"lastPage":1,"totalNum":1,"pName":"page","page":1,"paramStr":"http:\/\/live.sina.com.cn\/zt\/api\/app_zt\/f\/get\/finance\/globalnews1\/index.htm\/?format=json&callback=t14222533&id=114986&tag=0&pagesize=45&dire=f&"},"data":[{"id":"114988","mid":"3803267903335890","sp_id":"152","uid":"3969238805","content":"\u53d1\u6539\u59d4\u6279\u51c6\u5efa\u8bbe\u9999\u683c\u91cc\u62c9\u81f3\u4e3d\u6c5f\u516c\u8def\uff0c\u9879\u76ee\u9884\u8ba1\u6295\u8d44203\u4ebf\u5143\u4eba\u6c11\u5e01\u3002","source":"<a href=\"http:\/\/app.weibo.com\/t\/feed\/6n8uPl\" rel=\"nofollow\">\u65b0\u6d6a\u4e8b\u4ef6\u76f4\u64ad<\/a>","created_at":"1422253192","original_pic":"","pic_ids":"","video":"","reposts":0,"comments":0,"attitudes":0,"pmid":"0","re_mid":"0","re_uid":"0","re_content":"","re_source":"","re_created_at":"0","re_original_pic":"","re_pic_ids":"","re_video":"","re_reposts":"0","re_comments":"0","re_attitudes":"0","is_audit":"1","is_launch":"0","is_del":"0","creator":"yongliang3","mender":"","created_time":"1422253192","modified_time":"0","notes":"","user":{"id":3969238805,"idstr":"3969238805","class":1,"screen_name":"fin_\u56fe\u6587\u76f4\u64ad","name":"fin_\u56fe\u6587\u76f4\u64ad","province":"11","city":"1000","location":"\u5317\u4eac","description":"","url":"","profile_image_url":"http:\/\/tp2.sinaimg.cn\/3969238805\/50\/5690088076\/1","profile_url":"u\/3969238805","domain":"","weihao":"","gender":"m","followers_count":1849,"friends_count":2,"pagefriends_count":0,"statuses_count":72181,"favourites_count":0,"created_at":"Wed Jan 08 15:47:33 +0800 2014","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"verified_type":-1,"remark":"","ptype":0,"allow_all_comment":true,"avatar_large":"http:\/\/tp2.sinaimg.cn\/3969238805\/180\/5690088076\/1","avatar_hd":"http:\/\/ww4.sinaimg.cn\/crop.0.0.179.179.1024\/ec95c715jw1ecc6o54vfcj2050050aad.jpg","verified_reason":"","verified_trade":"","verified_reason_url":"","verified_source":"","verified_source_url":"","follow_me":false,"online_status":0,"bi_followers_count":0,"lang":"zh-cn","star":0,"mbtype":0,"mbrank":0,"block_word":0,"block_app":0,"credit_score":80,"urank":11},"base62mid":"C1n0OdZOG","base62pmid":"","base62re_mid":"","pic_ids_plus":"","re_pic_ids_plus":"","tag":[{"tag_id":"2","tag_name":"\u884c\u4e1a"}]}]}});
111 */
112 
113 var oneData = '<div class="bd_list" data-today="{%today%}">'
114                     +'<div class="bd_i bd_i_og bd_i_1st clearfix " data-id="{%id%}">'
115                     +'<div class="bd_date" style="display:{%display%};">{%day%}<!--2015年1月1日--></div>'
116                     +'<div class="bd_i_time clearfix">'
117                         +'<p class="bd_i_time_c">{%time%}<!--19:32:37--></p>'
118                         +'<p class="bd_i_tags"> {%tag%}<!--类型-->&nbsp;</p>'
119                     +'</div>'
120                     +'<div class="bd_i_c">'
121                         +'<div class="bd_i_txt clearfix">'
122                             +'<p class="bd_i_txt_c">{%content%}</p>'
123                         +'</div>'
124                     +'</div>'
125                 +'</div>';
126                                           
127 var scriptStr = "<script id=\'getData\' src=\'{%url%}\'><\/script>";
128 var pagesize = 10;
129 var tag = 0;
130 var urlStr = 'http://live.sina.com.cn/zt/api/f/get/finance/globalnews1/index.htm?format=json&callback=t14222533&id={%id%}&tag={%tag%}&pagesize={%pagesize%}&dire=f&dpc=1';
131 var id = '114765';
132 var orgId = '114765';
133 var scriptObj = null;
134 var maxTime = 60;
135 var setTimeoutObj = null;
136 function getData(){
137     $('#getData').remove();
138     var urlTmp = urlStr.replace(/{%id%}/g,id).replace(/{%pagesize%}/g,pagesize).replace(/{%tag%}/g,tag);
139     scriptObj = $((scriptStr.replace(/{%url%}/g,urlTmp))); 
140     $('body').append(scriptObj);
141     //console.log(scriptObj);
142 }
143 $(function(){
144     var urlTmp = urlStr.replace(/{%id%}/g,id).replace(/{%pagesize%}/g,pagesize).replace(/{%tag%}/g,tag);
145     scriptObj = $((scriptStr.replace(/{%url%}/g,urlTmp))); 
146     $('body').append(scriptObj);
147     $(".autorefreshsecs").html(maxTime);
148 });
149 function animate(){
150     var time = parseInt($(".autorefreshsecs").html())-1;
151     $(".autorefreshsecs").html(time);
152     //console.log(time);
153     if(time==0){
154         getData();
155     }else{
156         clearTimeout(setTimeoutObj);
157         setTimeoutObj = setTimeout(animate,1000);
158     }
159 };
160 function setTagAndGet(tag,obj){
161     $(".autorefreshsecs").html(maxTime);
162     $("#bd_c0").html('');
163     clearTimeout(setTimeoutObj);
164     $('.bd_topic_cur').removeClass('bd_topic_cur');
165     $(obj).addClass('bd_topic_cur');
166     id=orgId;
167     tag=tag
168     $('#getData').remove();
169     var urlTmp = urlStr.replace(/{%id%}/g,id).replace(/{%pagesize%}/g,pagesize).replace(/{%tag%}/g,tag);
170     scriptObj = $((scriptStr.replace(/{%url%}/g,urlTmp))); 
171     $('body').append(scriptObj);
172 }
173 
174 </script>
175 
176 </body>
177 </html>

第三篇Silverlight实例应用,我们从Silverlight的Out-of-Browser开首。在实例开首以前,大家对Silverlight的Out-of-Browser举行2个反驳回想。

 —

 

CSDN下载:

什么是Silverlight的Out-of-Browser应用?

http://download.csdn.net/detail/wangxsh42/8398785

Silverlight
Out-of-Browser应用,从字面明白是Silverlight脱离浏览器的选拔,也得以明白为Silverlight离线应用,简称为OOB。微软提交的疏解是OOB应用是足以设置到地头的运作在浏览器之外的利用,轻易的知晓,Silverlight
OOB应用正是贰个不必要存取HTML
DOM,并且完全脱离浏览器,具有独立窗口的Web应用。微软在Silverlight
三已经发表该功能,由于当下Silverlight
3的各种限制,Silverlight的OOB应用为主没有过多的开采进取,但是这一个新特征给当时的开采职员留下了深刻的纪念,微软在随着的Silverlight
肆版本中,对OOB成效进行的深化,例如OOB的权柄信任支持,自定义窗口设计支撑,音讯布告API援救等。这几个功效,不仅抓牢了Silverlight跨平台选取成效协理,而且还加大了用户对Silverlight离线应用的心得。

让大家看三个Silverlight OOB的案例,下图是今日头条财政和经济的Silverlight
OOB应用,该利用作为独立窗口运营,未有依照浏览器,

图片 2

 

 

Silverlight Out-of-Browser的运维规律?

Tim Heuer是微软Silverlight项目主管,他的博客中曾经宣布过有关Silverlight
Out-of-Browser的运作规律
 ,
在此处大家以简单的不二秘诀领会一下Silverlight OOB的运维规律。

作为Silverlight开荒人士应该都掌握访问Silverlight应用其实正是对服务器端的XAP文件举行读取,Silverlight
OOB一样是基于Silverlight技巧的运用,所以OOB应用也是访问运转XAP文件,可是该文件是缘于本地的目录。Silverlight
OOB应用的拜访步骤:

  1. 先是须求配置AppManifest.xml,使应用支撑Out-of-Browser;

2.
然后装置OOB应用,那时Silverlight项目标XAP文件将被下载到一个本地目录存款和储蓄;

三.
在地方运转OOB应用,那时,应用会依照XAP的原始UOdysseyL发出请求,检查测试是还是不是有新本子,假诺有,则更新,借使没有将连续运转;

如上是最简易的理解,在互连网上有一篇翻译Tim的稿子,我们能够阅读Silverlight
OOB的运营规律粤语版加深精通

 

Silverlight Out-of-Browser的仓库储存地方?

上文已经讲到Silverlight
OOB应用,安装成功后,XAP将保存在本地目录,而以此目录从桌面火速格局是无力回天查看到的,例如刚才大家演示的网易经济OOB应用,在快捷格局中,仅展现“”C:\Program
Files (x86)\Microsoft Silverlight\sllauncher.exe”
316146535壹.vip.stock.finance.sina.com.cn”,
从下面目录下的metadata元数据文件中得以查出316146535一.vip.stock.finance.sina.com.cn是该用户的唯1的AppID。

图片 3

 

 而其真实存款和储蓄目录则在C:\Users\<login
id>\AppData\Local\Microsoft\Silverlight\OutOfBrowser\3161465351.vip.stock.finance.sina.com.cn,

 

 一 ShortcutName=网易经济
 2 LaunchPath=C:\Users\kevin.fan\AppData\Local\Microsoft\Silverlight\OutOfBrowser\3161465351.vip.stock.finance.sina.com.cn\index.html
 3 CustomIcon=1
 4 TrimmedSourceDomain=vip.stock.finance.sina.com.cn
 5 TrimmedTitle=网易金融
 陆 TrimmedName=微博财政和经济
 7 ElevatedPermissions=2147483647
 8 XapLastModified=Thu, 27 May 2010 07:01:27 GMT
 9 EnableGPUAcceleration=False
10 WindowStartupLocation=0
11 WindowTop=0
12 WindowLeft=0
13 WindowWidth=800
14 WindowStyle=0
15 WindowHeight=600
16 SourceDomain=vip.stock.finance.sina.com.cn
17 OriginalSourceUri=http://vip.stock.finance.sina.com.cn/silverpulse/ClientBin/Loader.xap
18 FinalAppUri=http://vip.stock.finance.sina.com.cn/silverpulse/ClientBin/Loader.xap
19 RuntimeVersion=4.0.50401.0
20 AppID=3161465351.vip.stock.finance.sina.com.cn
贰一 Description=搜狐经济
2二 Title=新浪金融
二③ Name=今日头条经济

 

 

Silverlight In-of-Browser和Silverlight Out-of-Browser的对比**

在Silverlight 4中,微软对OOB作用拓展了助纣为虐,相比较Silverlight
In-of-Browser和Out-of-Browser,在效用上有着相当大的反差,

  1. OOB应用最大的特色是用户能够不供给其余互联网援救在地面运营应用;

  2. OOB应用支撑Trust权限升高效能,相当于所谓的Elevated
    Trust格局,该方式是Silverlight 4OOB强化中最要害的风味之1,通过权限提高,OOB应用能够做到许多Windows应用效益,例如:

a. 在权力允许的动静下,OOB应用能够访问当和姑件目录;

b.
在权力允许的意况下,OOB应用能够被锁定展现自定义应用Logo在Windows开头菜单和职务栏中;

c. 在权力允许的情形下,OOB应用能够访问COM API;

d. 在权力允许的情景下,OOB应用支撑XAP签名认证;

e. 在权力允许的景观下,OOB应用支撑音讯文告API调用;

d. 在权力允许的情况下,OOB帮忙HTML WebBrowser;

三.
OOB接纳每回运营都亟待进行版本进级检查,而In-of-Browser则是类别运作时自动更新;

  1. OOB应用不能够吸收接纳初阶化参数数据,而In-of-Browser能够;

  2. 对于Isolated
    Storage空间的分红,OOB应用暗中同意分配2五M,而根据浏览器的Silverlight应用仅为1M,然而相互都允许用户举行自定义扩充;

 

如上是Silverlight
Out-of-Browser的有的骨干理论,在理论的底子上,大家将启幕下壹篇的实例演示。


相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图