预览模式: 普通 | 列表

JS实现DIV提示框的效果

[隐藏日志]

这是隐藏日志,只有管理员或文章的作者可以查看。
分类:感悟 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 0

[隐藏日志]

这是隐藏日志,只有管理员或文章的作者可以查看。
分类:感悟 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 11

防刷新的音乐插件

练习js中类的写法而写的东西

 效果如页面右侧

JavaScript代码
  1. document.writeln('<div id="lymusicbox" style="width:90%;margin:0 auto;text-align:center"></div>')   
  2. //音乐类   
  3. function MusicInfo(){}   
  4. MusicInfo.prototype={   
  5.     title:"Unknown Music",   
  6.     author:"Unknown",   
  7.     url:"",   
  8.     id:0   
  9. }   
  10.   
  11. //播放器信息类   
  12. function PlayerInfo(){}   
  13. PlayerInfo.prototype={   
  14.     //播放状态,1=停止,2=暂停,3=播放,6=正在缓冲,9=正在连接,10=准备就绪   
  15.     playState:"",   
  16.     //当前进度,字符串格式。如“00:23”   
  17.     currentPositionString:"",   
  18.     //音量0-100   
  19.     volume:80,   
  20.     //媒体总长度,字符串格式。如“03:24”   
  21.     mediaDurationString:""  
  22. }   
  23.   
  24. //主体类   
  25. MusicPlayer = function() {   
  26.     var playerobj=null;   
  27.     var playerstr='';   
  28.     var musiclist=new Array();   
  29.     //尝试连接秒数   
  30.     var waitseconds=0;   
  31.     //停止播放秒数   
  32.     var stopseconds=0;   
  33.     //是否手动停止   
  34.     var stopclick=false;   
  35. return {   
  36. //public   
  37.     errmsg:"",   
  38.     israndom:true,   
  39.     parentwindow:null,   
  40.     status:"stop",   
  41.     musicinfo:new MusicInfo(),   
  42.     playerinfo:new PlayerInfo(),   
  43.     init: function() {   
  44.         //加载列表   
  45.         this.LoadMusicList();   
  46.         //随机挑选一首歌   
  47.         if(this.israndom){   
  48.             var r_id=Math.round(Math.random()*musiclist.length);   
  49.             this.musicinfo=musiclist[r_id];   
  50.             }   
  51.         else{   
  52.             this.musicinfo=musiclist[0];   
  53.         }   
  54.         if(this.errmsg!=""){$id("lymusicbox").innerHTML=this.errmsg;return;}   
  55.            
  56.         //获取父窗体,如果页面在框架中则取顶层窗体   
  57.         if(window.parent!=window.top){this.parentwindow=window.top;}   
  58.         else{this.parentwindow=window.parent;}   
  59.         if(this.parentwindow==window.self){return;}   
  60.         if(this.parentwindow.musicframe==null){   
  61.             var iframe=this.parentwindow.document.createElement("iframe");   
  62.             iframe.width="100%";   
  63.             iframe.height="0px";   
  64.             iframe.name="musicframe",   
  65.             iframe.id="musicframe",   
  66.             iframe.frameBorder="0";   
  67.             iframe.scrolling="no";   
  68.             iframe.src="about:blank";   
  69.             this.parentwindow.document.body.appendChild(iframe);   
  70.             if(navigatorname=="Firefox"){playerstr='<div id="currentmusicid">'+this.musicinfo.id+'</div><object id="m_player" type="application/x-mplayer2" width="99%" data="'+this.musicinfo.url+'"></object>';}   
  71.             else{   
  72.                 playerstr='<div id="currentmusicid">'+this.musicinfo.id+'</div><object id="m_player" type="application/x-oleobject" height="64" width="99%" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">';   
  73.                 playerstr+='<param value="'+this.musicinfo.url+'" name="url" />';   
  74.                 playerstr+='</object>';   
  75.                 }   
  76.             this.parentwindow.musicframe.document.writeln(playerstr);   
  77.             this.parentwindow.musicframe.document.close();   
  78.             }   
  79.         else{   
  80.             var currentmusicid=this.parentwindow.musicframe.document.getElementById("currentmusicid").innerHTML;   
  81.             this.musicinfo=musiclist[Math.round(currentmusicid)];   
  82.             }   
  83.         playerobj=this.parentwindow.musicframe.document.getElementById("m_player");   
  84.         this.status="play";   
  85.         //添加控制面板   
  86.         var plathtml='';   
  87.         plathtml+='<b id="music_status"></b><br/>\r\n';   
  88.         plathtml+='  <a href="javascript:MusicPlayer.Stop()">停止</a>';   
  89.         plathtml+=' <a href="javascript:MusicPlayer.Play()">播放</a>';   
  90.         plathtml+=' <a href="javascript:MusicPlayer.Pause()">暂停</a>';   
  91.         plathtml+=' <a href="javascript:MusicPlayer.Pre()">上一首</a>';   
  92.         plathtml+=' <a href="javascript:MusicPlayer.Next()">下一首</a><br/>';   
  93.         plathtml+=' <span id="music_t"></span>\r\n';   
  94.         plathtml+=' <a href="javascript:window.top.location.replace(this.location.href)">静音版</a>\r\n';   
  95.         $id("lymusicbox").innerHTML=plathtml;   
  96.         },   
  97.     Stop:function(){   
  98.         if(navigatorname!="Firefox"){playerobj.controls.stop();}   
  99.         else{this.parentwindow.musicframe.document.body.innerHTML="";}   
  100.         this.status="stop";   
  101.         stopclick=true;   
  102.         },   
  103.     Play:function(){   
  104.         if(this.status=="stop" || this.status=="pause"){   
  105.             if(navigatorname!="Firefox"){playerobj.controls.play();}   
  106.             else{this.parentwindow.musicframe.document.writeln(playerstr);this.parentwindow.musicframe.document.close();}   
  107.             this.status="play";   
  108.             }   
  109.         },   
  110.     ChangePlay:function(){   
  111.         if(navigatorname!="Firefox"){playerobj.controls.stop();playerobj.url=this.musicinfo.url;playerobj.controls.play();}   
  112.         else{   
  113.             playerstr='<div id="currentmusicid">'+this.musicinfo.id+'</div><object id="m_player" type="application/x-mplayer2" width="99%" data="'+this.musicinfo.url+'"></object>';   
  114.             this.parentwindow.musicframe.document.writeln(playerstr);   
  115.             this.parentwindow.musicframe.document.close();   
  116.             }   
  117.         this.status="play";   
  118.         },   
  119.     Pause:function(){   
  120.         if(this.status=="play"){   
  121.             if(navigatorname!="Firefox"){playerobj.controls.pause();}   
  122.             else{}   
  123.             this.status="pause";   
  124.             }   
  125.         },   
  126.     GoTo:function(id){   
  127.         if(Math.round(id)<0){id=musiclist.length-1;}   
  128.         else if(Math.round(id)>musiclist.length-1){id=0;}   
  129.         this.musicinfo=musiclist[id];   
  130.         this.ChangePlay();   
  131.         this.parentwindow.musicframe.document.getElementById("currentmusicid").innerHTML=id;   
  132.         },   
  133.     Next:function(){   
  134.         var nowid=this.musicinfo.id;   
  135.         this.GoTo(nowid+1);   
  136.         },   
  137.     Pre:function(){   
  138.         var nowid=this.musicinfo.id;   
  139.         this.GoTo(nowid-1);   
  140.         },   
  141.     RefreshStatus:function(){   
  142.         if(navigatorname!="Firefox"){   
  143.             switch(playerobj.playState){   
  144.                 case 1:   
  145.                     if(stopseconds>6 && stopclick==false){   
  146.                         if(this.israndom){this.GoTo(Math.round(Math.random()*musiclist.length));}   
  147.                         else{this.Next();}   
  148.                         }   
  149.                     this.playerinfo.playState="已停止";   
  150.                     this.status="stop";   
  151.                     stopseconds+=1;   
  152.                     break;   
  153.                 case 2:   
  154.                     this.playerinfo.playState="已暂停";   
  155.                     this.status="pause";   
  156.                     break;   
  157.                 case 3:   
  158.                     this.playerinfo.playState=this.musicinfo.title+"-"+this.musicinfo.author;   
  159.                     this.status="play";   
  160.                     waitseconds=0;   
  161.                     stopseconds=0;   
  162.                     stopclick=false;   
  163.                     break;   
  164.                 case 6:   
  165.                     this.playerinfo.playState="正在缓冲";   
  166.                     break;   
  167.                 case 9:   
  168.                     if(waitseconds>15){   
  169.                         if(this.israndom){this.GoTo(Math.round(Math.random()*musiclist.length));}   
  170.                         else{this.Next();}   
  171.                         }   
  172.                     this.playerinfo.playState="正在连接";   
  173.                     waitseconds+=1;   
  174.                     break;   
  175.                 case 10:   
  176.                     if(stopseconds>5){   
  177.                         if(this.israndom){this.GoTo(Math.round(Math.random()*musiclist.length));}   
  178.                         else{this.Next();}   
  179.                         }   
  180.                     this.playerinfo.playState="准备就绪";   
  181.                     this.status="stop";   
  182.                     stopseconds+=1;   
  183.                     break;   
  184.                 }   
  185.             this.playerinfo.currentPositionString=playerobj.controls.currentPositionString;   
  186.             this.playerinfo.volume=playerobj.controls.volume;   
  187.             this.playerinfo.mediaDurationString=playerobj.currentMedia.durationString;   
  188.             var n_t=Math.round(playerobj.controls.currentPositionString.replace(":",""));   
  189.             var t_t=Math.round(playerobj.currentMedia.durationString.replace(":",""));   
  190.             if((t_t-n_t<=5) && (n_t!=0) ){   
  191.                 if(this.israndom){   
  192.                     this.GoTo(Math.round(Math.random()*musiclist.length));   
  193.                     }   
  194.                 else{this.Next();}   
  195.                 }   
  196.             }   
  197.             $id("music_status").innerHTML=this.playerinfo.playState;   
  198.             $id("music_t").innerHTML=this.playerinfo.currentPositionString+"/"+this.playerinfo.mediaDurationString;   
  199.         },   
  200.     //加载音乐列表   
  201.     LoadMusicList:function(){   
  202.         try{   
  203.             var xmlobj=GetXMLContent(installpath+musiclistfile);   
  204.             var musiclistobj=xmlobj.selectNodes("//musiclist/music");   
  205.             var list_len=musiclistobj.length;   
  206.             if(list_len==0) this.errmsg="未成功加载音乐列表!";   
  207.             var musicinfo_t;   
  208.             for(var m_i=0;m_i<list_len;m_i++){   
  209.                 musicinfo_t=new MusicInfo();   
  210.                 musicinfo_t.title=musiclistobj[m_i].selectSingleNode("title/text()").nodeValue;   
  211.                 musicinfo_t.author=musiclistobj[m_i].selectSingleNode("author/text()").nodeValue;   
  212.                 musicinfo_t.url=musiclistobj[m_i].selectSingleNode("url/text()").nodeValue;   
  213.                 musicinfo_t.id=m_i;   
  214.                 musiclist.push(musicinfo_t);   
  215.                 }   
  216.             }   
  217.         catch(e){   
  218.             this.errmsg="未成功加载音乐列表!";   
  219.             }   
  220.         }   
  221.     };       
  222. }();    
  223.   
  224. function updatemusicstatus(){   
  225. if(MusicPlayer.errmsg!=""){$id("lymusicbox").innerHTML=MusicPlayer.errmsg;return;}   
  226. MusicPlayer.RefreshStatus();   
  227. $id("music_status").innerHTML=MusicPlayer.playerinfo.playState;   
  228. $id("music_t").innerHTML=MusicPlayer.playerinfo.currentPositionString+"/"+MusicPlayer.playerinfo.mediaDurationString;   
  229. }   
  230.   
  231. function loadfun(){   
  232. MusicPlayer.init();   
  233. window.setInterval(updatemusicstatus,1000);   
  234. }   
  235. if(window.parent!=window.self){   
  236. if(document.all){window.document.body.onload=loadfun}   
  237. else{window.addEventListener("load",loadfun,false);}   
  238. }   
  239. else{   
  240. $id("lymusicbox").innerHTML='<a href="index.htm">音乐版</a>';   
  241. }  

 

Tags: 音乐 插件

分类:技术 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 61

晋江文学网小偷

分类:技术 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 84

C# 检测图像中出现次数最多的颜色

C# 检测图像中出现次数最多的颜色
http://www.lingye.net/lingye_net/Demo/ImageCore/ImageColor.aspx

 

核心:

               

C#代码
  1. BitmapData srcData = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);   
  2.                 unsafe  
  3.                 {   
  4.                     byte* p = (byte*)srcData.Scan0.ToPointer();   
  5.                     for (int y = 0; y < h; y++)   
  6.                     {   
  7.                         for (int x = 0; x < w; x++)   
  8.                         {   
  9.                             string colorkey = ColorTranslator.ToHtml(Color.FromArgb(p[2], p[1], p[0]));   
  10.                             ......   
  11.                             p += 3;   
  12.                         }   
  13.                         p += srcData.Stride - w * 3;   
  14.                     }   
  15.                 }   
  16.   
  17.     

查看更多...

Tags: c# 颜色 BitmapData

分类:技术 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 278

用GDI+绘制你的任意窗口

通过GDI+可绘制任意的你想要得到的自定义窗口

本文讲的是非图片实现的一个圆角自定义窗口 支持窗口各种常见功能 包括任务栏右键菜单有效

先看个图:

查看更多...

Tags: GDI+ 窗口 自定义

分类:技术 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 313

利用google 做你的免费高效邮件服务器

只要你有域名 你就可以通过修改MX记录 而得到Google为你免费提供的可支持100个用户的邮件服务器

查看更多...

Tags: Google Apps 邮件服务器

分类:IT | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 418