<commit_before>/*
 *  FeedBridge.js
 *
 *  David Janes
 *  IOTDB.org
 *  2015-02-08
 *
 *  Copyright [2013-2015] [David P. Janes]
 *
 *  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.
 */

"use struct";

var iotdb = require('iotdb')
var _ = iotdb.helpers;

var unirest = require('unirest')

var bunyan = require('bunyan');
var logger = bunyan.createLogger({
    name: 'homestar-feed',
    module: 'FeedBridge',
});

/**
 *  EXEMPLAR and INSTANCE
 *

 *  No subclassing needed! The following functions are
 *  injected _after_ this is created, and before .discover and .connect
 *

 *
discovered - tell IOTDB that we're talking to a new Thing
 *
pulled - got new data
 *
connected - this is connected to a Thing
 *
disconnnected - this has been disconnected from a Thing
 *

 */
var FeedBridge = function(initd, native) {
    var self = this;

    self.initd = _.defaults(initd, {
        poll: 120,
        iri: null,
        fresh: false,
        track_links: false,
    });

    self.native = native;
};

/* --- lifecycle --- */

/**
 *  EXEMPLAR.
 *  Discover WeMo Socket
 *

 *
look for Things (using self.bridge data to initialize)
 *
find / create a native that does the talking
 *
create an FeedBridge(native)
 *
call self.discovered(bridge) with it
 */
FeedBridge.prototype.discover = function(discoverd) {
    var self = this;

    if (!self.initd.iri && discoverd && discoved.iri) {
        self.initd.iri = discoverd.iri;
    }

    if (!self.initd.iri) {
        logger.error({
            method: "discover",
            cause: "all Feeds must be explicitly set up with an IRI",
        }, "no 'iri' parameter - cannot do discovery");
        return;
    }

    self.discovered(new FeedBridge(self.initd, true));
};

/**
 *  INSTANCE
 *  This is called when the Bridge is no longer needed. When
 */
FeedBridge.prototype.connect = function() {
    var self = this;
    if (!self.native) {
        return;
    }
};

FeedBridge.prototype._forget = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    logger.info({
        method: "_forget"
    }, "called");

    self.native = null;
    self.pulled();
}

/**
 *  INSTANCE and EXEMPLAR (during shutdown).
 *  This is called when the Bridge is no longer needed. When
 */
FeedBridge.prototype.disconnect = function() {
    var self = this;
    if (!self.native || !self.native) {
        return;
    }
};

/* --- data --- */

/**
 *  INSTANCE.
 *  Send data to whatever you're taking to.
 */
FeedBridge.prototype.push = function(pushd) {
    var self = this;
    if (!self.native) {
        return;
    }

    logger.info({
        method: "push",
        unique_id: self.unique_id,
        pushd: pushd,
    }, "pushed");
};

/**
 *  INSTANCE.
 *  Pull data from whatever we're talking to. You don't
 *  have to implement this if it doesn't make sense
 */
FeedBridge.prototype.pull = function() {
    var self = this;
    if (!self.native) {
        return;
    }
};

/* --- state --- */

/**
 *  INSTANCE.
 *  Return the metadata - compact form can be used.
 *  Does not have to work when not reachable
 *

 *  Really really useful things are:
 *

 *
iot:thing required - a unique ID
 *
iot:device suggested if linking multiple things together
 *
iot:name
 *
iot:number
 *
schema:manufacturer
 *
schema:model
 */
FeedBridge.prototype.meta = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    return {
        "iot:thing": _.id.thing_urn.unique("Feed", self.native.uuid),
        "iot:name": self.native.friendlyName || "Feed",
        "schema:manufacturer": "http://www.belkin.com/",
        "schema:model": "http://www.belkin.com/us/p/P-F7C027/",
    };
};

/**
 *  INSTANCE.
 *  Return True if this is reachable. You
 *  do not need to worry about connect / disconnect /
 *  shutdown states, they will be always checked first.
 */
FeedBridge.prototype.reachable = function() {
    return this.native !== null;
};

/**
 *  INSTANCE.
 *  Return True if this is configured. Things
 *  that are not configured are always not reachable.
 *  If not defined, "true" is returned
 */
FeedBridge.prototype.configured = function() {
    return true;
};

/* --- injected: THIS CODE WILL BE REMOVED AT RUNTIME, DO NOT MODIFY  --- */
FeedBridge.prototype.discovered = function(bridge) {
    throw new Error("FeedBridge.discovered not implemented");
};

FeedBridge.prototype.pulled = function(pulld) {
    throw new Error("FeedBridge.pulled not implemented");
};

/* --- Internals --- */
FeedBridge.prototype._fetch = function () {
    var self = this;

    logger.info({
        method: "_fetch",
        iri: self.iri,
    }, "called");

    unirest
        .get(self.iri)
        .end(function (result) {
            if (result.error) {
                logger.error({
                    method: "_fetch",
                    iri: self.iri,
                    error: result.error,
                }, "can't get feed");
            } else {
                self._process(result.body);
            }

            self.poll_reschedule();
        });
};

FeedBridge.prototype._process = function (body) {
    var self = this;

    var s = new stream.Readable();
    s._read = function noop() {}; // redundant? see update below
    s.push(body);
    s.push(null);

    var fp = new FeedParser({
        feedurl: self.iri
    });
    fp.on('error', function () {});
    fp.on('readable', function () {
        var stream = this;
        var item = null;
        while (item = stream.read()) {
            if (item.guid === undefined) {
                continue;
            }

            if (self.seend[item.guid] && self.track_links) {
                continue;
            }
            self.seend[item.guid] = 1;

            var date = item.date;
            if (!date) {
                if (self.fresh) {
                    continue;
                }
            } else {
                item.is_fresh = date.getTime() >= self.started.getTime();
                if (self.fresh && !item.is_fresh) {
                    continue;
                }
            }

            self.pulled(self._flatten(item));
        }
    });

    s.pipe(fp);
};

FeedBridge.prototype._flatten = function (od) {
    var self = this;

    var nd = {};

    for (var okey in od) {
        var ovalue = od[okey];
        var nkey = okey.toLowerCase().replace(/[^a-z0-9]/g, '_');

        if (_.isString(ovalue)) {
            if (ovalue.length !== 0) {
                nd[nkey] = ovalue;
            }
        } else if (_.isArray(ovalue)) {
            if (ovalue.length !== 0) {
                nd[nkey] = ovalue;
            }
        } else if (_.isDate(ovalue)) {
            nd[nkey] = ovalue;
        } else if (_.isObject(ovalue)) {
            if (_.isEmpty(ovalue)) {
                continue;
            }

            var ohash = ovalue['#'];
            if (ohash === undefined) {
                continue;
            } else {
                nd[nkey] = ovalue['#'];
            }

            var oat = ovalue['@'];
            if (oat !== undefined) {
                for (var skey in oat) {
                    var svalue = oat[skey];
                    skey = skey.toLowerCase().replace(/[^a-z0-9]/g, '_');
                    nd[nkey + "_" + skey] = svalue;
                }
            }
        } else {
            nd[nkey] = ovalue;
        }
    }

    return nd;
};

/*
 *  API
 */
exports.Bridge = FeedBridge;
<commit_msg>add connect(conncted)<commit_after>/*
 *  FeedBridge.js
 *
 *  David Janes
 *  IOTDB.org
 *  2015-02-08
 *
 *  Copyright [2013-2015] [David P. Janes]
 *
 *  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.
 */

"use struct";

var iotdb = require('iotdb')
var _ = iotdb.helpers;

var unirest = require('unirest')

var bunyan = require('bunyan');
var logger = bunyan.createLogger({
    name: 'homestar-feed',
    module: 'FeedBridge',
});

/**
 *  EXEMPLAR and INSTANCE
 *

 *  No subclassing needed! The following functions are
 *  injected _after_ this is created, and before .discover and .connect
 *

 *
discovered - tell IOTDB that we're talking to a new Thing
 *
pulled - got new data
 *
connected - this is connected to a Thing
 *
disconnnected - this has been disconnected from a Thing
 *

 */
var FeedBridge = function(initd, native) {
    var self = this;

    self.initd = _.defaults(initd, {
        poll: 120,
        iri: null,
        fresh: false,
        track_links: false,
    });

    self.native = native;
};

/* --- lifecycle --- */

/**
 *  EXEMPLAR.
 *  Discover WeMo Socket
 *

 *
look for Things (using self.bridge data to initialize)
 *
find / create a native that does the talking
 *
create an FeedBridge(native)
 *
call self.discovered(bridge) with it
 */
FeedBridge.prototype.discover = function(discoverd) {
    var self = this;

    if (!self.initd.iri && discoverd && discoved.iri) {
        self.initd.iri = discoverd.iri;
    }

    if (!self.initd.iri) {
        logger.error({
            method: "discover",
            cause: "all Feeds must be explicitly set up with an IRI",
        }, "no 'iri' parameter - cannot do discovery");
        return;
    }

    self.discovered(new FeedBridge(self.initd, true));
};

/**
 *  INSTANCE
 *  This is called when the Bridge is no longer needed. When
 */
FeedBridge.prototype.connect = function(connectd) {
    var self = this;
    if (!self.native) {
        return;
    }
};

FeedBridge.prototype._forget = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    logger.info({
        method: "_forget"
    }, "called");

    self.native = null;
    self.pulled();
}

/**
 *  INSTANCE and EXEMPLAR (during shutdown).
 *  This is called when the Bridge is no longer needed. When
 */
FeedBridge.prototype.disconnect = function() {
    var self = this;
    if (!self.native || !self.native) {
        return;
    }
};

/* --- data --- */

/**
 *  INSTANCE.
 *  Send data to whatever you're taking to.
 */
FeedBridge.prototype.push = function(pushd) {
    var self = this;
    if (!self.native) {
        return;
    }

    logger.info({
        method: "push",
        unique_id: self.unique_id,
        pushd: pushd,
    }, "pushed");
};

/**
 *  INSTANCE.
 *  Pull data from whatever we're talking to. You don't
 *  have to implement this if it doesn't make sense
 */
FeedBridge.prototype.pull = function() {
    var self = this;
    if (!self.native) {
        return;
    }
};

/* --- state --- */

/**
 *  INSTANCE.
 *  Return the metadata - compact form can be used.
 *  Does not have to work when not reachable
 *

 *  Really really useful things are:
 *

 *
iot:thing required - a unique ID
 *
iot:device suggested if linking multiple things together
 *
iot:name
 *
iot:number
 *
schema:manufacturer
 *
schema:model
 */
FeedBridge.prototype.meta = function() {
    var self = this;
    if (!self.native) {
        return;
    }

    return {
        "iot:thing": _.id.thing_urn.unique("Feed", self.native.uuid),
        "iot:name": self.native.friendlyName || "Feed",
        "schema:manufacturer": "http://www.belkin.com/",
        "schema:model": "http://www.belkin.com/us/p/P-F7C027/",
    };
};

/**
 *  INSTANCE.
 *  Return True if this is reachable. You
 *  do not need to worry about connect / disconnect /
 *  shutdown states, they will be always checked first.
 */
FeedBridge.prototype.reachable = function() {
    return this.native !== null;
};

/**
 *  INSTANCE.
 *  Return True if this is configured. Things
 *  that are not configured are always not reachable.
 *  If not defined, "true" is returned
 */
FeedBridge.prototype.configured = function() {
    return true;
};

/* --- injected: THIS CODE WILL BE REMOVED AT RUNTIME, DO NOT MODIFY  --- */
FeedBridge.prototype.discovered = function(bridge) {
    throw new Error("FeedBridge.discovered not implemented");
};

FeedBridge.prototype.pulled = function(pulld) {
    throw new Error("FeedBridge.pulled not implemented");
};

/* --- Internals --- */
FeedBridge.prototype._fetch = function () {
    var self = this;

    logger.info({
        method: "_fetch",
        iri: self.iri,
    }, "called");

    unirest
        .get(self.iri)
        .end(function (result) {
            if (result.error) {
                logger.error({
                    method: "_fetch",
                    iri: self.iri,
                    error: result.error,
                }, "can't get feed");
            } else {
                self._process(result.body);
            }

            self.poll_reschedule();
        });
};

FeedBridge.prototype._process = function (body) {
    var self = this;

    var s = new stream.Readable();
    s._read = function noop() {}; // redundant? see update below
    s.push(body);
    s.push(null);

    var fp = new FeedParser({
        feedurl: self.iri
    });
    fp.on('error', function () {});
    fp.on('readable', function () {
        var stream = this;
        var item = null;
        while (item = stream.read()) {
            if (item.guid === undefined) {
                continue;
            }

            if (self.seend[item.guid] && self.track_links) {
                continue;
            }
            self.seend[item.guid] = 1;

            var date = item.date;
            if (!date) {
                if (self.fresh) {
                    continue;
                }
            } else {
                item.is_fresh = date.getTime() >= self.started.getTime();
                if (self.fresh && !item.is_fresh) {
                    continue;
                }
            }

            self.pulled(self._flatten(item));
        }
    });

    s.pipe(fp);
};

FeedBridge.prototype._flatten = function (od) {
    var self = this;

    var nd = {};

    for (var okey in od) {
        var ovalue = od[okey];
        var nkey = okey.toLowerCase().replace(/[^a-z0-9]/g, '_');

        if (_.isString(ovalue)) {
            if (ovalue.length !== 0) {
                nd[nkey] = ovalue;
            }
        } else if (_.isArray(ovalue)) {
            if (ovalue.length !== 0) {
                nd[nkey] = ovalue;
            }
        } else if (_.isDate(ovalue)) {
            nd[nkey] = ovalue;
        } else if (_.isObject(ovalue)) {
            if (_.isEmpty(ovalue)) {
                continue;
            }

            var ohash = ovalue['#'];
            if (ohash === undefined) {
                continue;
            } else {
                nd[nkey] = ovalue['#'];
            }

            var oat = ovalue['@'];
            if (oat !== undefined) {
                for (var skey in oat) {
                    var svalue = oat[skey];
                    skey = skey.toLowerCase().replace(/[^a-z0-9]/g, '_');
                    nd[nkey + "_" + skey] = svalue;
                }
            }
        } else {
            nd[nkey] = ovalue;
        }
    }

    return nd;
};

/*
 *  API
 */
exports.Bridge = FeedBridge;
<|endoftext|>


<commit_before>import {
  computed, observable,
} from 'mobx';

import BasicCourseUX from './basic-ux';
import Courses from '../courses-map';
import { filter, find, includes } from 'lodash';
import User from '../user';
import TeacherTaskPlans from '../teacher-task-plans';
import { TaskPlanStore } from '../../flux/task-plan';

import Nags from '../../components/onboarding/nags';

const IS_DISMISSED = observable.box(false);
const HAS_PUBLISHED = observable.box(false);
TaskPlanStore.on('publish-queued', () => HAS_PUBLISHED.set(true));

const NAG_PLAN_TYPES = [ 'homework', 'reading' ];

export default class CoursePreviewUX extends BasicCourseUX {

  hasViewedPublishWarning() {
    HAS_PUBLISHED.set(false);
    IS_DISMISSED.set(true);
  }

  dismissNag() {
    IS_DISMISSED.set(true);
  }

  @computed get shouldWarnPreviewOnly() {
    if (!HAS_PUBLISHED.get() ||
        this.hasCreatedRealCourse ||
        TeacherTaskPlans.hasApiRequestPending
       ) { return false; }

    const plans = TeacherTaskPlans.forCourseId(this.course.id).active;
    const realPlanCount = filter(
      plans, (plan) => !plan.is_preview && includes(NAG_PLAN_TYPES, plan.type)
    ).length;
    return (realPlanCount > 0 && realPlanCount % 2 === 0);
  }

  @computed get nagComponent() {
    // we warn about creating assigments in a preview regardless of previous dismissals
    if (this.shouldWarnPreviewOnly)  { return Nags.previewOnlyWarning;  }

    if (IS_DISMISSED.get() || this.hasCreatedRealCourse) { return null; }

    if (this.course.hasEnded)       { return Nags.expiredPreviewWarning; }
    if (User.sessionCount > 2)      { return Nags.secondSessionWarning;  }
    return null;
  }

  @computed get hasCreatedRealCourse() {
    return !Courses.tutor.currentAndFuture.nonPreview.isEmpty;
  }

  @computed get showCreateCourseAction() {
    return !this.hasCreatedRealCourse;
  }

  _setTaskPlanPublish(v = true) {
    HAS_PUBLISHED.set(v);
  }
}
<commit_msg>find wasn't used<commit_after>import {
  computed, observable,
} from 'mobx';

import BasicCourseUX from './basic-ux';
import Courses from '../courses-map';
import { filter, includes } from 'lodash';
import User from '../user';
import TeacherTaskPlans from '../teacher-task-plans';
import { TaskPlanStore } from '../../flux/task-plan';

import Nags from '../../components/onboarding/nags';

const IS_DISMISSED = observable.box(false);
const HAS_PUBLISHED = observable.box(false);
TaskPlanStore.on('publish-queued', () => HAS_PUBLISHED.set(true));

const NAG_PLAN_TYPES = [ 'homework', 'reading' ];

export default class CoursePreviewUX extends BasicCourseUX {

  hasViewedPublishWarning() {
    HAS_PUBLISHED.set(false);
    IS_DISMISSED.set(true);
  }

  dismissNag() {
    IS_DISMISSED.set(true);
  }

  @computed get shouldWarnPreviewOnly() {
    if (!HAS_PUBLISHED.get() ||
        this.hasCreatedRealCourse ||
        TeacherTaskPlans.hasApiRequestPending
       ) { return false; }

    const plans = TeacherTaskPlans.forCourseId(this.course.id).active;
    const realPlanCount = filter(
      plans, (plan) => !plan.is_preview && includes(NAG_PLAN_TYPES, plan.type)
    ).length;
    return (realPlanCount > 0 && realPlanCount % 2 === 0);
  }

  @computed get nagComponent() {
    // we warn about creating assigments in a preview regardless of previous dismissals
    if (this.shouldWarnPreviewOnly)  { return Nags.previewOnlyWarning;  }

    if (IS_DISMISSED.get() || this.hasCreatedRealCourse) { return null; }

    if (this.course.hasEnded)       { return Nags.expiredPreviewWarning; }
    if (User.sessionCount > 2)      { return Nags.secondSessionWarning;  }
    return null;
  }

  @computed get hasCreatedRealCourse() {
    return !Courses.tutor.currentAndFuture.nonPreview.isEmpty;
  }

  @computed get showCreateCourseAction() {
    return !this.hasCreatedRealCourse;
  }

  _setTaskPlanPublish(v = true) {
    HAS_PUBLISHED.set(v);
  }
}
<|endoftext|>


<commit_before>var head = [],
  body = [],
  bodyx = [],
  bodyy = [],
  stop = 0;

function setup() {
  createCanvas(600, 600);
  background(0);
  bodyx.push(head[0].x);
  bodyy.push(head[0].y);
  head.push(new Head());
  body.push(new Body());
}

function draw() {
  background(0);
  if (stop == 0) {
    for (var i = 0; i < head.length; i++) {
      head[i].display();
      head[i].move();
      head[0].food();
    }
  }
  if (stop == 0) {
    for (var l = 0; l < body.length; l++) {
      body[l].display();
    }
  }
  if (stop == 1) button();
  textSize(20);
  fill(255);
  text("©Javi", width - 55, height - 10);
}

function Head() {
  this.x = 0;
  this.y = 0;
  this.len = 10;
  this.del = 10;
  this.time = 0;
  this.speedX = 25;
  this.speedY = 0;
  this.foodX = random(width / 25);
  this.foodY = random(height / 25);
  this.foodX = round(this.foodX);
  this.foodY = round(this.foodY);
  if (this.foodX > width / 25 - 1) {
    this.foodX--;
  }
  if (this.foodY > height / 25 - 1) {
    this.foodY--;
  }
  this.display = function() {
    fill(255);
    rect(this.x, this.y, 25, 25);
  }

  this.food = function() {
    //display
    fill(255, 0, 0);
    rect(this.foodX * 25, this.foodY * 25, 25, 25);
    //eat
    if (this.foodX * 25 == this.x && this.foodY * 25 == this.y) {
      this.foodX = random(width / 25);
      this.foodY = random(height / 25);
      this.foodX = round(this.foodX);
      this.foodY = round(this.foodY);
      if (this.foodX > width / 25 - 1) {
        this.foodX--;
      }
      if (this.foodY > height / 25 - 1) {
        this.foodY--;
      }
      bodyx.push(this.x);
      bodyy.push(this.y);
      body.push(new Body());
      if (this.len > -1) {
        this.len = this.len - 0.15;
      }
    }
  };
  this.move = function() {
    if (keyIsDown(UP_ARROW) && this.speedY == 0 && this.del > this.len) {
      this.speedX = 0;
      this.speedY = -25;
      this.del = 0;
    }
    if (keyIsDown(DOWN_ARROW) && this.speedY == 0 && this.del > this.len) {
      this.speedX = 0;
      this.speedY = 25;
      this.del = 0;
    }
    if (keyIsDown(LEFT_ARROW) && this.speedX == 0 && this.del > this.len) {
      this.speedX = -25;
      this.speedY = 0;
      this.del = 0;
    }
    if (keyIsDown(RIGHT_ARROW) && this.speedX == 0 && this.del > this.len) {
      this.speedX = 25;
      this.speedY = 0;
      this.del = 0;
    }
    this.del++;

    if (this.time > this.len) {
      this.x = this.x + this.speedX;
      this.y = this.y + this.speedY;
      //stop
      if (this.x > width - 25 || this.x < 0) {
        stop = 1;
      }
      if (this.y > height - 25 || this.y < 0) {
        stop = 1;
      }
      for (var c = 0; c < bodyx.length - 1; c++) {
        if (bodyx[c] == this.x && bodyy[c] == this.y) {
          stop = 1;
        }
      }
      //stop
      this.time = 0;
      bodyx.push(this.x);
      bodyy.push(this.y);
      bodyx.splice(0, 1);
      bodyy.splice(0, 1);
    }
    this.time++;
  };
}

function Body() {
  this.time = 0;
  this.display = function() {
    for (var i = 0; i < bodyx.length; i++) {
      fill(255);
      rect(bodyx[i], bodyy[i], 25, 25);
    }
  };
}
<commit_msg>Update sketch.js<commit_after>var head = [],
  body = [],
  bodyx = [],
  bodyy = [],
  stop = 0;

function setup() {
  createCanvas(600, 600);
  background(0);
  head.push(new Head());
  bodyx.push(head[0].x);
  bodyy.push(head[0].y);
  body.push(new Body());
}

function draw() {
  background(0);
  if (stop == 0) {
    for (var i = 0; i < head.length; i++) {
      head[i].display();
      head[i].move();
      head[0].food();
    }
  }
  if (stop == 0) {
    for (var l = 0; l < body.length; l++) {
      body[l].display();
    }
  }
  if (stop == 1) button();
  textSize(20);
  fill(255);
  text("©Javi", width - 55, height - 10);
}

function Head() {
  this.x = 0;
  this.y = 0;
  this.len = 10;
  this.del = 10;
  this.time = 0;
  this.speedX = 25;
  this.speedY = 0;
  this.foodX = random(width / 25);
  this.foodY = random(height / 25);
  this.foodX = round(this.foodX);
  this.foodY = round(this.foodY);
  if (this.foodX > width / 25 - 1) {
    this.foodX--;
  }
  if (this.foodY > height / 25 - 1) {
    this.foodY--;
  }
  this.display = function() {
    fill(255);
    rect(this.x, this.y, 25, 25);
  }

  this.food = function() {
    //display
    fill(255, 0, 0);
    rect(this.foodX * 25, this.foodY * 25, 25, 25);
    //eat
    if (this.foodX * 25 == this.x && this.foodY * 25 == this.y) {
      this.foodX = random(width / 25);
      this.foodY = random(height / 25);
      this.foodX = round(this.foodX);
      this.foodY = round(this.foodY);
      if (this.foodX > width / 25 - 1) {
        this.foodX--;
      }
      if (this.foodY > height / 25 - 1) {
        this.foodY--;
      }
      bodyx.push(this.x);
      bodyy.push(this.y);
      body.push(new Body());
      if (this.len > -1) {
        this.len = this.len - 0.15;
      }
    }
  };
  this.move = function() {
    if (keyIsDown(UP_ARROW) && this.speedY == 0 && this.del > this.len) {
      this.speedX = 0;
      this.speedY = -25;
      this.del = 0;
    }
    if (keyIsDown(DOWN_ARROW) && this.speedY == 0 && this.del > this.len) {
      this.speedX = 0;
      this.speedY = 25;
      this.del = 0;
    }
    if (keyIsDown(LEFT_ARROW) && this.speedX == 0 && this.del > this.len) {
      this.speedX = -25;
      this.speedY = 0;
      this.del = 0;
    }
    if (keyIsDown(RIGHT_ARROW) && this.speedX == 0 && this.del > this.len) {
      this.speedX = 25;
      this.speedY = 0;
      this.del = 0;
    }
    this.del++;

    if (this.time > this.len) {
      this.x = this.x + this.speedX;
      this.y = this.y + this.speedY;
      //stop
      if (this.x > width - 25 || this.x < 0) {
        stop = 1;
      }
      if (this.y > height - 25 || this.y < 0) {
        stop = 1;
      }
      for (var c = 0; c < bodyx.length - 1; c++) {
        if (bodyx[c] == this.x && bodyy[c] == this.y) {
          stop = 1;
        }
      }
      //stop
      this.time = 0;
      bodyx.push(this.x);
      bodyy.push(this.y);
      bodyx.splice(0, 1);
      bodyy.splice(0, 1);
    }
    this.time++;
  };
}

function Body() {
  this.time = 0;
  this.display = function() {
    for (var i = 0; i < bodyx.length; i++) {
      fill(255);
      rect(bodyx[i], bodyy[i], 25, 25);
    }
  };
}
<|endoftext|>


<commit_before>// $Revision$

Ensembl.Panel.LocationNav = Ensembl.Panel.extend({
  constructor: function (id, params) {
    this.base(id, params);

    this.matchRegex   = new RegExp(/[\?;&]r=([^;&]+)/);
    this.replaceRegex = new RegExp(/([\?;&]r=)[^;&]+(;&?)*/);

    Ensembl.EventManager.register('hashChange',  this, this.getContent);
    Ensembl.EventManager.register('changeWidth', this, this.resize);
    Ensembl.EventManager.register('imageResize', this, this.resize);

    if (!window.location.pathname.match(/\/Multi/)) {
      Ensembl.EventManager.register('ajaxComplete', this, function () { this.enabled = true; });
    }
  },

  init: function () {
    var panel = this;

    this.base();

    if (Ensembl.ajax === 'disabled') {
      return; // If the user has ajax disabled, don't create the slider. The navigation will then be based on the ramp links.
    }

    this.enabled = this.params.enabled || false;
    this.reload  = false;

    var match        = (window.location.hash.replace(/^#/, '?') + ';').match(this.matchRegex);
    var sliderConfig = $('span.ramp', this.el).hide().children();
    var sliderLabel  = $('.slider_label', this.el);
    var hash, boundaries, r, l, i;

    if (match) {
      r = match[1].split(/\W/);
      l = r[2] - r[1] + 1;

      sliderLabel.html(l);
      sliderConfig.removeClass('selected');

      i = sliderConfig.length;

      if (l >= parseInt(sliderConfig[i-1].name, 10)) {
        sliderConfig.last().addClass('selected');
      } else {
        boundaries = $.map(sliderConfig, function (el, i) {
          return Math.sqrt((i ? parseInt(sliderConfig[i-1].name, 10) : 0) * parseInt(el.name, 10));
        });

        boundaries.push(1e30);

        while (i--) {
          if (l > boundaries[i] && l <= boundaries[i+1]) {
            sliderConfig.eq(i).addClass('selected');
            break;
          }
        }
      }
    }

    $('.slider_wrapper', this.el).children().css('display', 'inline-block');

    this.elLk.updateURL     = $('.update_url', this.el);
    this.elLk.locationInput = $('.location_selector', this.el);
    this.elLk.navbar        = $('.navbar', this.el);
    this.elLk.imageNav      = $('.image_nav', this.elLk.navbar);
    this.elLk.forms         = $('form', this.elLk.navbar);

    this.elLk.navLinks = $('a', this.el).addClass('constant').bind('click', function (e) {
      var newR;

      if (panel.enabled === true) {
        if ($(this).hasClass('move')) {
          panel.reload = true;
        }

        newR = this.href.match(panel.matchRegex)[1];

        if (newR !== Ensembl.coreParams.r) {
          window.location.hash = 'r=' + newR;
        }

        return false;
      }
    });

    this.elLk.slider = $('.slider', this.el).slider({
      value: sliderConfig.filter('.selected').index(),
      step:  1,
      min:   0,
      max:   sliderConfig.length - 1,
      force: false,
      slide: function (e, ui) {
        sliderLabel.html(sliderConfig[ui.value].name + ' bp').show();
      },
      change: function (e, ui) {
        var input = sliderConfig[ui.value];
        var url   = input.href;
        var r     = url.match(panel.matchRegex)[1];

        sliderLabel.html(input.name + ' bp');

        input = null;

        if (panel.elLk.slider.slider('option', 'force') === true) {
          return false;
        } else if (panel.enabled === false) {
          Ensembl.redirect(url);
          return false;
        } else if ((!window.location.hash || window.location.hash === '#') && url === window.location.href) {
          return false;
        } else if (window.location.hash.match('r=' + r)) {
          return false;
        }

        window.location.hash = 'r=' + r;
      },
      stop: function () {
        sliderLabel.hide();
        $('.ui-slider-handle', panel.elLk.slider).trigger('blur'); // Force the blur event to remove the highlighting for the handle
      }
    });

    this.resize();
  },

  getContent: function () {
    var panel = this;

    if (this.reload === true) {
      $.ajax({
        url: Ensembl.urlFromHash(panel.elLk.updateURL.val()),
        dataType: 'html',
        success: function (html) {
          Ensembl.EventManager.trigger('addPanel', panel.id, 'LocationNav', html, $(panel.el), { enabled: panel.enabled });
        }
      });
    } else {
      $.ajax({
        url: Ensembl.urlFromHash(this.elLk.updateURL.val() + ';update_panel=1'),
        dataType: 'json',
        success: function (json) {
          var sliderValue = json.shift();

          if (panel.elLk.slider.slider('value') !== sliderValue) {
            panel.elLk.slider.slider('option', 'force', true);
            panel.elLk.slider.slider('value', sliderValue);
            panel.elLk.slider.slider('option', 'force', false);
          }

          panel.elLk.updateURL.val(json.shift());
          panel.elLk.locationInput.val(json.shift());

          panel.elLk.navLinks.not('.ramp').attr('href', function () {
            return this.href.replace(panel.replaceRegex, '$1' + json.shift() + '$2');
          });
        }
      });
    }
  },

  resize: function () {
    var widths = {
      navbar: this.elLk.navbar.width(),
      slider: this.elLk.imageNav.width(),
      forms:  this.elLk.forms.width()
    };

    if (widths.navbar < widths.forms + widths.slider) {
      this.elLk.navbar.removeClass('narrow1').addClass('narrow2');
    } else if (widths.navbar < (widths.forms * this.elLk.forms.length) + widths.slider) {
      this.elLk.navbar.removeClass('narrow2').addClass('narrow1');
    } else {
      this.elLk.navbar.removeClass('narrow1 narrow2');
    }
  }
});
<commit_msg>allow hash change to change chromosome<commit_after>// $Revision$

Ensembl.Panel.LocationNav = Ensembl.Panel.extend({
  constructor: function (id, params) {
    this.base(id, params);

    this.matchRegex   = new RegExp(/[\?;&]r=([^;&]+)/);
    this.replaceRegex = new RegExp(/([\?;&]r=)[^;&]+(;&?)*/);

    Ensembl.EventManager.register('hashChange',  this, this.getContent);
    Ensembl.EventManager.register('changeWidth', this, this.resize);
    Ensembl.EventManager.register('imageResize', this, this.resize);

    if (!window.location.pathname.match(/\/Multi/)) {
      Ensembl.EventManager.register('ajaxComplete', this, function () { this.enabled = true; });
    }
  },

  init: function () {
    var panel = this;

    this.base();

    if (Ensembl.ajax === 'disabled') {
      return; // If the user has ajax disabled, don't create the slider. The navigation will then be based on the ramp links.
    }

    this.enabled = this.params.enabled || false;
    this.reload  = false;

    var match        = (window.location.hash.replace(/^#/, '?') + ';').match(this.matchRegex);
    var sliderConfig = $('span.ramp', this.el).hide().children();
    var sliderLabel  = $('.slider_label', this.el);
    var hash, boundaries, r, l, i;

    if (match) {
      r = match[1].split(/\W/);
      l = r[2] - r[1] + 1;

      sliderLabel.html(l);
      sliderConfig.removeClass('selected');

      i = sliderConfig.length;

      if (l >= parseInt(sliderConfig[i-1].name, 10)) {
        sliderConfig.last().addClass('selected');
      } else {
        boundaries = $.map(sliderConfig, function (el, i) {
          return Math.sqrt((i ? parseInt(sliderConfig[i-1].name, 10) : 0) * parseInt(el.name, 10));
        });

        boundaries.push(1e30);

        while (i--) {
          if (l > boundaries[i] && l <= boundaries[i+1]) {
            sliderConfig.eq(i).addClass('selected');
            break;
          }
        }
      }
    }

    $('.slider_wrapper', this.el).children().css('display', 'inline-block');

    this.elLk.updateURL     = $('.update_url', this.el);
    this.elLk.locationInput = $('.location_selector', this.el);
    this.elLk.navbar        = $('.navbar', this.el);
    this.elLk.imageNav      = $('.image_nav', this.elLk.navbar);
    this.elLk.forms         = $('form', this.elLk.navbar);

    this.elLk.navLinks = $('a', this.el).addClass('constant').bind('click', function (e) {
      var newR;

      if (panel.enabled === true) {
        if ($(this).hasClass('move')) {
          panel.reload = true;
        }

        newR = this.href.match(panel.matchRegex)[1];

        if (newR !== Ensembl.coreParams.r) {
          window.location.hash = 'r=' + newR;
        }

        return false;
      }
    });

    this.elLk.slider = $('.slider', this.el).slider({
      value: sliderConfig.filter('.selected').index(),
      step:  1,
      min:   0,
      max:   sliderConfig.length - 1,
      force: false,
      slide: function (e, ui) {
        sliderLabel.html(sliderConfig[ui.value].name + ' bp').show();
      },
      change: function (e, ui) {
        var input = sliderConfig[ui.value];
        var url   = input.href;
        var r     = url.match(panel.matchRegex)[1];

        sliderLabel.html(input.name + ' bp');

        input = null;

        if (panel.elLk.slider.slider('option', 'force') === true) {
          return false;
        } else if (panel.enabled === false) {
          Ensembl.redirect(url);
          return false;
        } else if ((!window.location.hash || window.location.hash === '#') && url === window.location.href) {
          return false;
        } else if (window.location.hash.match('r=' + r)) {
          return false;
        }

        window.location.hash = 'r=' + r;
      },
      stop: function () {
        sliderLabel.hide();
        $('.ui-slider-handle', panel.elLk.slider).trigger('blur'); // Force the blur event to remove the highlighting for the handle
      }
    });

    this.resize();
  },

  getContent: function () {
    var panel = this;

    if (this.reload === true || Ensembl.lastR.split(':')[0] !== Ensembl.coreParams.r.split(':')[0]) {
      $.ajax({
        url: Ensembl.urlFromHash(panel.elLk.updateURL.val()),
        dataType: 'html',
        success: function (html) {
          Ensembl.EventManager.trigger('addPanel', panel.id, 'LocationNav', html, $(panel.el), { enabled: panel.enabled });
        }
      });
    } else {
      $.ajax({
        url: Ensembl.urlFromHash(this.elLk.updateURL.val() + ';update_panel=1'),
        dataType: 'json',
        success: function (json) {
          var sliderValue = json.shift();

          if (panel.elLk.slider.slider('value') !== sliderValue) {
            panel.elLk.slider.slider('option', 'force', true);
            panel.elLk.slider.slider('value', sliderValue);
            panel.elLk.slider.slider('option', 'force', false);
          }

          panel.elLk.updateURL.val(json.shift());
          panel.elLk.locationInput.val(json.shift());

          panel.elLk.navLinks.not('.ramp').attr('href', function () {
            return this.href.replace(panel.replaceRegex, '$1' + json.shift() + '$2');
          });
        }
      });
    }
  },

  resize: function () {
    var widths = {
      navbar: this.elLk.navbar.width(),
      slider: this.elLk.imageNav.width(),
      forms:  this.elLk.forms.width()
    };

    if (widths.navbar < widths.forms + widths.slider) {
      this.elLk.navbar.removeClass('narrow1').addClass('narrow2');
    } else if (widths.navbar < (widths.forms * this.elLk.forms.length) + widths.slider) {
      this.elLk.navbar.removeClass('narrow2').addClass('narrow1');
    } else {
      this.elLk.navbar.removeClass('narrow1 narrow2');
    }
  }
});
<|endoftext|>


<commit_before><commit_msg>	modified:   main.js<commit_after><|endoftext|>


<commit_before>// 'use strict'; // Explicitly do not use strict mode
// We do not have foreknowledge of others' extensions,
// and cannot assume that they 'use strict';

(function(angular) {
  angular.module('ngLocale').
    config(function($provide) {
      $provide.value('services', []);
      // A provider is used to track services,
      // as this is available in all config blocks
      var $$elevenProvider = $provide.provider('$$eleven', {
        services: [],
        // This is not meant as a service, so we leave $get empty
        $get: function() {}
      });

      // $provide cannot be decorated conventionally:
      //   (only those providers named {service}Provider may be decorated);
      //   hence, $provide is a misnomer
      var origProvide = $provide,
        origProvider = origProvide.provider,
        origFactory = origProvide.factory,
        origService = origProvide.service;

      // Stick each service in a list on registration. This ensures uniqueness.
      // This list is consumed by .module('ngEleven').config
      origProvide.provider = function provider(serviceName) {
        if (typeof serviceName === 'string') {
          $$elevenProvider.services.push(serviceName);
        } else if (typeof serviceName === 'object') {
          // Angular internals are all loaded in objects
          for (var name in serviceName) {
            $$elevenProvider.services.push(name);
          }
        }
        return origProvider.apply(this, arguments);
      };
      origProvide.service = function(serviceName) {
        $$elevenProvider.services.push(serviceName);
        return origService.apply(this, arguments);
      };
      origProvide.factory = function(serviceName) {
        $$elevenProvider.services.push(serviceName);
        return origFactory.apply(this, arguments);
      };
    })
  ;

  angular.module('ngEleven', []).
    // These should be set in your app to control debugging.
    constant('eleven', true).    // Debug homespun services
    constant('eleven_', false).  // Debug         -services
    constant('eleven$', false).  // Debug         &services
    constant('eleven$$', false). // Debug        &&services (requires eleven&)

    config(function($provide, $$elevenProvider,
                    eleven, eleven_, eleven$, eleven$$) {
      if (eleven) {
        // Decorate our services, conditionally.
        angular.forEach($$elevenProvider.services, function(serviceName) {
          // This can be improved with RegExp
          if ((!eleven$$ && (serviceName.slice(0,2) === '$$')) ||
              (!eleven$ && (serviceName[0] === '$')) ||
              (!eleven_ && (serviceName[0] === '-'))) {
            return;
          }
          $provide.decorator(serviceName, function($delegate, $log) {
            var logger = function(key) {
              var args = Array.prototype.slice.call(arguments, 1);
              // This format is still up for discussion
              // Eventually, it will log to a sidebar, outside of the console
              $log.log('%c' + serviceName + '%c.%c' + key +
                       '%c invoked with arguments:',
                       'color: teal;',    // serviceName in teal
                       'color: black;',
                       'color: blue;',    // method in blue
                       'color: black;');
              $log.log('\t', args);
              return $delegate[key].apply($delegate, args);
            };

            if (typeof $delegate === 'object') {
              angular.forEach($delegate, function(val, key) {
                window.service = $delegate;
                logger[key] = (typeof val === 'function') ?
                  logger.bind($delegate, key) :
                  $delegate[key];
              });

              return logger;
            } else {
              return $delegate;
            }
          });
        });
      }
    })
  ;
}(angular) );
<commit_msg>(refactor) Separated internal service decorators.<commit_after>// 'use strict'; // Explicitly do not use strict mode
// We do not have foreknowledge of others' extensions,
// and cannot assume that they 'use strict';

(function(angular) {
  angular.module('ngLocale').
    config(function($provide) {
      $provide.value('services', []);
      // A provider is used to track services,
      // as this is available in all config blocks
      var $$elevenProvider = $provide.provider('$$eleven', {
        services: [],
        // This is not meant as a service, so we leave $get empty
        $get: function() {}
      });

      // $provide cannot be decorated conventionally:
      //   (only those providers named {service}Provider may be decorated);
      //   hence, $provide is a misnomer
      var origProvide = $provide,
        origProvider = origProvide.provider,
        origFactory = origProvide.factory,
        origService = origProvide.service;

      // Stick each service in a list on registration. This ensures uniqueness.
      // This list is consumed by .module('ngEleven').config
      origProvide.provider = function provider(serviceName) {
        if (typeof serviceName === 'string') {
          $$elevenProvider.services.push(serviceName);
        } else if (typeof serviceName === 'object') {
          // Angular internals are all loaded in objects
          for (var name in serviceName) {
            $$elevenProvider.services.push(name);
          }
        }
        return origProvider.apply(this, arguments);
      };
      origProvide.service = function(serviceName) {
        $$elevenProvider.services.push(serviceName);
        return origService.apply(this, arguments);
      };
      origProvide.factory = function(serviceName) {
        $$elevenProvider.services.push(serviceName);
        return origFactory.apply(this, arguments);
      };
    })
  ;

  angular.module('ngEleven', []).
    // These should be set in your app to control debugging.
    constant('eleven', true).    // Debug homespun services
    constant('eleven_', false).  // Debug         -services
    constant('eleven$', false).  // Debug         &services
    constant('eleven$$', false). // Debug        &&services (requires eleven&)

    config(function($provide, $$elevenProvider,
                    eleven, eleven_, eleven$, eleven$$) {

      if (eleven) {
        // Decorate our services, conditionally.
        angular.forEach($$elevenProvider.services, function(serviceName) {
          // This can be improved with RegExp
          if (serviceName[0] === '$') {
            if ((!eleven$$ && (serviceName.slice(0,2) === '$$')) ||
                (!eleven$ && (serviceName[0] === '$')) ||
                serviceName === '$document' ||
                serviceName === '$window' ||
                serviceName === '$log') {
              return;
            } else {
              $provide.decorator(serviceName, function($delegate, $log) {
                var logger = function(key) {
                  var args = Array.prototype.slice.call(arguments, 1);
                  // This format is still up for discussion
                  // Eventually, it will log to a sidebar, outside of the console
                  $log.log('%c' + serviceName + '%c.%c' + key +
                           '%c invoked with arguments:',
                           'color: teal;',    // serviceName in teal
                           'color: black;',
                           'color: blue;',    // method in blue
                           'color: black;');
                  $log.log('\t', args);
                  return $delegate[key].apply($delegate, args);
                };

                if (typeof $delegate === 'object') {
                  angular.forEach($delegate, function(val, key) {
                    window.service = $delegate;
                    logger[key] = (typeof val === 'function') ?
                      logger.bind($delegate, key) :
                      $delegate[key];
                  });

                  return logger;
                } else {
                  return $delegate;
                }
              });
            }
          } else {
            if (!eleven_ && (serviceName[0] === '-')) {
              return;
            } else {
              $provide.decorator(serviceName, function($delegate, $log) {
                var logger = function(key) {
                  var args = Array.prototype.slice.call(arguments, 1);
                  // This format is still up for discussion
                  // Eventually, it will log to a sidebar, outside of the console
                  $log.log('%c' + serviceName + '%c.%c' + key +
                           '%c invoked with arguments:',
                           'color: teal;',    // serviceName in teal
                           'color: black;',
                           'color: blue;',    // method in blue
                           'color: black;');
                  $log.log('\t', args);
                  return $delegate[key].apply($delegate, args);
                };

                if (typeof $delegate === 'object') {
                  angular.forEach($delegate, function(val, key) {
                    logger[key] = (typeof val === 'function') ?
                      logger.bind($delegate, key) :
                      $delegate[key];
                  });

                  return logger;
                } else {
                  return $delegate;
                }
              });
            }
          }
        });
      }
    })
  ;
}(angular) );
<|endoftext|>


<commit_before>"use strict"

function someFunc(){
  var x = 10;
}<commit_msg>Added good file<commit_after>"use strict"

function someFunc(){
  var x = 10;
  if(x < 10) {
  	x = 0;
  }
}

someFunc();
<|endoftext|>


<commit_before>/**
 * @author Gilles Coomans <gilles.coomans@gmail.com>
 * DOM only.
 * Container : The missing DOM node's type : a simple virtual nodes container that could be (un)mounted somewhere in other dom nodes.
 * Think it as an evoluated DocumentFragment.
 */
var utils = require('../../utils'),
	Emitter = require('nomocas-utils/lib/emitter');
var Container = function(parent) {
	this.__yContainer__ = true;
	this.parent = parent;
	this.childNodes = [];
};

Container.prototype = new Emitter();

var proto = {
	appendChildrenToFragment: function(frag, parentNode, mounted) {
		this.parentNode = parentNode;
		if (this.witness)
			frag.appendChild(this.witness);
		if (mounted)
			mounted.push(this);
		for (var i = 0, len = this.childNodes.length; i < len; ++i) {
			var child = this.childNodes[i];
			if (child.__yContainer__)
				child.appendChildrenToFragment(frag, parentNode, mounted);
			else
				frag.appendChild(child);
		}
		return this;
	},
	empty: function() {
		utils.destroyChildren(this.childNodes, true);
		this.childNodes = [];
		return this;
	},
	mount: function(node) {
		if (typeof node === 'string')
			node = document.querySelector(node);
		if (this.mounted && node === this.parentNode) {
			if (this.closing && this.transitionIn)
				this.transitionIn();
			return this;
		}
		utils.emptyNode(node);
		return this.appendTo(node);
	},
	appendTo: function(parent) {
		var par = parent;
		if (typeof parent === 'string')
			parent = document.querySelector(parent);
		if (this.mounted && parent === this.parentNode) {
			if (this.closing && this.transitionIn)
				this.transitionIn();
			return this;
		}
		if (!parent)
			throw new Error('could not mount container : no parent found with ' + par);
		this.mounted = true;
		if (parent.__yContainer__)
			parent.appendChild(this);
		else {
			if (this.witness)
				parent.appendChild(this.witness);
			this.parentNode = parent;
			for (var i = 0, len = this.childNodes.length; i < len; ++i) {
				var child = this.childNodes[i];
				if (child.__yContainer__)
					child.appendTo(parent);
				else
					parent.appendChild(child);
			}
		}
		this.emit('mounted', this);
		return this;
	},
	insertBeforeNode: function(node) {
		if (!node.parentNode)
			throw new Error('insertBeforeNode error : given node has no parent.');
		this.mounted = true;
		var frag = document.createDocumentFragment(),
			mounted = [];
		this.appendChildrenToFragment(frag, node.parentNode, mounted);
		// console.log('will insert container before : ', frag, node);
		node.parentNode.insertBefore(frag, node);
		for (var i = 0, len = mounted.length; i < len; ++i)
			mounted[i].emit('mounted', this);
		return this;
	},
	setWitness: function(witness) {
		this.witness = witness;
	},
	addWitness: function(title, parent) {
		if (this.witness)
			return this;
		this.witness = document.createComment(title);
		if (parent) {
			parent.appendChild(this.witness);
			return this;
		}
		if (!this.parentNode)
			return this;
		if (!this.childNodes.length) {
			console.warn('addWitness : container has been mounted without witness and children. Appending witness in parent.', this);
			this.parentNode.appendChild(this.witness);
		} else
			this.parentNode.insertBefore(this.witness, this.firstChild);
		return this;
	},
	removeWitness: function() {
		if (!this.witness)
			return this;
		if (this.witness.parentNode)
			this.witness.parentNode.removeChild(this.witness);
		this.witness = null;
		return this;
	},
	remount: function() {
		if (!this.witness.parentNode)
			throw new Error('container could not be remounted : witness has been unmounted.');
		if (this.mounted) {
			if (this.closing && this.transitionIn) {
				this.transitionIn();
			}
			return this;
		}
		var nextSibling = this.witness.nextSibling;
		if (nextSibling)
			this.insertBeforeNode(nextSibling);
		else
			this.appendTo(this.witness.parentNode);
		return this;
	},
	doUnmount: function(keepWitness) {
		this.mounted = false;
		if (!this.parentNode)
			return this;
		if (this.witness && !keepWitness)
			this.parentNode.removeChild(this.witness);
		for (var i = 0, len = this.childNodes.length; i < len; ++i) {
			var child = this.childNodes[i];
			if (child.__yContainer__)
				child.doUnmount();
			else if (child.parentNode)
				child.parentNode.removeChild(child);
		}
		this.parentNode = null;
		this.emit('unmounted', this);
		return this;
	},
	unmount: function(keepWitness, done) {
		if (!this.parentNode) { // container hasn't been mounted
			if (done)
				done(this);
			return this;
		}
		if (!this._beforeUnmount) {
			this.doUnmount(keepWitness);
			if (done)
				done(this);
			return this;
		}
		var self = this;
		this._beforeUnmount(function() {
			self.doUnmount(keepWitness);
			if (done)
				done(self);
		});
		return this;
	},
	appendChild: function(child) {
		if (this.parentNode) { // container has been mounted
			var nextSibling = this.nextSibling;
			if (nextSibling) {
				if (child.__yContainer__)
					child.insertBeforeNode(nextSibling);
				else
					this.parentNode.insertBefore(child, nextSibling);
			} else if (child.__yContainer__)
				child.appendTo(this.parentNode);
			else
				this.parentNode.appendChild(child);
		}
		this.childNodes.push(child);
		return this;
	},
	removeChild: function(child) {
		if (typeof child !== 'object') {
			var index = child;
			child = this.childNodes[index];
			if (!child)
				throw new Error('container.removeChild not found : ', index);
			this.childNodes.splice(index, 1);
		} else
			utils.array.remove(this.childNodes, child);
		if (this.parentNode) { // container has been mounted
			if (child.__yContainer__)
				child.unmount();
			else
				this.parentNode.removeChild(child);
		}
		return this;
	},
	destroyer: function() {
		var self = this;
		return function() {
			self.destroy();
		};
	},
	destroy: function() {
		this.mounted = false;
		this.emit('destroy', this);
		utils.destroyElement(this, true);
		this.destroyed = true;
		this.comment = null;
		this.parentNode = null;
	},
	hide: function() {
		this.childNodes.forEach(function(child) {
			if (child.__yContainer__)
				return child.hide();
			if (child.style)
				child.style.display = 'none';
		});
		return this;
	},
	show: function() {
		this.childNodes.forEach(function(child) {
			if (child.__yContainer__)
				return child.show();
			if (child.style)
				child.style.display = '';
		});
		return this;
	},
	beforeUnmount: function(handler) {
		this._beforeUnmount = handler;
	}
};

Object.defineProperty(Container.prototype, "nextSibling", {
	get: function() {
		if (!this.childNodes.length)
			if (this.witness)
				return this.witness.nextSibling;
			else
				return null;

		if (!this.parentNode)
			return null;
		var last = this.childNodes[this.childNodes.length - 1];
		if (last)
			return last.nextSibling;
		return null;
	}
});
Object.defineProperty(Container.prototype, "firstChild", {
	get: function() {
		var first = this.childNodes[0];
		if (first)
			if (first.__yContainer__)
				return first.firstChild;
			else
				return first;
		return null;
	}
});
Object.defineProperty(Container.prototype, "lastChild", {
	get: function() {
		var last = this.childNodes[this.childNodes.length - 1];
		if (last)
			if (last.__yContainer__)
				return last.lastChild;
			else
				return last;
		return null;
	}
});
utils.shallowMerge(proto, Container.prototype);

module.exports = Container;
<commit_msg>dom engine : container : reorder destroy sequence<commit_after>/**
 * @author Gilles Coomans <gilles.coomans@gmail.com>
 * DOM only.
 * Container : The missing DOM node's type : a simple virtual nodes container that could be (un)mounted somewhere in other dom nodes.
 * Think it as an evoluated DocumentFragment.
 */
var utils = require('../../utils'),
	Emitter = require('nomocas-utils/lib/emitter');
var Container = function(parent) {
	this.__yContainer__ = true;
	this.parent = parent;
	this.childNodes = [];
};

Container.prototype = new Emitter();

var proto = {
	appendChildrenToFragment: function(frag, parentNode, mounted) {
		this.parentNode = parentNode;
		if (this.witness)
			frag.appendChild(this.witness);
		if (mounted)
			mounted.push(this);
		for (var i = 0, len = this.childNodes.length; i < len; ++i) {
			var child = this.childNodes[i];
			if (child.__yContainer__)
				child.appendChildrenToFragment(frag, parentNode, mounted);
			else
				frag.appendChild(child);
		}
		return this;
	},
	empty: function() {
		utils.destroyChildren(this.childNodes, true);
		this.childNodes = [];
		return this;
	},
	mount: function(node) {
		if (typeof node === 'string')
			node = document.querySelector(node);
		if (this.mounted && node === this.parentNode) {
			if (this.closing && this.transitionIn)
				this.transitionIn();
			return this;
		}
		utils.emptyNode(node);
		return this.appendTo(node);
	},
	appendTo: function(parent) {
		var par = parent;
		if (typeof parent === 'string')
			parent = document.querySelector(parent);
		if (this.mounted && parent === this.parentNode) {
			if (this.closing && this.transitionIn)
				this.transitionIn();
			return this;
		}
		if (!parent)
			throw new Error('could not mount container : no parent found with ' + par);
		this.mounted = true;
		if (parent.__yContainer__)
			parent.appendChild(this);
		else {
			if (this.witness)
				parent.appendChild(this.witness);
			this.parentNode = parent;
			for (var i = 0, len = this.childNodes.length; i < len; ++i) {
				var child = this.childNodes[i];
				if (child.__yContainer__)
					child.appendTo(parent);
				else
					parent.appendChild(child);
			}
		}
		this.emit('mounted', this);
		return this;
	},
	insertBeforeNode: function(node) {
		if (!node.parentNode)
			throw new Error('insertBeforeNode error : given node has no parent.');
		this.mounted = true;
		var frag = document.createDocumentFragment(),
			mounted = [];
		this.appendChildrenToFragment(frag, node.parentNode, mounted);
		// console.log('will insert container before : ', frag, node);
		node.parentNode.insertBefore(frag, node);
		for (var i = 0, len = mounted.length; i < len; ++i)
			mounted[i].emit('mounted', this);
		return this;
	},
	setWitness: function(witness) {
		this.witness = witness;
	},
	addWitness: function(title, parent) {
		if (this.witness)
			return this;
		this.witness = document.createComment(title);
		if (parent) {
			parent.appendChild(this.witness);
			return this;
		}
		if (!this.parentNode)
			return this;
		if (!this.childNodes.length) {
			console.warn('addWitness : container has been mounted without witness and children. Appending witness in parent.', this);
			this.parentNode.appendChild(this.witness);
		} else
			this.parentNode.insertBefore(this.witness, this.firstChild);
		return this;
	},
	removeWitness: function() {
		if (!this.witness)
			return this;
		if (this.witness.parentNode)
			this.witness.parentNode.removeChild(this.witness);
		this.witness = null;
		return this;
	},
	remount: function() {
		if (!this.witness.parentNode)
			throw new Error('container could not be remounted : witness has been unmounted.');
		if (this.mounted) {
			if (this.closing && this.transitionIn) {
				this.transitionIn();
			}
			return this;
		}
		var nextSibling = this.witness.nextSibling;
		if (nextSibling)
			this.insertBeforeNode(nextSibling);
		else
			this.appendTo(this.witness.parentNode);
		return this;
	},
	doUnmount: function(keepWitness) {
		this.mounted = false;
		if (!this.parentNode)
			return this;
		if (this.witness && !keepWitness)
			this.parentNode.removeChild(this.witness);
		for (var i = 0, len = this.childNodes.length; i < len; ++i) {
			var child = this.childNodes[i];
			if (child.__yContainer__)
				child.doUnmount();
			else if (child.parentNode)
				child.parentNode.removeChild(child);
		}
		this.parentNode = null;
		this.emit('unmounted', this);
		return this;
	},
	unmount: function(keepWitness, done) {
		if (!this.parentNode) { // container hasn't been mounted
			if (done)
				done(this);
			return this;
		}
		if (!this._beforeUnmount) {
			this.doUnmount(keepWitness);
			if (done)
				done(this);
			return this;
		}
		var self = this;
		this._beforeUnmount(function() {
			self.doUnmount(keepWitness);
			if (done)
				done(self);
		});
		return this;
	},
	appendChild: function(child) {
		if (this.parentNode) { // container has been mounted
			var nextSibling = this.nextSibling;
			if (nextSibling) {
				if (child.__yContainer__)
					child.insertBeforeNode(nextSibling);
				else
					this.parentNode.insertBefore(child, nextSibling);
			} else if (child.__yContainer__)
				child.appendTo(this.parentNode);
			else
				this.parentNode.appendChild(child);
		}
		this.childNodes.push(child);
		return this;
	},
	removeChild: function(child) {
		if (typeof child !== 'object') {
			var index = child;
			child = this.childNodes[index];
			if (!child)
				throw new Error('container.removeChild not found : ', index);
			this.childNodes.splice(index, 1);
		} else
			utils.array.remove(this.childNodes, child);
		if (this.parentNode) { // container has been mounted
			if (child.__yContainer__)
				child.unmount();
			else
				this.parentNode.removeChild(child);
		}
		return this;
	},
	destroyer: function() {
		var self = this;
		return function() {
			self.destroy();
		};
	},
	destroy: function() {
		utils.destroyElement(this, true);
		this.mounted = false;
		this.destroyed = true;
		this.comment = null;
		this.parentNode = null;
		this.emit('destroy', this);
	},
	hide: function() {
		this.childNodes.forEach(function(child) {
			if (child.__yContainer__)
				return child.hide();
			if (child.style)
				child.style.display = 'none';
		});
		return this;
	},
	show: function() {
		this.childNodes.forEach(function(child) {
			if (child.__yContainer__)
				return child.show();
			if (child.style)
				child.style.display = '';
		});
		return this;
	},
	beforeUnmount: function(handler) {
		this._beforeUnmount = handler;
	}
};

Object.defineProperty(Container.prototype, "nextSibling", {
	get: function() {
		if (!this.childNodes.length)
			if (this.witness)
				return this.witness.nextSibling;
			else
				return null;

		if (!this.parentNode)
			return null;
		var last = this.childNodes[this.childNodes.length - 1];
		if (last)
			return last.nextSibling;
		return null;
	}
});
Object.defineProperty(Container.prototype, "firstChild", {
	get: function() {
		var first = this.childNodes[0];
		if (first)
			if (first.__yContainer__)
				return first.firstChild;
			else
				return first;
		return null;
	}
});
Object.defineProperty(Container.prototype, "lastChild", {
	get: function() {
		var last = this.childNodes[this.childNodes.length - 1];
		if (last)
			if (last.__yContainer__)
				return last.lastChild;
			else
				return last;
		return null;
	}
});
utils.shallowMerge(proto, Container.prototype);

module.exports = Container;
<|endoftext|>


<commit_before>import $ from 'jquery';
import template from 'lodash/template';
import Promise from "bluebird";

let html = template(`

<%= text %>

`)

export default class {
  start() {
    const frame = $('.main-content');

    //// For development:
    //return Promise.resolve();

    return new Promise((resolve, reject) => {
      frame.html(this.html('The second game by butt.team'));
      setTimeout(() => frame.html(this.html('Shift at the Circle Burger')), 2000);
      setTimeout(() => {
        frame.empty();
        resolve();
      }, 5000);
    });
  }
  html(text) {
    return html({ text });
  }
};
<commit_msg>Avoid lodash in Intro<commit_after>import $ from 'jquery';
import Promise from "bluebird";

export default class {
  start() {
    const frame = $('.main-content');

    //// For development:
    //return Promise.resolve();

    return new Promise((resolve, reject) => {
      frame.html(this.html('The second game by butt.team'));
      setTimeout(() => frame.html(this.html('Shift at the Circle Burger')), 2000);
      setTimeout(() => {
        frame.empty();
        resolve();
      }, 5000);
    });
  }
  html(text) {
    return `

${ text }

    `;
  }
};
<|endoftext|>


<commit_before>/**
 * @author Pedro Sanders
 * @since v1
 */
import Processor from 'core/processor/processor'
import ContextStorage from 'core/context_storage'
import Registry from 'registry/registry'
import RestService from 'rest/rest'
import ResourcesUtil from 'resources/utils'
import getConfig from 'core/config_util.js'
import { Status } from 'resources/status'

const InetAddress = Packages.java.net.InetAddress
const SipFactory = Packages.javax.sip.SipFactory
const Properties = Packages.java.util.Properties
const LogManager = Packages.org.apache.logging.log4j.LogManager
const LOG = LogManager.getLogger()
const ANSI_GREEN = "\u001B[32m"
const ANSI_YELLOW = "\u001B[33m"
const ANSI_RESET = "\u001B[0m"

export default class Server {

    constructor(locator, registrar, dataAPIs) {
        this.locator = locator
        this.registrar = registrar
        this.dataAPIs = dataAPIs
        this.contextStorage = new ContextStorage()
        this.config = getConfig()
        // Not sure if this is a good idea in terms of performance
        this.regTimeout = 0.6
        this.host = this.config.spec.bindAddr
    }

    start()  {
        const host = this.host
        const config = this.config
        const locator = this.locator
        const registrar = this.registrar
        const dataAPIs = this.dataAPIs
        const contextStorage = this.contextStorage
        const regTimeout = this.regTimeout

        LOG.info('Starting Sip I/O')

        const properties = new Properties()
        const sipFactory = SipFactory.getInstance()

        // See https://github.com/RestComm/jain-sip/blob/master/src/gov/nist/javax/sip/SipStackImpl.java for
        // many other options
        sipFactory.setPathName('gov.nist')
        properties.setProperty('javax.sip.STACK_NAME', 'sipio')
        // Default host
        properties.setProperty('javax.sip.IP_ADDRESS', host)
        properties.setProperty('javax.sip.AUTOMATIC_DIALOG_SUPPORT', 'OFF')
        // Guard against denial of service attack.
        properties.setProperty('gov.nist.javax.sip.MAX_MESSAGE_SIZE', '1048576')
        // Drop the client connection after we are done with the transaction.
        properties.setProperty('gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS', 'false')
        properties.setProperty('gov.nist.javax.sip.TRACE_LEVEL', config.spec.logging.traceLevel)
        properties.setProperty('gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY', 'gov.nist.javax.sip.stack.NioMessageProcessorFactory')
        properties.setProperty('gov.nist.javax.sip.PATCH_SIP_WEBSOCKETS_HEADERS', 'false')

        // See https://groups.google.com/forum/#!topic/mobicents-public/U_c7aLAJ_MU for useful info
        if (config.spec.securityContext) {
            properties.setProperty('gov.nist.javax.sip.TLS_CLIENT_PROTOCOLS', config.spec.securityContext.client.protocols.join())
            // This must be set to 'Disabled' when using WSS
            properties.setProperty('gov.nist.javax.sip.TLS_CLIENT_AUTH_TYPE', config.spec.securityContext.client.authType)
            properties.setProperty('javax.net.ssl.keyStore', config.spec.securityContext.keyStore)
            properties.setProperty('javax.net.ssl.trustStore', config.spec.securityContext.trustStore)
            properties.setProperty('javax.net.ssl.keyStorePassword', config.spec.securityContext.keyStorePassword)
            properties.setProperty('javax.net.ssl.keyStoreType', config.spec.securityContext.keyStoreType)

            if (config.spec.securityContext.debugging) {
                Packages.java.lang.System.setProperty('javax.net.debug', 'ssl')
            }
        }

        this.sipStack = sipFactory.createSipStack(properties)

        const defTransport = this.sipStack.createListeningPoint(config.spec.transport[0].port,
            config.spec.transport[0].protocol.toLowerCase())

        const sipProvider = this.sipStack.createSipProvider(defTransport)

        for (const key in config.spec.transport) {
            const transport = config.spec.transport[key]
            const proto = transport.protocol.toLowerCase()

            if ((proto == 'wss' || proto == 'tls') && !config.spec.securityContext) {
                LOG.warn(ANSI_YELLOW + 'Security context not found. Ignoring protocol: ' + proto + ANSI_RESET)
                continue;
            }

            if (transport.bindAddr == undefined) transport.bindAddr = this.host

            const lp = this.sipStack.createListeningPoint(transport.bindAddr, transport.port, proto)
            sipProvider.addListeningPoint(lp)

            LOG.info('Added listening point:' + ANSI_GREEN  + ' [ip => ' + transport.bindAddr
                + ', port => ' + transport.port
                + ', proto => ' + proto + ']'
                + ANSI_RESET)
        }

        const registry = new Registry(sipProvider, dataAPIs)
        const processor = new Processor(sipProvider, locator, registry, registrar, dataAPIs, contextStorage)

        sipProvider.addSipListener(processor.listener)

        locator.start()
        registry.start()
        this.restService = new RestService(this, locator, registry, dataAPIs)
        this.restService.start()
    }

    stop() {
        LOG.info('Stopping server')
        this.restService.stop()
        this.sipStack.stop()
        this.locator.stop()
        exit(0)
    }
}
<commit_msg>Updated some logging output<commit_after>/**
 * @author Pedro Sanders
 * @since v1
 */
import Processor from 'core/processor/processor'
import ContextStorage from 'core/context_storage'
import Registry from 'registry/registry'
import RestService from 'rest/rest'
import ResourcesUtil from 'resources/utils'
import getConfig from 'core/config_util.js'
import { Status } from 'resources/status'

const InetAddress = Packages.java.net.InetAddress
const SipFactory = Packages.javax.sip.SipFactory
const Properties = Packages.java.util.Properties
const LogManager = Packages.org.apache.logging.log4j.LogManager
const LOG = LogManager.getLogger()
const ANSI_GREEN = "\u001B[32m"
const ANSI_YELLOW = "\u001B[33m"
const ANSI_RESET = "\u001B[0m"

export default class Server {

    constructor(locator, registrar, dataAPIs) {
        this.locator = locator
        this.registrar = registrar
        this.dataAPIs = dataAPIs
        this.contextStorage = new ContextStorage()
        this.config = getConfig()
        // Not sure if this is a good idea in terms of performance
        this.regTimeout = 0.6
        this.host = this.config.spec.bindAddr
    }

    start()  {
        const host = this.host
        const config = this.config
        const locator = this.locator
        const registrar = this.registrar
        const dataAPIs = this.dataAPIs
        const contextStorage = this.contextStorage
        const regTimeout = this.regTimeout

        LOG.info('Starting Sip I/O')

        const properties = new Properties()
        const sipFactory = SipFactory.getInstance()

        // See https://github.com/RestComm/jain-sip/blob/master/src/gov/nist/javax/sip/SipStackImpl.java for
        // many other options
        sipFactory.setPathName('gov.nist')
        properties.setProperty('javax.sip.STACK_NAME', 'sipio')
        // Default host
        properties.setProperty('javax.sip.IP_ADDRESS', host)
        properties.setProperty('javax.sip.AUTOMATIC_DIALOG_SUPPORT', 'OFF')
        // Guard against denial of service attack.
        properties.setProperty('gov.nist.javax.sip.MAX_MESSAGE_SIZE', '1048576')
        // Drop the client connection after we are done with the transaction.
        properties.setProperty('gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS', 'false')
        properties.setProperty('gov.nist.javax.sip.TRACE_LEVEL', config.spec.logging.traceLevel)
        properties.setProperty('gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY', 'gov.nist.javax.sip.stack.NioMessageProcessorFactory')
        properties.setProperty('gov.nist.javax.sip.PATCH_SIP_WEBSOCKETS_HEADERS', 'false')

        // See https://groups.google.com/forum/#!topic/mobicents-public/U_c7aLAJ_MU for useful info
        if (config.spec.securityContext) {
            properties.setProperty('gov.nist.javax.sip.TLS_CLIENT_PROTOCOLS', config.spec.securityContext.client.protocols.join())
            // This must be set to 'Disabled' when using WSS
            properties.setProperty('gov.nist.javax.sip.TLS_CLIENT_AUTH_TYPE', config.spec.securityContext.client.authType)
            properties.setProperty('javax.net.ssl.keyStore', config.spec.securityContext.keyStore)
            properties.setProperty('javax.net.ssl.trustStore', config.spec.securityContext.trustStore)
            properties.setProperty('javax.net.ssl.keyStorePassword', config.spec.securityContext.keyStorePassword)
            properties.setProperty('javax.net.ssl.keyStoreType', config.spec.securityContext.keyStoreType)

            if (config.spec.securityContext.debugging) {
                Packages.java.lang.System.setProperty('javax.net.debug', 'ssl')
            }
        }

        this.sipStack = sipFactory.createSipStack(properties)

        const defTransport = this.sipStack.createListeningPoint(config.spec.transport[0].port,
            config.spec.transport[0].protocol.toLowerCase())

        const sipProvider = this.sipStack.createSipProvider(defTransport)

        for (const key in config.spec.transport) {
            const transport = config.spec.transport[key]
            const proto = transport.protocol.toLowerCase()

            if ((proto == 'wss' || proto == 'tls') && !config.spec.securityContext) {
                LOG.warn(ANSI_YELLOW + 'Security context not found. Ignoring protocol: ' + proto + ANSI_RESET)
                continue;
            }

            if (transport.bindAddr == undefined) transport.bindAddr = this.host

            const lp = this.sipStack.createListeningPoint(transport.bindAddr, transport.port, proto)
            sipProvider.addListeningPoint(lp)

            LOG.info('Listening @ ' + ANSI_GREEN  + transport.bindAddr
                + ':' + transport.port
                    + ' [' + proto + ']'
                        + ANSI_RESET)
        }

        const registry = new Registry(sipProvider, dataAPIs)
        const processor = new Processor(sipProvider, locator, registry, registrar, dataAPIs, contextStorage)

        sipProvider.addSipListener(processor.listener)

        locator.start()
        registry.start()
        this.restService = new RestService(this, locator, registry, dataAPIs)
        this.restService.start()
    }

    stop() {
        LOG.info('Stopping server')
        this.restService.stop()
        this.sipStack.stop()
        this.locator.stop()
        exit(0)
    }
}
<|endoftext|>


<commit_before>// @flow

import * as React from 'react';
import { Redirect } from 'react-router';

import { AuthToken } from 'lib/auth';

export default class Logout extends React.Component<{}> {
  constructor() {
    super();
    AuthToken.logout();
    window.location.href = '/'; // Hard navigation to login screen. Dirty fix for GIFT-216
  }

  render(): React.Node {
    // return <Redirect to="/auth/login"/>;
    return null;
  }
}
<commit_msg>Add text and manual redirect link to log out page<commit_after>// @flow

import * as React from 'react';
import { Redirect } from 'react-router';

import { AuthToken } from 'lib/auth';

export default class Logout extends React.Component<{}> {
  constructor() {
    super();
    AuthToken.logout();
    window.location.href = '/'; // Hard navigation to login screen. Dirty fix for GIFT-216
  }

  render(): React.Node {
    // return <Redirect to="/auth/login"/>;
    return (

Logging out

        Click here if you are not redirected.

      );
  }
}
<|endoftext|>


<commit_before>/**
	A Groupbox displays controls as a vertically stacked group.

	A header may be added by placing an onyx.GroupboxHeader as the first control in the Groupbox.

		{kind: "onyx.Groupbox", components: [
			{kind: "onyx.GroupboxHeader", content: "Sounds"},
				{components: [
					{content: "System Sounds"},
					{kind: "onyx.ToggleButton", value: true}
				]},
				{kind: "onyx.InputDecorator", components: [
					{kind: "onyx.Input"}
				]}
			]}
		]}

*/
enyo.kind({
	name: "onyx.Groupbox",
	classes: "onyx-groupbox"
});

/**
	A GroupboxHeader is designed to be placed inside an onyx.Groupbox. When a header for a group is desired,
	make a GroupboxHeader the first control inside a Groupbox.

		{kind: "onyx.Groupbox", components: [
			{kind: "onyx.GroupboxHeader", content: "Sounds"},
			{content: "Yawn"},
			{content: "Beep"}
		]}
*/
enyo.kind({
	name: "onyx.GroupboxHeader",
	classes: "onyx-groupbox-header"
});<commit_msg>In API comments, noted that child controls should be containers. For ENYO-1353. Enyo-DCO-1.0-Signed-off-by: Jim Tang <jim.tang@palm.com><commit_after>/**
	_onyx.Groupbox_ displays rows of controls as a vertically-stacked group. It
	is designed to have container controls as its children, with each container
	representing a row in the Groupbox.

	A header may be added by specifying an
	onyx.GroupboxHeader as the first control
	in the Groupbox, e.g.:

		{kind: "onyx.Groupbox", components: [
			{kind: "onyx.GroupboxHeader", content: "Sounds"},
				{components: [
					{content: "System Sounds"},
					{kind: "onyx.ToggleButton", value: true}
				]},
				{kind: "onyx.InputDecorator", components: [
					{kind: "onyx.Input"}
				]}
			]}
		]}

*/
enyo.kind({
	name: "onyx.Groupbox",
	classes: "onyx-groupbox"
});

/**
	A GroupboxHeader is designed to be placed inside an onyx.Groupbox. When a header for a group is desired,
	make a GroupboxHeader the first control inside a Groupbox.

		{kind: "onyx.Groupbox", components: [
			{kind: "onyx.GroupboxHeader", content: "Sounds"},
			{content: "Yawn"},
			{content: "Beep"}
		]}
*/
enyo.kind({
	name: "onyx.GroupboxHeader",
	classes: "onyx-groupbox-header"
});<|endoftext|>