<commit_before>'use strict';

var should = require('should');
var sprite = require('../lib/css-sprite');
var path = require('path');
var vfs = require('vinyl-fs');
var es = require('event-stream');
var Canvas = require('canvas');
var Image = Canvas.Image;

require('mocha');

describe('css-sprite (lib/css-sprite.js)', function () {
  it('should return a object stream with a sprite', function (done) {
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png'
      }))
      .pipe(es.map(function (file, cb) {
        var img = new Image();
        img.src = file.contents;
        file.path.should.be.equal('dist/img/sprites.png');
        file.relative.should.be.equal('sprites.png');
        img.width.should.be.equal(56);
        img.height.should.be.equal(125);
        cb();
      }))
      .on('end', done);
  });
  it('should return a object stream with a bigger sprite', function (done) {
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        margin: 20
      }))
      .pipe(es.map(function (file, cb) {
        var img = new Image();
        img.src = file.contents;
        img.width.should.be.equal(86);
        img.height.should.be.equal(185);
        cb();
      }))
      .on('end', done);
  });
  it('should return a object stream with a horizontal sprite', function (done) {
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        orientation: 'horizontal'
      }))
      .pipe(es.map(function (file, cb) {
        var img = new Image();
        img.src = file.contents;
        file.path.should.be.equal('dist/img/sprites.png');
        file.relative.should.be.equal('sprites.png');
        img.width.should.be.equal(110);
        img.height.should.be.equal(69);
        cb();
      }))
      .on('end', done);
  });
  it('should return a object stream with a sprite and a css file', function (done) {
    var png, css;
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        style: './dist/css/sprites.css'
      }))
      .pipe(es.map(function (file, cb) {
        if (file.relative.indexOf('png') > -1) {
          png = file;
        }
        else {
          css = file;
        }
        cb();
      }))
      .on('end', function () {
        png.should.be.ok;
        png.path.should.be.equal('dist/img/sprites.png');
        png.relative.should.be.equal('sprites.png');
        css.should.be.ok;
        css.path.should.be.equal('./dist/css/sprites.css');
        css.relative.should.be.equal('sprites.css');
        css.contents.toString('utf-8').should.containEql('.icon-floppy-disk');
        done();
      });
  });
  it('should return a object stream with a sprite and a scss file', function (done) {
    var png, css;
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        processor: 'scss',
        style: './dist/css/sprites.scss'
      }))
      .pipe(es.map(function (file, cb) {
        if (file.relative.indexOf('png') > -1) {
          png = file;
        }
        else {
          css = file;
        }
        cb();
      }))
      .on('end', function () {
        png.should.be.ok;
        png.path.should.be.equal('dist/img/sprites.png');
        png.relative.should.be.equal('sprites.png');
        css.should.be.ok;
        css.path.should.be.equal('./dist/css/sprites.scss');
        css.relative.should.be.equal('sprites.scss');
        css.contents.toString('utf-8').should.containEql('$floppy-disk');
        done();
      });
  });
  it('should do nothing when no files match', function (done) {
    var file = false;
    vfs.src('./test/fixtures/empty/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png'
      }))
      .pipe(es.map(function (f, cb) {
        file = file;
        cb();
      }))
      .on('end', function () {
        file.should.not.ok;
        done();
      });
  });
});
<commit_msg>add test for stream error<commit_after>'use strict';

var should = require('should');
var sprite = require('../lib/css-sprite');
var path = require('path');
var vfs = require('vinyl-fs');
var es = require('event-stream');
var Canvas = require('canvas');
var Image = Canvas.Image;

require('mocha');

describe('css-sprite (lib/css-sprite.js)', function () {
  it('should return a object stream with a sprite', function (done) {
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png'
      }))
      .pipe(es.map(function (file, cb) {
        var img = new Image();
        img.src = file.contents;
        file.path.should.be.equal('dist/img/sprites.png');
        file.relative.should.be.equal('sprites.png');
        img.width.should.be.equal(56);
        img.height.should.be.equal(125);
        cb();
      }))
      .on('end', done);
  });
  it('should return a object stream with a bigger sprite', function (done) {
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        margin: 20
      }))
      .pipe(es.map(function (file, cb) {
        var img = new Image();
        img.src = file.contents;
        img.width.should.be.equal(86);
        img.height.should.be.equal(185);
        cb();
      }))
      .on('end', done);
  });
  it('should return a object stream with a horizontal sprite', function (done) {
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        orientation: 'horizontal'
      }))
      .pipe(es.map(function (file, cb) {
        var img = new Image();
        img.src = file.contents;
        file.path.should.be.equal('dist/img/sprites.png');
        file.relative.should.be.equal('sprites.png');
        img.width.should.be.equal(110);
        img.height.should.be.equal(69);
        cb();
      }))
      .on('end', done);
  });
  it('should return a object stream with a sprite and a css file', function (done) {
    var png, css;
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        style: './dist/css/sprites.css'
      }))
      .pipe(es.map(function (file, cb) {
        if (file.relative.indexOf('png') > -1) {
          png = file;
        }
        else {
          css = file;
        }
        cb();
      }))
      .on('end', function () {
        png.should.be.ok;
        png.path.should.be.equal('dist/img/sprites.png');
        png.relative.should.be.equal('sprites.png');
        css.should.be.ok;
        css.path.should.be.equal('./dist/css/sprites.css');
        css.relative.should.be.equal('sprites.css');
        css.contents.toString('utf-8').should.containEql('.icon-floppy-disk');
        done();
      });
  });
  it('should return a object stream with a sprite and a scss file', function (done) {
    var png, css;
    vfs.src('./test/fixtures/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png',
        processor: 'scss',
        style: './dist/css/sprites.scss'
      }))
      .pipe(es.map(function (file, cb) {
        if (file.relative.indexOf('png') > -1) {
          png = file;
        }
        else {
          css = file;
        }
        cb();
      }))
      .on('end', function () {
        png.should.be.ok;
        png.path.should.be.equal('dist/img/sprites.png');
        png.relative.should.be.equal('sprites.png');
        css.should.be.ok;
        css.path.should.be.equal('./dist/css/sprites.scss');
        css.relative.should.be.equal('sprites.scss');
        css.contents.toString('utf-8').should.containEql('$floppy-disk');
        done();
      });
  });
  it('should do nothing when no files match', function (done) {
    var file = false;
    vfs.src('./test/fixtures/empty/**')
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png'
      }))
      .pipe(es.map(function (f, cb) {
        file = file;
        cb();
      }))
      .on('end', function () {
        file.should.not.ok;
        done();
      });
  });
  it('should throw error when file stream', function (done) {

    vfs.src('./test/fixtures/**', {buffer: false})
      .pipe(sprite({
        out: './dist/img',
        name: 'sprites.png'
      }))
      .on('error', function (err) {
        err.toString().should.equal('Error: Streaming not supported');
        done();
      })
  });
});
<|endoftext|>


<commit_before>/**
 * @type {Object} Hash of Number[]
 */
module.exports = {
    LENGTH_0: [],
    LENGTH_1: [ 1 ],
    LENGTH_2: [ 2, 1 ],
    LENGTH_3: [ 3, 1, 2 ],
    LENGTH_4: [ 3, 2, 3, 4 ],
    LENGTH_5: [ 2, 5, 0, 2, 3 ],
    LENGTH_ODD: [ 43, 2, 1, 5, 11, 32, 9, 1, 0, -4 ],
    LENGTH_EVEN: [ 43, 2, 1, 5, 11, 32, 9, 1, 0, 8 ],
    EQUAL_ITEMS: [ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 ],
    NEGATIVE_ITEMS: [ -7, 9, 0, 1, -1, -99, -6, -6 ],
    SORTED_ASC: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
    SORTED_DES: [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ],
    BIG: [
        0, 7, 63, 88, -7, 59, -30, 5, 70, 0, -66, -7,
        -9, 0, -52, 563, 9895, -3, 4, -9, 7, 36, -83,
        653, -8, 60, -3, 52, -93, 34, 36, 83, 653, 8,
        60, -3, 52, -93, 34, 0, 11, 47, 9, 9, 30, 25,
        3, 699, -422, -20, -60, 4, 49, 770, 65, -175,
        8, 0, 7, 63, 88, 7, 59, 30, 5, 70, 0, 66, -7,
        -9, 0, -52, 563, 9895, 3, 4, 9, -7, -83, 653,
        -8, 60, -3, 52, -93, 34, 36, -83, 653, -8, 6,
        -3, 52, -93, 34, 0, 11, 47, 9, 9, 30, 25, 31,
        699, -422, 2, -20, -60, 4, -49, 770, 65, -17,
        8, 0, 7, 63, 88, 7, 59, 30, 5, 70, 0, 66, -7,
        -9, 0, -52, 563, 9895, 3, -4, -9, 7, 36, -83,
        653, -8, 60, -3, 52, -93, -34, 36, -83, -653,
        -8, 60, -3, 52, -93, 314, 0, 11, 47, 9, -930,
        25, -3, 699, -422, 2, -20, -60, -4, -49, 770
    ]
};
<commit_msg>Improve sort tests.<commit_after>/**
 * @type {Object} Hash of Number[]
 */
module.exports = {
    LENGTH_0: [],
    LENGTH_1: [ 1 ],
    LENGTH_2: [ 2, 1 ],
    LENGTH_3: [ 3, 1, 2 ],
    LENGTH_4: [ 3, 2, 1, 4 ],
    LENGTH_5: [ 2, 5, 0, 1, 3 ],
    WITH_EQUAL_ITEMS: [ 7, 17, 1, 7, 1, 7, 5, 5, 4 ],
    EQUAL_ITEMS: [ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 ],
    LENGTH_ODD: [ 43, 2, 1, 5, 11, 32, 9, 1, 0, -4 ],
    LENGTH_EVEN: [ 43, 2, 1, 5, 11, 32, 9, 1, 0, 8 ],
    NEGATIVE_ITEMS: [ -7, 9, 0, 1, -1, -99, -6, -6 ],
    SORTED_ASC: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
    SORTED_DES: [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ],
    BIG: [
        0, 7, 63, 88, -7, 59, -30, 5, 70, 0, -66, -7,
        -9, 0, -52, 563, 9895, -3, 4, -9, 7, 36, -83,
        653, -8, 60, -3, 52, -93, 34, 36, 83, 653, 8,
        60, -3, 52, -93, 34, 0, 11, 47, 9, 9, 30, 25,
        3, 699, -422, -20, -60, 4, 49, 770, 65, -175,
        8, 0, 7, 63, 88, 7, 59, 30, 5, 70, 0, 66, -7,
        -9, 0, -52, 563, 9895, 3, 4, 9, -7, -83, 653,
        -8, 60, -3, 52, -93, 34, 36, -83, 653, -8, 6,
        -3, 52, -93, 34, 0, 11, 47, 9, 9, 30, 25, 31,
        699, -422, 2, -20, -60, 4, -49, 770, 65, -17,
        8, 0, 7, 63, 88, 7, 59, 30, 5, 70, 0, 66, -7,
        -9, 0, -52, 563, 9895, 3, -4, -9, 7, 36, -83,
        653, -8, 60, -3, 52, -93, -34, 36, -83, -653,
        -8, 60, -3, 52, -93, 314, 0, 11, 47, 9, -930,
        25, -3, 699, -422, 2, -20, -60, -4, -49, 770
    ]
};
<|endoftext|>


<commit_before>var tap = require("../")
  , fs = require("fs")
  , cp = require("child_process")
  , util = require("util")

tap.test("debug test", function (t) {
  console.error("debug test")
  t.plan(1)
  console.error("t.plan="+t._plan)

  cp.exec("../bin/tap.js --debug meta-test.js", function (err, stdo, stde) {
    console.error(util.inspect(stde))
    t.notEqual(stde.indexOf("debugger listening on port"), -1, "Should output debugger message")
    t.end();
  })
})
<commit_msg>Fixed tests in 0.12 / iojs<commit_after>var tap = require("../")
  , fs = require("fs")
  , cp = require("child_process")
  , util = require("util")

tap.test("debug test", function (t) {
  console.error("debug test")
  t.plan(1)
  console.error("t.plan="+t._plan)

  cp.exec("../bin/tap.js --debug meta-test.js", function (err, stdo, stde) {
    console.error(util.inspect(stde))
    // node 0.10 print "debugger", 0.12 and iojs are printing "Debugger"
    t.notEqual(stde.indexOf("ebugger listening on port"), -1, "Should output debugger message")
    t.end();
  })
})
<|endoftext|>


<commit_before>define(["doh", "require"], function(doh, require){
	doh.register("create-destroy", require.toUrl("./create-destroy.html"));
	doh.register("addCssRule", require.toUrl("./addCssRule.html"));
	doh.register("stores", require.toUrl("./stores.html"));
});<commit_msg>Add _StoreMixin tests to test/doh/module<commit_after>define(["doh", "require", "./_StoreMixin" ], function(doh, require){
	doh.register("create-destroy", require.toUrl("./create-destroy.html"));
	doh.register("addCssRule", require.toUrl("./addCssRule.html"));
	doh.register("stores", require.toUrl("./stores.html"));
});
<|endoftext|>


<commit_before>var assert = require('assert');
var H = require('../test_harness.js');
var couchbase = require('../lib/couchbase.js');

var cb = H.newClient();

describe('#durability', function() {

  it('should successfully observe', function(done) {
    var key = H.genKey("observe");

    cb.set(key, "value", H.okCallback(function(meta){
      cb.observeMulti([key], {}, H.okCallback(function(meta){
        assert(typeof meta == "object");
        assert(key in meta);
        assert(typeof meta[key] == 'object');
        assert('cas' in meta[key][0]);
        done();
      }));
    }));
  });

  // skip because durability requirements does not currently work property
  it.skip('should successfully set with durability requirements',
      function(done) {
    var key = H.genKey("endure");

    cb.set(key, "value", {persist_to:1, replicate_to:0},
        H.okCallback(function(meta){
      cb.remove(key, {persist_to:1, replicate_to:0},
          H.okCallback(function(mera) {
        cb.add(key, "value", {persist_to:1, replicate_to:0},
            H.okCallback(function(meta){
          done();
        }));
      }));
    }));
  });

});<commit_msg>Enable durability test<commit_after>var assert = require('assert');
var H = require('../test_harness.js');
var couchbase = require('../lib/couchbase.js');

var cb = H.newClient();

describe('#durability', function() {

  it('should successfully observe', function(done) {
    var key = H.genKey("observe");

    cb.set(key, "value", H.okCallback(function(meta){
      cb.observeMulti([key], {}, H.okCallback(function(meta){
        assert(typeof meta == "object");
        assert(key in meta);
        assert(typeof meta[key] == 'object');
        assert('cas' in meta[key][0]);
        done();
      }));
    }));
  });

  // skip because durability requirements does not currently work property
  it('should successfully set with durability requirements',
      function(done) {
    var key = H.genKey("endure");

    cb.set(key, "value", {persist_to:1, replicate_to:0},
        H.okCallback(function(meta){
      cb.remove(key, {persist_to:1, replicate_to:0},
          H.okCallback(function(mera) {
        cb.add(key, "value", {persist_to:1, replicate_to:0},
            H.okCallback(function(meta){
          done();
        }));
      }));
    }));
  });

});
<|endoftext|>


<commit_before>var ytdl = require('..');

var dl = ytdl.download('http://www.youtube.com/watch?v=90AiXO1pAiA',
  __dirname,
  // Optional arguments passed to youtube-dl.
  ['--max-quality=18']);

// Will be called when the download starts.
dl.on('download', function(data) {
  console.log('Download started');
  console.log('filename: ' + data.filename);
  console.log('size: ' + data.size);
});

// Will be called during download progress of a video.
dl.on('progress', function(data) {
  process.stdout.write(data.eta + ' ' + data.percent + '% at ' + data.speed + '\r');
});

// Catches any errors.
dl.on('error', function(err) {
  throw err;
});

// Called when youtube-dl finishes.
dl.on('end', function(data) {
  console.log('\nDownload finished!');
  console.log('Filename: ' + data.filename);
  console.log('Size: ' + data.size);
  console.log('Time Taken: ' + data.timeTaken);
  console.log('Time Taken in ms: ' + data.timeTakenms);
  console.log('Average Speed: ' + data.averageSpeed);
  console.log('Average Speed in Bytes: ' + data.averageSpeedBytes);
});
<commit_msg>cleaner example output<commit_after>var ytdl = require('..');

var dl = ytdl.download('http://www.youtube.com/watch?v=90AiXO1pAiA',
  __dirname,
  // Optional arguments passed to youtube-dl.
  ['--max-quality=18']);

// Will be called when the download starts.
dl.on('download', function(data) {
  console.log('Download started');
  console.log('filename: ' + data.filename);
  console.log('size: ' + data.size);
  console.log();
});

// Will be called during download progress of a video.
dl.on('progress', function(data) {
  process.stdout.write(data.eta + ' ' + data.percent + '% at ' + data.speed + '\r');
});

// Catches any errors.
dl.on('error', function(err) {
  throw err;
});

// Called when youtube-dl finishes.
dl.on('end', function(data) {
  console.log('\n\nDownload finished!');
  console.log('Filename: ' + data.filename);
  console.log('Size: ' + data.size);
  console.log('Time Taken: ' + data.timeTaken);
  console.log('Time Taken in ms: ' + data.timeTakenms);
  console.log('Average Speed: ' + data.averageSpeed);
  console.log('Average Speed in Bytes: ' + data.averageSpeedBytes);
});
<|endoftext|>


<commit_before>function runTest()
{
    FBTest.sysout("issue5262.START");

    FBTest.openNewTab(basePath + "css/5262/issue5262.html", function(win)
    {
        FBTest.openFirebug();
        var panel = FBTest.selectPanel("stylesheet");

        FBTest.selectPanelLocationByName(panel, "issue5262.html");

        var rows = FW.FBL.getElementsByClass(panel.panelNode, "cssCharsetRule");
        FBTest.compare(1, rows.length, "There must be one @charset rule");

        FBTest.testDone("issue5262.DONE");
    });
}
<commit_msg>Enhanced test case to cover the correct display of the @charset rule<commit_after>function runTest()
{
    FBTest.sysout("issue5262.START");

    FBTest.openNewTab(basePath + "css/5262/issue5262.html", function(win)
    {
        FBTest.openFirebug();
        var panel = FBTest.selectPanel("stylesheet");

        FBTest.selectPanelLocationByName(panel, "issue5262.html");

        var rows = FW.FBL.getElementsByClass(panel.panelNode, "cssCharsetRule");
        if (FBTest.compare(1, rows.length, "There must be one @charset rule"))
            FBTest.compare(/@charset\s\"UTF-8\";/, rows[0].textContent, "The @charset rule must be correct");

        FBTest.testDone("issue5262.DONE");
    });
}
<|endoftext|>


<commit_before>import styled from 'styled-components';

const Wrapper = styled.div`
  ul {
    padding-left: 0;
  }
  li {
    margin: auto 5px;
    padding-bottom: 20px;
    display: inline-block;
    &.active a {
      background: #dd5555;
      color: #ffffff;
    }
    a {
      border: none;
      text-align: center;
      border-radius: 3px;
      padding: 8px 12px;
      transition: border 0.25s linear, color 0.25s linear, background-color 0.25s linear;
      color: #dd5555;
      box-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 0 rgba(0, 0, 0, 0.1);
      background-color: #f9f9f9;
      text-decoration: none;
      cursor: pointer;
      font-size: 0.85em;

      &:active, &:hover {
        color: #ffffff;
        background: #d94040;
      }
    }
  }
`;

export default Wrapper;
<commit_msg>fix : make pagination responsive across devices<commit_after>import styled from 'styled-components';

const Wrapper = styled.div`
  ul {
    padding-left: 0;
  }
  li {
    @media (max-width: 375px) {
      margin: auto 2px;
    }
    margin: auto 5px;
    padding-bottom: 20px;
    display: inline-block;
    &.active a {
      background: #dd5555;
      color: #ffffff;
    }
    a {
      border: none;
      text-align: center;
      border-radius: 3px;
      padding: 8px 12px;
      @media (max-width: 414px) {
        padding: 6px 9px;
        font-size: 0.85em;
      }
      @media (max-width: 375px) {
        padding: 6px 8px;
        font-size: 0.75em;
      }
      transition: border 0.25s linear, color 0.25s linear, background-color 0.25s linear;
      color: #dd5555;
      box-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 0 rgba(0, 0, 0, 0.1);
      background-color: #f9f9f9;
      text-decoration: none;
      cursor: pointer;
      font-size: 0.85em;

      &:active, &:hover {
        color: #ffffff;
        background: #d94040;
      }
    }
  }
`;

export default Wrapper;
<|endoftext|>


<commit_before>import React from 'react';
import Relay from 'react-relay';

import Panel from '../../shared/Panel';
import Button from '../../shared/Button';
import Spinner from '../../shared/Spinner';
import { formatNumber } from '../../../lib/number';

import AgentRow from './row';
import Search from './search';

const AGENT_LIST_REFRESH_INTERVAL = 10 * 1000;
const PAGE_SIZE = 20;

class Agents extends React.Component {
  static propTypes = {
    organization: React.PropTypes.shape({
      agents: React.PropTypes.shape({
        count: React.PropTypes.number.isRequired,
        pageInfo: React.PropTypes.shape({
          hasNextPage: React.PropTypes.bool.isRequired
        }).isRequired,
        edges: React.PropTypes.array.isRequired
      })
    }).isRequired,
    relay: React.PropTypes.object.isRequired
  };

  state = {
    loading: false,
    searching: false
  };

  componentDidMount() {
    this._agentListRefreshInterval = setInterval(this.fetchUpdatedData, AGENT_LIST_REFRESH_INTERVAL);
    this.props.relay.setVariables({ isMounted: true });
  }

  componentWillUnmount() {
    clearInterval(this._agentListRefreshInterval);
  }

  fetchUpdatedData = () => {
    this.props.relay.forceFetch(true);
  };

  render() {
    return (
      <Panel>

Agents

              <Search
                className="input py1 px2"
                placeholder="Filter"
                style={{ fontSize: 12, lineHeight: 1.1, height: 30, width: 160 }}
                onSearch={this.handleSearch}
              />

        {this.renderSearchResults()}
        {this.renderRows()}
        {this.renderLoadMoreButton()}
      </Panel>
    );
  }

  renderSearchResults() {
    const { organization, relay } = this.props;

    if (organization.agents && relay.variables.search) {
      return (

            {formatNumber(organization.agents.count)} matching agents

      );
    }
  }

  renderRows() {
    const { organization } = this.props;

    if (!organization.agents || this.state.searching) {
      return (
        <Panel.Section className="center">
          <Spinner />
        </Panel.Section>
      );
    }

    if (organization.agents.edges.length > 0) {
      return organization.agents.edges.map((edge) => <AgentRow key={edge.node.id} agent={edge.node} />);
    }

    return (
      <Panel.Section className="dark-gray">
        No agents connected
      </Panel.Section>
    );
  }

  renderLoadMoreButton() {
    const { organization } = this.props;

    if (!organization.agents || !organization.agents.pageInfo.hasNextPage) {
      return;
    }

    let footerContent = (
      <Button
        outline={true}
        theme="default"
        onClick={this.handleLoadMoreAgentsClick}
      >
        Load more agents…
      </Button>
    );

    if (this.state.loading) {
      footerContent = <Spinner style={{ margin: 8 }} />;
    }

    return (
      <Panel.Footer className="center">
        {footerContent}
      </Panel.Footer>
    );
  }

  handleSearch = (query) => {
    this.setState({ searching: true });

    let search = null;
    if (query) {
      search = query.split(/\s+/g);
    }

    this.props.relay.forceFetch(
      {
        search: search
      },
      (readyState) => {
        if (readyState.done) {
          this.setState({ searching: false });
        }
      }
    );
  };

  handleLoadMoreAgentsClick = () => {
    this.setState({ loading: true });

    this.props.relay.setVariables(
      {
        pageSize: this.props.relay.variables.pageSize + PAGE_SIZE
      },
      (readyState) => {
        if (readyState.done) {
          this.setState({ loading: false });
        }
      }
    );
  };
}

export default Relay.createContainer(Agents, {
  initialVariables: {
    isMounted: false,
    search: null,
    pageSize: PAGE_SIZE
  },

  fragments: {
    organization: () => Relay.QL`
      fragment on Organization {
        agents(first: $pageSize, metaData: $search) @include(if: $isMounted) {
          count
          edges {
            node {
              id
              ${AgentRow.getFragment('agent')}
            }
          }
          pageInfo {
            hasNextPage
          }
        }
      }
    `
  }
});
<commit_msg>Sneaky local search for agents<commit_after>import React from 'react';
import Relay from 'react-relay';

import Panel from '../../shared/Panel';
import Button from '../../shared/Button';
import Spinner from '../../shared/Spinner';
import { formatNumber } from '../../../lib/number';

import AgentRow from './row';
import Search from './search';

const AGENT_LIST_REFRESH_INTERVAL = 10 * 1000;
const PAGE_SIZE = 100;

class Agents extends React.Component {
  static propTypes = {
    organization: React.PropTypes.shape({
      agents: React.PropTypes.shape({
        count: React.PropTypes.number.isRequired,
        pageInfo: React.PropTypes.shape({
          hasNextPage: React.PropTypes.bool.isRequired
        }).isRequired,
        edges: React.PropTypes.array.isRequired
      })
    }).isRequired,
    relay: React.PropTypes.object.isRequired
  };

  state = {
    loading: false,
    searchingRemotely: false,
    localSearchQuery: null
  };

  componentDidMount() {
    this._agentListRefreshInterval = setInterval(this.fetchUpdatedData, AGENT_LIST_REFRESH_INTERVAL);
    this.props.relay.setVariables({ isMounted: true });
  }

  componentWillUnmount() {
    clearInterval(this._agentListRefreshInterval);
  }

  fetchUpdatedData = () => {
    this.props.relay.forceFetch(true);
  };

  render() {
    // grab (potentially) filtered agent list here, as we need it in several places
    const agents = this.getRelevantAgents();

    return (
      <Panel>

Agents

              <Search
                className="input py1 px2"
                placeholder="Filter"
                style={{ fontSize: 12, lineHeight: 1.1, height: 30, width: 160 }}
                onSearch={this.handleSearch}
              />

        {this.renderSearchInfo(agents)}
        {this.renderAgentList(agents)}
        {this.renderFooter()}
      </Panel>
    );
  }

  getRelevantAgents() {
    const { organization: { agents: { edges: agents } = { } } } = this.props;
    const { localSearchQuery } = this.state;

    // return all agents if the search query is falsy
    if (!localSearchQuery) {
      return agents;
    }

    // otherwise, filter by name and metaData
    return agents.filter(({ node: agent }) => {
      const foundInName = localSearchQuery.some((query) =>
        agent.name.toLowerCase().indexOf(query.toLowerCase()) !== -1
      );

      const foundInMetaData = agent.metaData.some((metaDataKeyValue) =>
        localSearchQuery.some((query) =>
          (query.indexOf('=') === -1 ? metaDataKeyValue.split('=').pop() : metaDataKeyValue).toLowerCase().indexOf(query.toLowerCase()) !== -1
        )
      );

      return foundInName || foundInMetaData;
    });
  }

  renderSearchInfo(relevantAgents) {
    const { organization: { agents }, relay: { variables: { search: remoteSearchQuery } } } = this.props;
    const { searchingRemotely, localSearchQuery } = this.state;

    if ((localSearchQuery && relevantAgents) || remoteSearchQuery && agents && !searchingRemotely) {
      return (

            {formatNumber(localSearchQuery ? relevantAgents.length : agents.count)} matching agents

      );
    }
  }

  renderAgentList(relevantAgents) {
    const { relay: { variables: { search: remoteSearchQuery } } } = this.props;
    const { searchingRemotely, localSearchQuery } = this.state;

    const isContextFiltered = !!(remoteSearchQuery || localSearchQuery);

    if (!relevantAgents || searchingRemotely) {
      return (
        <Panel.Section className="center">
          <Spinner />
        </Panel.Section>
      );
    }

    if (relevantAgents.length > 0) {
      return relevantAgents.map(({ node: agent }) => <AgentRow key={agent.id} agent={agent} />);
    }

    return (
      <Panel.Section className="dark-gray">
        No agents {isContextFiltered ? 'found' : 'connected'}
      </Panel.Section>
    );
  }

  renderFooter() {
    const { organization } = this.props;
    const { loading, searchingRemotely, localSearchQuery } = this.state;

    // don't show any footer if we're searching locally, or awaiting results
    if (localSearchQuery || searchingRemotely) {
      return;
    }

    // don't show any footer if we haven't ever loaded
    // any agents, or if there's no next page
    if (!organization.agents || !organization.agents.pageInfo.hasNextPage) {
      return;
    }

    let footerContent = (
      <Button
        outline={true}
        theme="default"
        onClick={this.handleLoadMoreAgentsClick}
      >
        Load more agents…
      </Button>
    );

    // show a spinner if we're loading more agents
    if (loading) {
      footerContent = <Spinner style={{ margin: 8 }} />;
    }

    return (
      <Panel.Footer className="center">
        {footerContent}
      </Panel.Footer>
    );
  }

  handleSearch = (query) => {
    const { organization } = this.props;

    // if we have the full set of agents locally, do our searching here
    if (organization.agents && organization.agents.edges.length > 0 && !organization.agents.pageInfo.hasNextPage) {
      return this.handleLocalSearch(query);
    }

    // if we haven't loaded anything yet, last retrieved a total of 0 agents,
    // or have more agents than are displayed, do the searching on the server
    return this.handleRemoteSearch(query);
  };

  handleLocalSearch = (query) => {
    // if there's a remote search active we make doubly sure to
    // reset it this shouldn't happen but stranger things have!
    const shouldResetSearch = !!this.props.relay.variables.search;

    // remove leading and trailing whitespace
    query = query.trim();

    const newState = {
      localSearchQuery: query ? query.split(/\s+/g) : null
    };

    if (shouldResetSearch) {
      newState.searchingRemotely = true;
    }

    this.setState(newState);

    if (shouldResetSearch) {
      this.props.relay.setVariables(
        {
          search: null
        },
        (readyState) => {
          if (readyState.done) {
            this.setState({ searchingRemotely: false });
          }
        }
      );
    }
  };

  handleRemoteSearch = (query) => {
    this.setState({ localSearchQuery: null, searchingRemotely: true });

    let search = null;
    if (query) {
      search = query.split(/\s+/g);
    }

    this.props.relay.forceFetch(
      {
        search: search
      },
      (readyState) => {
        if (readyState.done) {
          this.setState({ searchingRemotely: false });
        }
      }
    );
  };

  handleLoadMoreAgentsClick = () => {
    this.setState({ loading: true });

    this.props.relay.setVariables(
      {
        pageSize: this.props.relay.variables.pageSize + PAGE_SIZE
      },
      (readyState) => {
        if (readyState.done) {
          this.setState({ loading: false });
        }
      }
    );
  };
}

export default Relay.createContainer(Agents, {
  initialVariables: {
    isMounted: false,
    search: null,
    pageSize: PAGE_SIZE
  },

  fragments: {
    organization: () => Relay.QL`
      fragment on Organization {
        agents(first: $pageSize, metaData: $search) @include(if: $isMounted) {
          count
          edges {
            node {
              id
              metaData
              name
              ${AgentRow.getFragment('agent')}
            }
          }
          pageInfo {
            hasNextPage
          }
        }
      }
    `
  }
});
<|endoftext|>


<commit_before>(function () {
  'use strict';

  angular
    .module('openSenseMapApp')
    .directive('osemCalendar', OsemCalendar);

  OsemCalendar.$inject = ['moment', '$timeout'];

  /* @ngInject */
  function OsemCalendar (moment, $timeout) {
    var directive = {
      templateUrl: 'components/calendar.directive.html',
      bindToController: true,
      controller: CalendarController,
      controllerAs: 'calendar',
      link: link,
      restrict: 'EA',
      transclude: true,
      scope: {
        osemStartDate: '=',
        osemEndDate: '=',
        osemCurrentText: '@',
        osemClearText: '@',
        osemCloseText: '@',
        osemPlaceholderTextStartDate: '@',
        osemPlaceholderTextEndDate: '@',
        onClear: '&osemOnClear',
        onRangeSet: '&osemOnRangeSet'
      }
    };
    return directive;

    function link(scope, element, attrs) {
      //TODO: destroy
    }
  }

  /* @ngInject */
  function CalendarController (moment, $timeout) {
    var vm = this;

    vm.startDateOpen = false;
    vm.endDateOpen = false;
    vm.stayFocused = false;
    vm.loading = false;

    vm.textStartDate = '';
    vm.textEndDate = '';

    vm.dateOptionsStartDate = {
      maxDate: moment().toDate()
    };
    vm.dateOptionsEndDate = {
      maxDate: moment().toDate()
    };

    vm.open = open;
    vm.close = close;
    vm.clear = clear;
    vm.dateSelected = dateSelected;
    vm.setRange = setRange;
    vm.hoverItem = hoverItem;
    vm.showReset = showReset;

    activate();

    ////

    function activate () {
      if (angular.isUndefined(vm.osemStartDate) || angular.equals({}, vm.osemStartDate)) {
        vm.textStartDate = vm.osemPlaceholderTextStartDate;
      }
      if (angular.isUndefined(vm.osemEndDate) || angular.equals({}, vm.osemEndDate)) {
        vm.textEndDate = vm.osemPlaceholderTextEndDate;
      }
    }

    function open (id) {
      vm.stayFocused = true;
      switch (id) {
        case 'startDate':
          vm.endDateOpen = false;
          vm.startDateOpen = true;
          break;
        case 'endDate':
          vm.startDateOpen = false;
          vm.endDateOpen = true;
          break;
      }
    }

    function close (id, focused) {
      if (!vm.stayFocused && focused) {
        switch (id) {
          case 'startDate':
            vm.startDateOpen = false;
            break;
          case 'endDate':
            vm.endDateOpen = false;
            break;
        }
      }
    }

    function dateSelected (id) {
      vm.stayFocused = false;
      switch (id) {
        case 'startDate':
          if (angular.isUndefined(vm.osemStartDate) || vm.osemStartDate === null) {
            vm.osemStartDate = new Date();
            vm.textStartDate = vm.osemPlaceholderTextStartDate;
          } else {
            vm.osemStartDate = moment(vm.osemStartDate);
            vm.textStartDate = moment(vm.osemStartDate).format('L');
            vm.dateOptionsEndDate.minDate = vm.osemStartDate.toDate();
          }
          close('startDate', true);
          break;
        case 'endDate':
          if (angular.isUndefined(vm.osemEndDate) || vm.osemEndDate === null) {
            vm.osemEndDate = new Date();
            vm.textEndDate = vm.osemPlaceholderTextEndDate;
          } else {
            vm.osemEndDate = moment(vm.osemEndDate);
            vm.textEndDate = moment(vm.osemEndDate).format('L');
            vm.dateOptionsStartDate.maxDate = vm.osemEndDate.toDate();
          }
          close('endDate', true);
          break;
      }

      //TODO check if time range has changed
      if (moment.isMoment(vm.osemStartDate) &&
        moment.isMoment(vm.osemEndDate)) {
        executeCallback(vm.onRangeSet);
      }
    }

    function executeCallback (func) {
      if (angular.isDefined(func) && angular.isFunction(func)) {
        vm.loading = true;
        $timeout(function () {
          func()
            .then(function (response) {
              vm.loading = false;
            });
        }, 500);
      }
    }

    function clear () {
      vm.osemStartDate = new Date();
      vm.textStartDate = vm.osemPlaceholderTextStartDate;
      vm.osemEndDate = new Date();
      vm.textEndDate = vm.osemPlaceholderTextEndDate;

      executeCallback(vm.onClear);
    }

    function setRange (number, type) {
      vm.osemEndDate = moment();
      vm.textEndDate = moment(vm.osemEndDate).format('L');
      vm.osemStartDate = moment(vm.osemEndDate).subtract(number, type);
      vm.textStartDate = moment(vm.osemStartDate).format('L');

      executeCallback(vm.onRangeSet);
    }

    function hoverItem (hover) {
      vm.hover = hover;
    }

    function showReset () {
      if (!vm.loading && vm.osemStartDate && vm.osemEndDate) {
        return true;
      }
      if (vm.loading && !angular.equals({}, vm.osemStartDate) && !angular.equals({}, vm.osemEndDate)) {
        return true;
      }
      return false;
    }
  }
})();
<commit_msg>use momentjs startOf functionality<commit_after>(function () {
  'use strict';

  angular
    .module('openSenseMapApp')
    .directive('osemCalendar', OsemCalendar);

  OsemCalendar.$inject = ['moment', '$timeout'];

  /* @ngInject */
  function OsemCalendar (moment, $timeout) {
    var directive = {
      templateUrl: 'components/calendar.directive.html',
      bindToController: true,
      controller: CalendarController,
      controllerAs: 'calendar',
      link: link,
      restrict: 'EA',
      transclude: true,
      scope: {
        osemStartDate: '=',
        osemEndDate: '=',
        osemCurrentText: '@',
        osemClearText: '@',
        osemCloseText: '@',
        osemPlaceholderTextStartDate: '@',
        osemPlaceholderTextEndDate: '@',
        onClear: '&osemOnClear',
        onRangeSet: '&osemOnRangeSet'
      }
    };
    return directive;

    function link(scope, element, attrs) {
      //TODO: destroy
    }
  }

  /* @ngInject */
  function CalendarController (moment, $timeout) {
    var vm = this;

    vm.startDateOpen = false;
    vm.endDateOpen = false;
    vm.stayFocused = false;
    vm.loading = false;

    vm.textStartDate = '';
    vm.textEndDate = '';

    vm.dateOptionsStartDate = {
      maxDate: moment().startOf('day').toDate()
    };
    vm.dateOptionsEndDate = {
      maxDate: moment().startOf('day').toDate()
    };

    vm.open = open;
    vm.close = close;
    vm.clear = clear;
    vm.dateSelected = dateSelected;
    vm.setRange = setRange;
    vm.hoverItem = hoverItem;
    vm.showReset = showReset;

    activate();

    ////

    function activate () {
      if (angular.isUndefined(vm.osemStartDate) || angular.equals({}, vm.osemStartDate)) {
        vm.textStartDate = vm.osemPlaceholderTextStartDate;
      }
      if (angular.isUndefined(vm.osemEndDate) || angular.equals({}, vm.osemEndDate)) {
        vm.textEndDate = vm.osemPlaceholderTextEndDate;
      }
    }

    function open (id) {
      vm.stayFocused = true;
      switch (id) {
        case 'startDate':
          vm.endDateOpen = false;
          vm.startDateOpen = true;
          break;
        case 'endDate':
          vm.startDateOpen = false;
          vm.endDateOpen = true;
          break;
      }
    }

    function close (id, focused) {
      if (!vm.stayFocused && focused) {
        switch (id) {
          case 'startDate':
            vm.startDateOpen = false;
            break;
          case 'endDate':
            vm.endDateOpen = false;
            break;
        }
      }
    }

    function dateSelected (id) {
      vm.stayFocused = false;
      switch (id) {
        case 'startDate':
          if (angular.isUndefined(vm.osemStartDate) || vm.osemStartDate === null) {
            vm.osemStartDate = new Date();
            vm.textStartDate = vm.osemPlaceholderTextStartDate;
          } else {
            vm.osemStartDate = moment(vm.osemStartDate).startOf('day');
            vm.textStartDate = moment(vm.osemStartDate).format('L');
            vm.dateOptionsEndDate.minDate = vm.osemStartDate.clone().add(1, 'days').toDate();
          }
          close('startDate', true);
          break;
        case 'endDate':
          if (angular.isUndefined(vm.osemEndDate) || vm.osemEndDate === null) {
            vm.osemEndDate = new Date();
            vm.textEndDate = vm.osemPlaceholderTextEndDate;
          } else {
            vm.osemEndDate = moment(vm.osemEndDate).startOf('day');
            vm.textEndDate = moment(vm.osemEndDate).format('L');
            vm.dateOptionsStartDate.maxDate = vm.osemEndDate.toDate();
          }
          close('endDate', true);
          break;
      }

      if (moment.isMoment(vm.osemStartDate) &&
        moment.isMoment(vm.osemEndDate)) {
        executeCallback(vm.onRangeSet);
      }
    }

    function executeCallback (func) {
      if (angular.isDefined(func) && angular.isFunction(func)) {
        vm.loading = true;
        $timeout(function () {
          func()
            .then(function (response) {
              vm.loading = false;
            });
        }, 500);
      }
    }

    function clear () {
      vm.osemStartDate = new Date();
      vm.textStartDate = vm.osemPlaceholderTextStartDate;
      vm.osemEndDate = new Date();
      vm.textEndDate = vm.osemPlaceholderTextEndDate;

      vm.dateOptionsStartDate.maxDate = moment().startOf('day').toDate();
      vm.dateOptionsEndDate.minDate = null;
      vm.dateOptionsEndDate.maxDate = moment().startOf('day').toDate();

      executeCallback(vm.onClear);
    }

    function setRange (number, type) {
      vm.osemEndDate = moment();
      vm.textEndDate = moment(vm.osemEndDate).format('L');
      vm.osemStartDate = moment(vm.osemEndDate).subtract(number, type);
      vm.textStartDate = moment(vm.osemStartDate).format('L');

      vm.dateOptionsStartDate.maxDate = vm.osemEndDate.toDate();
      vm.dateOptionsEndDate.minDate = vm.osemStartDate.clone().add(1, 'days').toDate();

      executeCallback(vm.onRangeSet);
    }

    function hoverItem (hover) {
      vm.hover = hover;
    }

    function showReset () {
      if (!vm.loading && vm.osemStartDate && vm.osemEndDate) {
        return true;
      }
      if (vm.loading && !angular.equals({}, vm.osemStartDate) && !angular.equals({}, vm.osemEndDate)) {
        return true;
      }
      return false;
    }
  }
})();
<|endoftext|>


<commit_before>import React, { Component, PropTypes } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

export default class EnqueteEditorApp extends Component {
  componentDidMount() {
    var data = [
      { id: 'flow1', type: 'page', pageId: 'page1', nextFlowId: 'flow2'},
      { id: 'flow2', type: 'page', pageId: 'page2', nextFlowId: 'flow3'},
      { id: "flow3", type: "branch", conditionId: 'cond1'},
      { id: 'flow4', type: 'page', pageId: 'page3', nextFlowId: '__END__'},
      { id: 'flow5', type: 'page', pageId: 'page4', nextFlowId: '__END__'}
    ];

    var hot = new Handsontable(this.refs.flowsHot, {
      colHeaders: ['ID', 'Type', 'PageId', 'NextFlowId', 'ConditionId'],
      columns: [
        {data: 'id'},
        {data: 'type', editor: 'select', selectOptions: ['page', 'branch']},
        {data: 'pageId'},
        {data: 'nextFlowId'},
        {data: 'conditionId'}
      ],
      width: 100,
      data: data
    });
  }
  render() {
    return (

cytoscape.jsを動かす

Flows

Conditions

Pages

Questions

Items

    )
  }
}
<commit_msg>tableのサイズを変更<commit_after>import React, { Component, PropTypes } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

export default class EnqueteEditorApp extends Component {
  componentDidMount() {
    var data = [
      { id: 'flow1', type: 'page', pageId: 'page1', nextFlowId: 'flow2'},
      { id: 'flow2', type: 'page', pageId: 'page2', nextFlowId: 'flow3'},
      { id: "flow3", type: "branch", conditionId: 'cond1'},
      { id: 'flow4', type: 'page', pageId: 'page3', nextFlowId: '__END__'},
      { id: 'flow5', type: 'page', pageId: 'page4', nextFlowId: '__END__'}
    ];

    var hot = new Handsontable(this.refs.flowsHot, {
      colHeaders: ['ID', 'Type', 'PageID', 'NextFlowID', 'ConditionID'],
      columns: [
        {data: 'id'},
        {data: 'type', editor: 'select', selectOptions: ['page', 'branch']},
        {data: 'pageId'},
        {data: 'nextFlowId'},
        {data: 'conditionId'}
      ],
      colWidths: [100, 60, 100, 100, 100],
      width: 1000,
      data: data
    });
    var conditionsHot = new Handsontable(this.refs.conditionsHot, {
      colHeaders: ['FlowID', 'Type', 'Question', 'Operator', 'Value', 'NextFlowID'],
      columns: [
        {data: 'flowId'},
        {data: 'type', editor: 'select', selectOptions: ['if', 'else']},
        {data: 'question'},
        {data: 'operator', editor: 'select', selectOptions: ['==', '!=', '<', '>', '<=', '>=']},
        {data: 'value'},
        {data: 'nextFlowId'}
      ],
      colWidths: [100, 50, 100, 70, 100, 100],
      data: [
        { flowId: 'flow3', type: 'if', question: 'q4', operator: '==', value: 'fuga1', nextFlowId: 'flow4' },
        { flowId: 'flow3', type: 'if', question: 'q4', operator: '==', value: 'fuga2', nextFlowId: 'flow5' },
        { flowId: 'flow3', type: 'else', nextFlowId: 'flow1'}
      ]
    });

  }
  render() {
    return (

cytoscape.jsを動かす

Flows

Conditions

Pages

Questions

Items

    )
  }
}
<|endoftext|>


<commit_before>var React = require('react');

var dashboard = React.createClass({
	getInitialState: function() {
		return { userPods: [] };
	},

	componentDidMount: function() {
	  	// Grab all of the user's pods from the database & display
	  	helpers.getPods().then(function(userPods) {
	      this.setState({ userPods: userPods.data });
	      console.log("User's pods ", userPods.data);
	    }.bind(this));
	},

	renderEmpty: function() {
	    return (

	            You haven't joined any Pods yet!

	    );
	},

	renderArticles: function() {
	    return this.state.userPods.map(function(pod, index) {

	      return (

	                {pod.title}

	                  <button className="btn btn-default ">Go to Pod</button>

Description: {pod.description}

	      );
	    }.bind(this));
	},

	render: function() {

				PodSquad

				dashboard
				<form className="navbar-form" role="search">

    			<input type="text" className="form-control text-center" id="title" placeholder="search" onChange= {this.handleChange} required/>

  				<button type="submit" className="btn btn-default" onClick={this.handleClick}>Search</button>
				</form>

Your Pods

						renderArticles();

You

Name

Pods

podname

podname

	}
});

module.exports = dashboard;<commit_msg>renders pods in the panel body<commit_after>var React = require('react');

var dashboard = React.createClass({
	getInitialState: function() {
		return { userPods: [] };
	},

	componentDidMount: function() {
		this.setState({userPods: []});
	  	// Grab all of the user's pods from the database & display
	  	helpers.getPods().then(function(userPods) {
	      this.setState({ userPods: userPods.data });
	      console.log("User's pods ", userPods.data);
	    }.bind(this));
	},

	renderEmpty: function() {
	    return (

	            You haven't joined any Pods yet!

	    );
	},

	renderPods: function() {
	    return this.state.userPods.map(function(pod, index) {

	      return (

	                {pod.title}

	                  <button className="btn btn-default ">Go to Pod</button>

Description: {pod.description}

	      );
	    }.bind(this));
	},

	render: function() {

				PodSquad

				dashboard
				<form className="navbar-form" role="search">

    			<input type="text" className="form-control text-center" id="title" placeholder="search" onChange= {this.handleChange} required/>

  				<button type="submit" className="btn btn-default" onClick={this.handleClick}>Search</button>
				</form>

Your Pods

						{this.renderPods()}

You

Name

Pods

podname

podname

	}
});

module.exports = dashboard;<|endoftext|>


<commit_before>var browserify = require('browserify');
var b = browserify();

b.transform('../index.js'); // or just 'vashify' in your case
b.add('./entry.js');
b.bundle().pipe(process.stdout);

<commit_msg>remove dead file<commit_after><|endoftext|>


<commit_before>/*

Metaball rendering demo. Many ideas and code taken from here

 */

const regl = require('../regl')()
const isosurface = require("isosurface")
const normals = require('angle-normals')
const mat3 = require("gl-mat3")
const camera = require('./util/camera')(regl, {
  distance: 1,
  maxDistance: 3,
  minDistance: 0.5,
  center: [0.5,0.5,0.5],
})

const drawMetaballs = regl({
  vert: `
    precision mediump float;
    uniform mat4 projection, view;
    uniform mat3 normalMatrix;
    attribute vec3 position, normal;
    varying vec3 vNormal, vONormal, vU;
    varying vec4 vPosition, vOPosition;
    void main () {
      vNormal = normalMatrix * normal;
      vONormal = normal;
      vPosition = vec4( position, 1.0 );
      vOPosition = view * vPosition;
      vU = normalize( vec3( vOPosition ) );
      gl_Position = projection * vOPosition;
    }`,
  frag: `
    precision mediump float;
    uniform sampler2D textureMap, normalMap;
    uniform vec3 color, eye;
    uniform float normalScale, texScale, useSSS, useScreen;

    varying vec3 vNormal, vONormal, vU;
    varying vec4 vPosition, vOPosition;

    float random(vec3 scale,float seed) {
      return fract(sin(dot(gl_FragCoord.xyz+seed,scale))*43758.5453+seed);
    }

    void main() {
      vec3 n = normalize( vONormal.xyz );
      vec3 blend_weights = abs( n );
      blend_weights = ( blend_weights - 0.2 ) * 7.;
      blend_weights = max( blend_weights, 0. );
      blend_weights /= ( blend_weights.x + blend_weights.y + blend_weights.z );

      vec2 coord1 = vPosition.yz * texScale;
      vec2 coord2 = vPosition.zx * texScale;
      vec2 coord3 = vPosition.xy * texScale;

      vec3 bump1 = texture2D( normalMap, coord1 ).rgb;
      vec3 bump2 = texture2D( normalMap, coord2 ).rgb;
      vec3 bump3 = texture2D( normalMap, coord3 ).rgb;

      vec3 blended_bump = bump1 * blend_weights.xxx +
                          bump2 * blend_weights.yyy +
                          bump3 * blend_weights.zzz;

      vec3 tanX = vec3( vNormal.x, -vNormal.z, vNormal.y);
      vec3 tanY = vec3( vNormal.z, vNormal.y, -vNormal.x);
      vec3 tanZ = vec3(-vNormal.y, vNormal.x, vNormal.z);
      vec3 blended_tangent = tanX * blend_weights.xxx +
                             tanY * blend_weights.yyy +
                             tanZ * blend_weights.zzz;

      vec3 normalTex = blended_bump * 2.0 - 1.0;
      normalTex.xy *= normalScale;
      normalTex.y *= -1.;
      normalTex = normalize( normalTex );
      mat3 tsb = mat3( normalize( blended_tangent ), normalize( cross( vNormal, blended_tangent ) ), normalize( vNormal ) );
      vec3 finalNormal = tsb * normalTex;

      vec3 r = reflect( normalize( vU ), normalize( finalNormal ) );
      float m = 2.0 * sqrt( r.x * r.x + r.y * r.y + ( r.z + 1.0 ) * ( r.z + 1.0 ) );
      vec2 calculatedNormal = vec2( r.x / m + 0.5,  r.y / m + 0.5 );

      vec3 base = texture2D( textureMap, calculatedNormal ).rgb;

      float rim = 1.75 * max( 0., abs( dot( normalize( vNormal ), normalize( -vOPosition.xyz ) ) ) );
      base += useSSS * color * ( 1. - .75 * rim );
      base += ( 1. - useSSS ) * 10. * base * color * clamp( 1. - rim, 0., .15 );

      if( useScreen == 1. ) {
        base = vec3( 1. ) - ( vec3( 1. ) - base ) * ( vec3( 1. ) - base );
      }

      float nn = .05 * random( vec3( 1. ), length( gl_FragCoord ) );
      base += vec3( nn );

      gl_FragColor = vec4( base.rgb, 1. );
    }`,
  attributes: {
    position: regl.prop('positions'),
    normal: (context, props) => normals(props.cells, props.positions)
  },
  uniforms: {
    color: [36/255.0, 70/255.0, 106/255.0],
    sphereColor: [36/255.0, 70/255.0, 106/255.0],
    normalScale: 1,
    texScale: 10,
    useSSS: 0,
    useScreen: 1,
    normalMatrix: (context) => {
      let a = mat3.create()
      mat3.normalFromMat4(a, context.view)
      return a
    },
    textureMap: regl.prop('textureMap'),
    normalMap: regl.prop('normalMap')
  },
  elements: regl.prop('cells')
})

const metaball = (px, py, pz, strength, subtract) => {
  return (x, y, z) => {
    return (strength / (Math.pow(x-px, 2) + Math.pow(y-py, 2) + Math.pow(z-pz, 2))) - subtract
  }
}

const numblobs = 20
const strength = 1.2 / ( ( Math.sqrt( numblobs ) - 1 ) / 4 + 1 )
const subtract = 12
const balls = Array(numblobs).fill().map((_, i) => {
  return (time) => {
    ballx = Math.sin( i + 1.26 * time * ( 1.03 + 0.5 * Math.cos( 0.21 * i ) ) ) * 0.27 + 0.5;
    bally = Math.cos( i + 1.12 * time * 0.21 * Math.sin( ( 0.72 + 0.83 * i ) ) ) * 0.27 + 0.5;
    ballz = Math.cos( i + 1.32 * time * 0.1 * Math.sin( ( 0.92 + 0.53 * i ) ) ) * 0.27 + 0.5;
    return metaball(ballx, bally, ballz, strength, subtract)
  }
})

require('resl')({
  manifest: {
    sphereTexture: {
      type: 'image',
      src: 'spheretexture.jpg',
      parser: (data) => regl.texture({
        data: data,
        wrapT: 'clamp',
        wrapS: 'clamp'
      })
    },
    normalTexture: {
      type: 'image',
      src: 'normaltexture.jpg',
      parser: (data) => regl.texture({
        data: data,
        wrapT: "repeat",
        wrapS: "repeat"
      })
    }
  },
  onDone: ({ sphereTexture, normalTexture }) => {
    let time = 0.05
    let field = (x,y,z) => {
      return balls.map((b) => b(1)(x,y,z)).reduce((a, b) => a + b)
    }
    let mesh = isosurface.surfaceNets([50,50,50], field, [[0,0,0], [1, 1, 1]])

    regl.frame(({tick}) => {
      // let time = 0.05 * tick
      // let field = (x,y,z) => {
      //   return balls.map((b) => b(time)(x,y,z)).reduce((a, b) => a + b)
      // }
      // let mesh = isosurface.surfaceNets([50,50,50], field, [[0,0,0], [1, 1, 1]])
      camera(() => {
        drawMetaballs({
          positions: mesh.positions,
          cells: mesh.cells,
          textureMap: sphereTexture,
          normalMap: normalTexture
        })
      })
    })
  }
})
<commit_msg>Fix tests for metaball example.<commit_after>/*

Metaball rendering demo. Many ideas and code taken from here

 */

const regl = require('../regl')()
const isosurface = require('isosurface')
const normals = require('angle-normals')
const mat3 = require('gl-mat3')
const camera = require('./util/camera')(regl, {
  distance: 1,
  maxDistance: 3,
  minDistance: 0.5,
  center: [0.5, 0.5, 0.5]
})

const drawMetaballs = regl({
  vert: `
    precision mediump float;
    uniform mat4 projection, view;
    uniform mat3 normalMatrix;
    attribute vec3 position, normal;
    varying vec3 vNormal, vONormal, vU;
    varying vec4 vPosition, vOPosition;
    void main () {
      vNormal = normalMatrix * normal;
      vONormal = normal;
      vPosition = vec4( position, 1.0 );
      vOPosition = view * vPosition;
      vU = normalize( vec3( vOPosition ) );
      gl_Position = projection * vOPosition;
    }`,
  frag: `
    precision mediump float;
    uniform sampler2D textureMap, normalMap;
    uniform vec3 color, eye;
    uniform float normalScale, texScale, useSSS, useScreen;

    varying vec3 vNormal, vONormal, vU;
    varying vec4 vPosition, vOPosition;

    float random(vec3 scale,float seed) {
      return fract(sin(dot(gl_FragCoord.xyz+seed,scale))*43758.5453+seed);
    }

    void main() {
      vec3 n = normalize( vONormal.xyz );
      vec3 blend_weights = abs( n );
      blend_weights = ( blend_weights - 0.2 ) * 7.;
      blend_weights = max( blend_weights, 0. );
      blend_weights /= ( blend_weights.x + blend_weights.y + blend_weights.z );

      vec2 coord1 = vPosition.yz * texScale;
      vec2 coord2 = vPosition.zx * texScale;
      vec2 coord3 = vPosition.xy * texScale;

      vec3 bump1 = texture2D( normalMap, coord1 ).rgb;
      vec3 bump2 = texture2D( normalMap, coord2 ).rgb;
      vec3 bump3 = texture2D( normalMap, coord3 ).rgb;

      vec3 blended_bump = bump1 * blend_weights.xxx +
                          bump2 * blend_weights.yyy +
                          bump3 * blend_weights.zzz;

      vec3 tanX = vec3( vNormal.x, -vNormal.z, vNormal.y);
      vec3 tanY = vec3( vNormal.z, vNormal.y, -vNormal.x);
      vec3 tanZ = vec3(-vNormal.y, vNormal.x, vNormal.z);
      vec3 blended_tangent = tanX * blend_weights.xxx +
                             tanY * blend_weights.yyy +
                             tanZ * blend_weights.zzz;

      vec3 normalTex = blended_bump * 2.0 - 1.0;
      normalTex.xy *= normalScale;
      normalTex.y *= -1.;
      normalTex = normalize( normalTex );
      mat3 tsb = mat3( normalize( blended_tangent ), normalize( cross( vNormal, blended_tangent ) ), normalize( vNormal ) );
      vec3 finalNormal = tsb * normalTex;

      vec3 r = reflect( normalize( vU ), normalize( finalNormal ) );
      float m = 2.0 * sqrt( r.x * r.x + r.y * r.y + ( r.z + 1.0 ) * ( r.z + 1.0 ) );
      vec2 calculatedNormal = vec2( r.x / m + 0.5,  r.y / m + 0.5 );

      vec3 base = texture2D( textureMap, calculatedNormal ).rgb;

      float rim = 1.75 * max( 0., abs( dot( normalize( vNormal ), normalize( -vOPosition.xyz ) ) ) );
      base += useSSS * color * ( 1. - .75 * rim );
      base += ( 1. - useSSS ) * 10. * base * color * clamp( 1. - rim, 0., .15 );

      if( useScreen == 1. ) {
        base = vec3( 1. ) - ( vec3( 1. ) - base ) * ( vec3( 1. ) - base );
      }

      float nn = .05 * random( vec3( 1. ), length( gl_FragCoord ) );
      base += vec3( nn );

      gl_FragColor = vec4( base.rgb, 1. );
    }`,
  attributes: {
    position: regl.prop('positions'),
    normal: (context, props) => normals(props.cells, props.positions)
  },
  uniforms: {
    color: [36 / 255.0, 70 / 255.0, 106 / 255.0],
    sphereColor: [36 / 255.0, 70 / 255.0, 106 / 255.0],
    normalScale: 1,
    texScale: 10,
    useSSS: 0,
    useScreen: 1,
    normalMatrix: (context) => {
      let a = mat3.create()
      mat3.normalFromMat4(a, context.view)
      return a
    },
    textureMap: regl.prop('textureMap'),
    normalMap: regl.prop('normalMap')
  },
  elements: regl.prop('cells')
})

const metaball = (px, py, pz, strength, subtract) => {
  return (x, y, z) => {
    return (strength / (Math.pow(x - px, 2) + Math.pow(y - py, 2) + Math.pow(z - pz, 2))) - subtract
  }
}

const numblobs = 20
const strength = 1.2 / ((Math.sqrt(numblobs) - 1) / 4 + 1)
const subtract = 12
const balls = Array(numblobs).fill().map((_, i) => {
  return (time) => {
    let ballx = Math.sin(i + 1.26 * time * (1.03 + 0.5 * Math.cos(0.21 * i))) * 0.27 + 0.5
    let bally = Math.cos(i + 1.12 * time * 0.21 * Math.sin((0.72 + 0.83 * i))) * 0.27 + 0.5
    let ballz = Math.cos(i + 1.32 * time * 0.1 * Math.sin((0.92 + 0.53 * i))) * 0.27 + 0.5
    return metaball(ballx, bally, ballz, strength, subtract)
  }
})

require('resl')({
  manifest: {
    sphereTexture: {
      type: 'image',
      src: 'spheretexture.jpg',
      parser: (data) => regl.texture({
        data: data,
        wrapT: 'clamp',
        wrapS: 'clamp'
      })
    },
    normalTexture: {
      type: 'image',
      src: 'normaltexture.jpg',
      parser: (data) => regl.texture({
        data: data,
        wrapT: 'repeat',
        wrapS: 'repeat'
      })
    }
  },
  onDone: ({sphereTexture, normalTexture}) => {
    let field = (x, y, z) => {
      return balls.map((b) => b(1)(x, y, z)).reduce((a, b) => a + b)
    }
    let mesh = isosurface.surfaceNets([50, 50, 50], field, [[0, 0, 0], [1, 1, 1]])

    regl.frame(({tick}) => {
      // let time = 0.05 * tick
      // let field = (x,y,z) => {
      //   return balls.map((b) => b(time)(x,y,z)).reduce((a, b) => a + b)
      // }
      // let mesh = isosurface.surfaceNets([50,50,50], field, [[0,0,0], [1, 1, 1]])
      camera(() => {
        drawMetaballs({
          positions: mesh.positions,
          cells: mesh.cells,
          textureMap: sphereTexture,
          normalMap: normalTexture
        })
      })
    })
  }
})
<|endoftext|>


<commit_before>/**
 * Created by apple on 2017/7/19.
 */
import React, { Component } from 'react';
import { Menu, Icon } from 'antd';
import styles from './RightMenuList.css';

const SubMenu = Menu.SubMenu;

class RightMenuList extends Component {
  state = {
    current: '1',
    openKeys: [],
  }

  /**
   * modified by wsw, add selectMode Param(sunMenu Index)
   * @param e which is selected
   */
  handleClick = (e) => {
    // alert("hello" + e.key);
    if (e.key === '1') {
      this.props.selectMode(1, 1);
    } else if (e.key === '2') {
      this.props.selectMode(1, 2);
    } else if (e.key === '3') {
      this.props.selectMode(2, 1);
    } else if (e.key === '4') {
      this.props.selectMode(2, 2);
    } else if (e.key === '5') {
      this.props.selectMode(3, 1);
    }
    console.log('Hello Clicked: ', e);
    this.setState({ current: e.key });
  }
  onOpenChange = (openKeys) => {
    const state = this.state;
    const latestOpenKey = openKeys.find(key => !(state.openKeys.indexOf(key) > -1));
    const latestCloseKey = state.openKeys.find(key => !(openKeys.indexOf(key) > -1));

    let nextOpenKeys = [];
    if (latestOpenKey) {
      nextOpenKeys = this.getAncestorKeys(latestOpenKey).concat(latestOpenKey);
    }
    if (latestCloseKey) {
      nextOpenKeys = this.getAncestorKeys(latestCloseKey);
    }
    this.setState({ openKeys: nextOpenKeys });
  }
  getAncestorKeys = (key) => {
    const map = {
      sub3: ['sub2'],
    };
    return map[key] || [];
  }

  render() {
    return (

        <Menu
          theme="dark"
          mode="inline"
          selectedKeys={[this.state.current]}
          style={{ width: 'auto', background: '#1e1e1e' }}
          onOpenChange={this.onOpenChange}
          onClick={this.handleClick}
          inlineIndent="10"
        >
          <SubMenu key="sub1" title={<Icon type="mail" />Resolution}>
            <Menu.Item key="1">Single Super</Menu.Item>
            <Menu.Item key="2">Multiple Super</Menu.Item>
          </SubMenu>
          <SubMenu
            key="sub2"
            title={<Icon type="appstore" />FocusDepth    }
          >
            <Menu.Item key="3">Normal</Menu.Item>
            <Menu.Item key="4">For Expert</Menu.Item>
          </SubMenu>
          <SubMenu key="sub3" title={<Icon type="setting" />Stylize }>
            <Menu.Item key="5">Stylize Export</Menu.Item>
          </SubMenu>
        </Menu>

    );
  }
}

export default RightMenuList;
RightMenuList.propTypes = {
  selectMode: React.PropTypes.func.isRequired,
};
<commit_msg>fix<components>: fix right menu list<commit_after>/**
 * Created by apple on 2017/7/19.
 */
import React, { Component } from 'react';
import { Menu, Icon } from 'antd';
import styles from './RightMenuList.css';

const SubMenu = Menu.SubMenu;

class RightMenuList extends Component {
  state = {
    current: '1',
    openKeys: [],
  }

  /**
   * modified by wsw, add selectMode Param(sunMenu Index)
   * @param e which is selected
   */
  handleClick = (e) => {
    // alert("hello" + e.key);
    if (e.key === '1') {
      this.props.selectMode(1, 1);
    } else if (e.key === '2') {
      this.props.selectMode(1, 2);
    } else if (e.key === '3') {
      this.props.selectMode(2, 1);
    } else if (e.key === '4') {
      this.props.selectMode(2, 2);
    } else if (e.key === '5') {
      this.props.selectMode(3, 1);
    }
    console.log('Hello Clicked: ', e);
    this.setState({ current: e.key });
  }
  onOpenChange = (openKeys) => {
    const state = this.state;
    const latestOpenKey = openKeys.find(key => !(state.openKeys.indexOf(key) > -1));
    const latestCloseKey = state.openKeys.find(key => !(openKeys.indexOf(key) > -1));

    let nextOpenKeys = [];
    if (latestOpenKey) {
      nextOpenKeys = this.getAncestorKeys(latestOpenKey).concat(latestOpenKey);
    }
    if (latestCloseKey) {
      nextOpenKeys = this.getAncestorKeys(latestCloseKey);
    }
    this.setState({ openKeys: nextOpenKeys });
  }
  getAncestorKeys = (key) => {
    const map = {
      sub3: ['sub2'],
    };
    return map[key] || [];
  }

  render() {
    return (

        <Menu
          theme="dark"
          mode="inline"
          selectedKeys={[this.state.current]}
          style={{ width: 'auto', background: '#1e1e1e' }}
          onOpenChange={this.onOpenChange}
          onClick={this.handleClick}
          inlineIndent="10"
        >
          <SubMenu key="sub1" title={<Icon type="mail" />Resolution}>
            <Menu.Item key="1">Single Super</Menu.Item>
            <Menu.Item key="2">Multiple Super</Menu.Item>
          </SubMenu>
          <SubMenu
            key="sub2"
            title={<Icon type="appstore" />FocusDepth    }
          >
            <Menu.Item key="3">For Expert</Menu.Item>
          </SubMenu>
        </Menu>

    );
  }
}

export default RightMenuList;
RightMenuList.propTypes = {
  selectMode: React.PropTypes.func.isRequired,
};
<|endoftext|>