﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-ivaneeo's blog-随笔分类-web2.0</title><link>http://www.blogjava.net/ivanwan/category/50836.html</link><description>自由的力量，自由的生活。</description><language>zh-cn</language><lastBuildDate>Thu, 01 Mar 2012 16:54:54 GMT</lastBuildDate><pubDate>Thu, 01 Mar 2012 16:54:54 GMT</pubDate><ttl>60</ttl><item><title>大文件上传 进度条显示 </title><link>http://www.blogjava.net/ivanwan/archive/2012/02/29/371033.html</link><dc:creator>ivaneeo</dc:creator><author>ivaneeo</author><pubDate>Wed, 29 Feb 2012 12:42:00 GMT</pubDate><guid>http://www.blogjava.net/ivanwan/archive/2012/02/29/371033.html</guid><wfw:comment>http://www.blogjava.net/ivanwan/comments/371033.html</wfw:comment><comments>http://www.blogjava.net/ivanwan/archive/2012/02/29/371033.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ivanwan/comments/commentRss/371033.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ivanwan/services/trackbacks/371033.html</trackback:ping><description><![CDATA[<div><p>浏览-选择文件-点击 &#8220;上传 &#8221;后，效果如下：</p> <p>弹出透明UI遮罩层 并显示上传这个过程 我这里设置太透明了 效果不是很立体</p> <p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="曾祥展" alt="曾祥展" src="http://images.cnblogs.com/cnblogs_com/zengxiangzhan/WindowsLiveWriter/csdn_E739/2_3.jpg" height="535" width="638" border="0" /> </p> <p>文件结构如图：</p> <p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="曾祥展" alt="曾祥展" src="http://images.cnblogs.com/cnblogs_com/zengxiangzhan/WindowsLiveWriter/csdn_E739/01_3.jpg" height="396" width="395" border="0" /> </p> <p>&nbsp;</p> <p>说明：用到&#8220;高山来客&#8221;的大文件上传组件 <a href="http://www.cnblogs.com/bashan/archive/2008/05/23/1206095.html" target="_blank">http://www.cnblogs.com/bashan/archive/2008/05/23/1206095.html</a></p> <p>以及Newtonsoft.Json.dll Json字符串反序列化为对象 <a title="http://james.newtonking.com/projects/json-net.aspx" href="http://james.newtonking.com/projects/json-net.aspx" target="_blank">http://james.newtonking.com/projects/json-net.aspx</a></p> <p>jquery.blockUI.js 弹出透明遮罩层 <a title="http://malsup.com/jquery/block/" href="http://malsup.com/jquery/block/" target="_blank">http://malsup.com/jquery/block/</a></p> <p>jquery.form.js&nbsp;&nbsp; 表单验证Ajax提交&nbsp; </p> <p>参照了&#8220;蚂蚁飞了&#8221;的文章 多谢多谢 <a title="http://blog.csdn.net/jetsteven" href="http://blog.csdn.net/jetsteven" target="_blank">http://blog.csdn.net/jetsteven</a></p> <p>&nbsp;</p> <p>&nbsp;</p> <p>HTML：</p><pre><span style="color: blue">&lt;</span><span style="color: #a31515">form </span><span style="color: red">id</span><span style="color: blue">="uploadForm" </span><span style="color: red">runat</span><span style="color: blue">="server" </span><span style="color: red">enctype</span><span style="color: blue">="multipart/form-data"&gt;   &lt;</span><span style="color: #a31515">div </span><span style="color: red">id</span><span style="color: blue">="uploadfield"  </span><span style="color: red">style</span><span style="color: blue">="width:600px; height:500px"&gt;    &lt;</span><span style="color: #a31515">input </span><span style="color: red">id</span><span style="color: blue">="File1" </span><span style="color: red">type</span><span style="color: blue">="file" </span><span style="color: red">runat</span><span style="color: blue">="server" /&gt;    &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Button </span><span style="color: red">ID</span><span style="color: blue">="Button1" </span><span style="color: red">runat</span><span style="color: blue">="server"  </span><span style="color: red">Text</span><span style="color: blue">="上传" </span><span style="color: red">onclick</span><span style="color: blue">="Button1_Click" /&gt;     &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span>文件上传进度条<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;     &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span>文件上传进度条<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;     &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span>文件上传进度条<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;     &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span>文件上传进度条<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;     &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span>文件上传进度条<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;     &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span>文件上传进度条<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;      &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span>文件上传进度条<span style="color: blue">&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;    &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;                    &lt;</span><span style="color: #a31515">div </span><span style="color: red">id</span><span style="color: blue">="ui"  </span><span style="color: red">style</span><span style="color: blue">="display:none"  &gt;      &lt;</span><span style="color: #a31515">div </span><span style="color: red">id</span><span style="color: blue">="output" &gt; &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;        &lt;</span><span style="color: #a31515">div </span><span style="color: red">id</span><span style="color: blue">="progressbar"</span><span style="color: red">class</span><span style="color: blue">="ui-progressbar ui-widget ui-widget-content ui-corner-all" </span><span style="color: red">style</span><span style="color: blue">="width:296px; height:20px;"&gt;&lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;    &lt;</span><span style="color: #a31515">input </span><span style="color: red">id</span><span style="color: blue">="btn_cancel" </span><span style="color: red">type</span><span style="color: blue">="button" </span><span style="color: red">value</span><span style="color: blue">="取消上传" /&gt;   &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt; &lt;/</span><span style="color: #a31515">form</span><span style="color: blue">&gt;</span></pre><pre>&nbsp;</pre><pre><span style="color: blue">js:</span></pre><pre>&nbsp;</pre><pre><span style="color: blue">var </span>inte; $(<span style="color: blue">function</span>() { $(<span style="color: #a31515">'#uploadForm'</span>).submit(<span style="color: blue">function</span>() {     <span style="color: blue">return false</span>; });  $(<span style="color: #a31515">'#uploadForm'</span>).ajaxForm({ <span style="color: green">//这里调用jquery.form.js表单注册方法     </span>beforeSubmit: <span style="color: blue">function</span>(a, f, o) {<span style="color: green">//提交前的处理         </span>o.dataType = <span style="color: #a31515">"json"</span>;         $(<span style="color: #a31515">'#uploadfield'</span>).block({ message: $(<span style="color: #a31515">'#ui'</span>), css: { width: <span style="color: #a31515">'300px'</span>, border: <span style="color: #a31515">'#b9dcfe 1px solid'</span>,padding: <span style="color: #a31515">'0.5em 0.2em'  </span>}         });         inte = self.setInterval(<span style="color: #a31515">"getprogress()"</span>, 500);     } });  $(<span style="color: #a31515">'#btn_cancel'</span>).click(<span style="color: blue">function</span>() {     <span style="color: blue">var </span>uploadid = $(<span style="color: #a31515">"#UploadID"</span>).val();     $.ajax({         type: <span style="color: #a31515">"POST"</span>,         dataType: <span style="color: #a31515">"json"</span>,         async: <span style="color: blue">false</span>, <span style="color: green">//ajax的请求时同步 只有一个线程         </span>url: <span style="color: #a31515">"upload_ajax.ashx"</span>,         data: <span style="color: #a31515">"UploadID=" </span>+ uploadid + <span style="color: #a31515">"&amp;cancel=true"</span>,         success: <span style="color: blue">function</span>(obj) {             $(<span style="color: #a31515">"#output"</span>).html(obj.msg);             inte = self.clearInterval(inte);             $(<span style="color: #a31515">'#uploadfield'</span>).unblock();                            }     }); }); });  <span style="color: blue">function </span>getprogress() { <span style="color: blue">var </span>uploadid = $(<span style="color: #a31515">"#UploadID"</span>).val() $.ajax({     type: <span style="color: #a31515">"POST"</span>,     dataType: <span style="color: #a31515">"json"</span>,     async: <span style="color: blue">false</span>,     url: <span style="color: #a31515">"upload_ajax.ashx"</span>,     data: <span style="color: #a31515">"UploadID=" </span>+ uploadid,     success: <span style="color: blue">function</span>(obj) {     <span style="color: blue">var </span>p = obj.msg.Readedlength / obj.msg.TotalLength * 100;     <span style="color: blue">var </span>info = <span style="color: #a31515">"&lt;FONT color=Green&gt; 当前上传文件:&lt;/FONT&gt;" </span>+ obj.msg.CurrentFile;     info += <span style="color: #a31515">"&lt;br&gt;&lt;FONT color=Green&gt;" </span>+ obj.msg.FormatStatus + <span style="color: #a31515">":&lt;/FONT&gt;" </span>+ obj.msg.Status;     info += <span style="color: #a31515">"&lt;br&gt;&lt;FONT color=Green&gt;文件大小:&lt;/FONT&gt;" </span>+ obj.msg.TotalLength;     info += <span style="color: #a31515">"&lt;br&gt;&lt;FONT color=Green&gt;速度:&lt;/FONT&gt;" </span>+ obj.msg.FormatRatio;     info += <span style="color: #a31515">"&lt;br&gt;&lt;FONT color=Green&gt;剩余时间:&lt;/FONT&gt;" </span>+ obj.msg.LeftTime;       $(<span style="color: #a31515">"#output"</span>).html(info);     $(<span style="color: #a31515">"#progressbar"</span>).progressbar({ value: 0 }); <span style="color: green">//初始化     </span>$(<span style="color: #a31515">"#progressbar"</span>).progressbar(<span style="color: #a31515">"option"</span>, <span style="color: #a31515">"value"</span>, p);     $(<span style="color: #a31515">"#progressbar div"</span>).html(p.toFixed(2) + <span style="color: #a31515">"%"</span>);     $(<span style="color: #a31515">"#progressbar div"</span>).addClass(<span style="color: #a31515">"percentText"</span>);     <span style="color: blue">if </span>(obj.msg.Status == 4) {         inte = self.clearInterval(inte);         $(<span style="color: #a31515">'#uploadfield'</span>).unblock();      }            } }); }</pre><pre>&nbsp;</pre><pre><span style="color: blue">交互过程代码：</span></pre><pre>&nbsp;</pre><pre><span style="background: #ffee62">&lt;%</span><span style="color: blue">@ </span><span style="color: #a31515">WebHandler </span><span style="color: red">Language</span><span style="color: blue">="C#" </span><span style="color: red">Class</span><span style="color: blue">="progressbar" </span><span style="background: #ffee62">%&gt;  </span><span style="color: blue">using </span>System; <span style="color: blue">using </span>System.Web;  <span style="color: blue">using </span>BigFileUpload;<span style="color: green">//大文件引用命名空间 </span><span style="color: blue">using </span>Newtonsoft.Json;<span style="color: green">//对象到JSON的相互转换 </span><span style="color: blue">using </span>System.Text.RegularExpressions;<span style="color: green">//正则  </span><span style="color: blue">public class </span><span style="color: #2b91af">progressbar </span>: <span style="color: #2b91af">IHttpHandler </span>{      <span style="color: blue">private string </span>template = <span style="color: #a31515">"{{statue:'{0}',msg:{1}}}"</span>;    <span style="color: blue">public void </span>ProcessRequest(<span style="color: #2b91af">HttpContext </span>context)    {        context.Response.ContentType = <span style="color: #a31515">"text/plain"</span>;        <span style="color: blue">try       </span>{        <span style="color: blue">string </span>guid = context.Request[<span style="color: #a31515">"UploadID"</span>];        <span style="color: blue">string </span>cancel =context.Request[<span style="color: #a31515">"cancel"</span>];     <span style="color: #2b91af">UploadContext </span>c = <span style="color: #2b91af">UploadContextFactory</span>.GetUploadContext(guid);       <span style="color: blue">if </span>(!<span style="color: blue">string</span>.IsNullOrEmpty(cancel))     {                    c.Abort=<span style="color: blue">true</span>;                    <span style="color: blue">throw new </span><span style="color: #2b91af">Exception</span>(<span style="color: #a31515">"用户取消"</span>);        }        <span style="color: blue">string </span>json = Newtonsoft.Json.<span style="color: #2b91af">JsonConvert</span>.SerializeObject(c);                    WriteResultJson(1, json, context,template);                 }<span style="color: blue">catch </span>(<span style="color: #2b91af">Exception </span>err)        {            WriteResultJson(0, err.Message, context);        }    }      <span style="color: blue">public static void </span>WriteResultJson(<span style="color: blue">int </span>resultno, <span style="color: blue">string </span>description, <span style="color: #2b91af">HttpContext </span>context) {     WriteResultJson(resultno, description, context, <span style="color: #a31515">"{{statue:'{0}',msg:'{1}'}}"</span>); }  <span style="color: blue">public static void </span>WriteResultJson(<span style="color: blue">int </span>resultno, <span style="color: blue">string </span>description, <span style="color: #2b91af">HttpContext </span>context, <span style="color: blue">string </span>template) {     description = ClearBR(ReplaceString(description, <span style="color: #a31515">"'"</span>, <span style="color: #a31515">"|"</span>, <span style="color: blue">false</span>));     context.Response.Write(<span style="color: blue">string</span>.Format(template, resultno, description)); }  <span style="color: blue">public static string </span>ClearBR(<span style="color: blue">string </span>str) {     <span style="color: #2b91af">Regex </span>r = <span style="color: blue">null</span>;     <span style="color: #2b91af">Match </span>m = <span style="color: blue">null</span>;     r = <span style="color: blue">new </span><span style="color: #2b91af">Regex</span>(<span style="color: #a31515">@"(\r|\n)"</span>, <span style="color: #2b91af">RegexOptions</span>.IgnoreCase);     <span style="color: blue">for </span>(m = r.Match(str); m.Success; m = m.NextMatch())     {         str = str.Replace(m.Groups[0].ToString(), <span style="color: #a31515">@"\n"</span>);     }     <span style="color: blue">return </span>str; }  <span style="color: blue">public static string </span>ReplaceString(<span style="color: blue">string </span>SourceString, <span style="color: blue">string </span>SearchString, <span style="color: blue">string </span>ReplaceString, <span style="color: blue">bool </span>IsCaseInsensetive) {     <span style="color: blue">return </span><span style="color: #2b91af">Regex</span>.Replace(SourceString, <span style="color: #2b91af">Regex</span>.Escape(SearchString), ReplaceString, IsCaseInsensetive ? <span style="color: #2b91af">RegexOptions</span>.IgnoreCase : <span style="color: #2b91af">RegexOptions</span>.None); }    <span style="color: blue">public bool </span>IsReusable    {        <span style="color: blue">get       </span>{         <span style="color: blue">return false</span>;        }    }  }         </pre></div>转<div>http://www.cnblogs.com/jcomet/archive/2010/03/24/1693467.html</div><img src ="http://www.blogjava.net/ivanwan/aggbug/371033.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ivanwan/" target="_blank">ivaneeo</a> 2012-02-29 20:42 <a href="http://www.blogjava.net/ivanwan/archive/2012/02/29/371033.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Javascript文件加密</title><link>http://www.blogjava.net/ivanwan/archive/2012/02/28/370944.html</link><dc:creator>ivaneeo</dc:creator><author>ivaneeo</author><pubDate>Tue, 28 Feb 2012 14:41:00 GMT</pubDate><guid>http://www.blogjava.net/ivanwan/archive/2012/02/28/370944.html</guid><wfw:comment>http://www.blogjava.net/ivanwan/comments/370944.html</wfw:comment><comments>http://www.blogjava.net/ivanwan/archive/2012/02/28/370944.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ivanwan/comments/commentRss/370944.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ivanwan/services/trackbacks/370944.html</trackback:ping><description><![CDATA[<div><p><span style="font-size: 14px">原理简单的不能再简单，就是替换变量，用转义字符替换你的字符串，把整个js变成一个字符串，然后随便加密替换，最后用eval来解释他。最后把整个js文件压缩下，没有注释，没有换行，没有空格，一般人都会看到吐血。</span></p> <p><span style="font-size: 14px">说了半天不够爽，总不能让大家手动加密和替换吧，以下是我的御用在线加密工具，jQuery就是用其中一个加密和压缩的：</span></p> <p><span style="font-size: 14px"><a href="http://www.javascriptobfuscator.com/Default.aspx">http://www.javascriptobfuscator.com/Default.aspx</a></span></p> <p><span style="font-size: 14px"><a href="http://dean.edwards.name/packer/">http://dean.edwards.name/packer/</a></span></p> <p><span style="font-size: 14px">这2网站只提供加密，不提供解密，其实你解密了看得人也很痛苦，没有注释，没有格式，全是abcd这样无意义的变量，真有心想学你js的人，那就让他学吧。你如果真的变态，那你不妨两边混合加密几次，保准没人看得懂，不过估计浏览器解释起来也挺费劲的。</span></p> <p><span style="font-size: 14px">特别友情提醒：<a target="_blank" href="http://www.meebe.net/"><span style="font-size: 10px">meebe.net</span></a></span></p> <p><span style="font-size: 14px">1.加密后记着留住你原本的js文件，不要到时候改bug都改不了了。</span></p> <p><strong><span style="color: #ff0000;"><span style="font-size: 14px;">2.加密后如果出现运行不了，请把你加密前的文件每次函数结束都加上";",因为去除换行后，浏览器解释器没碰到";"有时候会报错。如果加密后有错，请务必多加几个";"在每个语句结束或者定义结束的时候。</span></span></strong></p><p><strong><span style="color: #ff0000"><span style="font-size: 14px"><br /></span></span></strong></p> <p><span style="font-size: 14px">转自 <a target="_blank" href="http://www.meebe.net/blog"><span style="font-size: 10px">meebe.net</span></a></span></p></div><img src ="http://www.blogjava.net/ivanwan/aggbug/370944.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ivanwan/" target="_blank">ivaneeo</a> 2012-02-28 22:41 <a href="http://www.blogjava.net/ivanwan/archive/2012/02/28/370944.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>bootstrap toolkit sample例子</title><link>http://www.blogjava.net/ivanwan/archive/2012/02/14/369902.html</link><dc:creator>ivaneeo</dc:creator><author>ivaneeo</author><pubDate>Mon, 13 Feb 2012 16:26:00 GMT</pubDate><guid>http://www.blogjava.net/ivanwan/archive/2012/02/14/369902.html</guid><wfw:comment>http://www.blogjava.net/ivanwan/comments/369902.html</wfw:comment><comments>http://www.blogjava.net/ivanwan/archive/2012/02/14/369902.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ivanwan/comments/commentRss/369902.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ivanwan/services/trackbacks/369902.html</trackback:ping><description><![CDATA[最近发现bootstrap toolkit非常好用，现在收集一下sample网站：<br />1.http://twitter.github.com/bootstrap/（首先主站，可惜要fq）<br />2.http://webdesigntutsplus.s3.amazonaws.com/tuts/195_bootstrap/demo/main.html （也是一个简单的列子，可以作为参考)<br />3.http://www.breakingnews.com/ (新闻类网站，做的漂亮呀。。。）<br />4.http://www.mobile-loft.com/ &nbsp;(整体风格简洁)<br />5.http://demo.newfies-dialer.org/ (ajax登录的例子)<img src ="http://www.blogjava.net/ivanwan/aggbug/369902.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ivanwan/" target="_blank">ivaneeo</a> 2012-02-14 00:26 <a href="http://www.blogjava.net/ivanwan/archive/2012/02/14/369902.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>