<commit_before>new Class('StressTest', {
    StressTest: function () {
        // Make a global reference to the game object
        game = this;

        loader.hideOverlay(function () {
            game.onLoaded();
        });

        this.objectView = new View.Container();
        this.hudView = new View.Container();
        engine.currentRoom.addChildren(this.objectView, this.hudView);

        fpsCounter = new View.TextBlock('FPS: 0', 10, 10, 100, {color: '#FFF'});
        objectCounter = new View.TextBlock('Objects: 0', 10, 30, 100, {color: '#FFF'});
        this.hudView.addChildren(fpsCounter, objectCounter);

        engine.currentRoom.addLoop('each20Frames', new Engine.CustomLoop(20));
        engine.currentRoom.loops.each20Frames.attachFunction(this, this.updateFPS);
        engine.currentRoom.loops.eachFrame.attachFunction(this, this.controls);
    },

    onLoaded: function() {
        this.addObjects(1000);
    },

    updateFPS: function () {
        fpsCounter.string = 'FPS: ' + engine.fps;
        objectCounter.string = 'Objects: ' + (Object.keys(engine.objectIndex).length - 2);
    },

    addObjects: function (count) {
        count = count !== undefined ? count : 10;
        var i;

        for (i = 0; i < count; i++) {
            sprite = new View.GameObject(
                'Rock',
                Math.random() * 600,
                Math.random() * 400,
                Math.random() * Math.PI * 2,
                {speed: new Math.Vector(-5 + Math.random() * 10, -5 + Math.random() * 10)}
            );
            sprite.checkBounce = function () {
                if (this.x < 0) {
                    this.x = 0;
                    this.speed.x = -this.speed.x;
                }
                else if (this.x > 600) {
                    this.x = 600;
                    this.speed.x = -this.speed.x;
                }

                if (this.y < 0) {
                    this.y = 0;
                    this.speed.y = -this.speed.y;
                }
                else if (this.y > 400) {
                    this.y = 400;
                    this.speed.y = -this.speed.y;
                }
            }
            engine.currentRoom.loops.eachFrame.attachFunction(sprite, sprite.checkBounce);

            this.objectView.addChildren(sprite);
        }
    },

    removeObjects: function (count) {
        var i;

        count = count !== undefined ? count : 10;
        objects = this.objectView.getChildren();
        count = Math.min(count, objects.length);

        for (i = 0; i < count; i++) {
            engine.purge(objects.shift());
        }
    },

    controls: function () {
        // Add objects when arrow up key is down
        if (keyboard.isDown(KEY_UP)) {
            this.addObjects();
        }

        // Remove objects when arrow down key is down
        if (keyboard.isDown(KEY_DOWN)) {
            this.removeObjects();
        }
    }
});

<commit_msg>Stresstest now creates 2000 objects by default - 1000 is now too few<commit_after>new Class('StressTest', {
    StressTest: function () {
        // Make a global reference to the game object
        game = this;

        loader.hideOverlay(function () {
            game.onLoaded();
        });

        this.objectView = new View.Container();
        this.hudView = new View.Container();
        engine.currentRoom.addChildren(this.objectView, this.hudView);

        fpsCounter = new View.TextBlock('FPS: 0', 10, 10, 100, {color: '#FFF'});
        objectCounter = new View.TextBlock('Objects: 0', 10, 30, 100, {color: '#FFF'});
        this.hudView.addChildren(fpsCounter, objectCounter);

        engine.currentRoom.addLoop('each20Frames', new Engine.CustomLoop(20));
        engine.currentRoom.loops.each20Frames.attachFunction(this, this.updateFPS);
        engine.currentRoom.loops.eachFrame.attachFunction(this, this.controls);
    },

    onLoaded: function() {
        this.addObjects(2000);
    },

    updateFPS: function () {
        fpsCounter.string = 'FPS: ' + engine.fps;
        objectCounter.string = 'Objects: ' + (Object.keys(engine.objectIndex).length - 2);
    },

    addObjects: function (count) {
        count = count !== undefined ? count : 10;
        var i;

        for (i = 0; i < count; i++) {
            sprite = new View.GameObject(
                'Rock',
                Math.random() * 600,
                Math.random() * 400,
                Math.random() * Math.PI * 2,
                {speed: new Math.Vector(-5 + Math.random() * 10, -5 + Math.random() * 10)}
            );
            sprite.checkBounce = function () {
                if (this.x < 0) {
                    this.x = 0;
                    this.speed.x = -this.speed.x;
                }
                else if (this.x > 600) {
                    this.x = 600;
                    this.speed.x = -this.speed.x;
                }

                if (this.y < 0) {
                    this.y = 0;
                    this.speed.y = -this.speed.y;
                }
                else if (this.y > 400) {
                    this.y = 400;
                    this.speed.y = -this.speed.y;
                }
            }
            engine.currentRoom.loops.eachFrame.attachFunction(sprite, sprite.checkBounce);

            this.objectView.addChildren(sprite);
        }
    },

    removeObjects: function (count) {
        var i;

        count = count !== undefined ? count : 10;
        objects = this.objectView.getChildren();
        count = Math.min(count, objects.length);

        for (i = 0; i < count; i++) {
            engine.purge(objects.shift());
        }
    },

    controls: function () {
        // Add objects when arrow up key is down
        if (keyboard.isDown(KEY_UP)) {
            this.addObjects();
        }

        // Remove objects when arrow down key is down
        if (keyboard.isDown(KEY_DOWN)) {
            this.removeObjects();
        }
    }
});

<|endoftext|>


<commit_before>// Copyright 2010 WebDriver committers
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Utilities for working with errors as defined by WebDriver's
 * wire protocol: http://code.google.com/p/selenium/wiki/JsonWireProtocol.
 */

goog.provide('bot.Error');
goog.provide('bot.ErrorCode');

goog.require('goog.debug.Error');
goog.require('goog.object');

/**
 * Error codes from the WebDriver wire protocol:
 * http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
 *
 * @enum {number}
 */
bot.ErrorCode = {
  SUCCESS: 0,  // Included for completeness

  NO_SUCH_ELEMENT: 7,
  NO_SUCH_FRAME: 8,
  UNKNOWN_COMMAND: 9,
  UNSUPPORTED_OPERATION: 9,  // Alias.
  STALE_ELEMENT_REFERENCE: 10,
  ELEMENT_NOT_VISIBLE: 11,
  INVALID_ELEMENT_STATE: 12,
  UNKNOWN_ERROR: 13,
  ELEMENT_NOT_SELECTABLE: 15,
  JAVASCRIPT_ERROR: 17,
  XPATH_LOOKUP_ERROR: 19,
  NO_SUCH_WINDOW: 23,
  INVALID_COOKIE_DOMAIN: 24,
  UNABLE_TO_SET_COOKIE: 25,
  MODAL_DIALOG_OPENED: 26,
  MODAL_DIALOG_OPEN: 27,
  SCRIPT_TIMEOUT: 28
};

/**
 * Error extension that includes error status codes from the WebDriver wire
 * protocol:
 * http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
 *
 * @param {!bot.ErrorCode} code The error's status code.
 * @param {string} opt_message Optional error message.
 * @constructor
 * @extends {goog.debug.Error}
 */
bot.Error = function(code, opt_message) {
  goog.base(this, opt_message);

  /**
   * This error's status code.
   * @type {!bot.ErrorCode}
   */
  this.code = code;

  /** @inheritDoc */
  this.name = (/**@type {string}*/ bot.Error.NAMES_[code] ||
      bot.Error.NAMES_[bot.ErrorCode.UNKNOWN_ERROR]);
};
goog.inherits(bot.Error, goog.debug.Error);

/**
 * A map of error codes to error names.
 * @type {Object.<bot.ErrorCode, String>}
 * @const
 * @private
 */
bot.Error.NAMES_ = goog.object.transpose({
  'NoSuchElementError': bot.ErrorCode.NO_SUCH_ELEMENT,
  'NoSuchFrameError': bot.ErrorCode.NO_SUCH_FRAME,
  'UnknownCommandError': bot.ErrorCode.UNKNOWN_COMMAND,
  'StaleElementReferenceError': bot.ErrorCode.STALE_ELEMENT_REFERENCE,
  'ElementNotVisibleError': bot.ErrorCode.ELEMENT_NOT_VISIBLE,
  'InvalidElementStateError': bot.ErrorCode.INVALID_ELEMENT_STATE,
  'UnknownError': bot.ErrorCode.UNKNOWN_ERROR,
  'ElementNotSelectableError': bot.ErrorCode.ELEMENT_NOT_SELECTABLE,
  'XPathLookupError': bot.ErrorCode.XPATH_LOOKUP_ERROR,
  'NoSuchWindowError': bot.ErrorCode.NO_SUCH_WINDOW,
  'InvalidCookieDomainError': bot.ErrorCode.INVALID_COOKIE_DOMAIN,
  'UnableToSetCookieError': bot.ErrorCode.UNABLE_TO_SET_COOKIE,
  'ModalDialogOpenedError': bot.ErrorCode.MODAL_DIALOG_OPENED,
  'ModalDialogOpenError': bot.ErrorCode.MODAL_DIALOG_OPEN,
  'ScriptTimeoutError': bot.ErrorCode.SCRIPT_TIMEOUT
});

/**
 * Flag used for duck-typing when this code is embedded in a Firefox extension.
 * This is required since an Error thrown in one component and the reported
 * to another will fail instanceof checks in the second component.
 * @type {boolean}
 */
bot.Error.prototype.isAutomationError = true;

if (goog.DEBUG) {
  /** @return {string} The string representation of this error. */
  bot.Error.prototype.toString = function() {
    return '[' + this.name + '] ' + this.message;
  };
}
<commit_msg>SimonStewart: Restoring the invalid element selector to the js code<commit_after>// Copyright 2010 WebDriver committers
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Utilities for working with errors as defined by WebDriver's
 * wire protocol: http://code.google.com/p/selenium/wiki/JsonWireProtocol.
 */

goog.provide('bot.Error');
goog.provide('bot.ErrorCode');

goog.require('goog.debug.Error');
goog.require('goog.object');

/**
 * Error codes from the WebDriver wire protocol:
 * http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
 *
 * @enum {number}
 */
bot.ErrorCode = {
  SUCCESS: 0,  // Included for completeness

  NO_SUCH_ELEMENT: 7,
  NO_SUCH_FRAME: 8,
  UNKNOWN_COMMAND: 9,
  UNSUPPORTED_OPERATION: 9,  // Alias.
  STALE_ELEMENT_REFERENCE: 10,
  ELEMENT_NOT_VISIBLE: 11,
  INVALID_ELEMENT_STATE: 12,
  UNKNOWN_ERROR: 13,
  ELEMENT_NOT_SELECTABLE: 15,
  JAVASCRIPT_ERROR: 17,
  XPATH_LOOKUP_ERROR: 19,
  NO_SUCH_WINDOW: 23,
  INVALID_COOKIE_DOMAIN: 24,
  UNABLE_TO_SET_COOKIE: 25,
  MODAL_DIALOG_OPENED: 26,
  MODAL_DIALOG_OPEN: 27,
  SCRIPT_TIMEOUT: 28,
  INVALID_SELECTOR_ERROR: 32
};

/**
 * Error extension that includes error status codes from the WebDriver wire
 * protocol:
 * http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
 *
 * @param {!bot.ErrorCode} code The error's status code.
 * @param {string} opt_message Optional error message.
 * @constructor
 * @extends {goog.debug.Error}
 */
bot.Error = function(code, opt_message) {
  goog.base(this, opt_message);

  /**
   * This error's status code.
   * @type {!bot.ErrorCode}
   */
  this.code = code;

  /** @inheritDoc */
  this.name = (/**@type {string}*/ bot.Error.NAMES_[code] ||
      bot.Error.NAMES_[bot.ErrorCode.UNKNOWN_ERROR]);
};
goog.inherits(bot.Error, goog.debug.Error);

/**
 * A map of error codes to error names.
 * @type {Object.<bot.ErrorCode, String>}
 * @const
 * @private
 */
bot.Error.NAMES_ = goog.object.transpose({
  'NoSuchElementError': bot.ErrorCode.NO_SUCH_ELEMENT,
  'NoSuchFrameError': bot.ErrorCode.NO_SUCH_FRAME,
  'UnknownCommandError': bot.ErrorCode.UNKNOWN_COMMAND,
  'StaleElementReferenceError': bot.ErrorCode.STALE_ELEMENT_REFERENCE,
  'ElementNotVisibleError': bot.ErrorCode.ELEMENT_NOT_VISIBLE,
  'InvalidElementStateError': bot.ErrorCode.INVALID_ELEMENT_STATE,
  'UnknownError': bot.ErrorCode.UNKNOWN_ERROR,
  'ElementNotSelectableError': bot.ErrorCode.ELEMENT_NOT_SELECTABLE,
  'XPathLookupError': bot.ErrorCode.XPATH_LOOKUP_ERROR,
  'NoSuchWindowError': bot.ErrorCode.NO_SUCH_WINDOW,
  'InvalidCookieDomainError': bot.ErrorCode.INVALID_COOKIE_DOMAIN,
  'UnableToSetCookieError': bot.ErrorCode.UNABLE_TO_SET_COOKIE,
  'ModalDialogOpenedError': bot.ErrorCode.MODAL_DIALOG_OPENED,
  'ModalDialogOpenError': bot.ErrorCode.MODAL_DIALOG_OPEN,
  'ScriptTimeoutError': bot.ErrorCode.SCRIPT_TIMEOUT
});

/**
 * Flag used for duck-typing when this code is embedded in a Firefox extension.
 * This is required since an Error thrown in one component and the reported
 * to another will fail instanceof checks in the second component.
 * @type {boolean}
 */
bot.Error.prototype.isAutomationError = true;

if (goog.DEBUG) {
  /** @return {string} The string representation of this error. */
  bot.Error.prototype.toString = function() {
    return '[' + this.name + '] ' + this.message;
  };
}
<|endoftext|>


<commit_before>$(document).ready(function(){
    var treeData = {
        name: "Grove",
        contents: [
            {name: "First Tree",
            value: -6,
            contents: [
                {   name: "",
                    value: -13,
                    contents: [
                    {
                        name: "",
                        value: -17,
                        contents: [
                            { name: "two",
                            value: 16 },
                            { name: "three",
                            value: -16 },
                            { name: "4",
                            value: -5 }
                        ]
                    },
                    {
                        name: "",
                        value: -10,
                        contents: [
                            { name: "9" ,
                            value: -1
                        }
                        ]
                    },
                    {
                        name: "",
                        value: -1,
                        contents: [
                            {
                                name: "",
                                value: 9,
                                contents: [
                                    { name: "6",
                                    value: 19 },
                                    { name: "7",
                                    value: -55 },
                                    { name: "8",
                                    value: -19 }
                                ]
                            },
                            {
                                name: "",
                                value: 20,
                                contents: [
                                    { name: "ten",
                                    value: 12 }
                                ]
                            },
                            {
                                name: "",
                                value: -18,
                                contents: [
                                    { name: "11",
                                    value: 4},
                                    {
                                        name: "",
                                        value: 4,
                                        contents: [
                                        { name: 4,
                                        value: 4},
                                        { name: "13",
                                        value: 4},
                                        { name: "14",
                                        value: 4}
                                        ]
                                     }
                                ]
                            },
                            {
                                name: "",
                                value: -2,
                                contents: [
                                    { name: "1",
                                    value: -4 }
                                ]
                            }
                        ]
                    },
                    {
                        name: "5",
                        value: -32,
                        contents: []
                    }
                ]
            },
            ]

        },
            {
            name: "Second Tree",
            contents: [
                {   name: "",
                    contents: [
                    {
                        name: "",
                        contents: [
                            { name: "2T1" }
                        ]
                    },
                    {
                        name: "",
                        contents: [
                            { name: "2T2" },
                            { name: "2T3" }
                        ]
                    },
                    {
                        name: "",
                        contents: [
                            {
                                name: "",
                                contents: [
                                    { name: "2T4" },
                                    { name: "2T5" },
                                    { name: "2T6" },
                                    { name: "2T7" },
                                    { name: "2T8" },
                                    { name: "",
                                        contents: [
                                            { name: "2T9"  },
                                            { name: "2T10" }
                                            ]
                                    },
                                ]
                            },
                        ]
                    },
                ]
            }
            ]
        },
        {
        name: "Third Tree",
        contents: [
            {   name: "",
                contents: [
                {
                    name: "",
                    contents: [
                        {name: "",
                        contents:[
                            { name: "3T1" }
                        ]
                    },
                    ]
                },
                {
                    name: "",
                    contents: [
                        { name: "3T2" },
                        { name: "3T3" },
                        { name: "3T4" },
                        { name: "3T5",
                            contents: [
                                { name: "3T12" },
                                { name: "3T13" },
                                { name: "3T14" },
                                { name: "3T15" },
                                { name: "3T16" }
                                ]
                                },
                        { name: "3T6" },
                        { name: "3T7" },
                        { name: "3T8" },
                        { name: "3T9" },
                        { name: "3T10" },
                        { name: "3T11" }
                    ]
                },
                {
                    name: "",
                    contents: [
                        {
                            name: "",
                            contents: [
                                { name: "2T4" },
                                { name: "2T5" },
                                { name: "",
                                    contents: [
                                        { name: "2T9"  },
                                        { name: "2T10" }
                                        ]
                                },
                            ]
                        },
                    ]
                },
                ]
            }
            ]
        }
        ]

    };

    function visit(parent, visitFn, childrenFn)
    {
        if (!parent) return;

        visitFn(parent);

        var children = childrenFn(parent);
        if (children) {
            var count = children.length;
            for (var i = 0; i < count; i++) {
                visit(children[i], visitFn, childrenFn);
            }
        };
    }

    var ui;

    function buildTree(containerName, customOptions)
    {
        // build the options object
        var options = $.extend({
            nodeRadius: 4, fontSize: 22
        }, customOptions);

        // Calculate total nodes, max label length
        var totalNodes = 0;
        var maxLabelLength = 0;
        visit(treeData, function(d)
        {
            totalNodes++;
            maxLabelLength = Math.max(d.name.length, maxLabelLength);
        }, function(d)
        {
            return d.contents && d.contents.length > 0 ? d.contents : null;
        });

        // size of the diagram
        var size = { width:$(containerName).outerWidth() , height: (totalNodes * 8) };
        var tree = d3.layout.tree()
            .sort(null)
            .size([size.width - 200,size.height - 10])
            .children(function(d)
            {
                return (!d.contents || d.contents.length === 0) ? null : d.contents;
            });

        var nodes = tree.nodes(treeData);
        var links = tree.links(nodes);
        var svgRoot = d3.select(containerName)
            .append("svg:svg").attr("height", size.height+20).attr("width", size.width);
                 // Add the clipping path
        svgRoot.append("svg:clipPath").attr("id", "clipper")
            .append("svg:rect")
            .attr('id', 'clip-rect');

        var layoutRoot = svgRoot
            .append("svg:g")
            .attr("class", "container")
            .attr("transform", "translate(0," + size.height + ")");

        // Edges between nodes as a <path class="link" />
        var link = d3.svg.diagonal()
            .projection(function(d)
            { if(d.value !=undefined){
                return [(d.x - d.value) , (-d.y + d.value) ];
            }
            else{
                console.log(d.value);
                return [d.x , (-d.y ) ];
            }
            });

        var linkGroup = layoutRoot.append("svg:g");

        linkGroup.selectAll("path.link")
            .data(links)
            .enter()
            .append("svg:path")
            .attr("class", "link")
            .attr("d", link);

        var animGroup = layoutRoot.append("svg:g")
            .attr("clip-path", "url(#clipper)");

        var nodeGroup = layoutRoot.selectAll("g.node")
            .data(nodes)
            .enter()
            .append("svg:g")
            .attr("class", "node")
            .attr("transform", function(d)
            {
                var transpointx = d.x - d.value;
                var transpointy = -d.y + d.value;
                return "translate(" + transpointx + "," + transpointy + ")";
            });

        // Cache the UI elements
        ui = {
            svgRoot: svgRoot,
            nodeGroup: nodeGroup,
            linkGroup: linkGroup,
            animGroup: animGroup
        };

        // Attach the hover and click handlers
        setupMouseEvents();

        nodeGroup.append("svg:image")
            .attr("xlink:href", "svg-leave1.svg")
            .attr("width", 140)
            .attr("height", 140)
            .attr("transform", "translate(-25,-5)");

        nodeGroup.append("svg:text")
            .attr("text-anchor", function(d)
            {
                return d.children ? "end" : "start";
            })
            .attr("dx", function(d)
            {
                var gap = 2 * options.nodeRadius;
                return d.children ? -gap : gap;
            })
            .attr("dy", 3)
            .text(function(d)
            {
                return d.name;
            });
    }// close build tree
    var dur = 0;
    function setupMouseEvents(){
        ui.nodeGroup.on('mouseover', function(d, i)
        {
            d3.select(this).select("circle").classed("hover", true);
        })
            .on('mouseout', function(d, i)
            {
                d3.select(this).select("circle").classed("hover", false);
            })
            .on('click', function(nd, i)
            {
                // Walk parent chain
                var ancestors = [];
                var parent = nd;
                while (!_.isUndefined(parent)) {
                    ancestors.push(parent);
                    parent = parent.parent;
                };

                // Get the matched links
                var matchedLinks = [];
                ui.linkGroup.selectAll('path.link')
                    .filter(function(d, i)
                    {
                        return _.any(ancestors, function(p)
                        {
                            return p === d.target;
                        });
                    })
                    .each(function(d)
                    {
                        matchedLinks.push(d);
                    });
                var last_element = matchedLinks[matchedLinks.length - 1];
                var track = last_element.target.name;
                soundManager.play(track);
                // setTimeout(function(){dur = soundManager.getSoundById(track).duration
                // // var dur = soundManager.getSoundById(track).duration;
                // console.log(dur);
                animateParentChain(matchedLinks,soundManager);
                // },3000);
           });
        }

    function animateParentChain(links){
        var linkRenderer = d3.svg.diagonal()
            .projection(function(d){
                  if(d.value !=undefined){
                return [(d.x - d.value) , (-d.y + d.value) ];
            }
            else{
                console.log(d.value);
                return [d.x , (-d.y ) ];
            }
            });
        // Links
        ui.animGroup.selectAll("path.selected")
            .data([])
            .exit().remove();

        ui.animGroup
            .selectAll("path.selected")
            .data(links)
            .enter().append("svg:path")
            .attr("class", "selected")
            .attr("d", linkRenderer);

        // Animate the clipping path
        var overlayBox = ui.svgRoot.node().getBBox();

        ui.svgRoot.select("#clip-rect")
            .attr("x", overlayBox.x + overlayBox.width)
            .attr("y", overlayBox.y -540)
            .attr("width", 0)
            .attr("height", overlayBox.height)
            .transition().duration(5000)
            .attr("x", overlayBox.x)
            .attr("width", overlayBox.width);
    }
    //Soundmanager

    soundManager.setup({
    // where to find flash audio SWFs, as needed
        url: '/.',
        onready: function() {
         soundManager.createSound({
          id: 'two', // optional: provide your own unique id
          url: 'PIano Improvs6-first tree2.mp3',
          multiShot: false,
          onload: function() {
            if( this.readyState === 3 ) {
            soundDuration = this.duration;
            console.log(soundDuration);
                }
            }
        });
          soundManager.createSound({
          id: 'three', // optional: provide your own unique id
          url: 'PIano Improvs6-first tree3.mp3',
          multiShot: false,
          onload: function() {
            if( this.readyState === 3 ) {
            soundDuration = this.duration;
            console.log(soundDuration);
                }
            }
        });
          soundManager.createSound({
          id: 'ten', // optional: provide your own unique id
          url: 'PIano Improvs6-first tree3.mp3',
          multiShot: false,
          onload: function() {
            if( this.readyState === 3 ) {
            soundDuration = this.duration;
            console.log(soundDuration);
                }
            }
        });
        }
    });

    $(function(){
        buildTree("#tree-container");
    });
});<commit_msg>tree animation moving from bottom to top<commit_after>$(document).ready(function(){
    var treeData = {
        name: "Grove",
        contents: [
            {name: "First Tree",
            value: -6,
            contents: [
                {   name: "",
                    value: -13,
                    contents: [
                    {
                        name: "",
                        value: -17,
                        contents: [
                            { name: "two",
                            value: 16 },
                            { name: "three",
                            value: -16 },
                            { name: "4",
                            value: -5 }
                        ]
                    },
                    {
                        name: "",
                        value: -10,
                        contents: [
                            { name: "9" ,
                            value: -1
                        }
                        ]
                    },
                    {
                        name: "",
                        value: -1,
                        contents: [
                            {
                                name: "",
                                value: 9,
                                contents: [
                                    { name: "6",
                                    value: 19 },
                                    { name: "7",
                                    value: -55 },
                                    { name: "8",
                                    value: -19 }
                                ]
                            },
                            {
                                name: "",
                                value: 20,
                                contents: [
                                    { name: "ten",
                                    value: 12 }
                                ]
                            },
                            {
                                name: "",
                                value: -18,
                                contents: [
                                    { name: "11",
                                    value: 4},
                                    {
                                        name: "",
                                        value: 4,
                                        contents: [
                                        { name: 4,
                                        value: 4},
                                        { name: "13",
                                        value: 4},
                                        { name: "14",
                                        value: 4}
                                        ]
                                     }
                                ]
                            },
                            {
                                name: "",
                                value: -2,
                                contents: [
                                    { name: "1",
                                    value: -4 }
                                ]
                            }
                        ]
                    },
                    {
                        name: "5",
                        value: -32,
                        contents: []
                    }
                ]
            },
            ]

        },
            {
            name: "Second Tree",
            contents: [
                {   name: "",
                    contents: [
                    {
                        name: "",
                        contents: [
                            { name: "2T1" }
                        ]
                    },
                    {
                        name: "",
                        contents: [
                            { name: "2T2" },
                            { name: "2T3" }
                        ]
                    },
                    {
                        name: "",
                        contents: [
                            {
                                name: "",
                                contents: [
                                    { name: "2T4" },
                                    { name: "2T5" },
                                    { name: "2T6" },
                                    { name: "2T7" },
                                    { name: "2T8" },
                                    { name: "",
                                        contents: [
                                            { name: "2T9"  },
                                            { name: "2T10" }
                                            ]
                                    },
                                ]
                            },
                        ]
                    },
                ]
            }
            ]
        },
        {
        name: "Third Tree",
        contents: [
            {   name: "",
                contents: [
                {
                    name: "",
                    contents: [
                        {name: "",
                        contents:[
                            { name: "3T1" }
                        ]
                    },
                    ]
                },
                {
                    name: "",
                    contents: [
                        { name: "3T2" },
                        { name: "3T3" },
                        { name: "3T4" },
                        { name: "3T5",
                            contents: [
                                { name: "3T12" },
                                { name: "3T13" },
                                { name: "3T14" },
                                { name: "3T15" },
                                { name: "3T16" }
                                ]
                                },
                        { name: "3T6" },
                        { name: "3T7" },
                        { name: "3T8" },
                        { name: "3T9" },
                        { name: "3T10" },
                        { name: "3T11" }
                    ]
                },
                {
                    name: "",
                    contents: [
                        {
                            name: "",
                            contents: [
                                { name: "2T4" },
                                { name: "2T5" },
                                { name: "",
                                    contents: [
                                        { name: "2T9"  },
                                        { name: "2T10" }
                                        ]
                                },
                            ]
                        },
                    ]
                },
                ]
            }
            ]
        }
        ]

    };

    function visit(parent, visitFn, childrenFn)
    {
        if (!parent) return;

        visitFn(parent);

        var children = childrenFn(parent);
        if (children) {
            var count = children.length;
            for (var i = 0; i < count; i++) {
                visit(children[i], visitFn, childrenFn);
            }
        };
    }

    var ui;

    function buildTree(containerName, customOptions)
    {
        // build the options object
        var options = $.extend({
            nodeRadius: 4, fontSize: 22
        }, customOptions);

        // Calculate total nodes, max label length
        var totalNodes = 0;
        var maxLabelLength = 0;
        visit(treeData, function(d)
        {
            totalNodes++;
            maxLabelLength = Math.max(d.name.length, maxLabelLength);
        }, function(d)
        {
            return d.contents && d.contents.length > 0 ? d.contents : null;
        });

        // size of the diagram
        var size = { width:$(containerName).outerWidth() , height: (totalNodes * 8) };
        var tree = d3.layout.tree()
            .sort(null)
            .size([size.width - 200,size.height - 10])
            .children(function(d)
            {
                return (!d.contents || d.contents.length === 0) ? null : d.contents;
            });

        var nodes = tree.nodes(treeData);
        var links = tree.links(nodes);
        var svgRoot = d3.select(containerName)
            .append("svg:svg").attr("height", size.height+20).attr("width", size.width);
                 // Add the clipping path
        svgRoot.append("svg:clipPath").attr("id", "clipper")
            .append("svg:rect")
            .attr('id', 'clip-rect');

        var layoutRoot = svgRoot
            .append("svg:g")
            .attr("class", "container")
            .attr("transform", "translate(0," + size.height + ")");

        // Edges between nodes as a <path class="link" />
        var link = d3.svg.diagonal()
            .projection(function(d)
            { if(d.value !=undefined){
                return [(d.x - d.value) , (-d.y + d.value) ];
            }
            else{
                console.log(d.value);
                return [d.x , (-d.y ) ];
            }
            });

        var linkGroup = layoutRoot.append("svg:g");

        linkGroup.selectAll("path.link")
            .data(links)
            .enter()
            .append("svg:path")
            .attr("class", "link")
            .attr("d", link);

        var animGroup = layoutRoot.append("svg:g")
            .attr("clip-path", "url(#clipper)");

        var nodeGroup = layoutRoot.selectAll("g.node")
            .data(nodes)
            .enter()
            .append("svg:g")
            .attr("class", "node")
            .attr("transform", function(d)
            {
                var transpointx = d.x - d.value;
                var transpointy = -d.y + d.value;
                return "translate(" + transpointx + "," + transpointy + ")";
            });

        // Cache the UI elements
        ui = {
            svgRoot: svgRoot,
            nodeGroup: nodeGroup,
            linkGroup: linkGroup,
            animGroup: animGroup
        };

        // Attach the hover and click handlers
        setupMouseEvents();

        nodeGroup.append("svg:image")
            .attr("xlink:href", "svg-leave1.svg")
            .attr("width", 140)
            .attr("height", 140)
            .attr("transform", "translate(-25,-5)");

        nodeGroup.append("svg:text")
            .attr("text-anchor", function(d)
            {
                return d.children ? "end" : "start";
            })
            .attr("dx", function(d)
            {
                var gap = 2 * options.nodeRadius;
                return d.children ? -gap : gap;
            })
            .attr("dy", 3)
            .text(function(d)
            {
                return d.name;
            });
    }// close build tree
    var dur = 0;
    function setupMouseEvents(){
        ui.nodeGroup.on('mouseover', function(d, i)
        {
            d3.select(this).select("circle").classed("hover", true);
        })
            .on('mouseout', function(d, i)
            {
                d3.select(this).select("circle").classed("hover", false);
            })
            .on('click', function(nd, i)
            {
                // Walk parent chain
                var ancestors = [];
                var parent = nd;
                while (!_.isUndefined(parent)) {
                    ancestors.push(parent);
                    parent = parent.parent;
                };

                // Get the matched links
                var matchedLinks = [];
                ui.linkGroup.selectAll('path.link')
                    .filter(function(d, i)
                    {
                        return _.any(ancestors, function(p)
                        {
                            return p === d.target;
                        });
                    })
                    .each(function(d)
                    {
                        matchedLinks.push(d);
                    });
                var last_element = matchedLinks[matchedLinks.length - 1];
                var track = last_element.target.name;
                soundManager.play(track);
                // setTimeout(function(){dur = soundManager.getSoundById(track).duration
                // // var dur = soundManager.getSoundById(track).duration;
                // console.log(dur);
                animateParentChain(matchedLinks,soundManager);
                // },3000);
           });
        }

    function animateParentChain(links){
        var linkRenderer = d3.svg.diagonal()
            .projection(function(d){
                  if(d.value !=undefined){
                return [(d.x - d.value) , (-d.y + d.value) ];
            }
            else{
                console.log(d.value);
                return [d.x , (-d.y ) ];
            }
            });
        // Links
        ui.animGroup.selectAll("path.selected")
            .data([])
            .exit().remove();

        ui.animGroup
            .selectAll("path.selected")
            .data(links)
            .enter().append("svg:path")
            .attr("class", "selected")
            .attr("d", linkRenderer);

        // Animate the clipping path
        var overlayBox = ui.svgRoot.node().getBBox();

        ui.svgRoot.select("#clip-rect")
            .attr("x", overlayBox.x )
            .attr("y", 0)
            .attr("width", overlayBox.width)
            .attr("height", 0)
            .transition().duration(5000)
            .attr("y", overlayBox.y -540)
            .attr("height", 14);
    }
    //Soundmanager

    soundManager.setup({
    // where to find flash audio SWFs, as needed
        url: '/.',
        onready: function() {
         soundManager.createSound({
          id: 'two', // optional: provide your own unique id
          url: 'PIano Improvs6-first tree2.mp3',
          multiShot: false,
          onload: function() {
            if( this.readyState === 3 ) {
            soundDuration = this.duration;
            console.log(soundDuration);
                }
            }
        });
          soundManager.createSound({
          id: 'three', // optional: provide your own unique id
          url: 'PIano Improvs6-first tree3.mp3',
          multiShot: false,
          onload: function() {
            if( this.readyState === 3 ) {
            soundDuration = this.duration;
            console.log(soundDuration);
                }
            }
        });
          soundManager.createSound({
          id: 'ten', // optional: provide your own unique id
          url: 'PIano Improvs6-first tree3.mp3',
          multiShot: false,
          onload: function() {
            if( this.readyState === 3 ) {
            soundDuration = this.duration;
            console.log(soundDuration);
                }
            }
        });
        }
    });

    $(function(){
        buildTree("#tree-container");
    });
});<|endoftext|>


<commit_before>(function(){function c(a,b){var c=a+" ";for(var d=0;d<b-c.length+1;d++)c=" "+c;return c}var a=exports||{},b={};if(a.client=typeof window!="undefined")window.blade={runtime:a,cachedViews:b,cb:{}};a.escape=function(a){return(new String(a)).replace(/&(?!\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},a.attrs=function(b,c){for(var d in b){if(b[d].val==null)continue;d=="class"&&(b[d].val instanceof Array&&(b[d].val=b[d].val.join(" ")),b[d].append&&(b[d].val=(b[d].val.length>0?" ":"")+b[d].append)),b[d].escape?c.push(" "+d+'="'+a.escape(b[d].val)+'"'):c.push(" "+d+'="'+b[d].val+'"')}},a.loadTemplate=function(b,c,d){if(a.client){var e=document.createElement("script");e.type="application/javascript",e.async=!0,e.src="/views/"+b;var f=document.getElementsByTagName("script")[0];f.parentNode.insertBefore(e,f);var g=setTimeout(function(){delete h.cb[b],d(new Error("Timeout Error: Blade Template ["+b+"] could not be loaded."))},15e3);h.cb[b]=function(a){clearTimeout(g),delete h.cb[b],d(null,a[b])}}else{var h=require("./blade");h.compileFile(b,c,function(a,b){if(a)return d(a);d(null,b.template)})}},a.include=function(c,d,e){function f(a,b,c){if(a)return e(a);for(var f in c.blocks){var g=c.blocks[f],h=d.blocks[f];g.pos!=null?(g.pos+=d.buf.length,d.blocks[f]=g):(g.replace&&(delete h.paramBlock,delete h.renderArgs,delete h.append,delete h.prepend,h.replace=!0),g.renderArgs!=null&&(h.renderArgs=g.renderArgs),g.block!=null&&(h.block=g.block),g.append!=null&&(h.append!=null?h.append+=g.append:h.append=g.append),g.prepend!=null&&(h.prepend!=null?h.prepend=g.prepend+h.prepend:h.prepend=g.prepend))}for(var f in c.buf)d.buf.push(c.buf[f]);e(null)}b[c]?b[c](d.locals,a,f):a.loadTemplate(c,a.compileOptions,function(b,c){if(b)return e(b);c(d.locals,a,f)})},a.blockDef=function(a,b,c){var d=b.blocks[a]={pos:b.buf.length};return b.buf.push(""),c.length>0?d.paramBlock=c:d.block=c().join(""),d},a.blockRender=function(a,b){var c=b.blocks[a]=b.blocks[a]||{},d=[];for(var e=2;e<arguments.length;e++)d[e-2]=arguments[e];c.renderArgs=d},a.blockMod=function(a,b,c,d){var e=c.blocks[b]=c.blocks[b]||{};a=="replace"?(delete e.paramBlock,delete e.renderArgs,delete e.append,delete e.prepend,e.replace=!0,e.block=d().join("")):a=="append"?e.append=(e.append==null?"":e.append)+d().join(""):e.prepend=d().join("")+(e.prepend==null?"":e.prepend)},a.done=function(a){var b=a.blocks;for(var c in b){var d=b[c];d.pos!=null&&(d.paramBlock&&d.renderArgs&&(d.block=d.paramBlock.apply(this,d.renderArgs).join("")),a.buf[d.pos]=(d.prepend?d.prepend:"")+(d.block?d.block:"")+(d.append?d.append:""))}},a.rethrow=function(a,b){b==undefined&&(b=a),b.column=b.col;var d=a.message+"\n    at "+(b.filename==null?"<anonymous>":b.filename)+(b.line==null?"":":"+b.line)+(b.column==null?"":":"+b.column);if(b.source!=null){const e=3;var f=b.source.split("\n"),g=Math.max(b.line-e,0),h=Math.min(b.line+e,f.length),i=(new String(h)).length;f=f.slice(g,h),d+="\n\n";for(var j=0;j<f.length;j++)d+=c(j+g+1,i)+(j+g+1==b.line?">	":"|	")+f[j]+"\n"}return a.message=d,a.filename=b.filename,a.line=b.line,a.column=b.column,a}})();<commit_msg>New runtime build<commit_after>(function(){function c(a,b){var c=a+" ";for(var d=0;d<b-c.length+1;d++)c=" "+c;return c}var a=exports||{},b={};if(a.client=typeof window!="undefined")window.blade={runtime:a,cachedViews:b,cb:{}};a.escape=function(a){return(new String(a)).replace(/&(?!\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},a.attrs=function(b,c){for(var d in b){if(b[d].val==null)continue;d=="class"&&(b[d].val instanceof Array&&(b[d].val=b[d].val.join(" ")),b[d].append&&(b[d].val=(b[d].val.length>0?b[d].val+" ":"")+b[d].append)),b[d].escape?c.push(" "+d+'="'+a.escape(b[d].val)+'"'):c.push(" "+d+'="'+b[d].val+'"')}},a.loadTemplate=function(b,c,d){if(a.client){var e=document.createElement("script");e.type="application/javascript",e.async=!0,e.src="/views/"+b;var f=document.getElementsByTagName("script")[0];f.parentNode.insertBefore(e,f);var g=setTimeout(function(){delete h.cb[b],d(new Error("Timeout Error: Blade Template ["+b+"] could not be loaded."))},15e3);h.cb[b]=function(a){clearTimeout(g),delete h.cb[b],d(null,a[b])}}else{var h=require("./blade");h.compileFile(b,c,function(a,b){if(a)return d(a);d(null,b.template)})}},a.include=function(c,d,e){function f(a,b,c){if(a)return e(a);for(var f in c.blocks){var g=c.blocks[f],h=d.blocks[f];g.pos!=null?(g.pos+=d.buf.length,d.blocks[f]=g):h==null?d.blocks[f]=g:(g.replace&&(delete h.paramBlock,delete h.renderArgs,delete h.append,delete h.prepend,h.replace=!0),g.renderArgs!=null&&(h.renderArgs=g.renderArgs),g.block!=null&&(h.block=g.block),g.append!=null&&(h.append!=null?h.append+=g.append:h.append=g.append),g.prepend!=null&&(h.prepend!=null?h.prepend=g.prepend+h.prepend:h.prepend=g.prepend))}for(var f in c.buf)d.buf.push(c.buf[f]);e(null)}b[c]?b[c](d.locals,a,f):a.loadTemplate(c,a.compileOptions,function(b,c){if(b)return e(b);c(d.locals,a,f)})},a.blockDef=function(a,b,c){var d=b.blocks[a]={pos:b.buf.length};return b.buf.push(""),c.length>0?d.paramBlock=c:d.block=c().join(""),d},a.blockRender=function(a,b){var c=b.blocks[a]=b.blocks[a]||{},d=[];for(var e=2;e<arguments.length;e++)d[e-2]=arguments[e];c.renderArgs=d},a.blockMod=function(a,b,c,d){var e=c.blocks[b]=c.blocks[b]||{};a=="replace"?(delete e.paramBlock,delete e.renderArgs,delete e.append,delete e.prepend,e.replace=!0,e.block=d().join("")):a=="append"?e.append=(e.append==null?"":e.append)+d().join(""):e.prepend=d().join("")+(e.prepend==null?"":e.prepend)},a.done=function(a){var b=a.blocks;for(var c in b){var d=b[c];d.pos!=null&&(d.paramBlock&&d.renderArgs&&(d.block=d.paramBlock.apply(this,d.renderArgs).join("")),a.buf[d.pos]=(d.prepend?d.prepend:"")+(d.block?d.block:"")+(d.append?d.append:""))}},a.rethrow=function(a,b){b==undefined&&(b=a),b.column=b.col;var d=a.message+"\n    at "+(b.filename==null?"<anonymous>":b.filename)+(b.line==null?"":":"+b.line)+(b.column==null?"":":"+b.column);if(b.source!=null){const e=3;var f=b.source.split("\n"),g=Math.max(b.line-e,0),h=Math.min(b.line+e,f.length),i=(new String(h)).length;f=f.slice(g,h),d+="\n\n";for(var j=0;j<f.length;j++)d+=c(j+g+1,i)+(j+g+1==b.line?">	":"|	")+f[j]+"\n"}return a.message=d,a.filename=b.filename,a.line=b.line,a.column=b.column,a}})();<|endoftext|>


<commit_before>jQuery(document).ready(function($) {
    var jcrop_api;

    $.ajaxSetup({
        type: "POST",
        url: _hh_ajax_fe_profile.ajaxurl
    });

    if ( $('#profile-editor-container').length ) hh_profile_edit_ajax_load_template();

    $(document).on('submit','.hh-update-profile',function(e) {
        e.preventDefault();

        var formfield = $(this).attr('data-meta_key');
        var $formfield = $('#main-'+formfield);
        var meta_key = $formfield.attr('data-meta_key');  console.log('meta_key: '+meta_key);
        var nonce = $formfield.attr('data-nonce');  console.log('nonce: '+nonce);
        var meta_value = $('#input-'+meta_key).val();  console.log('meta_value: '+meta_value);

        $.ajax({
            dataType : "json",
            data : {action: "hh_update_user_profile", meta_key : meta_key, meta_value : meta_value, nonce: nonce},
            beforeSend: function() {
                edit_stop(meta_key);
                edit_alert_show(meta_key,'info','Submitting Request...',true);
                $('.edit-field').addClass('disabled');
            },
            complete: function() {
                edit_stop(meta_key);
                $('#message-'+meta_key).hide();
            },
            success: function(response) {
                var $data = $('#data-'+meta_key);
                $data.html(response.new_value);
                $('Updated').insertAfter('#data-'+meta_key);
                $('.fadeOut').fadeOut(1600,function(){
                    $(this).remove();
                    $('.edit-field').removeClass('disabled');
                });
            },
            error: function () {
                var $data = $('#data-'+meta_key);
                $('Failed!!').insertAfter('#data-'+meta_key);
                $('.fadeOut').fadeOut(2600,function(){
                    $(this).remove();
                    $('.edit-field').removeClass('disabled');
                });
            }
        });
    });

    $(document).on('click','.edit-field', function() {
        if ( $(this).hasClass('disabled') ) return;
        edit_start($(this).attr('data-meta_key'));
    });

    $(document).on('click','.pr-cancel', function() {
        edit_stop($(this).attr('data-meta_key'));
    });

    function edit_start(meta_key) {
        $('#current_meta_key').val(meta_key);
        $('#'+meta_key).show();
        $('#main-'+meta_key).addClass('edit-highlight');
        $('#swap-'+meta_key).hide();
        $('#pad-'+meta_key).addClass('field-highlight').css('padding','0');
        $('#controls-'+meta_key).show().css('height','auto');
        $('#input-'+meta_key).focus();
    }
    function edit_stop(meta_key) {
        $('#'+meta_key).removeAttr('style');
        $('#input-'+meta_key).val($('#data-'+meta_key).text());
        $('#main-'+meta_key).removeClass('edit-highlight').removeAttr('style');
        $('#pad-'+meta_key).removeClass('field-highlight').removeAttr('style');
        $('#swap-'+meta_key).removeAttr('style');
        $('#controls-'+meta_key).removeAttr('style');
    }

    function edit_alert_show(meta_key,type,message,show_process) {
        $('#main-'+meta_key).addClass('disabled');
        $('#pad-'+meta_key).hide();
        var processing_img = $('#hh_update_profile').attr('data-processing-uri');
        var msg  = '
';
        msg  += '
'+message+'
';
        if (show_process) {
            msg += '';
        }
        msg += '
';
        $('#message-'+meta_key).html(msg).show();
    }

    /**
     * When you click on your profile picture in form.
     */
    $(document).on('click','#hh-change-profile-photo',function(e) {
        e.preventDefault();
        $('#fileUpload-container').show();
        $('.edit-field').addClass('disabled');
    });

    /**
     * When you click you click on the X button to close the container
     */
    $(document).on('click','.close-fileUpload-container',function() {
        location.reload();
        /*
         var previewFields = $('.fileUpload-preview');
         var selectFields = $('.fileUpload-select');
         var errorFields = $('.fileUpload-error');
         var cropFields = $('.fileUpload-crop');
         selectFields.hide();
         cropFields.hide();
         $('#fileUpload-canvas').removeAttr('style');
         previewFields.hide().removeAttr('style');
         errorFields.hide();
         selectFields.show();
         if (jcrop_api) {
         jcrop_api.destroy();
         }
         $('#fileUpload-container').hide();
         $('.edit-field').removeClass('disabled');
         */
    });

    /**
     *  When the input id fileUpload-file has changed.
     */
    $(document).on('change','#fileUpload-file', function() {

        var file = this.files[0];
        var valid_exts = ['jpeg', 'jpg', 'png', 'gif']; // valid extensions
        var ext = file.name.split('.').pop().toLowerCase();
        if (valid_exts.indexOf(ext) > -1) {
            if (file.size < 1048576) {
                /* html FileRender Api */
                var oFReader = new FileReader();
                oFReader.readAsDataURL(document.getElementById("fileUpload-file").files[0]);
                oFReader.onload = function (oFREvent) {
                    $('.fileUpload-select').hide();
                    $('.fileUpload-preview').show();
                    $editImage = $('#fileUpload-preview');
                    $editImage.removeAttr('style');
                    $editImage.css('visibility', 'visible');
                    $editImage.attr('src', oFREvent.target.result).fadeIn();
                    $canvas = $('#fileUpload-canvas');
                    $editImage.Jcrop({
                        setSelect: [100,100,400,400],
                        minSize: [150,150],
                        aspectRatio: 1,
                        boxWidth: $canvas.width(),
                        onSelect: storeCoords
                    },function() {
                        jcrop_api = this;
                        $canvas.width(jcrop_api.getWidgetSize()[0]);
                        $canvas.height(jcrop_api.getWidgetSize()[1]);
                    });

                }
            } else {
                errorFields.fadeIn();
                $('#fileUpload-errorMessage').html('Too big!
 (Your file must be less than 1MB in size)');
            }
        } else {
            errorFields.fadeIn();
            $('#fileUpload-errorMessage').html('Invalid Filetype!
 (Only jpeg, jpg, png, gif are supported)');
        }
    });

    function storeCoords(c)
    {
        // variables can be accessed here as
        // c.x, c.y, c.x2, c.y2, c.w, c.h
        $fileContainer = $('#fileUpload-file');
        $fileContainer.attr('data-x1',c.x);
        $fileContainer.attr('data-y1',c.y);
        $fileContainer.attr('data-x2',c.x2);
        $fileContainer.attr('data-y2',c.y2);
        $fileContainer.attr('data-w',c.w);
        $fileContainer.attr('data-h',c.h);

    };

    /**
     * Save Cropped Photo
     */
    $(document).on('submit','#fileUpload-container',function(e) {
        debugger;
        e.preventDefault();
        nonce = $(this).attr('data-nonce');
        $fileContainer = $('#fileUpload-file');
        params = {
            x1 : $fileContainer.attr('data-x1') ,
            y1 : $fileContainer.attr('data-y1') ,
            x2 : $fileContainer.attr('data-x2') ,
            y2 : $fileContainer.attr('data-y2')
        };
        $.ajaxForm({
            dataType : "json",
            data : {
                action: "hh_save_profile_pic",
                nonce: nonce,
                params: params
            },
            beforeSend: function() {
                console.log('beforeSend');
            },
            complete: function(response) {
                console.log(response.responseText);
                console.log('complete');
            },
            success: function(response) {
                console.log(response);
            },
            error: function () {
            }
        });

    });

});

window.hh_profile_edit_ajax_load_template = function () {
    jQuery(document).ready(function($) {
        $.ajax({
            dataType : "html",
            data: { action: "hh_ajax_load_profile_editor" },
            success: function (data) {
                $('#profile-editor-preloader').fadeOut('fast');
                $('#profile-editor-container').fadeIn('slow').html(data);
            }
        });

    });
};

<commit_msg>use ajaxform instead of ajax<commit_after>jQuery(document).ready(function($) {
    var jcrop_api;

    $.ajaxSetup({
        type: "POST",
        url: _hh_ajax_fe_profile.ajaxurl
    });

    if ( $('#profile-editor-container').length ) hh_profile_edit_ajax_load_template();

    $(document).on('submit','.hh-update-profile',function(e) {
        e.preventDefault();

        var formfield = $(this).attr('data-meta_key');
        var $formfield = $('#main-'+formfield);
        var meta_key = $formfield.attr('data-meta_key');  console.log('meta_key: '+meta_key);
        var nonce = $formfield.attr('data-nonce');  console.log('nonce: '+nonce);
        var meta_value = $('#input-'+meta_key).val();  console.log('meta_value: '+meta_value);

        $.ajax({
            dataType : "json",
            data : {action: "hh_update_user_profile", meta_key : meta_key, meta_value : meta_value, nonce: nonce},
            beforeSend: function() {
                edit_stop(meta_key);
                edit_alert_show(meta_key,'info','Submitting Request...',true);
                $('.edit-field').addClass('disabled');
            },
            complete: function() {
                edit_stop(meta_key);
                $('#message-'+meta_key).hide();
            },
            success: function(response) {
                var $data = $('#data-'+meta_key);
                $data.html(response.new_value);
                $('Updated').insertAfter('#data-'+meta_key);
                $('.fadeOut').fadeOut(1600,function(){
                    $(this).remove();
                    $('.edit-field').removeClass('disabled');
                });
            },
            error: function () {
                var $data = $('#data-'+meta_key);
                $('Failed!!').insertAfter('#data-'+meta_key);
                $('.fadeOut').fadeOut(2600,function(){
                    $(this).remove();
                    $('.edit-field').removeClass('disabled');
                });
            }
        });
    });

    $(document).on('click','.edit-field', function() {
        if ( $(this).hasClass('disabled') ) return;
        edit_start($(this).attr('data-meta_key'));
    });

    $(document).on('click','.pr-cancel', function() {
        edit_stop($(this).attr('data-meta_key'));
    });

    function edit_start(meta_key) {
        $('#current_meta_key').val(meta_key);
        $('#'+meta_key).show();
        $('#main-'+meta_key).addClass('edit-highlight');
        $('#swap-'+meta_key).hide();
        $('#pad-'+meta_key).addClass('field-highlight').css('padding','0');
        $('#controls-'+meta_key).show().css('height','auto');
        $('#input-'+meta_key).focus();
    }
    function edit_stop(meta_key) {
        $('#'+meta_key).removeAttr('style');
        $('#input-'+meta_key).val($('#data-'+meta_key).text());
        $('#main-'+meta_key).removeClass('edit-highlight').removeAttr('style');
        $('#pad-'+meta_key).removeClass('field-highlight').removeAttr('style');
        $('#swap-'+meta_key).removeAttr('style');
        $('#controls-'+meta_key).removeAttr('style');
    }

    function edit_alert_show(meta_key,type,message,show_process) {
        $('#main-'+meta_key).addClass('disabled');
        $('#pad-'+meta_key).hide();
        var processing_img = $('#hh_update_profile').attr('data-processing-uri');
        var msg  = '
';
        msg  += '
'+message+'
';
        if (show_process) {
            msg += '';
        }
        msg += '
';
        $('#message-'+meta_key).html(msg).show();
    }

    /**
     * When you click on your profile picture in form.
     */
    $(document).on('click','#hh-change-profile-photo',function(e) {
        e.preventDefault();
        $('#fileUpload-container').show();
        $('.edit-field').addClass('disabled');
    });

    /**
     * When you click you click on the X button to close the container
     */
    $(document).on('click','.close-fileUpload-container',function() {
        location.reload();
        /*
         var previewFields = $('.fileUpload-preview');
         var selectFields = $('.fileUpload-select');
         var errorFields = $('.fileUpload-error');
         var cropFields = $('.fileUpload-crop');
         selectFields.hide();
         cropFields.hide();
         $('#fileUpload-canvas').removeAttr('style');
         previewFields.hide().removeAttr('style');
         errorFields.hide();
         selectFields.show();
         if (jcrop_api) {
         jcrop_api.destroy();
         }
         $('#fileUpload-container').hide();
         $('.edit-field').removeClass('disabled');
         */
    });

    /**
     *  When the input id fileUpload-file has changed.
     */
    $(document).on('change','#fileUpload-file', function() {

        var file = this.files[0];
        var valid_exts = ['jpeg', 'jpg', 'png', 'gif']; // valid extensions
        var ext = file.name.split('.').pop().toLowerCase();
        if (valid_exts.indexOf(ext) > -1) {
            if (file.size < 1048576) {
                /* html FileRender Api */
                var oFReader = new FileReader();
                oFReader.readAsDataURL(document.getElementById("fileUpload-file").files[0]);
                oFReader.onload = function (oFREvent) {
                    $('.fileUpload-select').hide();
                    $('.fileUpload-preview').show();
                    $editImage = $('#fileUpload-preview');
                    $editImage.removeAttr('style');
                    $editImage.css('visibility', 'visible');
                    $editImage.attr('src', oFREvent.target.result).fadeIn();
                    $canvas = $('#fileUpload-canvas');
                    $editImage.Jcrop({
                        setSelect: [100,100,400,400],
                        minSize: [150,150],
                        aspectRatio: 1,
                        boxWidth: $canvas.width(),
                        onSelect: storeCoords
                    },function() {
                        jcrop_api = this;
                        $canvas.width(jcrop_api.getWidgetSize()[0]);
                        $canvas.height(jcrop_api.getWidgetSize()[1]);
                    });

                }
            } else {
                errorFields.fadeIn();
                $('#fileUpload-errorMessage').html('Too big!
 (Your file must be less than 1MB in size)');
            }
        } else {
            errorFields.fadeIn();
            $('#fileUpload-errorMessage').html('Invalid Filetype!
 (Only jpeg, jpg, png, gif are supported)');
        }
    });

    function storeCoords(c)
    {
        // variables can be accessed here as
        // c.x, c.y, c.x2, c.y2, c.w, c.h
        $fileContainer = $('#fileUpload-file');
        $fileContainer.attr('data-x1',c.x);
        $fileContainer.attr('data-y1',c.y);
        $fileContainer.attr('data-x2',c.x2);
        $fileContainer.attr('data-y2',c.y2);
        $fileContainer.attr('data-w',c.w);
        $fileContainer.attr('data-h',c.h);

    };

    /**
     * Save Cropped Photo
     */
    $(document).on('submit','#fileUpload-container',function(e) {
        debugger;
        e.preventDefault();
        nonce = $(this).attr('data-nonce');
        $fileContainer = $('#fileUpload-file');
        $.ajaxForm({
            dataType : "json",
            data : {
                action: "hh_save_profile_pic",
                nonce: nonce,
                x1 : $fileContainer.attr('data-x1') ,
                y1 : $fileContainer.attr('data-y1') ,
                x2 : $fileContainer.attr('data-x2') ,
                y2 : $fileContainer.attr('data-y2')
            },
            beforeSend: function() {
                console.log('beforeSend');
            },
            complete: function(response) {
                console.log(response.responseText);
                console.log('complete');
            },
            success: function(response) {
                console.log(response);
            },
            error: function () {
            }
        });

    });

});

window.hh_profile_edit_ajax_load_template = function () {
    jQuery(document).ready(function($) {
        $.ajax({
            dataType : "html",
            data: { action: "hh_ajax_load_profile_editor" },
            success: function (data) {
                $('#profile-editor-preloader').fadeOut('fast');
                $('#profile-editor-container').fadeIn('slow').html(data);
            }
        });

    });
};

<|endoftext|>


<commit_before>//live ticks
(function () {
    "use strict";
    //script for live ticks
    function loadLive(e) {
        e.fail(function(jqXHR, textStatus, errorThrown) {
            console.error(jqXHR.responseJSON.msg);
        });
        e.done(function(e, textStatus, jqXHR) {
            let actions = e.actions;
            if (actions !== null) {
    //                actions.reverse();
                for (let i = 0; i < actions.length; i++) {
    //                    var dateRaw = new Date (actions[i].time*1000);
    //                    var hours = '0' + dateRaw.getHours();
    //                    var minutes = '0' + dateRaw.getMinutes();
    //                    var date = hours.substr(-2) + ':' + minutes.substr(-2);
                    $('#dashLiveList').prepend("
" +
                        actions[i].dateTime + ": " + actions[i].userName + " ...called: " + actions[i].url + "
");
                }
            }
            setTimeout(function() {
                let ele =  $('#dashLiveList li:nth-child(1)');
                let since = ele.data('timestamp');
                livereload(since);
            }, 4500);
        });
    }
    function livereload(since) {
        let data = {
            method: "getLiveActions",
            since: since,
        };
        $.ajax({
            url: "/system/json",
            type: "POST",
            data: JSON.stringify(data),
            complete: loadLive,
        });
    }
    livereload( $('#dashLiveList li:nth-child(1)').data('timestamp'), 0);
})();
//
(function () {
    "use strict";
    //script for live ticks
    function loadActive(e) {
        e.fail(function(jqXHR, textStatus, errorThrown) {
            console.error(jqXHR.responseJSON.msg);
        });
        e.done(function(e, textStatus, jqXHR) {
            let user = e.users;
            // active users
            if (user !== null) {
                // user.reverse();
                for (let c = 0; c < user.length; c++){
                    // remove updated user
                    if (user[c].userId == $('li[data-userId="' + user[c].userId + '"]').data('userId') ) {
                        if (user[c].microtime == $('li[data-microtime="' + user[c].microtime + '"]').data('microtime')) continue;
                    }
                    $('li[data-firstCall="' + user[c].firstCall + '"]').remove();
                    // prepend updated user
                    $('#users').prepend("
" +
                        user[c].userName + ": " + user[c].url + " @ " + user[c].dateTime + "
");
                }
            }
            setTimeout(function() {
                let elm = $('#users li:nth-child(1)');
                let microtime = elm.data('microtime');
                activereload(microtime);
            }, 4500);
        });
    }
    function activereload(microtime) {
        let data = {
            method: "getActiveUsers",
            microtime: microtime,
        };
        $.ajax({
            url: "/system/json",
            type: "POST",
            data: JSON.stringify(data),
            complete: loadActive
        });
    }
    activereload( 1 );
})();
//
(function(){
    var html = $('.dashboard.systemLog boxcontent').html();;
    // function closefunction(){
    //
    // }
    $('.systemLog').on('click', function(){
        // html = $('.dashboard.systemLog boxcontent').html();
        // html = $('#sysTable').html();
        $('

').dialog({
            // close: closefunction,
            width: "100%",
            // top: "30%",
        });
        $('#pop').append(html);
        $('#pop ul').css('max-height', '60vh');
    });
})();
//system config control
(function () {
    "use strict";
    //scan system vars and register handler
    var $systemPanel = $('.systemPanel'),
        $cachePanel = $('.cachePanel');

    $("button", $systemPanel).on('click', function(e) {
        let type = $(this).data('type');
        if (type === 'function') {
            let valueName = $(this).attr('name');
            //handle function
            console.log(valueName, type);
            setSystemConfig(valueName, []);
        } else if (type === 'boolean') {
            //handle string, number
            let $input = $(this).parent().children('input');
            let valueName = $input.attr('name');
            let value = $input.prop('checked');
            //handle checkbox
            console.log(valueName, value, type);
            setSystemConfig(valueName, value);
        } else {
            let $input = $(this).parent().children('input');
            let valueName = $input.attr('name');
            let value = $input.val();
            console.log(valueName, value, type);
            setSystemConfig(valueName, value);
        }
    });
    function getSystemConfig() {
        send({
            method: 'getSystemConfig'
        }).fail(function() {
            console.log('######### fail');
        }).done(function() {
            console.log('############ nice');
        });
    }
    function setSystemConfig(key, value) {
        send({
            method: 'setSystemConfig',
            valueName: key,
            value: value,
        }).fail(function() {
            console.log('######### fail');
        }).done(function() {
            console.log('############ nice');
        });
    }
    function send(data) {
        return $.ajax({
            url: "/system/json",
            type: "POST",
            data: JSON.stringify(data),
        });
    }
    // function loadLive(e) {
    //     e.fail(function(jqXHR, textStatus, errorThrown) {
    //         console.error(jqXHR.responseJSON.msg);
    //     });
    //     e.done(function(e, textStatus, jqXHR) {
    //         let actions = e.actions;
    //         if (actions !== null) {
    //             //                actions.reverse();
    //             for (let i = 0; i < actions.length; i++) {
    //                 //                    var dateRaw = new Date (actions[i].time*1000);
    //                 //                    var hours = '0' + dateRaw.getHours();
    //                 //                    var minutes = '0' + dateRaw.getMinutes();
    //                 //                    var date = hours.substr(-2) + ':' + minutes.substr(-2);
    //                 $('#dashLiveList').prepend("
" +
    //                     actions[i].dateTime + ": " + actions[i].userName + " ...called: " + actions[i].url + "
");
    //             }
    //         }
    //         setTimeout(function() {
    //             let ele =  $('#dashLiveList li:nth-child(1)');
    //             let since = ele.data('timestamp');
    //             livereload(since);
    //         }, 4500);
    //     });
    // }
    // function livereload(since) {
    //     let data = {
    //         method: "getLiveActions",
    //         since: since,
    //     };
    //     $.ajax({
    //         url: "/system/json",
    //         type: "POST",
    //         data: JSON.stringify(data),
    //         complete: loadLive,
    //     });
    // }
})();<commit_msg>cache config js<commit_after>//live ticks
(function () {
    "use strict";
    //script for live ticks
    function loadLive(e) {
        e.fail(function(jqXHR, textStatus, errorThrown) {
            console.error(jqXHR.responseJSON.msg);
        });
        e.done(function(e, textStatus, jqXHR) {
            let actions = e.actions;
            if (actions !== null) {
    //                actions.reverse();
                for (let i = 0; i < actions.length; i++) {
    //                    var dateRaw = new Date (actions[i].time*1000);
    //                    var hours = '0' + dateRaw.getHours();
    //                    var minutes = '0' + dateRaw.getMinutes();
    //                    var date = hours.substr(-2) + ':' + minutes.substr(-2);
                    $('#dashLiveList').prepend("
" +
                        actions[i].dateTime + ": " + actions[i].userName + " ...called: " + actions[i].url + "
");
                }
            }
            setTimeout(function() {
                let ele =  $('#dashLiveList li:nth-child(1)');
                let since = ele.data('timestamp');
                livereload(since);
            }, 4500);
        });
    }
    function livereload(since) {
        let data = {
            method: "getLiveActions",
            since: since,
        };
        $.ajax({
            url: "/system/json",
            type: "POST",
            data: JSON.stringify(data),
            complete: loadLive,
        });
    }
    livereload( $('#dashLiveList li:nth-child(1)').data('timestamp'), 0);
})();
//
(function () {
    "use strict";
    //script for live ticks
    function loadActive(e) {
        e.fail(function(jqXHR, textStatus, errorThrown) {
            console.error(jqXHR.responseJSON.msg);
        });
        e.done(function(e, textStatus, jqXHR) {
            let user = e.users;
            // active users
            if (user !== null) {
                // user.reverse();
                for (let c = 0; c < user.length; c++){
                    // remove updated user
                    if (user[c].userId == $('li[data-userId="' + user[c].userId + '"]').data('userId') ) {
                        if (user[c].microtime == $('li[data-microtime="' + user[c].microtime + '"]').data('microtime')) continue;
                    }
                    $('li[data-firstCall="' + user[c].firstCall + '"]').remove();
                    // prepend updated user
                    $('#users').prepend("
" +
                        user[c].userName + ": " + user[c].url + " @ " + user[c].dateTime + "
");
                }
            }
            setTimeout(function() {
                let elm = $('#users li:nth-child(1)');
                let microtime = elm.data('microtime');
                activereload(microtime);
            }, 4500);
        });
    }
    function activereload(microtime) {
        let data = {
            method: "getActiveUsers",
            microtime: microtime,
        };
        $.ajax({
            url: "/system/json",
            type: "POST",
            data: JSON.stringify(data),
            complete: loadActive
        });
    }
    activereload( 1 );
})();
//
(function(){
    var html = $('.dashboard.systemLog boxcontent').html();;
    // function closefunction(){
    //
    // }
    $('.systemLog').on('click', function(){
        // html = $('.dashboard.systemLog boxcontent').html();
        // html = $('#sysTable').html();
        $('

').dialog({
            // close: closefunction,
            width: "100%",
            // top: "30%",
        });
        $('#pop').append(html);
        $('#pop ul').css('max-height', '60vh');
    });
})();
//system config control
(function () {
    "use strict";
    //scan system vars and register handler
    var $systemPanel = $('.systemPanel'),
        $cachePanel = $('.cachePanel');

    $("button", $systemPanel).on('click', function(e) {
        let type = $(this).data('type');
        if (type === 'function') {
            let valueName = $(this).attr('name');
            //handle function
            console.log(valueName, type);
            setSystemConfig(valueName, []);
        } else if (type === 'boolean') {
            //handle string, number
            let $input = $(this).parent().children('input');
            let valueName = $input.attr('name');
            let value = $input.prop('checked');
            //handle checkbox
            console.log(valueName, value, type);
            setSystemConfig(valueName, value);
        } else {
            let $input = $(this).parent().children('input');
            let valueName = $input.attr('name');
            let value = $input.val();
            console.log(valueName, value, type);
            setSystemConfig(valueName, value);
        }
    });

    $("button", $cachePanel).on('click', function(e) {
        let cacheName = $(this).attr('name');
        console.log('clear');
        clearCache(cacheName);
    });

    function getSystemConfig() {
        send({
            method: 'getSystemConfig'
        }).fail(function() {
            console.log('######### fail');
        }).done(function() {
            console.log('############ nice');
        });
    }
    function setSystemConfig(key, value) {
        send({
            method: 'setSystemConfig',
            valueName: key,
            value: value,
        }).fail(function() {
            console.log('fail setting system config');
        }).done(function() {
            console.log('set system config');
        });
    }
    function clearCache(name) {
        send({
            method: 'clearCache',
            name: name,
        }).fail(function() {
            console.log('failed clearing cache');
        }).done(function() {
            console.log('Cache cleared');
        });
    }
    function send(data) {
        return $.ajax({
            url: "/system/json",
            type: "POST",
            data: JSON.stringify(data),
        });
    }
})();<|endoftext|>


<commit_before>export { testCorrectness };

import * as RandTools from "../util/RandTools.js";
import * as TensorTools from "../util/TensorTools.js";
import * as FloatValue from "../Unpacker/FloatValue.js";

/**
 * Test ScaleTranslate.
 */
class Base {

  constructor() {
    this.asserter_Equal = TensorTools.Asserter_Equal();
  }

  assert_PropertyProperty_Value( strThisPropertyName, strThisPropertyPropertyName, rhsValue ) {
    let thisValue = this[ strThisPropertyName ][ strThisPropertyPropertyName ];

//!!! (2021/12/31 Remarked)
//     tf.util.assert( thisValue == rhsValue, `jsPerf_FloatValue_ScaleTranslate.testCorrectness(): `
//       + `this.${strThisPropertyName}.${strThisPropertyPropertyName} ( ${thisValue} ) should be ( ${rhsValue} ).` );

    this.assert_Number_Number( thisValue, rhsValue,
      `jsPerf_FloatValue_ScaleTranslate.testCorrectness(): this.`, // prefixMsg,
      `${strThisPropertyName}.${strThisPropertyPropertyName}`, // lhsNumberName,
      ``, // rhsNumberName,
      ``  // postfixMsg
    );
  }

}

/**
 * Test ScaleTranslate.
 */
class Case extends Base {

  constructor() {
    super();

    { // Test setBy_undoScaleTranslate().
      let scale = RandTools.getRandomIntInclusive( -10, +10 ); //
      scale = Math.sign( scale ) * ( Math.abs( scale ) + 0.05 );  // Force to non-zero. (Note: undoScaleTranslate does not work for zero.)

      let aScaleTranslate = new FloatValue.ScaleTranslate( scale, RandTools.getRandomIntInclusive( -10, +10 ) ); // Random scale-translate.

      let undoScaleTranslate = new FloatValue.ScaleTranslate();
      undoScaleTranslate.setBy_undoScaleTranslate( aScaleTranslate );

      let originalValue = RandTools.getRandomIntInclusive( -10, +10 );
      let changedValue = ( originalValue * aScaleTranslate.scale ) + aScaleTranslate.translate;
      this.undoTest = {
        undoChangedValue: ( changedValue * undoScaleTranslate.scale ) + undoScaleTranslate.translate
      };

      this.assert_PropertyProperty_Value( "undoTest", "undoChangedValue", originalValue );
    }
  }

}

/**
 * Test ScaleTranslateArray.
 */
class Cases extends Base {

  constructor() {
    super();

  }

}

function testCorrectness() {
  let casesArray = [
    new Cases( [
      new Case(),
    ] ),
  ];

//!!! ...unfinished... (2021/12/31)

//   let casesArray = [
//     new Cases( [
//       new Case( [  1,  2 ], [  3,  4 ],  5, [  4,  6 ], [  3,  8 ], [   5,  10 ] ),
//       new Case( [ -1,  2 ], [  3,  4 ],  5, [  2,  6 ], [ -4,  8 ], [  -5,  10 ] ),
//       new Case( [  1, -2 ], [  3,  4 ],  5, [  1,  5 ], [ -8,  4 ], [ -10,   5 ] ),
//       new Case( [ -1, -2 ], [  3,  4 ],  5, [  1,  3 ], [ -8, -3 ], [ -10,  -5 ] ),
//     ] ),

//     new Cases( [
//       new Case( [  1,  2 ], [ -3,  4 ], -5, [ -2,  6 ], [ -6,  8 ], [ -10,  -5 ] ),
//       new Case( [ -1,  2 ], [ -3,  4 ], -5, [ -4,  6 ], [ -6,  8 ], [ -10,   5 ] ),
//       new Case( [  1, -2 ], [ -3,  4 ], -5, [ -5,  5 ], [ -8,  6 ], [  -5,  10 ] ),
//       new Case( [ -1, -2 ], [ -3,  4 ], -5, [ -5,  3 ], [ -8,  6 ], [   5,  10 ] ),
//     ] ),

//     new Cases( [
//       new Case( [  1,  2 ], [  3, -4 ],  5, [ -3,  5 ], [ -8,  6 ], [   5,  10 ] ),
//       new Case( [ -1,  2 ], [  3, -4 ],  5, [ -5,  5 ], [ -8,  6 ], [  -5,  10 ] ),
//       new Case( [  1, -2 ], [  3, -4 ],  5, [ -6,  4 ], [ -6,  8 ], [ -10,   5 ] ),
//       new Case( [ -1, -2 ], [  3, -4 ],  5, [ -6,  2 ], [ -6,  8 ], [ -10,  -5 ] ),
//     ] ),

//     new Cases( [
//       new Case( [  1,  2 ], [ -3, -4 ], -5, [ -3, -1 ], [ -8, -3 ], [ -10,  -5 ] ),
//       new Case( [ -1,  2 ], [ -3, -4 ], -5, [ -5, -1 ], [ -8,  4 ], [ -10,   5 ] ),
//       new Case( [  1, -2 ], [ -3, -4 ], -5, [ -6, -2 ], [ -4,  8 ], [  -5,  10 ] ),
//       new Case( [ -1, -2 ], [ -3, -4 ], -5, [ -6, -4 ], [  3,  8 ], [   5,  10 ] ),
//     ] ),
//   ];

}
<commit_msg>Update jsPerf_FloatValue_ScaleTranslate.js<commit_after>export { testCorrectness };

import * as RandTools from "../util/RandTools.js";
import * as TensorTools from "../util/TensorTools.js";
import * as FloatValue from "../Unpacker/FloatValue.js";

/**
 * Test ScaleTranslate.
 */
class Base {

  constructor() {
    this.asserter_Equal = new TensorTools.Asserter_Equal();
  }

  assert_PropertyProperty_Value( strThisPropertyName, strThisPropertyPropertyName, rhsValue ) {
    let thisValue = this[ strThisPropertyName ][ strThisPropertyPropertyName ];

//!!! (2021/12/31 Remarked)
//     tf.util.assert( thisValue == rhsValue, `jsPerf_FloatValue_ScaleTranslate.testCorrectness(): `
//       + `this.${strThisPropertyName}.${strThisPropertyPropertyName} ( ${thisValue} ) should be ( ${rhsValue} ).` );

    this.assert_Number_Number( thisValue, rhsValue,
      `jsPerf_FloatValue_ScaleTranslate.testCorrectness(): this.`, // prefixMsg,
      `${strThisPropertyName}.${strThisPropertyPropertyName}`, // lhsNumberName,
      ``, // rhsNumberName,
      ``  // postfixMsg
    );
  }

}

/**
 * Test ScaleTranslate.
 */
class Case extends Base {

  constructor() {
    super();

    { // Test setBy_undoScaleTranslate().
      let scale = RandTools.getRandomIntInclusive( -10, +10 ); //
      scale = Math.sign( scale ) * ( Math.abs( scale ) + 0.05 );  // Force to non-zero. (Note: undoScaleTranslate does not work for zero.)

      let aScaleTranslate = new FloatValue.ScaleTranslate( scale, RandTools.getRandomIntInclusive( -10, +10 ) ); // Random scale-translate.

      let undoScaleTranslate = new FloatValue.ScaleTranslate();
      undoScaleTranslate.setBy_undoScaleTranslate( aScaleTranslate );

      let originalValue = RandTools.getRandomIntInclusive( -10, +10 );
      let changedValue = ( originalValue * aScaleTranslate.scale ) + aScaleTranslate.translate;
      this.undoTest = {
        undoChangedValue: ( changedValue * undoScaleTranslate.scale ) + undoScaleTranslate.translate
      };

      this.assert_PropertyProperty_Value( "undoTest", "undoChangedValue", originalValue );
    }
  }

}

/**
 * Test ScaleTranslateArray.
 */
class Cases extends Base {

  constructor() {
    super();

  }

}

function testCorrectness() {
  let casesArray = [
    new Cases( [
      new Case(),
    ] ),
  ];

//!!! ...unfinished... (2021/12/31)

//   let casesArray = [
//     new Cases( [
//       new Case( [  1,  2 ], [  3,  4 ],  5, [  4,  6 ], [  3,  8 ], [   5,  10 ] ),
//       new Case( [ -1,  2 ], [  3,  4 ],  5, [  2,  6 ], [ -4,  8 ], [  -5,  10 ] ),
//       new Case( [  1, -2 ], [  3,  4 ],  5, [  1,  5 ], [ -8,  4 ], [ -10,   5 ] ),
//       new Case( [ -1, -2 ], [  3,  4 ],  5, [  1,  3 ], [ -8, -3 ], [ -10,  -5 ] ),
//     ] ),

//     new Cases( [
//       new Case( [  1,  2 ], [ -3,  4 ], -5, [ -2,  6 ], [ -6,  8 ], [ -10,  -5 ] ),
//       new Case( [ -1,  2 ], [ -3,  4 ], -5, [ -4,  6 ], [ -6,  8 ], [ -10,   5 ] ),
//       new Case( [  1, -2 ], [ -3,  4 ], -5, [ -5,  5 ], [ -8,  6 ], [  -5,  10 ] ),
//       new Case( [ -1, -2 ], [ -3,  4 ], -5, [ -5,  3 ], [ -8,  6 ], [   5,  10 ] ),
//     ] ),

//     new Cases( [
//       new Case( [  1,  2 ], [  3, -4 ],  5, [ -3,  5 ], [ -8,  6 ], [   5,  10 ] ),
//       new Case( [ -1,  2 ], [  3, -4 ],  5, [ -5,  5 ], [ -8,  6 ], [  -5,  10 ] ),
//       new Case( [  1, -2 ], [  3, -4 ],  5, [ -6,  4 ], [ -6,  8 ], [ -10,   5 ] ),
//       new Case( [ -1, -2 ], [  3, -4 ],  5, [ -6,  2 ], [ -6,  8 ], [ -10,  -5 ] ),
//     ] ),

//     new Cases( [
//       new Case( [  1,  2 ], [ -3, -4 ], -5, [ -3, -1 ], [ -8, -3 ], [ -10,  -5 ] ),
//       new Case( [ -1,  2 ], [ -3, -4 ], -5, [ -5, -1 ], [ -8,  4 ], [ -10,   5 ] ),
//       new Case( [  1, -2 ], [ -3, -4 ], -5, [ -6, -2 ], [ -4,  8 ], [  -5,  10 ] ),
//       new Case( [ -1, -2 ], [ -3, -4 ], -5, [ -6, -4 ], [  3,  8 ], [   5,  10 ] ),
//     ] ),
//   ];

}
<|endoftext|>


<commit_before>var git = require( '../' ).git2;

var repo = new git.Repo();

// Access existing repository
repo.open( '/home/tim/Dropbox/Projects/dotfiles/.git', function( err, path ) {
  var revwalk = new git.RevWalk( repo ),
      oid = new git.Oid(),
      error = new git.Error(),
      master = new git.Ref( repo ),
      commit = new git.Commit( repo );

  if( err ) { console.log( error.strError( err ) ); return; }

  oid.mkstr( '3b6adb69dde2cf72ce0e5dd81f51e3d72f08db24' );

  //repo.lookupRef( master, "refs/heads/master", function( err, ref ) {
  //  if( err ) { return; }
  //
  //  var newOid = new git.Oid();
  //  master.oid(newOid);
  //  commit.lookup( repo, newOid, function( err ) {
  //    if( err ) { console.log('Error', error.strError(err)); return; }
  //    console.log(newOid.toString(40));
  //    var _commit = new git.Commit(repo);
  //    function walk() {
  //      revwalk.next(_commit, function( err ) {
  //        if( err ) { console.log(error.strError(err));return; }
  //        console.log( _commit.messageShort() );
  //        walk();
  //      });
  //    }
  //
  //    walk();
  //  });
  //
  //  //var _commit = new git.Commit(repo);
  //
  //});

  commit.lookup( repo, oid, function( err ) {
    if( err ) { console.log('Error', error.strError(err)); return; }
    revwalk.push( commit );

    var _commit = new git.Commit(repo);

    function walk() {
      revwalk.next(_commit, function( err ) {
        if( err ) { return; }
        console.log( _commit.messageShort() );
        walk();
      });
    }

    walk();
  });

  //repo.lookupRef( master, "refs/heads/master", function( err, ref ) {
  //  if( err ) { console.log(error.strError(err)); return; }
  //  var newOid = new git.Oid();
  //  console.log(newOid.toString(40));
  //  commit.lookup( repo, newOid, function( err ) {
  //    console.log( err );
  //    console.log('Test', this);
  //    console.log( error.strError( revwalk.push( this ) ) );
  //  });
  //});
});
<commit_msg>update revwalk lib<commit_after>var git = require( '../' ).git2;

var repo = new git.Repo();

// Access existing repository
repo.open( '.git', function( err, path ) {
  var revwalk = new git.RevWalk( repo ),
      oid = new git.Oid(),
      error = new git.Error(),
      master = new git.Ref( repo ),
      commit = new git.Commit( repo );

  if( err ) { console.log( error.strError( err ) ); return; }

  oid.mkstr( '7e1fad218e6c0b910c4780b0da111ed5a52dde79' );

  //repo.lookupRef( master, "refs/heads/master", function( err, ref ) {
  //  if( err ) { return; }
  //
  //  var newOid = new git.Oid();
  //  master.oid(newOid);
  //  commit.lookup( repo, newOid, function( err ) {
  //    if( err ) { console.log('Error', error.strError(err)); return; }
  //    console.log(newOid.toString(40));
  //    var _commit = new git.Commit(repo);
  //    function walk() {
  //      revwalk.next(_commit, function( err ) {
  //        if( err ) { console.log(error.strError(err));return; }
  //        console.log( _commit.messageShort() );
  //        walk();
  //      });
  //    }
  //
  //    walk();
  //  });
  //
  //  //var _commit = new git.Commit(repo);
  //
  //});

  commit.lookup( repo, oid, function( err ) {
    if( err ) { console.log('Error', error.strError(err)); return; }
    revwalk.push( commit );

    var _commit = new git.Commit(repo);

    function walk() {
      revwalk.next(_commit, function( err ) {
        if( err ) { return; }
        console.log( _commit.messageShort() );
        walk();
      });
    }

    walk();
  });

  //repo.lookupRef( master, "refs/heads/master", function( err, ref ) {
  //  if( err ) { console.log(error.strError(err)); return; }
  //  var newOid = new git.Oid();
  //  console.log(newOid.toString(40));
  //  commit.lookup( repo, newOid, function( err ) {
  //    console.log( err );
  //    console.log('Test', this);
  //    console.log( error.strError( revwalk.push( this ) ) );
  //  });
  //});
});
<|endoftext|>


<commit_before>require([
    'vue',
    'vue-router',
    './rooms-create.component',
    './rooms.component',
    './chat.component'
    ], function(Vue, VueRouter, RoomsCreateComponent, RoomsComponent, ChatComponent){

Vue.use(VueRouter);

var appComponent = Vue.extend({});
var router = new VueRouter();

router.map({
    '/chat/:room': {
        component: ChatComponent,
    },
    '/rooms': {
        component: RoomsComponent,
    },
    '/rooms-create': {
        component: RoomsCreateComponent,
    },
});
router.start(appComponent, '#app');

});<commit_msg>webpack/es6_primeiras_importacoes<commit_after>import Vue from 'vue';
import VueRouter from 'vue-router';

require([
    './rooms-create.component',
    './rooms.component',
    './chat.component'
    ], function(RoomsCreateComponent, RoomsComponent, ChatComponent){

Vue.use(VueRouter);

var appComponent = Vue.extend({});
var router = new VueRouter();

router.map({
    '/chat/:room': {
        component: ChatComponent,
    },
    '/rooms': {
        component: RoomsComponent,
    },
    '/rooms-create': {
        component: RoomsCreateComponent,
    },
});
router.start(appComponent, '#app');

});<|endoftext|>