zoukankan      html  css  js  c++  java
  • 合成艺术字二 :使用的透明类以及所用的颜色选择器JS(完整事列源码)

    1.透明类 ImageToTrans

    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Collections;


            public static Bitmap MakeTransparentGif(Bitmap bitmap, Color color)
            {
                byte R = color.R;
                byte G = color.G;
                byte B = color.B;
                MemoryStream fin = new MemoryStream();
                bitmap.Save(fin, System.Drawing.Imaging.ImageFormat.Gif);
                MemoryStream fout = new MemoryStream((int)fin.Length);
                int count = 0;
                byte[] buf = new byte[256];
                byte transparentIdx = 0;
                fin.Seek(0, SeekOrigin.Begin);
                //header   
                count = fin.Read(buf, 0, 13);
                if ((buf[0] != 71) || (buf[1] != 73) || (buf[2] != 70)) return null; //GIF   
                fout.Write(buf, 0, 13);
                int i = 0;
                if ((buf[10] & 0X80) > 0)
                {
                    i = 1 << ((buf[10] & 7) + 1) == 256 ? 256 : 0;
                }
                for (; i != 0; i--)
                {
                    fin.Read(buf, 0, 3);
                    if ((buf[0] == R) && (buf[1] == G) && (buf[2] == B))
                    {
                        transparentIdx = (byte)(256 - i);
                    }
                    fout.Write(buf, 0, 3);
                }
                bool gcePresent = false;
                while (true)
                {
                    fin.Read(buf, 0, 1);
                    fout.Write(buf, 0, 1);
                    if (buf[0] != 0X21) break;
                    fin.Read(buf, 0, 1);
                    fout.Write(buf, 0, 1);
                    gcePresent = (buf[0] == 0xf9);
                    while (true)
                    {
                        fin.Read(buf, 0, 1);
                        fout.Write(buf, 0, 1);
                        if (buf[0] == 0) break;
                        count = buf[0];
                        if (fin.Read(buf, 0, count) != count) return null;
                        if (gcePresent)
                        {
                            if (count == 4)
                            {
                                buf[0] = 0X01;
                                buf[3] = transparentIdx;
                            }
                        }
                        fout.Write(buf, 0, count);
                    }
                }
                while (count > 0)
                {
                    count = fin.Read(buf, 0, 1);
                    fout.Write(buf, 0, 1);
                }
                fin.Close();
                fout.Flush();
                return new Bitmap(fout);
            } 

    =================================================

    2.所用JS1 veryide.color.js

    /*
    * Copyright VeryIDE,2007-2008
    * http://www.veryide.com/

    * $Id: veryide.color.js,v1.1 18:48 2008-11-19 leilei $
    */


    /*
     onfocus="VeryIDE.Color(this)"
    */

    VeryIDE.Color=function(o,i,s,f){
     

        VeryIDE.tmpColorA=o;
        VeryIDE.tmpColorB=arguments[1];
        VeryIDE.tmpColorF=f;
       
        //随机ID
        if(!VeryIDE.tmpID){
      VeryIDE.tmpID=getRnd(10);
        }
       
        var id=VeryIDE.tmpID;
       
        var color='';
        if(o.tagName=="IMG"){
      color=VeryIDE.tmpColorB.value;
        }else{
      color=o.value;
        }
       
        color?color:'#eeeeee';

     var active=['#fff','','#0A66EE','#EEEEEE'];
        o.onkeyup=this;
       
        var pos=new getPosition(o);
       
        var obj=$(id);
        if(obj){
       delElement(id);
        }
       
     var obj=document.createElement("DIV");
      obj.id=id;
      
      with(obj.style){
       backgroundColor = "#f9f8f7";
       border = "solid #999999 1px";
       fontSize = "12px";
       position="absolute";
       top=pos.top+pos.height+"px";
       left=pos.left+"px";
      }

        var colorlist=["#000000","#000033","#000066","#000099","#0000cc","#0000ff","#003300","#003333","#003366","#003399","#0033cc","#0033ff","#006600","#006633","#006666","#006699","#0066cc","#0066ff","#009900","#009933","#009966","#009999","#0099cc","#0099ff","#00cc00","#00cc33","#00cc66","#00cc99","#00cccc","#00ccff","#00ff00","#00ff33","#00ff66","#00ff99","#00ffcc","#00ffff","#330000","#330033","#330066","#330099","#3300cc","#3300ff","#333300","#333333","#333366","#333399","#3333cc","#3333ff","#336600","#336633","#336666","#336699","#3366cc","#3366ff","#339900","#339933","#339966","#339999","#3399cc","#3399ff","#33cc00","#33cc33","#33cc66","#33cc99","#33cccc","#33ccff","#33ff00","#33ff33","#33ff66","#33ff99","#33ffcc","#33ffff","#660000","#660033","#660066","#660099","#6600cc","#6600ff","#663300","#663333","#663366","#663399","#6633cc","#6633ff","#666600","#666633","#666666","#666699","#6666cc","#6666ff","#669900","#669933","#669966","#669999","#6699cc","#6699ff","#66cc00","#66cc33","#66cc66","#66cc99","#66cccc","#66ccff","#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#990000","#990033","#990066","#990099","#9900cc","#9900ff","#993300","#993333","#993366","#993399","#9933cc","#9933ff","#996600","#996633","#996666","#996699","#9966cc","#9966ff","#999900","#999933","#999966","#999999","#9999cc","#9999ff","#99cc00","#99cc33","#99cc66","#99cc99","#99cccc","#99ccff","#99ff00","#99ff33","#99ff66","#99ff99","#99ffcc","#99ffff","#cc0000","#cc0033","#cc0066","#cc0099","#cc00cc","#cc00ff","#cc3300","#cc3333","#cc3366","#cc3399","#cc33cc","#cc33ff","#cc6600","#cc6633","#cc6666","#cc6699","#cc66cc","#cc66ff","#cc9900","#cc9933","#cc9966","#cc9999","#cc99cc","#cc99ff","#cccc00","#cccc33","#cccc66","#cccc99","#cccccc","#ccccff","#ccff00","#ccff33","#ccff66","#ccff99","#ccffcc","#ccffff","#ff0000","#ff0033","#ff0066","#ff0099","#ff00cc","#ff00ff","#ff3300","#ff3333","#ff3366","#ff3399","#ff33cc","#ff33ff","#ff6600","#ff6633","#ff6666","#ff6699","#ff66cc","#ff66ff","#ff9900","#ff9933","#ff9966","#ff9999","#ff99cc","#ff99ff","#ffcc00","#ffcc33","#ffcc66","#ffcc99","#ffcccc","#ffccff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff"];
       
     var ocbody;
     ocbody = '<table border="0" cellspacing="3" cellpadding="0" style="font-size:12px;cursor:default;line-height:20px;">';
       
        ocbody += "<tr height=\"20\"><td colspan=\"4\" bgcolor=\""+color+"\"><td><td colspan=\"3\" style=\"font-size:12px;\" align=\"center\">当前颜色</td>";
       
        ocbody += "<td colspan=\"2\"><td><td align=\"center\" height=\"20\" colspan=\"8\" onMouseOut=\"this.style.borderColor='"+active[0]+"';this.bgColor='"+active[1]+"';\" onMouseOver=\"this.style.borderColor='"+active[2]+"';this.bgColor='"+active[3]+"';\"  onclick=\"window.open('http://www.i2up.com/lab/flash.color.php','_color');\" style=\"border:"+active[0]+" 1px solid;\">其它颜色</td>";
       
        ocbody += "<td colspan=\"2\"><td><td align=\"center\" colspan=\"2\" style='background:#666;color:#fff;' onclick='VeryIDE.Color.close(\"color\");'>关闭</td></tr>";
       
      for(var i=0;i<colorlist.length;i++){
       if(i%24==0){
        ocbody += "<tr>";
       }
        ocbody += "<td width=\"16\" height=\"18\" style=\"border:"+active[0]+" 1px solid;\" onMouseOut=\"this.style.borderColor='"+active[0]+"';this.bgColor='"+active[1]+"';\" onMouseOver=\"this.style.borderColor='"+active[2]+"';this.bgColor='"+active[3]+"';\" onMouseDown=\"VeryIDE.Color.select('"+colorlist[i]+"','"+s+"')\" align=\"center\" valign=\"middle\"><table style=\"border:1px solid #808080;\" width=\"14\" height=\"14\" bgcolor=\""+colorlist[i]+"\"><tr><td></td></tr></table></td>";

       if(i%24==23){
        ocbody += "</tr>";
       }
      }
       
        ocbody += "</table>";

     obj.innerHTML=ocbody;
        document.body.appendChild(obj);
       
    }

    VeryIDE.Color.select=function(color,select){
        var o=VeryIDE.tmpColorA;
       
        if(typeof(VeryIDE.tmpColorF)=="function"){
      VeryIDE.tmpColorF(color);
        }
       
        if(select=="rgb"){
      var colorValue=VeryIDE.Color.rgb(color);
        }else{
      var colorValue=color;
        }
       
        if(o.tagName=="IMG"){
      o.style.backgroundColor=color;
      
      VeryIDE.tmpColorB.value=colorValue;
        }else{
      o.style.color=color;
      
      o.value=colorValue;
        }
     delElement(VeryIDE.tmpID);
    }

    VeryIDE.Color.close=function(){
        delElement(VeryIDE.tmpID);
    }

    VeryIDE.Color.rgb=function(hexColor){
     var a=hexColor;
     if(a.substr(0,1)=="#"){a=a.substring(1);}
     if(a.length!=6){return alert("请输入正确的颜色编码!");}
     a=a.toLowerCase()

     var b=new Array();
     for(x=0;x<3;x++){
      b[0]=a.substr(x*2,2)
      b[3]="0123456789abcdef";b[1]=b[0].substr(0,1)
      b[2]=b[0].substr(1,1)
      b[20+x]=b[3].indexOf(b[1])*16+b[3].indexOf(b[2])
     }
     return b[20]+","+b[21]+","+b[22];
    }

    VeryIDE.Color.hex=function(rgbColor){
     var hexcode="#";
     for(x=0;x<3;x++){
      var n=r1e[x].value;
      if(n==""){n="0";}
      
      if(parseInt(n)!=n){
       return alert("请输入数字!");
      }
      if(a<0 && a>255){
       return alert("数字在0-255之间!");
      }
      var c="0123456789abcdef";
      var b="";
      var a=n%16;b=c.substr(a,1)
      a=(n-a)/16;hexcode+=c.substr(a,1)+b
     }
     return hexcode;
    }

    /*state*/
    VeryIDE.script["color"]=true;

    ============================================================

    js  :veryide.core.js

    ==============================================================

    /*
    * Copyright VeryIDE,2007-2008
    * http://www.veryide.com/

    * $Id: veryide.core.js v1.2 19:47 2008-2-18 leilei $
    */

    var VeryIDE={

     /*config*/
     site  :"VeryIDE",
     url   :"http://"+location.host+"/",
     domain :location.host,
     path  :"/veryide/",

     /*version*/
     version  :1.2,
     versionBuild : 20080904,
     
     /*developer*/
     developer   : "VeryIDE.Com",
     developerWeb : "http://www.veryide.com",

     /*event*/
     mouseX:0,
     mouseY:0,
     
     /*inti*/
     inti:null,
     layer:100,
     temp:"",
     
     /*script*/
     script:[],
     
     /*debug*/
     debug:false,
     
     /*info*/
     title:document.title,
     url:location.href,
     host:location.host,
     
     /*random*/
     rnd:Math.random(),
     getRnd:function(){
      return Math.random();
     },
     
     /*ui*/
     screenW:screen.width,
     screenH:screen.height,
     bodyW:document.documentElement.scrollWidth,
     bodyH:document.documentElement.scrollHeight,
     
     /*analytics*/
     referrer:document.referrer,
     isSearch:(/(baidu|yahoo|google|sogou|zhongsou|soso|youdao|tom|yisou|vnet|china|live|msn)\.(cn|com|net)/.test(document.referrer)),
     isIE   :false,
     isOpera  :false,
     isSafari  :false,
     isFirefox  :false,
     isMaxthon :false,
     appName:"",
     appVersion:"",
     appLang:"",

     /*load*/
     start:function(){
      /*powered*/
      VeryIDE.powered="Powered by <a href='http://www.veryide.com/?version="+VeryIDE.version+"&versionBuild="+VeryIDE.versionBuild+"&developer="+VeryIDE.developer+"&from="+location.host+"' title='VeryIDE' target='_blank'>VeryIDE</a> &amp; <a href='"+VeryIDE.developerWeb+"' title='"+VeryIDE.developerWeb+"' target='_blank'>"+VeryIDE.developer+"</a>",

     
      /*folder*/
      VeryIDE.folder={
       js    : VeryIDE.path+"js/",
       xml   :  VeryIDE.path+"xml/",
       skin  : VeryIDE.path+"skins/",
       icon  : VeryIDE.path+"images/icon/",
       cache  :  VeryIDE.path+"cache/",
       images : VeryIDE.path+"images/",
       plugins : VeryIDE.path+"plugins/"
      }

      /*browse*/
      switch (navigator.appName){
       case "Microsoft Internet Explorer":{
        VeryIDE.appName = "ie";
        var reg = /^.+MSIE (\d+\.\d+);.+$/;
        VeryIDE.isIE=true;
        
        if(navigator.userAgent.indexOf ("MAXTHON") != -1){
         VeryIDE.isMaxthon=true;
         var regMax = /^.+MAXTHON ([\d\.]+).{0,}$/;
         VeryIDE.maxVersion=navigator.userAgent.replace (regMax, "$1");
        }
        
        break;
       }default:{
        if (navigator.userAgent.indexOf ("Safari") != -1){
         VeryIDE.appName = "safari";
         var reg = /^.+Version\/([\d\.]+?) Safari.+$/;
         VeryIDE.isSafari=true;
        }else if (navigator.userAgent.indexOf ("Opera") != -1){
         VeryIDE.appName = "opera";
         var reg = /^.{0,}Opera\/(.+?) \(.+$/;
         VeryIDE.isOpera=true;
        }else{
         VeryIDE.appName = "firefox";
         var reg = /^.+Firefox\/([\d\.]+).{0,}$/;
         VeryIDE.isFirefox=true;
        }
       }
       break;
      }
         VeryIDE.appVersion = navigator.userAgent.replace (reg, "$1");
         
      if(!VeryIDE.isIE){
       var lang=navigator.language;
      }else{
       var lang=navigator.browserLanguage;
      }
      VeryIDE.appLang=lang.toLowerCase();
         
      /*bg cache*/
      if(VeryIDE.isIE && !VeryIDE.appVersion<7){
       try{
        //document.documentElement.addBehavior("#default#userdata");
        VeryIDE.getDocment().addBehavior("#default#userdata");
        document.execCommand("BackgroundImageCache", false, true);
       }catch(e){}
      }      
         
        },
       
     /*document*/
     getDocment:function(){
      var doc= (document.compatMode=="BackCompat"?document.body:document.documentElement);
      return doc;
     },
     
     /*script*/
     loadScript:function(name){
      if(VeryIDE.script[name]) return true;
     
      var root=document.getElementsByTagName("HEAD")[0];
      
      var script=document.createElement("script");
      script.type="text/javascript";
      script.src=VeryIDE.folder.js +"veryide."+ name+".js";
      root.appendChild(script);
     },
     
     showScript:function(){
      var str="";
      for(var key in VeryIDE.script){
       str+="veryide."+key+".js"+"\n";
      }
      alert(str);
     },
     
     showNavigator:function(){
      var str="";
      for(var key in navigator){
       str+= key+": "+navigator[key]+"\n";
      }
      alert(str);
     }, 
     
     /*event*/
     getMouse:function(e){
      if(!document.all){
       VeryIDE.mouseX = e.pageX;
       VeryIDE.mouseY = e.pageY;
      }else{
       VeryIDE.mouseX = e.x + VeryIDE.getDocment().scrollLeft;
       VeryIDE.mouseY = e.y + VeryIDE.getDocment().scrollTop;
      }
     },
     
     /*status*/
     setStatus:function(str){
      window.status=str;
     },
      
     /*message*/
     showMessage:function(str,fun){
      if (typeof fun != 'function') {
       alert(str.replace("<br />","\n\n"));
      }else{
       fun(str);
      }
     },

     /*test*/
     test:function(){
      // <input type="button" class="input-button" value="测 试" onclick="VeryIDE.test();" />
      VeryIDE.showError("拖动框测试<br />拖动框测试<br />拖动框测试");
     }
     
    }

    VeryIDE.start();

    /*state*/
    VeryIDE.script["core"]=true;

    ===================================================

       js :veryide.library.js

    ===================================================

    /*
    * Copyright VeryIDE,2007-2008
    * http://www.veryide.com/

    * $Id: veryide.library.js,v2.3 17:29 2008-11-16 leilei $
    */


    function $(obj){return document.getElementById(obj);}
    function $N(obj){return document.getElementsByName(obj);}
    function $T(obj){return document.getElementsByTagName(obj);}

    function $V(str){document.write(str);}

    //body load
    function addLoadEvent(func) {
     var oldonload = window.onload;
     if (typeof window.onload != 'function') {
      window.onload = func;
     } else {
      window.onload = function() {
       oldonload();
       func();
      }
     }
    }

    //object event
    function addObjectEvent(ele,evt,func){
     var oldonevent = ele['on'+evt];
     if (typeof ele['on'+evt] != 'function') {
      ele['on'+evt] = func;
     } else {
      ele['on'+evt] = function(event) {
       oldonevent(event);
       func(event);
      }
     }
    }

    //key event
    function addKeyEvent(key,func){
     if(!VeryIDE.tmpKey){
      VeryIDE.tmpKey=[];
     }
     
     VeryIDE.tmpKey["k"+key]=func;
    }

    addKeyEvent.Listener=function(e,test){
     var event=e||window.event;
     if(VeryIDE.tmpKey["k"+event.keyCode]){
      VeryIDE.tmpKey["k"+event.keyCode](event);
     }
     if(test){
      alert(event.keyCode);
     }
    }
    //onkeydown判断charCode/keyCode

    //获取对象
    function getObject(o){
     if(typeof(o)!="object"){
      var o=$(o);
     }
     return o;
    }

    /*
    String.prototype.trim = function(){
       return this.replace(/(^\s+)|\s+$/g,"");
    }
    */

    String.prototype.Trim = function(){
        return this.replace(/(^\s*)|(\s*$)/g, "");
    }
    String.prototype.LTrim = function(){
        return this.replace(/(^\s*)/g, "");
    }
    String.prototype.Rtrim = function(){
        return this.replace(/(\s*$)/g, "");
    }

    //返回字符串字节数
    String.prototype.long = function(){
     var i;
     var l = this.length;
     var len;
     len = 0;
     for (i=0;i<l;i++){
      if (this.charCodeAt(i)>255)
       len+=2;
      else
       len++;
     }
     return len;
    }

    //检查在数组内是否存在某值
    function inArray(a,v) {
     var l = a.length;
     for(var i=0; i<=l; i++) {
      if(a[i]==v) return true;
     }
     return false;
    }

    //class为*的所有元素
    document.getElementsByClassName = function() {
      var children = document.getElementsByTagName('*') || document.all;
      var elements = new Array();
      var len = children.length;

      for (var i = 0; i < len; i++) {
        var child = children[i];
        var classNames = child.className.split(' ');
        for (var j = 0; j < classNames.length; j++) {
         for (var k = 0; k < arguments.length; k++) { 
       if (classNames[j] == arguments[k]) {
              elements.push(child);
              break;
            }
          }
        }
      }
     
      return elements;
    }

    //ID以*开头的所有元素
    document.getElementsByPrefix = function(prefix) {
      var children = document.getElementsByTagName('*') || document.all;
      var elements = new Array();
      var len = children.length;
     
      for (var i = 0; i < len; i++) {
        var child = children[i];
        var eid = child.id;
        if(eid&&eid.indexOf(prefix)>-1)
            elements.push(child);
      }
     
      return elements;
    }

    /*查找页面Meta*/    
    function getMeta(name,att){
      metatags = document.getElementsByTagName("meta");
      for (cnt = 0; cnt < metatags.length; cnt++){                  
        if(metatags[cnt].getAttribute("name")==name){
          if(!att){
            return metatags[cnt];
          }else{
            return metatags[cnt].getAttribute(att);
          }
        }else{
          return null;
        }
      }
    }

    //加载新脚本
    function loadScript(src,target){
     if(!target){
      var root=$T("HEAD")[0];
     }else{
      var root=getObject(target);
     }
     
     var script=document.createElement("script");
     script.type="text/javascript";
     script.src=src;
     
     var code=arguments[2];
     if(code){
      script.charset=code;
     }
     
     root.appendChild(script);
    }

    //取得文件名
    function getFileName(url){
     var strUrl=location.href;
     if(url){
      strUrl=url;
     }
     var arrUrl=strUrl.split("/");
     var strPage=arrUrl[arrUrl.length-1];
     return strPage;
    }

    //对象绝对位置
    function getPosition(obj){ 
     var obj=getObject(obj);

     this.width=obj.offsetWidth;
     this.height=obj.offsetHeight; 
     this.top=obj.offsetTop; 
     this.left=obj.offsetLeft; 
     while(obj=obj.offsetParent){ 
      this.top+=obj.offsetTop; 
      this.left+=obj.offsetLeft;
     }
    }

    function getSelect(obj){
     var obj=getObject(obj);
     
     this.value="";
     this.text="";
     this.index="";
     
     if(obj.length>0){
      this.value=obj[obj.selectedIndex].value;
      this.text=obj[obj.selectedIndex].text;
      this.index=obj.selectedIndex;
     }
     this.getAtt=function(att){
      return obj[obj.selectedIndex].getAttribute(att);
     }
    }

    //
    function getRadio(obj){
     var obj=$N(obj);
     var len = obj.length;
     
     this.value="";
     for(var i=0;i<len;i++){
      if(obj[i].checked==true){
       this.value=obj[i].value;
       break;
      }
     }
    }

    //对象显示隐藏
    function showHide(obj){
     var obj=getObject(obj);
     if(obj){
      if(obj.offsetHeight==0||obj.style.display== "none") {obj.style.display = "block";}else{obj.style.display = "none";}
     }
    }

    function setCheckBox(obj,v){
     var obj=$N(obj);

     if(obj[0]){
      var len = obj.length;
      for(var i=0;i<len;i++){
       if(obj[i].value==v){
        obj[i].checked=true;
       }else{
        obj[i].checked=false;
       }
      }
     }else{
      obj=$(obj);
      if(obj.value==v){
       obj.checked=true;
      }else{
       obj[i].checked=false;
      }
     }
    }

    //选择列表项
    function setSelect(obj,v){
     var obj=$(obj);
     var len = obj.length;
     for(var i=0;i<len;i++){
      if(obj[i].value == v){
       obj.selectedIndex=i;
       break;
      }
     }
    }

    //选择单选项
    function setRadio(o,v){  
     var obj=$N(o);
     var len = obj.length;
     for(var i=0;i<len;i++){
      if(obj[i].value == v){
       obj[i].checked=true;
       break;
      }
     }
    }

    //禁用对象
    function setDisabled(obj,b){ 
     var obj=getObject(obj);
     if (obj){obj.disabled=b;}
    }

    function setClass(obj,Class,Type){
     var obj=getObject(obj);
     if(obj){
      switch(Type){
       case "+":
        obj.className+=" "+Class;
       break;
       
       case "-":
        obj.className=obj.className.replace(Class,"");
       break;
       
       case "":
        obj.className=Class;
       break;
       
      }
     }
    }

    //新建连续下接列表项
    function newNumOption(obj,s,e,t){
     var obj=getObject(obj);
     if(t=="new"){obj.length=0;}
     for(var i=s;i<(e+1);i++){
      obj.options[obj.length] = new Option(i,i);
     }
    }

    //删除对象
    function delElement(obj){
     var obj=getObject(obj);
     var p=obj.parentNode;
     p.removeChild(obj);
    }

    //确认操作
    function getConfirm(info){
     if(!confirm(info)){return false}
    }

    //新窗口打开链接
    //rel="_blank"
    function _blank(){
     var anchors = document.getElementsByTagName("A");
     var len = anchors.length;
     for (var i=0; i<len; i++) {
      var anchor = anchors[i];
      if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "_blank"){
       anchor.target = "_blank";
      }
     }
    }

    //获取URL参数
    function getQuery(n,url){
     if(!url){
      var url=location.href;
     }
     
     var v = '';
     var o = url.indexOf(n+"=");
     if (o != -1){
      o += n.length + 1 ;
      e = url.indexOf("&", o);
      if (e == -1){
       e = url.length;
      }
      v = unescape(url.substring(o, e));
     }
     
     //seo
     if(!v){
      var o = url.indexOf(n+"-");
      if (o != -1){
       o += n.length + 1 ;
       e = url.indexOf("-", o);
       if (e == -1){
        e = url.length;
       }
       v = unescape(url.substring(o, e));
      }
     }
     
     return v;
    }

    //全角转半角
    function switchChar(str){
     var str1="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     var str2="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     
     var len=str.length;
     for(var i=0; i<len; i++){
      var n = str2.indexOf(str.charAt(i));
      if(n != -1) str = str.replace(str.charAt(i), str1.charAt(n));
     }
     return str;
    }

    /*
     获取随机字符
     ***********
     len  长度
     vUpper 是否大写字母
     vLower 是否小写字母
     vNum  是否数字
    */
    function getRnd(len,vUpper,vLower,vNum){
     var seed_array=new Array();
     var seedary;

     seed_array[0]=""
     seed_array[1]= "a b c d e f g h i j k l m n o p q r s t u v w x y z";
     seed_array[2]= "a b c d e f g h i j k l m n o p q r s t u v w x y z";
     seed_array[3]= "0 1 2 3 4 5 6 7 8 9";

     if (!vUpper&&!vLower&&!vNum){vUpper=true;vLower=true;vNum=true;}

     if (vUpper){seed_array[0]+=seed_array[1];}
     if (vLower){seed_array[0]+=" "+seed_array[2];}
     if (vNum){seed_array[0]+=" "+seed_array[3];}

     seed_array[0]= seed_array[0].split(" ");
     seedary="";
     
     for (var i=0;i<len;i++){
      seedary+=seed_array[0][Math.round(Math.random()*(seed_array[0].length-1))]
     }
     return(seedary);
    }


    /*
     获取cookies
     name cookie名称
     sub  子cookie名称
    */
    function getCookie(name,sub){
     var str="";
     var arr = document.cookie.replace(/%25/g,"%").replace(/%5F/g,"_").match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr !=null){
      try{
       str=decodeURIComponent(arr[2]);
      }catch(e){
       str=arr[2];
      }
     }
     
     if(sub){
      if(str){
       var nSubValueBegin = str.indexOf(sub+"=");
      }else{
       var nSubValueBegin =-1
      }
      
      if(nSubValueBegin != -1){
       var nSubValueEnd = str.indexOf("&", nSubValueBegin);
       if(nSubValueEnd == -1)
       nSubValueEnd = str.length;
       var sSubValue = str.substring(nSubValueBegin + sub.length+1, nSubValueEnd);//获得指定的子键值
       str=sSubValue;
      }else{
       str="";
      }
     }
     return str;
    }

    function setCookie(key,value,iExpireDays,domain){
     var cookies=key.replace("_","%5F") + "=" + encodeURIComponent(value)+ "; ";
     
     if (iExpireDays){
      var dExpire = new Date();
      dExpire.setTime(dExpire.getTime()+parseInt(iExpireDays*24*60*60*1000));
      cookies += "expires=" + dExpire.toGMTString()+ "; ";
     }
     
     if(domain){
      cookies += "domain="+domain+"; ";
     }
     cookies += "path=/;";
     document.cookie = cookies;
    }

    /*state*/
    VeryIDE.script["library"]=true;

    =================================================

    以上完全可以合成艺术字,下载地址http://www.100disk.net/pick.aspx?code=1846447509

  • 相关阅读:
    Java中字符串中子串的查找共有四种方法(indexof())
    idea常用快捷键
    用hive或mr清洗app数据
    使用kafka作为生产者生产数据到hdfs(单节点)
    使用kafka作为生产者生产数据到hdfs
    c++ map的使用
    c++ set集合的使用
    c++ 木块问题
    c++ 大理石
    c 蛇形数字
  • 原文地址:https://www.cnblogs.com/ggbbeyou/p/1356879.html
Copyright © 2011-2022 走看看