test

原创 2005年05月25日 09:58:00

//puzzExt.js

    puzzLeft = puzzTop = null;
    puzzWidth = puzzHeight = null;
    bordWidth = 3;

    puzzAcross = puzzDown = 5;

    isPuzzDraggable = true;
    isGrid = false;
   
    isNewPuzz = null;
    isCreated = null;

    piecesCreated = 0
    pieceCount = 1;
    topCount = 0;

    isBroken = false;

    solvedCount = 1;
        pieceToSolve = null;

    flashTotal = 5;
    flashCount = 0;

    loadTotal = 3;
    loadCount = 0;

    tempEl = null;
    sp = " ";

function whenLoaded() {
    loadCount++;
    if (loadCount < loadTotal) { return };
    if (isPuzzDraggable) {
        elPuzzle.draggable = true;
        elPuzzle.style.cursor = "move";
    }
    else {
        elPuzzle.draggable = false;   
        dragBut.value = "Drag OFF";
    }

    elPuzzle.clipLeft = elPuzzle.clipTop = 0;
    initPuzz();
}

function initPuzz() {
    if (isBroken) {allDone(false)};
    puzzWidth = document.images["imOrig"].width;
    puzzHeight =  document.images["imOrig"].height;
    elPuzzle.style.width  = elControls.style.width = puzzWidth;
    elPuzzle.style.visibility = "visible";
    isNewPuzz = true;
    isCreated = false;
    pieceToSolve = 1;
}

function createPieces(){
    puzzPieces = puzzAcross * puzzDown;
    if (puzzPieces > piecesCreated) {
        makeStart = piecesCreated+1;
        for(i=makeStart; i<=puzzPieces; i++) {
            window.status = "Creating puzzle piece... " + i;
                   
            divStr = "<DIV ID=PIECE" + i + " CLASS=clPuzzPiece>"
                   + "<IMG NAME=imPiece" + i + " ></DIV>";

            document.body.insertAdjacentHTML("BeforeEnd",divStr);
            tempEl = eval("PIECE" + i);
            tempEl.draggable = true;           
        }
    piecesCreated = puzzPieces;
    }
    activeEl = eval("PIECE" + puzzPieces);
}

function createPuzzle() {
    if (!isCreated) { createPieces() };
    pieceWidth = puzzWidth/puzzAcross;
    pieceHeight = puzzHeight/puzzDown;

    while (pieceCount<=puzzPieces) {
        pixT = topCount * pieceHeight;
        pixB = (topCount + 1) * pieceHeight;

        for (i=1; i<=puzzAcross; i++) {
            window.status="Clipping image for piece... " + pieceCount;

            tempEl = eval("PIECE" + pieceCount);

            document.images["imPiece" + pieceCount].src = document.images["imOrig"].src;
            tempEl.style.pixelLeft = puzzLeft;
            tempEl.style.pixelTop = puzzTop;

            pixR = pieceWidth * i;
            pixL = pieceWidth * (i-1);       
            tempEl.style.clip = "rect(" + pixT + sp + pixR + sp + pixB + sp + pixL + ")";
            tempEl.clipLeft = pixL;
            tempEl.clipTop = pixT;
            pieceCount++
        }
        topCount++
    }
    if (isGrid) {setGrid()};   
    isNewPuzz = false;
    isCreated = true;
    pieceCount=1;
    topCount=0;
    window.status = "";
}

function breakUp() {
    puzzLeft = elPuzzle.style.pixelLeft + bordWidth;
    puzzTop = elPuzzle.style.pixelTop + bordWidth;
    pieceToSolve = 1;

    if (isNewPuzz && isBroken) { allDone(false) };
    if (isNewPuzz) { createPuzzle() };

    if (isPuzzDraggable) {
        elPuzzle.draggable = false;
        elPuzzle.style.cursor = "default";
    }
    elImOrig.style.visibility = "hidden";

    startL = document.body.scrollLeft;
    startT = document.body.scrollTop;
    endL = (startL + document.body.offsetWidth) - puzzWidth;
    endT = (startT + document.body.offsetHeight) - puzzHeight;

    for (i=1; i<=puzzPieces; i++) {
        putL = getRandNums(startL,endL);
        putT = getRandNums(startT,endT);

        tempEl = eval("PIECE" + i);
        tempEl.draggable = true;
        tempEl.style.pixelLeft = putL;
        tempEl.style.pixelTop = putT;
        tempEl.style.cursor = "move";
        tempEl.style.visibility = "visible";
    }

    if (isGrid) {elGrid.style.visibility = "visible"};

    isBroken = true;
    solvedCount=1;
}

function getRandNums(from,to){

    temp = parseInt((Math.random() * (to-from)) + (from));
    while (isNaN(temp)) {
        temp = parseInt((Math.random() * (to - from)) + (from))
    }
    return temp
}

function setGrid() {
    elImGrid.style.width = (9/puzzAcross) * puzzWidth;
    elImGrid.style.height = (9/puzzDown) * puzzHeight;
    elGrid.style.clip = "rect(0 " + puzzWidth + " " + puzzHeight + " 0)";
    gridBut.value = "Grid ON";
    if (isBroken) {elGrid.style.visibility = "visible"}
}

function visToggle(isFullSolve){
    if (flashCount!=flashTotal) {
        tempEl.style.visibility = (tempEl.style.visibility=='visible') ? 'hidden' : 'visible';
        flashCount++;
    }
    else {
        clearInterval(flashTimer);
        flashCount=0;
        tempEl.style.visibility = "visible";
        if (tempEl != elImOrig) {origPos(tempEl)};
        if (isFullSolve) {pieceToSolve++; solve(true) }
    }
}

function solve(isFullSolve) {
    if (!isBroken) { return };
    if (pieceToSolve > puzzPieces) { pieceToSolve=1; return }
    tempEl = eval("PIECE" + pieceToSolve);
    if (tempEl.draggable){
        if (tempEl != activeEl ) {
            tempEl.style.zIndex = activeEl.style.zIndex + 1;
            activeEl = tempEl;
        }

    flashTimer = setInterval("visToggle(" + isFullSolve + ")",100);

    }
    else { pieceToSolve++; solve(isFullSolve) };

}

   function origPos(tempEl) {
        tempEl.style.pixelLeft = puzzLeft;
        tempEl.style.pixelTop = puzzTop;
        tempEl.draggable=false;
        tempEl.style.cursor = 'default';
        solvedCount++;
        if (solvedCount > puzzPieces) {
            allDone(true);
        }
    }

function allDone(solved){
       for (i=1; i<=puzzPieces; i++) {
        tempEl = eval("PIECE" + i);
        tempEl.style.visibility = "hidden";
    }
    elImOrig.style.visibility = "visible";
    if (isGrid) { elGrid.style.visibility = "hidden" };
    if (isPuzzDraggable) {
        elPuzzle.draggable = true;
        elPuzzle.style.cursor = "move";
    }

    solvedCount = 1;
    if (solved) {
        isBroken = false;
        tempEl = elImOrig;
        flashTimer = setInterval("visToggle(false)",100);
    }
}

function giveHint() {
    if (isBroken) { solve(false) };
}

function gridToggle(){
    if (isGrid) {
        elGrid.style.visibility = "hidden";
        elImGrid.style.width=1;
        elImGrid.style.height=1;
        gridBut.value = "Grid OFF";
    }
    else { setGrid() };
    isGrid = !isGrid;
}

function dragToggle(){
    isPuzzDraggable = !isPuzzDraggable;
    if (!isBroken) { elPuzzle.draggable = !elPuzzle.draggable };
    if (isPuzzDraggable) {
        elPuzzle.style.cursor = "move";
        dragBut.value = "Drag ON";
    }
    else {
        elPuzzle.style.cursor = "default";
        dragBut.value = "Drag OFF";
    }
}

Struts2 用 s:if test 判断属性和字符串相等时 注意双引号和单引号的使用

字符串N一定要用“”双引号包含,从test的包含则用单引号 ‘ ’,如果相反,则不能正确判断该属性是否与该字符串相等。 正确: 错误: 因为java是强类型语言,单引号表...

A/B test 到底应该怎么做?

/ B测试,也称为对比测试,是让两个版本的登陆页面的相互pk测试。看看哪个版本能更好地引导访问者达到你的预设目标,如注册或订阅。可以通过测试两个设计方式迥异的登陆页面或者尝试一些局部调整,例如某一版本...
  • joeyon
  • joeyon
  • 2015年01月14日 17:57
  • 1184

maven中使用spring的test包结合junit4进行测试。

1.先在src/test/resources中加入spring的配置文件spring.xml 2.引入maven org.springframework spring-tes...
  • czlpf
  • czlpf
  • 2015年08月04日 17:39
  • 10480

《工作杂记》之phoronix-test-suite

1 下载官方下载网址www.phoronix-test-suite.com 从官网下载后获得phoronix-test-suite-7.6.0m1.tar.gz源码包 解压到当前目录 $tar -zx...

对web项目的执行过程的理解,从一个http请求如http://localhost:8080/test/login.action开始

对web项目的执行过程的理解,内容包括1 http url  2 html、servlet、jsp 3 tomcat等。web项目的整个执行过程,从一个http请求如http://localhost:...

有关camera image quality test 的网站,软件,链接

image quality test: 1、http://www.imatest.com/   点击打开链接   Imatest provides customers with software, ...
  • baraba
  • baraba
  • 2016年11月23日 11:34
  • 943

Google Test(GTest)使用方法和源码解析——结果统计机制分析

本文分析了GTest框架中结果统计机制的实现

001test 测试程序

001test 测试程序002test 测试程序003test 测试程序004test 测试程序005test 测试程序006test 测试程序007test 测试程序008test 测试程序009t...
  • D98A12B
  • D98A12B
  • 2011年05月05日 22:41
  • 100

[DP]【最大全零矩阵】【2015.7.9TEST】E

E 0.9 seconds, 32 MB “ 于是乎,你至少证明了你智商比金天成高,也就说你证明了你不是低智儿童,不错不错。 然而这次, 我貌似也卡住了,你给我打下手吧。勇敢的少年啊快去创造奇迹...

利用mmc_test.c研究mmc模块

mmc初始化流程研究及mmc_test.c的使用 不清楚mmc_test.c的作者希望大家如何利用该模块,通过向该模块的probe函数传入一个合法的mmc_card指针,便可完成对该模块的使用。...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:test
举报原因:
原因补充:

(最多只允许输入30个字)