<commit_before>// MIT License
//
// Copyright (c) 2017 Eric Laspe
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

// Ported to Processing.js from my Khan Academy project, here:
// https://www.khanacademy.org/computer-programming/brick-brick-gear-pixel-creator/5760802139734016

var cOrange = color(255, 132, 0);
var cYellow = color(238, 255, 0);
var cBrown = color(161, 106, 47);
var cBlack = color(0, 0, 0);
var cPink = color(254, 187, 223);
var cBlue = color(41, 59, 255);
var cNavy = color(0, 12, 117);
var cGray = color(140, 140, 140);
var cPeach = color(255, 206, 122);
var cGreen = color(0, 184, 0);
var cPurple = color(144, 0, 196);
var cRed = color(255, 0, 0);
var cWhite = color(255, 255, 255);
var cErase = color(50, 50, 50);
var cTransparent = color(255, 0, 0, 0);

var paletteColors = [
    cWhite, cBlack, cGray, cNavy, cBlue,
    cYellow, cPeach, cOrange, cRed, cPurple,
    cGreen, cBrown, cPink, cErase
];

var paletteOffsetX = 125;
var paletteOffsetY = 320;
var paletteNCols = 5;
var palettePSize = 70;
var paletteLen = paletteColors.length;
var paletteSelected = 0;

var boardBgColor = cBlack + 1;
var boardStColor = color(40, 40, 40);

var drawColor = paletteColors[0];
var nCols = 36;
var nRows = 16;
var nPixels = nCols * nRows;
var pSize = floor(600 / nCols);
var offset = 12;
var pA = [nPixels];
var pCounts = [paletteLen];

var f = createFont("monospace");
textFont(f);

var paletteGetLowerBoundX = function(i) {
    return palettePSize * (i % paletteNCols) + paletteOffsetX;
};

var paletteGetLowerBoundY = function(i) {
    return palettePSize * floor(i / paletteNCols) + paletteOffsetY;
};

var paletteDraw = function() {
    var textStr;
    var currentColor;

    strokeWeight(2);
    stroke(cWhite);
    fill(cWhite);

    rect(paletteGetLowerBoundX(0) - 1,
         paletteGetLowerBoundY(0) - 1,
         palettePSize * paletteNCols + 2,
         palettePSize * 3 + 2);

    for (var i = 0; i < paletteLen; i++) {
        currentColor = paletteColors[i];
        strokeWeight(2);
        stroke(cWhite);
        fill(currentColor);
        rect(paletteGetLowerBoundX(i),
             paletteGetLowerBoundY(i),
             palettePSize, palettePSize);

        if (currentColor === cErase) {
            textStr = 'Eraser';
        } else {
            textStr = pCounts[i];

            // Draw the nib
            if (currentColor === cNavy)
                stroke(cBlack);
            else
                stroke(boardStColor);

            fill(currentColor);
            ellipse(paletteGetLowerBoundX(i) + palettePSize * 0.5 + 2,
                    paletteGetLowerBoundY(i) + palettePSize * 0.5 + 2,
                    palettePSize * 0.6, palettePSize * 0.6);
            ellipse(paletteGetLowerBoundX(i) + palettePSize * 0.5,
                    paletteGetLowerBoundY(i) + palettePSize * 0.5,
                    palettePSize * 0.6, palettePSize * 0.6  );
        }

        // Print counts in contrasting color
        if (currentColor <= cErase) {
            fill(255, 255, 255);
        } else {
            fill(40, 40, 40);
        }
        textSize(14);
        text(textStr,
             paletteGetLowerBoundX(i) + palettePSize * 0.05,
             paletteGetLowerBoundY(i) + palettePSize * 0.2);
    }

    // Stroke selected color in white
    strokeWeight(4);
    stroke(cBlack);
    fill(cTransparent);

    rect(paletteGetLowerBoundX(paletteSelected),
         paletteGetLowerBoundY(paletteSelected),
         palettePSize, palettePSize);
};

var updatePixelCounts = function() {
    var c, i;
    for (c = 0; c < paletteLen; c++) {
        pCounts[c] = 0;
    }

    for (i = 0; i < nPixels; i++) {
        for (c = 0; c < paletteLen; c++) {
            if (pA[i] === paletteColors[c]) {
                ++pCounts[c];
            }
        }
    }

    paletteDraw();
};

var paletteHit = function(mX, mY) {
    var hitColor;
    var i;
    var lowerX, lowerY;

    for (var i = 0; i < paletteLen; i++) {
        lowerX = paletteGetLowerBoundX(i);
        lowerY = paletteGetLowerBoundY(i);

        if (mX >= lowerX && mX < lowerX + palettePSize &&
            mY >= lowerY && mY < lowerY + palettePSize) {

            hitColor = paletteColors[i];
            drawColor = hitColor;
            paletteSelected = i;
            paletteDraw();
            return true;
        }
    }

    return false;
};

// Based on the linear gradient here:
// http://processingjs.org/learning/basic/lineargradient/
var setGradient = function(w, h) {
    var i, j;
    var fromColor = cGray;
    var toColor = cWhite;
    var c;

    // calculate differences between color components
    var deltaR = red(toColor) - red(fromColor);
    var deltaG = green(toColor) - green(fromColor);
    var deltaB = blue(toColor) - blue(fromColor);

    /*nested for loops set pixels
     in a basic table structure */
    // column
    for (i = 0; i <= w; i++) {
        // row
        for (j = 0; j <= h; j++) {
            c = color((red(fromColor)+j*(deltaR/h)),
                      (green(fromColor)+j*(deltaG/h)),
                      (blue(fromColor)+j*(deltaB/h)));
            set(i, j, c);
        }
    }
};

var boardGetLowerBound = function(i) {
    return floor(i * pSize + offset);
};

var numberColumns = function() {
    var i;

    fill(cGray);
    textSize(10);

    text(1, pSize, 11);
    for (i = 0; i <= nCols; i += 4) {
        if (i != 0)
            text(i, i * pSize, 11);
    }
};

var numberRows = function(i) {
    var i;

    fill(cGray);
    textSize(10);

    for (i = 1; i <= nRows; i += 3) {
        if (i < 10)
            text(i, 7, i * pSize + 8);
        else
            text(i, 1, i * pSize + 8);
    }
};

var boardInit = function() {
    for (var i = 0; i < nCols; i++) {
        for (var j = 0; j < nRows; j++) {

            // Init each pixel color
            pA[nCols * j + i] = boardBgColor;
        }
    }

    updatePixelCounts();
    boardDraw();
};

var boardBgDraw = function() {
    fill(boardBgColor);
    rect(0, 0, 600, pSize * (nRows + 2), 12);
};

var boardDraw = function() {
    var i, j;
    var pixelColor = pA
    var cornerX, cornerY;
    var circleOffset = pSize/2;
    var circleDiam = 8;
    var LabelNum = 1;

    strokeWeight(1);
    noStroke();

    boardBgDraw();
    numberColumns();
    numberRows();

    for (i = 0; i < nCols; i++) {
        for (j = 0; j < nRows; j++) {

            // Get pixel parameters
            pixelColor = pA[nCols * j + i];
            cornerX = boardGetLowerBound(i);
            cornerY = boardGetLowerBound(j);

            if (pixelColor === boardBgColor)
                noStroke();
            else
                stroke(boardStColor);

            // Draw pixel
            fill(pixelColor);
            rect(cornerX,
                 cornerY,
                 pSize, pSize);

            // Draw the nib
            if (pixelColor === boardBgColor)
                stroke(boardStColor);
            else if (pixelColor === cBlack)
                stroke(color(70, 70, 70));
            else
                stroke(cBlack);

            ellipse(cornerX + circleOffset + 1,
                    cornerY + circleOffset + 1,
                    circleDiam, circleDiam);
            ellipse(cornerX + circleOffset,
                    cornerY + circleOffset,
                    circleDiam, circleDiam);
        }
    }

};

var boardHit = function(mX, mY) {
    var i, j;
    var lowerX, lowerY;
    var pixelColor;

    for (i = 0; i < nCols; i++) {
        for (j = 0; j < nRows; j++) {
            lowerX = boardGetLowerBound(i);
            lowerY = boardGetLowerBound(j);

            if (mX >= lowerX && mX < lowerX + pSize &&
                mY >= lowerY && mY < lowerY + pSize) {

                pixelColor = drawColor;
                if (drawColor === cErase) {
                    pixelColor = boardBgColor;
                }
                pA[nCols * j + i] = pixelColor;
                updatePixelCounts();
                boardDraw();
                return;
            }
        }
    }
};

void mouseDragged() {
    // Only check for board hit on drag
    var pixHit = boardHit(mouseX, mouseY);
};

void mousePressed() {
    // Only check for board hit on drag
    var pixHit = boardHit(mouseX, mouseY);
};

void mouseReleased() {
    // First check for palette hit
    if (paletteHit(mouseX, mouseY)) {
        return;
    }

    // Next check for board hit
    boardHit(mouseX, mouseY);
};

void setup() {
    size(600, 600);
    background(cWhite);
    setGradient(600, 500);

    boardInit();
    paletteDraw();
}
<commit_msg>Fix row numbering<commit_after>// MIT License
//
// Copyright (c) 2017 Eric Laspe
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

// Ported to Processing.js from my Khan Academy project, here:
// https://www.khanacademy.org/computer-programming/brick-brick-gear-pixel-creator/5760802139734016

var cOrange = color(255, 132, 0);
var cYellow = color(238, 255, 0);
var cBrown = color(161, 106, 47);
var cBlack = color(0, 0, 0);
var cPink = color(254, 187, 223);
var cBlue = color(41, 59, 255);
var cNavy = color(0, 12, 117);
var cGray = color(140, 140, 140);
var cPeach = color(255, 206, 122);
var cGreen = color(0, 184, 0);
var cPurple = color(144, 0, 196);
var cRed = color(255, 0, 0);
var cWhite = color(255, 255, 255);
var cErase = color(50, 50, 50);
var cTransparent = color(255, 0, 0, 0);

var paletteColors = [
    cWhite, cBlack, cGray, cNavy, cBlue,
    cYellow, cPeach, cOrange, cRed, cPurple,
    cGreen, cBrown, cPink, cErase
];

var paletteOffsetX = 125;
var paletteOffsetY = 320;
var paletteNCols = 5;
var palettePSize = 70;
var paletteLen = paletteColors.length;
var paletteSelected = 0;

var boardBgColor = cBlack + 1;
var boardStColor = color(40, 40, 40);

var drawColor = paletteColors[0];
var nCols = 36;
var nRows = 16;
var nPixels = nCols * nRows;
var pSize = floor(600 / nCols);
var offset = 12;
var pA = [nPixels];
var pCounts = [paletteLen];

var f = createFont("monospace");
textFont(f);

var paletteGetLowerBoundX = function(i) {
    return palettePSize * (i % paletteNCols) + paletteOffsetX;
};

var paletteGetLowerBoundY = function(i) {
    return palettePSize * floor(i / paletteNCols) + paletteOffsetY;
};

var paletteDraw = function() {
    var textStr;
    var currentColor;

    strokeWeight(2);
    stroke(cWhite);
    fill(cWhite);

    rect(paletteGetLowerBoundX(0) - 1,
         paletteGetLowerBoundY(0) - 1,
         palettePSize * paletteNCols + 2,
         palettePSize * 3 + 2);

    for (var i = 0; i < paletteLen; i++) {
        currentColor = paletteColors[i];
        strokeWeight(2);
        stroke(cWhite);
        fill(currentColor);
        rect(paletteGetLowerBoundX(i),
             paletteGetLowerBoundY(i),
             palettePSize, palettePSize);

        if (currentColor === cErase)
            textStr = 'Eraser';
        else
            textStr = pCounts[i];

        // Print counts in contrasting color
        if (currentColor <= cErase) {
            fill(255, 255, 255);
        } else {
            fill(40, 40, 40);
        }
        textSize(14);
        text(textStr,
             paletteGetLowerBoundX(i) + palettePSize * 0.05,
             paletteGetLowerBoundY(i) + palettePSize * 0.2);
    }

    // Stroke selected color in white
    strokeWeight(4);
    stroke(cBlack);
    fill(cTransparent);

    rect(paletteGetLowerBoundX(paletteSelected),
         paletteGetLowerBoundY(paletteSelected),
         palettePSize, palettePSize);
};

var updatePixelCounts = function() {
    var c, i;
    for (c = 0; c < paletteLen; c++) {
        pCounts[c] = 0;
    }

    for (i = 0; i < nPixels; i++) {
        for (c = 0; c < paletteLen; c++) {
            if (pA[i] === paletteColors[c]) {
                ++pCounts[c];
            }
        }
    }

    paletteDraw();
};

var paletteHit = function(mX, mY) {
    var hitColor;
    var i;
    var lowerX, lowerY;

    for (var i = 0; i < paletteLen; i++) {
        lowerX = paletteGetLowerBoundX(i);
        lowerY = paletteGetLowerBoundY(i);

        if (mX >= lowerX && mX < lowerX + palettePSize &&
            mY >= lowerY && mY < lowerY + palettePSize) {

            hitColor = paletteColors[i];
            drawColor = hitColor;
            paletteSelected = i;
            paletteDraw();
            return true;
        }
    }

    return false;
};

// Based on the linear gradient here:
// http://processingjs.org/learning/basic/lineargradient/
var setGradient = function(w, h) {
    var i, j;
    var fromColor = cGray;
    var toColor = cWhite;
    var c;

    // calculate differences between color components
    var deltaR = red(toColor) - red(fromColor);
    var deltaG = green(toColor) - green(fromColor);
    var deltaB = blue(toColor) - blue(fromColor);

    /*nested for loops set pixels
     in a basic table structure */
    // column
    for (i = 0; i <= w; i++) {
        // row
        for (j = 0; j <= h; j++) {
            c = color((red(fromColor)+j*(deltaR/h)),
                      (green(fromColor)+j*(deltaG/h)),
                      (blue(fromColor)+j*(deltaB/h)));
            set(i, j, c);
        }
    }
};

var boardGetLowerBound = function(i) {
    return floor(i * pSize + offset);
};

var numberColumns = function() {
    var i;

    fill(cGray);
    textSize(10);

    text(1, pSize, 11);
    for (i = 0; i <= nCols; i += 4) {
        if (i != 0)
            text(i, i * pSize, 11);
    }
};

var numberRows = function(i) {
    var i;

    fill(cGray);
    textSize(10);

    text(1, 7, pSize + 8);
    for (i = 0; i <= nRows; i += 4) {
        if (i === 0)
            continue;
        if (i < 10)
            text(i, 7, i * pSize + 8);
        else
            text(i, 1, i * pSize + 8);
    }
};

var boardInit = function() {
    for (var i = 0; i < nCols; i++) {
        for (var j = 0; j < nRows; j++) {

            // Init each pixel color
            pA[nCols * j + i] = boardBgColor;
        }
    }

    updatePixelCounts();
    boardDraw();
};

var boardBgDraw = function() {
    fill(boardBgColor);
    rect(0, 0, 600, pSize * (nRows + 2), 12);
};

var boardDraw = function() {
    var i, j;
    var pixelColor = pA
    var cornerX, cornerY;
    var circleOffset = pSize/2;
    var circleDiam = 8;
    var LabelNum = 1;

    strokeWeight(1);
    noStroke();

    boardBgDraw();
    numberColumns();
    numberRows();

    for (i = 0; i < nCols; i++) {
        for (j = 0; j < nRows; j++) {

            // Get pixel parameters
            pixelColor = pA[nCols * j + i];
            cornerX = boardGetLowerBound(i);
            cornerY = boardGetLowerBound(j);

            if (pixelColor === boardBgColor)
                noStroke();
            else
                stroke(boardStColor);

            // Draw pixel
            fill(pixelColor);
            rect(cornerX,
                 cornerY,
                 pSize, pSize);

            // Draw the nib
            if (pixelColor === boardBgColor)
                stroke(boardStColor);
            else if (pixelColor === cBlack)
                stroke(color(70, 70, 70));
            else
                stroke(cBlack);

            ellipse(cornerX + circleOffset + 1,
                    cornerY + circleOffset + 1,
                    circleDiam, circleDiam);
            ellipse(cornerX + circleOffset,
                    cornerY + circleOffset,
                    circleDiam, circleDiam);
        }
    }

};

var boardHit = function(mX, mY) {
    var i, j;
    var lowerX, lowerY;
    var pixelColor;

    for (i = 0; i < nCols; i++) {
        for (j = 0; j < nRows; j++) {
            lowerX = boardGetLowerBound(i);
            lowerY = boardGetLowerBound(j);

            if (mX >= lowerX && mX < lowerX + pSize &&
                mY >= lowerY && mY < lowerY + pSize) {

                pixelColor = drawColor;
                if (drawColor === cErase) {
                    pixelColor = boardBgColor;
                }
                pA[nCols * j + i] = pixelColor;
                updatePixelCounts();
                boardDraw();
                return;
            }
        }
    }
};

void mouseDragged() {
    // Only check for board hit on drag
    var pixHit = boardHit(mouseX, mouseY);
};

void mousePressed() {
    // Only check for board hit on drag
    var pixHit = boardHit(mouseX, mouseY);
};

void mouseReleased() {
    // First check for palette hit
    if (paletteHit(mouseX, mouseY)) {
        return;
    }

    // Next check for board hit
    boardHit(mouseX, mouseY);
};

void setup() {
    size(600, 600);
    background(cWhite);
    setGradient(600, 500);

    boardInit();
    paletteDraw();
}
<|endoftext|>


<commit_before>/**
 * Dual licensed under the Apache License 2.0 and the MIT license.
 * $Revision$ $Date$
 */
(function($)
{
    // Remap cometd JSON functions to jquery JSON functions
    org.cometd.JSON.toJSON = $.toJSON;
    org.cometd.JSON.fromJSON = $.evalJSON;

    function _setHeaders(xhr, headers)
    {
        if (headers)
        {
            for (var headerName in headers)
            {
                if (headerName.toLowerCase() === 'content-type')
                {
                    continue;
                }
                xhr.setRequestHeader(headerName, headers[headerName]);
            }
        }
    }

    // The default cometd instance
    $.cometd = new org.cometd.Cometd();

    // Remap toolkit-specific transport calls
    $.cometd.LongPollingTransport = function()
    {
        this.xhrSend = function(packet)
        {
            return $.ajax({
                url: packet.url,
                type: 'POST',
                contentType: 'text/json;charset=UTF-8',
                data: packet.body,
                beforeSend: function(xhr)
                {
                    _setHeaders(xhr, packet.headers);
                    // Returning false will abort the XHR send
                    return true;
                },
                success: packet.onSuccess,
                error: function(xhr, reason, exception)
                {
                    packet.onError(reason, exception);
                }
            });
        };
    };
    $.cometd.LongPollingTransport.prototype = new org.cometd.LongPollingTransport();
    $.cometd.LongPollingTransport.prototype.constructor = $.cometd.LongPollingTransport;

    $.cometd.CallbackPollingTransport = function()
    {
        this.jsonpSend = function(packet)
        {
            $.ajax({
                url: packet.url,
                type: 'GET',
                dataType: 'jsonp',
                jsonp: 'jsonp',
                data: {
                    // In callback-polling, the content must be sent via the 'message' parameter
                    message: packet.body
                },
                beforeSend: function(xhr)
                {
                    _setHeaders(xhr, packet.headers);
                    // Returning false will abort the XHR send
                    return true;
                },
                success: packet.onSuccess,
                error: function(xhr, reason, exception)
                {
                    packet.onError(reason, exception);
                }
            });
        };
    };
    $.cometd.CallbackPollingTransport.prototype = new org.cometd.CallbackPollingTransport();
    $.cometd.CallbackPollingTransport.prototype.constructor = $.cometd.CallbackPollingTransport;

    $.cometd.registerTransport('long-polling', new $.cometd.LongPollingTransport());
    $.cometd.registerTransport('callback-polling', new $.cometd.CallbackPollingTransport());

})(jQuery);
<commit_msg>Fix for COMETD-39: javascript-jquery should not be using raw "eval" for JSON.<commit_after>/**
 * Dual licensed under the Apache License 2.0 and the MIT license.
 * $Revision$ $Date$
 */
(function($)
{
    // Remap cometd JSON functions to jquery JSON functions
    org.cometd.JSON.toJSON = $.toJSON;
    org.cometd.JSON.fromJSON = $.secureEvalJSON;

    function _setHeaders(xhr, headers)
    {
        if (headers)
        {
            for (var headerName in headers)
            {
                if (headerName.toLowerCase() === 'content-type')
                {
                    continue;
                }
                xhr.setRequestHeader(headerName, headers[headerName]);
            }
        }
    }

    // The default cometd instance
    $.cometd = new org.cometd.Cometd();

    // Remap toolkit-specific transport calls
    $.cometd.LongPollingTransport = function()
    {
        this.xhrSend = function(packet)
        {
            return $.ajax({
                url: packet.url,
                type: 'POST',
                contentType: 'text/json;charset=UTF-8',
                data: packet.body,
                beforeSend: function(xhr)
                {
                    _setHeaders(xhr, packet.headers);
                    // Returning false will abort the XHR send
                    return true;
                },
                success: packet.onSuccess,
                error: function(xhr, reason, exception)
                {
                    packet.onError(reason, exception);
                }
            });
        };
    };
    $.cometd.LongPollingTransport.prototype = new org.cometd.LongPollingTransport();
    $.cometd.LongPollingTransport.prototype.constructor = $.cometd.LongPollingTransport;

    $.cometd.CallbackPollingTransport = function()
    {
        this.jsonpSend = function(packet)
        {
            $.ajax({
                url: packet.url,
                type: 'GET',
                dataType: 'jsonp',
                jsonp: 'jsonp',
                data: {
                    // In callback-polling, the content must be sent via the 'message' parameter
                    message: packet.body
                },
                beforeSend: function(xhr)
                {
                    _setHeaders(xhr, packet.headers);
                    // Returning false will abort the XHR send
                    return true;
                },
                success: packet.onSuccess,
                error: function(xhr, reason, exception)
                {
                    packet.onError(reason, exception);
                }
            });
        };
    };
    $.cometd.CallbackPollingTransport.prototype = new org.cometd.CallbackPollingTransport();
    $.cometd.CallbackPollingTransport.prototype.constructor = $.cometd.CallbackPollingTransport;

    $.cometd.registerTransport('long-polling', new $.cometd.LongPollingTransport());
    $.cometd.registerTransport('callback-polling', new $.cometd.CallbackPollingTransport());

})(jQuery);
<|endoftext|>


<commit_before>'use strict';

var d                   = require('d')
  , db = require('mano').db
  , ns = require('mano').domjs.ns
  , headersMap = require('../utils/headers-map')
  , resolvePropertyPath = require('dbjs/_setup/utils/resolve-property-path');

module.exports = Object.defineProperty(db.FormEntitiesTable.prototype, 'toDOM',
	d(function (document/*, options */) {
		var self, headerRank, options, resolved;
		self = this;
		options = Object(arguments[1]);
		headerRank = options.headerRank || 3;
		resolved = resolvePropertyPath(this.master, this.constructor.propertyName);
		return ns.section({ class: 'entity-data-section' },
			(function () {
				if (self.label) {
					return [headersMap[headerRank++](self._label), ns.hr()];
				}
				headerRank++;
			}()),
			ns._if(resolved.value._size,
				ns.ul({ class: 'entity-data-section-entities' },
					resolved.value,
					function (entityObject) {
						return ns.li(headersMap[headerRank](
							resolvePropertyPath(entityObject, self.constructor.entityTitleProperty).value
						), ns.list(resolvePropertyPath(entityObject, self.constructor.sectionProperty).value,
							function (section) {
								return section.toDOM(document, { headerRank: headerRank + 1 });
							}));
					}
					), ns.p({ class: 'entity-data-section-empty' }, self.constructor.onEmptyMessage)));
	}));
<commit_msg>Assure correct display of entity title<commit_after>'use strict';

var d                   = require('d')
  , db = require('mano').db
  , ns = require('mano').domjs.ns
  , headersMap = require('../utils/headers-map')
  , resolvePropertyPath = require('dbjs/_setup/utils/resolve-property-path');

module.exports = Object.defineProperty(db.FormEntitiesTable.prototype, 'toDOM',
	d(function (document/*, options */) {
		var self, headerRank, options, resolved;
		self = this;
		options = Object(arguments[1]);
		headerRank = options.headerRank || 3;
		resolved = resolvePropertyPath(this.master, this.constructor.propertyName);
		return ns.section({ class: 'entity-data-section' },
			(function () {
				if (self.label) {
					return [headersMap[headerRank++](self._label), ns.hr()];
				}
				headerRank++;
			}()),
			ns._if(resolved.value._size,
				ns.ul({ class: 'entity-data-section-entities' },
					resolved.value,
					function (entityObject) {
						return ns.li(headersMap[headerRank](
							resolvePropertyPath(entityObject, self.constructor.entityTitleProperty).observable
						), ns.list(resolvePropertyPath(entityObject, self.constructor.sectionProperty).value,
							function (section) {
								return section.toDOM(document, { headerRank: headerRank + 1 });
							}));
					}
					), ns.p({ class: 'entity-data-section-empty' }, self.constructor.onEmptyMessage)));
	}));
<|endoftext|>


<commit_before>'use strict';

module.exports = function(express) {

  const router = express.Router();
  const async = require('async');
  let groceryLists = require('../models/grocery_lists.js');
  let ingredients = require('../models/ingredients.js');
  let users = require('../models/users.js');
  const db = require('../server/db.js');

  router.route('/')

  .put((req, res) => {
    let data = req.body;

    async.waterfall([
      (callback) => {
        users.find(data,
        (err) => {
          res.status(500).json({ error: err });
        },
        (foundUser) => {
          callback(null, foundUser);
        });
      },
      (foundUser, callback) => {
        groceryLists.create(data,
        (err) => {
          res.status(500).json({ error: err });
        },
        (createdList) => {
          callback(null, createdList)
        });
      }
    ],
    (err, createdList) => {
      if(err) {
        res.status(500).json({ error: err });
      }
      res.status(200).json({ createdList });
    });
  })

  .delete((req, res) => {
    let data = req.body;

    async.waterfall([
      (callback) => {
        groceryLists.find(data,
        (err) => {
          res.status(500).json({ error: err });
        },
        (deletedList) => {
          callback(null, deletedList);
        });
      }
    ],
    (err, deletedList) => {
      if(err) {
        res.status(500).json({ error: err });
      }
      res.status(200).json({ deletedList });
    });
  });

  router.route('/:userId')

  .get((req, res) => {
    let userId = req.params.userId;

    async.waterfall([
      (callback) => {
        groceryLists.findAll(
        (err) => {
          res.status(500).json({ error: err });
        },
        (allLists) => {
          let userGroceryLists = [];
          for(let i = 0; i < allLists.length; i++) {
            if(allLists[i].userId === userId) {
              userGroceryLists.push(allLists[i]);
            }
          }
          callback(null, userGroceryLists)l
        });
      }
    ],
    (err, userGroceryLists) => {
      if(err) {
        res.status(500).json({ error: err });
      }
      res.status(200).json({ userGroceryLists });
    });
  });

  return router;
};
<commit_msg>added semi colons<commit_after>'use strict';

module.exports = function(express) {

  const router = express.Router();
  const async = require('async');
  let groceryLists = require('../models/grocery_lists.js');
  let ingredients = require('../models/ingredients.js');
  let users = require('../models/users.js');
  const db = require('../server/db.js');

  router.route('/')

  .put((req, res) => {
    let data = req.body;

    async.waterfall([
      (callback) => {
        users.find(data,
        (err) => {
          res.status(500).json({ error: err });
        },
        (foundUser) => {
          callback(null, foundUser);
        });
      },
      (foundUser, callback) => {
        groceryLists.create(data,
        (err) => {
          res.status(500).json({ error: err });
        },
        (createdList) => {
          callback(null, createdList)
        });
      }
    ],
    (err, createdList) => {
      if(err) {
        res.status(500).json({ error: err });
      }
      res.status(200).json({ createdList });
    });
  })

  .delete((req, res) => {
    let data = req.body;

    async.waterfall([
      (callback) => {
        groceryLists.find(data,
        (err) => {
          res.status(500).json({ error: err });
        },
        (deletedList) => {
          callback(null, deletedList);
        });
      }
    ],
    (err, deletedList) => {
      if(err) {
        res.status(500).json({ error: err });
      }
      res.status(200).json({ deletedList });
    });
  });

  router.route('/:userId')

  .get((req, res) => {
    let userId = req.params.userId;

    async.waterfall([
      (callback) => {
        groceryLists.findAll(
        (err) => {
          res.status(500).json({ error: err });
        },
        (allLists) => {
          let userGroceryLists = [];
          for(let i = 0; i < allLists.length; i++) {
            if(allLists[i].userId === userId) {
              userGroceryLists.push(allLists[i]);
            }
          };
          callback(null, userGroceryLists)l
        });
      }
    ],
    (err, userGroceryLists) => {
      if(err) {
        res.status(500).json({ error: err });
      }
      res.status(200).json({ userGroceryLists });
    });
  });

  return router;
};
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import { Button } from 'antd';
import { Link } from 'react-router-dom';
import Newsletter from '../../../components/Newsletter';
import styled from 'styled-components';
import { media } from '../../../utils/media';
import { ReactComponent as Logo } from '../../../assets/logo/JamhacksFullV.svg';

import './Hero.css';

const registerLinks = [
  'https://wvmzd7k3wc0.typeform.com/to/hTLmCfSw',
  'https://wvmzd7k3wc0.typeform.com/to/ZomNkpto',
  /*'https://uhsftk4mjsw.typeform.com/to/nBOIo2cb',*/
  /*'https://uhsftk4mjsw.typeform.com/to/Ef4CMC4A',*/
  /*'https://uhsftk4mjsw.typeform.com/to/skRsl7ss',*/
];

const Hero = ({ register }) => {
  return (


<commit_before>'use-strict';

process.env.NODE_ENV = 'test';

var chai = require('../../helper/setup-chai')
  , PostCtrl = require('../../../lib/controller/post')
  , status = require('../../../lib/server/status')
  , request = require('../../helper/setup-supertest')('http://localhost:3001')
  , mongoInit = require('../../init/mongo-init')
  , postInit = require('../../init/posts-init')
  , login = require('../../helper/login')(request)
  , logout = require('../../helper/logout')(request)
  ;

describe('Add Post API', () => {

  before((done) => {
    mongoInit.connect().then(postInit).catch(console.log).fin(done);
  });

  after((done) => {
    postInit().then(mongoInit.disconnect).catch(console.log).fin(done);
  });

  describe("#addPost", () => {
    /* 익명의 사용자 접근 여부 테스트 */
    it('should not allow access to anonymous users', (done) => {
      request
        .post('/api/v1/posts')
        .send({
          title: 'testPost4',
          text: 'testPost4',
          univid: '56ac6f7b9b0d0b0457673daf'
        })
        .toPromise()
        .then((res) => {
          res.body.status.should.be.equal(status.codes.UserAuthRequired.code);
          res.body.value.should.have.property('message');
        })
        .then(done)
        .catch(done)
        .done();
    });

    /* 관리자 접근 여부 테스트 */
    it('should allow access to admin users', (done) => {
      login('admin@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPost4',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(0);
          // res.body.status.should.be.equal(status.codes.UserPermissionNotAllowed.code);
          // res.body.value.should.have.property('message');
        })
        .then(postInit)
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* 게시물 제목 */
    // 1: 게시물 제목이 있어야
    it('should not have empty title', (done) => {
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              // title: ,
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TitleOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    // 2: 게시물 제목에 space나 newline만 있으면 안 됨
    it('should have title with not only white space and newline but also meaningful words', (done) => {
      // login('test@test.com', 'test')
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: '    \n    ',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TitleOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    // 3: 게시물 제목이 ''일 때
    it('should not have \'null\' title', (done) => {
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: '',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TitleOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* 게시물 내용 */
    // 1: 게시물 내용이 있어야
    it('should not have empty text', (done) => {
      // login('test@test.com', 'test')
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPost4',
              // text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TextOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });
    // 2: 게시물 내용에 space나 newline만 있으면 안 됨
    it('should have text with not only white space and newline but also meaningful words', (done) => {
      // login('test@test.com', 'test')
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPost4',
              text: '    \n   ',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TextOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* 맞는 pid 인가 */
    it('should get the right pid of the post', (done) => {
      var pid = -1;
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPostTitle4',
              text: 'testPostText4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(0);
          res.body.value.should.exist;
          pid = res.body.value;
          return request
            .get('/api/v1/posts/' + pid)
            .toPromise();
        })
        .then((res) => {
          res.body.value.should.have.property('title', 'testPostTitle4');
          res.body.value.should.have.property('text', 'testPostText4');
        })
        .then(postInit)
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* addPost 했을 때, universities의 getPosts에서 제대로 추가 되어 있는지 확인 */
    it('should get right posts when add post', (done) => {
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'TEST',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(0);
          res.body.value.should.have.lengthOf(24);

          var pid = res.body.value;
          var univId = '56ac6f7b9b0d0b0457673daf';

          return request
            .get('/api/v1/universities/'+ univId +'/posts')
            .toPromise();
        })
        .then((res) => {
          res.body.value[0].should.have.property('title', 'TEST'); /////////////// is this right? I thought 0th element is the most recent one
        })
        .then(postInit)
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });
    /* addPost 했을 때 글 쓴 학교외 다른 학교의 getPosts에 나오지 않는 것 확인 */
    it('should not show the post added when get posts in another University', (done) => {
      var anotherUnivId = '77cc6f7b9b0d0b0457673daa';
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'TEST',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then(logout)
        // .then((res) => {
        //   // var pid = res.body.value;
        //   logout();
        // })
        .then(() => {
          // console.log("login again");
          login('admin@test.com', 'test');
        })
        .then(() => {
          return request
            .get('/api/v1/universities/'+ anotherUnivId +'/posts')
            .toPromise();
        })
        .then((res) => {
          // console.log(res.body.value);
          res.body.value[0].should.not.have.property('title', 'TEST');
        })
        .then(postInit)
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });
  });
});<commit_msg>change test code in add post<commit_after>'use-strict';

process.env.NODE_ENV = 'test';

var chai = require('../../helper/setup-chai')
  , PostCtrl = require('../../../lib/controller/post')
  , status = require('../../../lib/server/status')
  , request = require('../../helper/setup-supertest')('http://localhost:3001')
  , mongoInit = require('../../init/mongo-init')
  , postInit = require('../../init/posts-init')
  , login = require('../../helper/login')(request)
  , logout = require('../../helper/logout')(request)
  ;

describe('Add Post API', () => {

  before((done) => {
    mongoInit.connect().then(postInit).catch(console.log).fin(done);
  });

  after((done) => {
    postInit().then(mongoInit.disconnect).catch(console.log).fin(done);
  });

  describe("#addPost", () => {
    /* 익명의 사용자 접근 여부 테스트 */
    it('should not allow access to anonymous users', (done) => {
      request
        .post('/api/v1/posts')
        .send({
          title: 'testPost4',
          text: 'testPost4',
          univid: '56ac6f7b9b0d0b0457673daf'
        })
        .toPromise()
        .then((res) => {
          res.body.status.should.be.equal(status.codes.UserAuthRequired.code);
          res.body.value.should.have.property('message');
        })
        .then(done)
        .catch(done)
        .done();
    });

    /* 관리자 접근 여부 테스트 */
    it('should allow access to admin users', (done) => {
      login('admin@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPost4',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(0);
          // res.body.status.should.be.equal(status.codes.UserPermissionNotAllowed.code);
          // res.body.value.should.have.property('message');
        })
        .then(postInit)
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* 게시물 제목 */
    // 1: 게시물 제목이 있어야
    it('should not have empty title', (done) => {
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              // title: ,
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TitleOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    // 2: 게시물 제목에 space나 newline만 있으면 안 됨
    it('should have title with not only white space and newline but also meaningful words', (done) => {
      // login('test@test.com', 'test')
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: '    \n    ',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TitleOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    // 3: 게시물 제목이 ''일 때
    it('should not have \'null\' title', (done) => {
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: '',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TitleOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* 게시물 내용 */
    // 1: 게시물 내용이 있어야
    it('should not have empty text', (done) => {
      // login('test@test.com', 'test')
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPost4',
              // text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TextOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });
    // 2: 게시물 내용에 space나 newline만 있으면 안 됨
    it('should have text with not only white space and newline but also meaningful words', (done) => {
      // login('test@test.com', 'test')
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPost4',
              text: '    \n   ',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(status.codes.TextOfPostIsInvalid.code);
          res.body.value.should.have.property('message');
        })
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* 맞는 pid 인가 */
    it('should get the right pid of the post', (done) => {
      var pid = -1;
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'testPostTitle4',
              text: 'testPostText4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(0);
          res.body.value.should.exist;
          pid = res.body.value;
          return request
            .get('/api/v1/posts/' + pid)
            .toPromise();
        })
        .then((res) => {
          res.body.value.should.have.property('title', 'testPostTitle4');
          res.body.value.should.have.property('text', 'testPostText4');
        })
        .then(postInit)
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });

    /* addPost 했을 때, universities의 getPosts에서 제대로 추가 되어 있는지 확인 */
    it('should get right posts when add post', (done) => {
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'TEST',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then((res) => {
          res.body.status.should.be.equal(0);
          res.body.value.should.have.lengthOf(24);

          var pid = res.body.value;
          var univId = '56ac6f7b9b0d0b0457673daf';

          return request
            .get('/api/v1/universities/'+ univId +'/posts')
            .toPromise();
        })
        .then((res) => {
          res.body.value[0].should.have.property('title', 'TEST'); /////////////// is this right? I thought 0th element is the most recent one
        })
        .then(postInit)
        .then(logout)
        .then(done)
        .catch(done)
        .done();
    });
    /* addPost 했을 때 글 쓴 학교외 다른 학교의 getPosts에 나오지 않는 것 확인 */
    it('should not show the post added when get posts in another University', (done) => {
      var anotherUnivId = '77cc6f7b9b0d0b0457673daa';
      login('test@test.com', 'test')
        .then(() => {
          return request
            .post('/api/v1/posts')
            .send({
              title: 'TEST',
              text: 'testPost4',
              univid: '56ac6f7b9b0d0b0457673daf'
            })
            .toPromise();
        })
        .then(logout)
        .then(() => {
          login('admin@test.com', 'test')
            .then(() => {
              return request
              .get('/api/v1/universities/'+ anotherUnivId +'/posts')
              .toPromise();
            })
            .then((res) => {
              res.body.value[0].should.not.have.property('title', 'TEST');
            })
            .then(postInit)
            .then(logout)
            .then(done)
            .catch(done)
            .done();
        });
        // .then(logout)
    });
  });
});<|endoftext|>


<commit_before>/**
 * Copyright (C) 2009 Orbeon, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free Software Foundation; either version
 * 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "Controls in repeat (also tests setvalue/getvalue)",

    repeatRebuildWorker: function(controlId) {
        var fullId = controlId + XFORMS_SEPARATOR_1 + "1";
        YAHOO.util.Assert.areEqual("true", ORBEON.xforms.Document.getValue(fullId));
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue("repeat-shown", "false");
        }, function() {
            ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
                ORBEON.xforms.Document.setValue("repeat-shown", "true");
            }, function() {
                YAHOO.util.Assert.areEqual("true", ORBEON.xforms.Document.getValue(fullId));
                YAHOO.util.Assert.areEqual("Label", ORBEON.xforms.Controls.getLabelMessage(YAHOO.util.Dom.get(fullId)));
            });
        });
   },

   testInput: function() { this.repeatRebuildWorker("input"); },
   testTextarea: function() { this.repeatRebuildWorker("textarea"); },
   testSecret: function() { this.repeatRebuildWorker("secret"); },
   testInputBoolean: function() { this.repeatRebuildWorker("input-boolean"); }

}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:select1 appearance=full",

    dateValueInputId: "date-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",

    getSelect: function(controlId) {
        var control = YAHOO.util.Dom.get(controlId);
        return ORBEON.util.Utils.getProperty(NEW_XHTML_LAYOUT_PROPERTY)
            ? control.getElementsByTagName("select")[0]
            : control;
    },

    testAddToItemset: function() {
        // Get initial value for flavor and carrier
        var flavorSelect1 = YAHOO.util.Dom.get("flavor-select1-full" + XFORMS_SEPARATOR_1 + "1");
        var carrierSelect1 = YAHOO.util.Dom.get("carrier-select1-full" + XFORMS_SEPARATOR_1 + "1");
        var initialFlavorValue = ORBEON.xforms.Controls.getCurrentValue(flavorSelect1);
        var initialCarrierValue = ORBEON.xforms.Controls.getCurrentValue(carrierSelect1);
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            // Click on text field
            var addTrigger = YAHOO.util.Dom.get("add-flavor-carrier" + XFORMS_SEPARATOR_1 + "1");
            YAHOO.util.UserAction.click(addTrigger);
        }, function() {
            // Check that the values didn't change
            YAHOO.util.Assert.areEqual(initialFlavorValue, ORBEON.xforms.Controls.getCurrentValue(flavorSelect1));
            YAHOO.util.Assert.areEqual(initialCarrierValue, ORBEON.xforms.Controls.getCurrentValue(carrierSelect1));
       });
    },

    testUpdateRadio: function() {
         ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
             // Click on DHL radio
             var dhlRadio = YAHOO.util.Dom.get("carrier-select1-full$$e2" + XFORMS_SEPARATOR_1 + "1");
             dhlRadio.click();
         }, function() {
             // Check DHL checkbox is checked, and DHL item in lists is selected
             YAHOO.util.Assert.isTrue(YAHOO.util.Dom.get("carrier-select-full$$e2" + XFORMS_SEPARATOR_1 + "1").checked);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select1-compact" + XFORMS_SEPARATOR_1 + "1").options[2].selected);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[2].selected);
        });
    },

    testUpdateList: function() {
         ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
             // Set value in list to TNT
             var select1List = this.getSelect("carrier-select1-compact" + XFORMS_SEPARATOR_1 + "1");
             ORBEON.xforms.Controls.setCurrentValue(select1List, select1List.options[3].value);
             ORBEON.xforms.Events.change({target: select1List});
         }, function() {
             // Check TNT radio button and checkbox is checked, and TNT item in list is selected
             YAHOO.util.Assert.isTrue(YAHOO.util.Dom.get("carrier-select1-full$$e3" + XFORMS_SEPARATOR_1 + "1").checked);
             YAHOO.util.Assert.isTrue(YAHOO.util.Dom.get("carrier-select-full$$e3" + XFORMS_SEPARATOR_1 + "1").checked);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[3].selected);
        });
    },

    testUpdateCheckbox: function() {
         ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
             // Click on DHL checkbox (in addition to already selected TNT)
             var dhlCheckbox = YAHOO.util.Dom.get("carrier-select-full$$e2" + XFORMS_SEPARATOR_1 + "1");
             dhlCheckbox.click();
         }, function() {
             // Check DHL and TNT are selected in the list
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[2].selected);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[3].selected);
        });
    }
}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:input type xs:date",

    dateValueControlId: "date-value" + XFORMS_SEPARATOR_1 + "1",
    dateValueInputId: "date-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",

    testOpenHideCalendar: function() {
        // Click on text field
        YAHOO.util.UserAction.click(this.dateValueInputId);
        // Check calendar div shown
        YAHOO.util.Assert.areEqual("block", document.getElementById("orbeon-calendar-div").style.display);
        // Click on body
        YAHOO.util.UserAction.click(document.body);
        // Check calendar div is hidden
        YAHOO.util.Assert.areEqual("none", document.getElementById("orbeon-calendar-div").style.display);
    },

    testCantOpenReadonly: function() {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue("readonly", "true");
        }, function() {
            // Check input field has been disabled
            YAHOO.util.Assert.areEqual(true, document.getElementById(this.dateValueInputId).disabled);
            // Click on text field
            YAHOO.util.UserAction.click(this.dateValueInputId);
            // Check that the div is still hidden
            YAHOO.util.Assert.areEqual("none", document.getElementById("orbeon-calendar-div").style.display);
            // Restore read-only = false
            ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
                ORBEON.xforms.Document.setValue("readonly", "false");
            }, function() {});
        });
    },

    checkDateConversion: function(twoDigits, fourDigits) {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            // This year taken in the 21th century
            ORBEON.xforms.Document.setValue(this.dateValueControlId, "1/1/" + twoDigits);
        }, function() {
            YAHOO.util.Assert.areEqual(fourDigits + "-01-01", ORBEON.xforms.Document.getValue(this.dateValueControlId));
       });
    },

    testTwoDigitClose: function() { this.checkDateConversion ("02", "2002"); },
    testTwoDigitTwentyFirst: function() { this.checkDateConversion ("40", "2040"); },
    testTwoDigitTwentieth: function() { this.checkDateConversion ("85", "1985"); }
}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:input type xs:time",

    timeValueId: "time-value" + XFORMS_SEPARATOR_1 + "1",
    timeValueInputId: "time-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",
    dateValueId: "date-value" + XFORMS_SEPARATOR_1 + "1",
    dateValueInputId: "date-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",

    workerTimeParsing: function(typedValue, expectedValue) {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue(this.timeValueId, typedValue);
        }, function() {
            YAHOO.util.Assert.areEqual(expectedValue, YAHOO.util.Dom.get(this.timeValueInputId).value);
        });
    },

    // Test for: Regression: dateTime field is always invalid when "p.m." is entered
    // http://forge.objectweb.org/tracker/?func=detail&atid=350207&aid=313427&group_id=168
    testParsing: function() {
        var parsedTime = ORBEON.util.DateTime.magicTimeToJSDate("6:00:00 p");
        YAHOO.util.Assert.isNotNull(parsedTime);
    },

    testFirstHourShort:     function() { this.workerTimeParsing("12 am",        "0:00:00 a.m."); },
    testFirstHourMedium:    function() { this.workerTimeParsing("12:30 am",     "0:30:00 a.m."); },
    testFirstHourLong:      function() { this.workerTimeParsing("12:30:40 am",  "0:30:40 a.m."); },
    testNoAmPmShort:        function() { this.workerTimeParsing("12",           "12:00:00 p.m."); },
    testNoAmPmMedium:       function() { this.workerTimeParsing("12:30",        "12:30:00 p.m."); },
    testNoAmPmLong:         function() { this.workerTimeParsing("12:30:40",     "12:30:40 p.m."); },

    testNextYear: function() {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue(this.dateValueId, "10/20/2030");
        }, function() {
            // Click on Next Year
            ORBEON.xforms.Events.click({target: YAHOO.util.Dom.get(this.dateValueInputId) });
            var nextYear = YAHOO.util.Dom.getElementsByClassName("calyearright", null, "orbeon-calendar-div")[0];
            YAHOO.util.UserAction.click(nextYear);
            this.wait(function() {
                var monthYear = YAHOO.util.Dom.getElementsByClassName("calnav", null, "orbeon-calendar-div")[0];
                // Check we are no in 2031
                YAHOO.util.Assert.areEqual("October 2031", monthYear.innerHTML);
                // Click previous year twice
                var previousYear = YAHOO.util.Dom.getElementsByClassName("calyearleft", null, "orbeon-calendar-div")[0];
                YAHOO.util.UserAction.click(previousYear);
                YAHOO.util.UserAction.click(previousYear);
                this.wait(function() {
                    // Check we are no in 2029
                    monthYear = YAHOO.util.Dom.getElementsByClassName("calnav", null, "orbeon-calendar-div")[0];
                    YAHOO.util.Assert.areEqual("October 2029", monthYear.innerHTML);
                    YAHOO.util.UserAction.click(document.body);
                }, XFORMS_INTERNAL_SHORT_DELAY_IN_MS);
            }, XFORMS_INTERNAL_SHORT_DELAY_IN_MS);
        });

    }
}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:output appearance=\"xxforms:download\"",

    outputFileId: "output-file-value" + XFORMS_SEPARATOR_1 + "1",

    // Test that the control is correctly restored when the iteration is recreated
    // http://forge.objectweb.org/tracker/index.php?func=detail&aid=313369&group_id=168&atid=350207
    testRepeatCreate: function() {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue("repeat-shown", "false");
        }, function() {
            ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
                ORBEON.xforms.Document.setValue("repeat-shown", "true");
            }, function() {
                var control = document.getElementById(this.outputFileId);
                var children = YAHOO.util.Dom.getChildren(control);
                // Check we still have the link
                YAHOO.util.Assert.areEqual(1, children.length);
                var a = children[0];
                // The link points to a dynamic resource
                YAHOO.util.Assert.areNotEqual(-1, a.href.indexOf("/orbeon/xforms-server/dynamic/"));
                // The text for the link is still the same
                YAHOO.util.Assert.areEqual("Download file", ORBEON.util.Dom.getStringValue(a));
            });
        });
    }
}));

ORBEON.xforms.Events.orbeonLoadedEvent.subscribe(function() {
    if (parent && parent.TestManager) {
        parent.TestManager.load();
    } else {
        new YAHOO.tool.TestLogger();
        YAHOO.tool.TestRunner.run();
    }
});
<commit_msg>Fix text for IE in new xhtml mode<commit_after>/**
 * Copyright (C) 2009 Orbeon, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free Software Foundation; either version
 * 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "Controls in repeat (also tests setvalue/getvalue)",

    repeatRebuildWorker: function(controlId) {
        var fullId = controlId + XFORMS_SEPARATOR_1 + "1";
        YAHOO.util.Assert.areEqual("true", ORBEON.xforms.Document.getValue(fullId));
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue("repeat-shown", "false");
        }, function() {
            ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
                ORBEON.xforms.Document.setValue("repeat-shown", "true");
            }, function() {
                YAHOO.util.Assert.areEqual("true", ORBEON.xforms.Document.getValue(fullId));
                YAHOO.util.Assert.areEqual("Label", ORBEON.xforms.Controls.getLabelMessage(YAHOO.util.Dom.get(fullId)));
            });
        });
   },

   testInput: function() { this.repeatRebuildWorker("input"); },
   testTextarea: function() { this.repeatRebuildWorker("textarea"); },
   testSecret: function() { this.repeatRebuildWorker("secret"); },
   testInputBoolean: function() { this.repeatRebuildWorker("input-boolean"); }

}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:select1 appearance=full",

    dateValueInputId: "date-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",

    getSelect: function(controlId) {
        var control = YAHOO.util.Dom.get(controlId);
        return ORBEON.util.Utils.getProperty(NEW_XHTML_LAYOUT_PROPERTY)
            ? control.getElementsByTagName("select")[0]
            : control;
    },

    testAddToItemset: function() {
        // Get initial value for flavor and carrier
        var flavorSelect1 = YAHOO.util.Dom.get("flavor-select1-full" + XFORMS_SEPARATOR_1 + "1");
        var carrierSelect1 = YAHOO.util.Dom.get("carrier-select1-full" + XFORMS_SEPARATOR_1 + "1");
        var initialFlavorValue = ORBEON.xforms.Controls.getCurrentValue(flavorSelect1);
        var initialCarrierValue = ORBEON.xforms.Controls.getCurrentValue(carrierSelect1);
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            // Click on text field
            var addTrigger = YAHOO.util.Dom.get("add-flavor-carrier" + XFORMS_SEPARATOR_1 + "1");
            YAHOO.util.UserAction.click(addTrigger);
        }, function() {
            // Check that the values didn't change
            YAHOO.util.Assert.areEqual(initialFlavorValue, ORBEON.xforms.Controls.getCurrentValue(flavorSelect1));
            YAHOO.util.Assert.areEqual(initialCarrierValue, ORBEON.xforms.Controls.getCurrentValue(carrierSelect1));
       });
    },

    testUpdateRadio: function() {
         ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
             // Click on DHL radio
             var dhlRadio = YAHOO.util.Dom.get("carrier-select1-full$$e2" + XFORMS_SEPARATOR_1 + "1");
             dhlRadio.click();
         }, function() {
             // Check DHL checkbox is checked, and DHL item in lists is selected
             YAHOO.util.Assert.isTrue(YAHOO.util.Dom.get("carrier-select-full$$e2" + XFORMS_SEPARATOR_1 + "1").checked);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select1-compact" + XFORMS_SEPARATOR_1 + "1").options[2].selected);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[2].selected);
        });
    },

    testUpdateList: function() {
         ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
             // Set value in list to TNT
             var select1Id = "carrier-select1-compact" + XFORMS_SEPARATOR_1 + "1";
             var select1Control = YAHOO.util.Dom.get(select1Id);
             var select1List = this.getSelect(select1Id);
             ORBEON.xforms.Controls.setCurrentValue(select1Control, select1List.options[3].value);
             ORBEON.xforms.Events.change({target: select1Control});
         }, function() {
             // Check TNT radio button and checkbox is checked, and TNT item in list is selected
             YAHOO.util.Assert.isTrue(YAHOO.util.Dom.get("carrier-select1-full$$e3" + XFORMS_SEPARATOR_1 + "1").checked);
             YAHOO.util.Assert.isTrue(YAHOO.util.Dom.get("carrier-select-full$$e3" + XFORMS_SEPARATOR_1 + "1").checked);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[3].selected);
        });
    },

    testUpdateCheckbox: function() {
         ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
             // Click on DHL checkbox (in addition to already selected TNT)
             var dhlCheckbox = YAHOO.util.Dom.get("carrier-select-full$$e2" + XFORMS_SEPARATOR_1 + "1");
             dhlCheckbox.click();
         }, function() {
             // Check DHL and TNT are selected in the list
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[2].selected);
             YAHOO.util.Assert.isTrue(this.getSelect("carrier-select-compact" + XFORMS_SEPARATOR_1 + "1").options[3].selected);
        });
    }
}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:input type xs:date",

    dateValueControlId: "date-value" + XFORMS_SEPARATOR_1 + "1",
    dateValueInputId: "date-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",

    testOpenHideCalendar: function() {
        // Click on text field
        YAHOO.util.UserAction.click(this.dateValueInputId);
        // Check calendar div shown
        YAHOO.util.Assert.areEqual("block", document.getElementById("orbeon-calendar-div").style.display);
        // Click on body
        YAHOO.util.UserAction.click(document.body);
        // Check calendar div is hidden
        YAHOO.util.Assert.areEqual("none", document.getElementById("orbeon-calendar-div").style.display);
    },

    testCantOpenReadonly: function() {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue("readonly", "true");
        }, function() {
            // Check input field has been disabled
            YAHOO.util.Assert.areEqual(true, document.getElementById(this.dateValueInputId).disabled);
            // Click on text field
            YAHOO.util.UserAction.click(this.dateValueInputId);
            // Check that the div is still hidden
            YAHOO.util.Assert.areEqual("none", document.getElementById("orbeon-calendar-div").style.display);
            // Restore read-only = false
            ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
                ORBEON.xforms.Document.setValue("readonly", "false");
            }, function() {});
        });
    },

    checkDateConversion: function(twoDigits, fourDigits) {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            // This year taken in the 21th century
            ORBEON.xforms.Document.setValue(this.dateValueControlId, "1/1/" + twoDigits);
        }, function() {
            YAHOO.util.Assert.areEqual(fourDigits + "-01-01", ORBEON.xforms.Document.getValue(this.dateValueControlId));
       });
    },

    testTwoDigitClose: function() { this.checkDateConversion ("02", "2002"); },
    testTwoDigitTwentyFirst: function() { this.checkDateConversion ("40", "2040"); },
    testTwoDigitTwentieth: function() { this.checkDateConversion ("85", "1985"); }
}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:input type xs:time",

    timeValueId: "time-value" + XFORMS_SEPARATOR_1 + "1",
    timeValueInputId: "time-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",
    dateValueId: "date-value" + XFORMS_SEPARATOR_1 + "1",
    dateValueInputId: "date-value$xforms-input-1" + XFORMS_SEPARATOR_1 + "1",

    workerTimeParsing: function(typedValue, expectedValue) {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue(this.timeValueId, typedValue);
        }, function() {
            YAHOO.util.Assert.areEqual(expectedValue, YAHOO.util.Dom.get(this.timeValueInputId).value);
        });
    },

    // Test for: Regression: dateTime field is always invalid when "p.m." is entered
    // http://forge.objectweb.org/tracker/?func=detail&atid=350207&aid=313427&group_id=168
    testParsing: function() {
        var parsedTime = ORBEON.util.DateTime.magicTimeToJSDate("6:00:00 p");
        YAHOO.util.Assert.isNotNull(parsedTime);
    },

    testFirstHourShort:     function() { this.workerTimeParsing("12 am",        "0:00:00 a.m."); },
    testFirstHourMedium:    function() { this.workerTimeParsing("12:30 am",     "0:30:00 a.m."); },
    testFirstHourLong:      function() { this.workerTimeParsing("12:30:40 am",  "0:30:40 a.m."); },
    testNoAmPmShort:        function() { this.workerTimeParsing("12",           "12:00:00 p.m."); },
    testNoAmPmMedium:       function() { this.workerTimeParsing("12:30",        "12:30:00 p.m."); },
    testNoAmPmLong:         function() { this.workerTimeParsing("12:30:40",     "12:30:40 p.m."); },

    testNextYear: function() {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue(this.dateValueId, "10/20/2030");
        }, function() {
            // Click on Next Year
            ORBEON.xforms.Events.click({target: YAHOO.util.Dom.get(this.dateValueInputId) });
            var nextYear = YAHOO.util.Dom.getElementsByClassName("calyearright", null, "orbeon-calendar-div")[0];
            YAHOO.util.UserAction.click(nextYear);
            this.wait(function() {
                var monthYear = YAHOO.util.Dom.getElementsByClassName("calnav", null, "orbeon-calendar-div")[0];
                // Check we are no in 2031
                YAHOO.util.Assert.areEqual("October 2031", monthYear.innerHTML);
                // Click previous year twice
                var previousYear = YAHOO.util.Dom.getElementsByClassName("calyearleft", null, "orbeon-calendar-div")[0];
                YAHOO.util.UserAction.click(previousYear);
                YAHOO.util.UserAction.click(previousYear);
                this.wait(function() {
                    // Check we are no in 2029
                    monthYear = YAHOO.util.Dom.getElementsByClassName("calnav", null, "orbeon-calendar-div")[0];
                    YAHOO.util.Assert.areEqual("October 2029", monthYear.innerHTML);
                    YAHOO.util.UserAction.click(document.body);
                }, XFORMS_INTERNAL_SHORT_DELAY_IN_MS);
            }, XFORMS_INTERNAL_SHORT_DELAY_IN_MS);
        });

    }
}));

YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({

    name: "xforms:output appearance=\"xxforms:download\"",

    outputFileId: "output-file-value" + XFORMS_SEPARATOR_1 + "1",

    // Test that the control is correctly restored when the iteration is recreated
    // http://forge.objectweb.org/tracker/index.php?func=detail&aid=313369&group_id=168&atid=350207
    testRepeatCreate: function() {
        ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
            ORBEON.xforms.Document.setValue("repeat-shown", "false");
        }, function() {
            ORBEON.util.Test.executeCausingAjaxRequest(this, function() {
                ORBEON.xforms.Document.setValue("repeat-shown", "true");
            }, function() {
                var control = document.getElementById(this.outputFileId);
                var children = YAHOO.util.Dom.getChildren(control);
                // Check we still have the link
                YAHOO.util.Assert.areEqual(1, children.length);
                var a = children[0];
                // The link points to a dynamic resource
                YAHOO.util.Assert.areNotEqual(-1, a.href.indexOf("/orbeon/xforms-server/dynamic/"));
                // The text for the link is still the same
                YAHOO.util.Assert.areEqual("Download file", ORBEON.util.Dom.getStringValue(a));
            });
        });
    }
}));

ORBEON.xforms.Events.orbeonLoadedEvent.subscribe(function() {
    if (parent && parent.TestManager) {
        parent.TestManager.load();
    } else {
        new YAHOO.tool.TestLogger();
        YAHOO.tool.TestRunner.run();
    }
});
<|endoftext|>