HTML5技术

jQuery-H5-css3转盘抽奖-遁地龙卷风 - 遁地龙卷风(3)

字号+ 作者:H5之家 来源:H5之家 2016-10-03 11:00 我要评论( )

$(this).css("left",parent != window ?(parent.offsetWidth-this.offsetWidth)/2:(parent.innerWidth-this.offsetWidth)/2); $(this).css("top",parent != window ?(parent.offsetHeight-this.offsetHeight)/2:(pa

                 $(this).css("left",parent != window ?(parent.offsetWidth-this.offsetWidth)/2:(parent.innerWidth-this.offsetWidth)/2);

                 $(this).css("top",parent != window ?(parent.offsetHeight-this.offsetHeight)/2:(parent.innerHeight-this.offsetHeight)/2);

           }

           else

           {

                 window.console.error("没有设置有效的position值");

           }

     })

     return this;

}   

function next(current)

{

     var parent = current.parentNode,

           children = parent.children,

           //childNodes、nextSibling maybe contain ObjectText

           length = children.length;

     for(var i=0;i<length;i++)

     {

           if(current == children[i])

                 break;

     }

     //if not lastChild

     if(i<length-1)

     {

           return children[i+1];

     }

     else

     {

           //recursion search until parent == document.body

           if(parent != document.body)

           {

                 return next(parent);

           }

           else

           {

                 window.console.warn("Can not get next sibling");

           }

     }

    

}

function getRandomInteger(min,max)

{

     return Math.floor(Math.random()*(max-min+1))+min

}

function imitateMouseEvent(element,type)

{

     var event = document.createEvent("Events");

     event.initEvent(type,true,true);

     element.dispatchEvent(event);

}

showMessage.i = 0;

function showMessage(object)

{

     var body = $("body")[0];

     var $p =$("#debugp");

    

     if($p.length==0)

     {

           $p = $("<p/>").attr("id","debugp");

           $(body).prepend($p);

     }

     $p[0].innerHTML += "<br/>"+(showAttribute.i++)+"   |   "+object;

}

showAttribute.i=0;

function showAttribute(object,filter)

{

     var body = $("body")[0];

     var $p =$("#debugp");

    

     if($p.length==0)

     {

           $p = $("<p/>").attr("id","debugp");

           $(body).prepend($p);

     }

     if(getType(filter).indexOf(DataType.string)!=-1)

     {

           for(var a in object)

           {

                 if(a.indexOf(filter)!=-1)

                 {

                      $p[0].innerHTML += a+"   "+object[a]+"<br/>";

                 }

           }

     }

     else if(getType(filter) == DataType.RegExp)

     {

           for(var a in object)

           {

                 if(filter.test(a))

                 {

                      $p[0].innerHTML += a+"   "+object[a]+"<br/>";

                 }

           }

     }

     else if(getType(filter) == DataType.UNDEFINED)

     {

           for(var a in object)

           {

                 $p[0].innerHTML += a+"   "+object[a]+"<br/>";

           }   

     }

     else

     {

           window.console.error(arguments.callee.toString().match(/^function +(.+)\(/)[1]+"第二个参数应传递字符串或正则表达式");

     }

     $p[0].innerHTML +=showAttribute.i+++"--------------------------------------<br/>"

}

function showCollection(collection)

{

     var body = $("body")[0];

     var $p =$("#debugp");

    

     if($p.length==0)

     {

           $p = $("<p/>").attr("id","debugp");

           $(body).prepend($p);

     }

     for(var i=0;i<collection.length;i++)

     $p[0].innerHTML = collection[i]+"    |"+"<br/>" + $p[0].innerHTML;

}

function showLength(collection)

{

     var body = $("body")[0];

     var $p =$("#debugp");

    

     if($p.length==0)

     {

           $p = $("<p/>").attr("id","debugp");

           $(body).prepend($p);

     }

     $p[0].innerHTML = collection.length+"     |"+"<br/>" +      $p[0].innerHTML;

}

function DataType()

{

    

}

DataType.RegExp = "RegExp";

DataType.ObjectString = "Objectstring";

DataType.string = "string";

DataType.NULL = "null";

DataType.UNDEFINED = "undefined";

DataType.ObjectNumber = "Objectnumber";

DataType.number = "number";

DataType.ObjectBoolean = "Objectboolean";

DataType.boolean = "boolean";

DataType.function = "function";

DataType.array = "array";

function getType(type)

{

     if(typeof type == DataType.UNDEFINED)

  {

    return DataType.UNDEFINED;

  }

  else if(typeof type == "object")

  {

    if(type == null)

    {

      return DataType.NULL ;

    }

    else

    {

                

      if(typeof type.valueOf() == DataType.string)

      {

        return DataType.ObjectString

      }

      else if(typeof type.valueOf() == DataType.number)

      {

        return DataType.ObjectNumber;

      }

      else if(typeof type.valueOf() == DataType.boolean)

      {

        return DataType.ObjectBoolean;

      }

      else if(type instanceof Array)

      {

        return DataType.array;

      }

                 else if(type instanceof RegExp)

                 {

                      return DataType.RegExp;

                 }

                 else if(typeof type.constructor == DataType.function)

                 {

                      return type.constructor.toString().match(/^function +(.+)\(/)[1];

                 }

                

    }

  }

  else if(typeof type == DataType.function)

  {

    return DataType.function

 

  }

  else

  {

    return typeof type;

  }

}                         

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • HTML5 Canvas绘制转盘抽奖 - givebest

    HTML5 Canvas绘制转盘抽奖 - givebest

    2016-03-28 11:00

  • 青瓷qici - H5小游戏 抽奖机 1 素材 - $JackChen

    青瓷qici - H5小游戏 抽奖机 1 素材 - $JackChen

    2016-03-04 12:00

  • 青瓷qici - H5小游戏 抽奖机 “one-arm bandit” - $JackChen

    青瓷qici - H5小游戏 抽奖机 “one-arm bandit” - $JackChen

    2016-03-04 11:00

  • Html5-Canvas实现简易的抽奖转盘 - VVJason

    Html5-Canvas实现简易的抽奖转盘 - VVJason

    2015-09-24 12:00

网友点评