一步步創建 邊欄 Gadget(二)

??? 相信使用上篇中創建的邊欄Gadget之后,大家會很郁悶。難道視頻窗口就那么小嗎?看起來真費勁。我能通過該Gadget看著一部電視劇。而不能夠定制自己需要的或者想要看的電視劇。

??? 在上一篇一步步創建 邊欄 Gadget(一)中,我們創建了一個簡單的邊欄Gadget。細心的朋友們也許會發現我們創建的Gadget中沒有下圖中 圈選的按鈕,僅僅擁有上方的關閉按鈕。本篇將介紹如何為我們的邊欄Gadget添加配置屬性改變邊欄Gadget的大小,以及添加播放URL配置選項。

?

?

??? 總體來講,本部分比第一部分僅僅多出兩個js文件以及一個HTML頁面(用于構成系統配置頁面)。不過為了添加這些功能到我們的邊欄Gadget中我們需要對上一篇中的文件做部分修改。

?

步驟一:為邊欄Gadget添加配置屬性

? a.創建一html文件命名為setting.html

?1?<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.0?Transitional//EN">
?2?<html?>
?3?????<head>
?4?????????<title>SidebarShell:Settings</title>
?5?????????<script?type="text/javascript"?src="js/setting.js"></script>
?6?????<style?type="text/css">
?7?????body{width:240;height:180;?font-size:12px;?background-image:url(images/bg.jpg);?background-repeat:repeat-x;}
?8?????ul{?margin:16px;?padding:0px;?list-style-type:none;}
?9?????li{?margin:4px;?padding:4px;}
10?????#btnsv{?margin-left:40px;}
11?????</style>
12?????</head>
13?????<body?onLoad="loadsett()">
14?????<ul>
15?????????<li>URL:&nbsp;&nbsp;<input?type="text"??id="txturl"?name="txturl"?size="14"?value=""/></li>
16?????????<li>DIS:&nbsp;&nbsp;&nbsp;&nbsp;<select?id="seldis"?name="seldis">
17?????????????<option?value="120X90">120X90</option>
18?????????????<option?value="160X120">160X120</option>
19?????????????<option?value="200X150">200X150</option>
20?????????????<option?value="240X180">240X180</option>
21?????????????<option?value="280X210">280X210</option>
22?????????????<option?value="320X240">320X240</option>
23?????????????</select>
24?????????</li>
25?????</ul>
26?????<hr/>
27?????<div?style="text-align:center;">
28?????????<a?href="http://netwenchao.cnblogs.com">更多信息請訪問Denny.dong</a>
29?????</div>
30?????</body>
31?

b.在該html文件中添加html代碼,在此我們僅僅添加URL以及尺寸等配置項。

c.添加一腳本文件命名為setting.js,并輸入如下代碼(用于存放以及加載配置信息)。

?1?var?dfUrl="http://www.tudou.com/l/e3MBzOUVNaQ";
?2?function?procSettingsClosingEvent(event){
?3?????if?(event.closeAction?==?event.Action.commit)
?4?????{???
?5?????????System.Gadget.Settings.write("vurl",$("txturl").value);//存儲配置信息
?6?????????System.Gadget.Settings.write("dis",$("seldis").value);
?7?????}
?8?????event.cancel?=?false;?
?9?}
10?function?loadsett()
11?{
12?????var?gSE="";
13?????var?gUrl="";
14?????System.Gadget.onSettingsClosing?=?procSettingsClosingEvent;????
15?????gSE=?System.Gadget.Settings.read("dis");??//讀取配置信息
16?????gUrl=System.Gadget.Settings.read("vurl");?//讀取配置信息?
17?????$("seldis").value=(gSE=="")?"120X90":gSE;//填充默認的配置信息
18?????$("txturl").value=(gUrl=="")?dfUrl:gUrl;
19?}
20?function?$(el){return?typeof(el)=="string"?document.getElementById(el):el;}
21?

d.添加video.js文件,在其中填寫如下代碼。用于加載配置信息以及應用配置信息到頁面上。

?

?1?//Enable?the?gadget?setting?UI.
?2?System.Gadget.settingsUI="settings.htm";
?3?//?Delegate?for?when?the?Settings?dialog?is?closed.
?4?System.Gadget.onSettingsClosed?=?SettingsClosed;
?5?//default?width
?6?var?strWidth="180";
?7?var?strDis="";
?8?var?timeTransition=3;
?9?
10?function?$(el){return?typeof(el)=="string"?document.getElementById(el):el;}
11?function?SettingsClosed(m_event){
12?????if(m_event.closeAction==m_event.Action.commit){
13?????????strDis=System.Gadget.Settings.readString("dis");
14?????????strvUrl=System.Gadget.Settings.readString("vurl");
15?????????SetGadgetSetting(strDis,strvUrl);
16?????}
17?}
18?//初始化gadget,并未其加載默認參數。
19?function?Init_gadget(){
20?????strDis=System.Gadget.Settings.read("dis");
21?????strUrl=System.Gadget.Settings.read("vurl");
22?????SetGadgetSetting(strDis,strUrl);
23?}
24?function?SetGadgetSetting(strFeedback,strUrl){
25?????switch(strFeedback){
26?????????case?"120X90":
27?????????????setwd(120,90,strUrl);
28?????????????break;
29?????????case?"160X120":
30?????????????setwd(160,120,strUrl);
31?????????????break;
32?????????case?"200X150":
33?????????????setwd(200,150,strUrl);
34?????????????break;
35?????????case?"240X180":
36?????????????setwd(240,180,strUrl);
37?????????????break;
38?????????case?"280X210":
39?????????????setwd(280,210,strUrl);
40?????????????break;
41?????????case?"320X240":
42?????????????setwd(320,240,strUrl);
43?????????????break;
44?????????default:
45?????????????setwd(120,90,strUrl);
46?????????????break;
47?????????}
48?}
49?//set?the?element?size
50?function?setwd(intwid,inthid,strUrl){
51?????debugger;
52?????$("gb").style.width=intwid;
53?????$("gb").style.height=inthid+2;
54?????defURL="http://www.tudou.com/l/e3MBzOUVNaQ"
55?????
56?????src="<embed?src='$URL'?type='application/x-shockwave-flash'?allowscriptaccess='always'?allowfullscreen='true'?wmode='opaque'?id='elpy'?name='elpy'?width='"+intwid+"'?height='"+inthid+"'></embed>"
57?????if(strUrl.length>1){
58?????????$("palyerHoder").innerHTML=src.replace("$URL",strUrl);
59?????}
60?????else
61?????????$("palyerHoder").innerHTML=src.replace("$URL",defURL);
62?
63?}

e.修改video.html文件在頁面初始化之后加載配置信息。

?

?1?<html?xmlns="http://www.w3.org/1999/xhtml">
?2?????<head>
?3?????????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
?4?????????<title>My?Video</title>
?5?????????<script?type="text/javascript"?src="js/video.js"></script>
?6?????????<style?type="text/css">
?7?????????body{margin:?0px;padding:0px;?background-image:url(images/bg.jpg);?background-repeat:repeat-x;?width:200;?height:155;?background-color:#000;}
?8?????????</style>
?9?????</head>
10?????<body?id="gb"?onLoad="Init_gadget()">
11?????????<div?id="palyerHoder">
12?????????</div>
13?????</body>
14?

f.發布Gadget效果如下

?????????????????????
?

步驟二:為邊欄Gadget添加Dock屬性,使其在Dock狀態下視頻尺寸變大。

a.在video.js中添加如下代碼,使其在Dock狀態下尺寸變為系統設定的尺寸,而在非Dock狀態下尺寸設定為360X270.

?

?1?//define?dock?event
?2?System.Gadget.onDock?=?CheckDockState;
?3?//define?undock?event
?4?System.Gadget.onUndock?=?CheckDockState;
?5?
?6?function?CheckDockState(){
?7?????System.Gadget.beginTransition();
?8?
?9?????var?oBody?=?document.body.style;
10?????if?(System.Gadget.docked){
11?????????SetGadgetSetting(System.Gadget.Settings.readString("dis"),"");
12?????}
13?????else{
14?????setwd(360,270,"");
15?????}
16?????System.Gadget.endTransition(System.Gadget.TransitionType.morph,?timeTransition);
17?

?

b.發布Gadget,效果如圖一。

?

點擊此下載代碼

轉載于:https://www.cnblogs.com/netwenchao/archive/2009/08/03/1537622.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/274887.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274887.shtml
英文地址,請注明出處:http://en.pswp.cn/news/274887.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

tableau 自定義圖表_一種新的十六進制美國地圖布局的案例-Tableau中的自定義圖表

tableau 自定義圖表For whatever reason, 無論出于什么原因 maps are cool. Even though the earth has mostly been the same since those 地圖很酷 。 即使自Pangaea days, we humans make and remake maps constantly. It might be that old maps remind us of how things …

2022,前端工具鏈十年盤點

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列2021 …

var result = ![] == []; console.log(result); // 結果是?為什么?

相等操作符會對操作值進行隱式轉換后進行比較&#xff0c;如果一個操作值為布爾值&#xff0c;則在比較之前先將其轉換為數值&#xff0c;這里 ![] 一定是布爾值了。 http://www.csser.com/board/4f3f516e38a5ebc9780004d3轉載于:https://www.cnblogs.com/anjey/archive/2012/0…

講講volatile的作用

講講volatile的作用 講講volatile的作用254推薦一個定義為volatile的變量是說這變量可能會被意想不到地改變&#xff0c;這樣&#xff0c;編譯器就不會去假設這個變量的值了。精確地說就是&#xff0c;優化器在用到這個變量時必須每次都小心地重新讀取這個變量的值&#xff0c;…

書籍排版學習心得_為什么排版是您可以學習的最佳技能

書籍排版學習心得重點 (Top highlight)I was introduced to design in a serpentine fashion. I don’t have any formal training. Instead, I’ve learned everything through the Web, books, and by interacting with designers daily.我被介紹為蛇形設計。 我沒有任何正規…

javascript專題:如何構建自己的js庫

首先看看這個&#xff1a; (function(){ //運行的代碼 })(); 紅色括號里面是一個匿名函數&#xff0c;紅色括號是分割&#xff0c;表示里面的函數是一個部分&#xff0c;綠色的括號表示一個運算符&#xff0c;表示紅色括號里面的函數要運行。 相當于定義完一個匿名函數后讓它直…

若川的 2021 年度總結,彈指之間

1前言從2014年開始&#xff0c;每一年都會寫年度總結&#xff0c;已經堅持了7個年頭。7年的光陰就是彈指之間&#xff0c;轉瞬即逝。正如孔子所說&#xff1a;逝者如斯夫&#xff0c;不舍晝夜。回顧2014&#xff0c;約定2015&#xff08;QQ空間日志&#xff09;2015年總結&…

線框圖用什么軟件_為什么要在線框中著色?

線框圖用什么軟件I was recently involved in a debate around why some wireframes (which were definitely not UI screens) were not 100% greyscale. This got me thinking — when is it ok to use colour in wireframes, and when is it going to cause you problems fur…

Linux 內核

Linux 內核是一個龐大而復雜的操作系統的核心&#xff0c;不過盡管龐大&#xff0c;但是卻采用子系統和分層的概念很好地進行了組織。通過本專題&#xff0c;我們可以學習 Linux 的分層架構、內核配置和編譯、內核性能調試和 Linux 2.6 中的許多提升功能。Linux 內核組成 Linux…

給asterisk寫app供CLI調用

環境&#xff1a;CentOS6.2 Asterisk 1.8.7.1 一、添加源文件 復制app_verbose.c為app_testApp.c 復制app_verbose.exports為app_testApp.exports 主要是修改一些標識&#xff0c;編譯不會出錯就行&#xff0c;這里列出我進行的主要修改。 1、添加頭文件 #include "aster…

前端,校招,面淘寶,指南

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列雖然是…

qq空間網頁設計_網頁設計中負空間的有效利用

qq空間網頁設計Written by Alan Smith由艾倫史密斯 ( Alan Smith)撰寫 Negative space is a key design element that you may come across in the fields of art, architecture, interior design, landscaping and web design. Rather than serving as awkward, empty areas …

自定義異常拋法

public List<LogRec> readLogs() throws ReadDataException { try { return returnLogRec(logFileName); } catch(Exception e) { throw new ReadDataException(e); } } 轉載于:https://www.cnblogs.com/zengmiaogen/archive/2012/04/15/2450438.html

SQL SERVER服務停止和啟動命令行

停止服務: net stop mssqlserver 啟動服務: net start mssqlserver 轉載于:https://www.cnblogs.com/davidgu/archive/2010/01/06/1640466.html

Git 和 GitHub 教程——版本控制入門

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列Learn…

matlab中的:的優先級_內容早期設計:內容優先

matlab中的:的優先級By Simone Ehrlich, Content Strategy Manager由 西蒙埃利希 &#xff0c;內容策略經理 Words are cheap. Cheaper than wires; cheaper than mocks. That doesn’t mean words aren’t important, just less expensive to produce as a design asset. So …

Nunit2.5.10快速上手

1、下載Nunit&#xff1a;http://www.nunit.org/index.php?pdownload&#xff0c;下載MSI格式的安裝包&#xff1b; 2、安裝Nunit&#xff0c;根據提示安裝即可&#xff0c;沒有什么需要配置的&#xff0c;直接下一步就可以了。 3、新建類庫項目NUnitQuickStart&#xff0c;在…

我真的哭了,哭過后呢(-)

這些是山區的孩子們&#xff01; 這是他們的教室。這個也算是&#xff01;如此的師資力量自己解決吃飯問題冬天到了&#xff0c;一起烤烤火與泥土污水一起還好&#xff0c;最大的數字只是10老師抱著孩子來給我們上課了不知道山那邊會是什么呢&#xff1f;又一雙充滿了渴望的大眼…

腦裂問題解決方案_從解決方案到問題

腦裂問題解決方案Once upon a time a couple of years ago, one of my mentors (and favourite people in the world) repeatedly drilled the idea above into my brain. Her advice for Product people was to “fall in love with the problem, not the solution”. At the …

Vue.js 官方團隊成員霍春陽新作,深入解析 Vue.js 設計細節【文末送書】

霍春陽&#xff08;Hcy&#xff09;&#xff0c;Vue.js 官方團隊成員。專注于 Web 研發領域&#xff0c;是 Vue.js 3 的核心貢獻者之一&#xff0c;Vue.js 文檔生成工具 Vuese 的作者&#xff0c;技術社區活躍者&#xff0c;曾撰寫大量頗受好評的技術博客。經過一年的準備&…