<commit_before>/* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';

var path = require('path');
var webpack = require('webpack');

var babelOptions = {
  "presets": [
    "react",
    [
      "es2015",
      {
        "modules": false
      }
    ],
    "es2016"
  ]
};

module.exports = {
  cache: true,
  entry: {
    main: './src/main.tsx',
    vendor: [
      'babel-polyfill',
      'jquery',
      'moment',
      'fbemitter',
      'flux',
      'react',
      'react-dom',
      'react-bootstrap',
      'react-router',
      'react-router-bootstrap',
      'toastr'
    ]
  },
  output: {
    path: path.resolve(__dirname, './dist/scripts'),
    filename: '[name].js',
    chunkFilename: '[chunkhash].js'
  },
  module: {
    rules: [{
      test: /\.ts(x?)$/,
      exclude: /node_modules/,
      use: [
        {
          loader: 'babel-loader',
          options: babelOptions
        },
        {
          loader: 'ts-loader'
        }
      ]
    }, {
      test: /\.js$/,
      exclude: /node_modules/,
      use: [
        {
          loader: 'babel-loader',
          options: babelOptions
        }
      ]
    }]
  },
  plugins: [ // Check gulp/webpack.js for build specific plugins
      new webpack.ProvidePlugin({
          "window.jQuery": "jquery",
          "jQuery": "jquery",
          "$": "jquery"
      })
  ],
  resolve: {
    // Add `.ts` and `.tsx` as a resolvable extension.
    extensions: ['.ts', '.tsx', '.js']
  },
};
<commit_msg>i reall like john lennon<commit_after>/* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';

var path = require('path');
var webpack = require('webpack');

var babelOptions = {
  "presets": [
    "react",
    [
      "es2015",
      {
        "modules": false
      }
    ],
    "es2016"
  ]
};

module.exports = {
  cache: true,
  entry: {
    main: './src/main.tsx',
    vendor: ['babel-polyfill'].concat(vendorDependencies).filter(function (dependency) {
       return dependency !== 'bootstrap' && dependency !== 'font-awesome';
    })
  },
  output: {
    path: path.resolve(__dirname, './dist/scripts'),
    filename: '[name].js',
    chunkFilename: '[chunkhash].js'
  },
  module: {
    rules: [{
      test: /\.ts(x?)$/,
      exclude: /node_modules/,
      use: [
        {
          loader: 'babel-loader',
          options: babelOptions
        },
        {
          loader: 'ts-loader'
        }
      ]
    }, {
      test: /\.js$/,
      exclude: /node_modules/,
      use: [
        {
          loader: 'babel-loader',
          options: babelOptions
        }
      ]
    }]
  },
  plugins: [ // Check gulp/webpack.js for build specific plugins
      new webpack.ProvidePlugin({
          "window.jQuery": "jquery",
          "jQuery": "jquery",
          "$": "jquery"
      })
  ],
  resolve: {
    // Add `.ts` and `.tsx` as a resolvable extension.
    extensions: ['.ts', '.tsx', '.js']
  },
};
<|endoftext|>


<commit_before>/*
 ***** 已使用的子域名
 * ***********************
 *
 * 目前以下子域名已经启用
 * 提交一个 PR， 添加你想使用的的域名
 *
 *
 **** 说明
 * ***********
 *
 * KEY:         你提交的域名（如：`foo` 表示自定义子域名为 `foo.js.cool`）
 *
 * VALUE:       以 Github 为例，`foo.github.io` 表示用户/组织的主页，
 *              或 `foo.github.io/bar` 表示项目主页，也可以绑定 Gitee、 CODING.NET 等其它开源托管服务商。
 *
 * CLOUDFLARE:  目前 JS.COOL 使用的 DNS 服务商为 CloudFlare。默认情况下代理状态为自动（支持 SSL），
 *              通过 HTTPS 链接（如： https://foo.js.cool ）进行访问。
 *              但如果你不希望通过 CloudFlare 加速，可以选择 `仅限 DNS` 选项，
 *              只需要在你提交的代码后面添加 `// noCF` 注释即可。
 */
module.exports = {
  // 请在此处区域内添加自定义域名
  "color-ui": "colorui-kit.github.io",
  "icns": "icnskit.github.io",
  "j2me_games": "waifu-project.github.io",
  'cnchar': 'theajack.github.io',
  'leader': 'willin.github.io',
  'codewars': 'js-cool.github.io',
  'dataloader': 'shiwangme.github.io',
  'hyperapp': 'willin.github.io',
  'anime': 'js-cool.github.io',
  'learn': 'hosting.gitbook.com',
  'vchart': 'willin.github.io',
  'graphql': 'willin.github.io',
  'speech': 'willin.github.io',
  'blockchain': 'willin.github.io',
  'antiadblock': 'js-cool.github.io',
  'noho': 'willin.github.io',
  'jen': 'dirkhe1051931999.github.io',
  'uiw': 'uiwjs.github.io',
  'xrkffgg': 'xrkffgg.github.io',
  'interview': 'front-end-interview.netlify.app',
  'xiaomeiwu':'xiaomeiwu.github.io/vue-admin',
  'ip': 'ipip.vercel.app', // noCF
  'mingyan': 'lehs8n.coding-pages.com', //noCf
  'na': 'qq.mcust.cn',
  'rx': 'willin.github.io',
  'bbx': 'appser.gitee.io',
  'mengd': 'cname.vercel-dns.com',
  'kali': '551kdx.coding-pages.com',
  'zwt': 'zwtdyhm.github.io',
  'zwtdwz': 'zwtdzh.github.io',
  'zwtdwlzd': 'zwtdwlid.github.io',
  'histcat': 'jessejeson.github.io',
  'wangdabao-resume': 'wangdabaoqq.github.io/resume-new',
  'wangdabao': 'wangdabaoqq.github.io/hexo',
  // 请在此行之上新增一行并提交 Pull Request
  // 示例：
  // 'youarname': 'username.github.io' // noCF
  // 以下为已启用的保留域名，请勿修改
  '@': 'js-cool.github.io',
  'www': 'kv6xcc.coding-pages.com', // 国内镜像
  'logo': 'js-cool.github.io'
};
<commit_msg>Update active_cname.js (#45)<commit_after>/*
 ***** 已使用的子域名
 * ***********************
 *
 * 目前以下子域名已经启用
 * 提交一个 PR， 添加你想使用的的域名
 *
 *
 **** 说明
 * ***********
 *
 * KEY:         你提交的域名（如：`foo` 表示自定义子域名为 `foo.js.cool`）
 *
 * VALUE:       以 Github 为例，`foo.github.io` 表示用户/组织的主页，
 *              或 `foo.github.io/bar` 表示项目主页，也可以绑定 Gitee、 CODING.NET 等其它开源托管服务商。
 *
 * CLOUDFLARE:  目前 JS.COOL 使用的 DNS 服务商为 CloudFlare。默认情况下代理状态为自动（支持 SSL），
 *              通过 HTTPS 链接（如： https://foo.js.cool ）进行访问。
 *              但如果你不希望通过 CloudFlare 加速，可以选择 `仅限 DNS` 选项，
 *              只需要在你提交的代码后面添加 `// noCF` 注释即可。
 */
module.exports = {
  // 请在此处区域内添加自定义域名
  "color-ui": "colorui-kit.github.io",
  "icns": "icnskit.github.io",
  "j2me_games": "waifu-project.github.io",
  'cnchar': 'theajack.github.io',
  'leader': 'willin.github.io',
  'codewars': 'js-cool.github.io',
  'dataloader': 'shiwangme.github.io',
  'hyperapp': 'willin.github.io',
  'anime': 'js-cool.github.io',
  'learn': 'hosting.gitbook.com',
  'vchart': 'willin.github.io',
  'graphql': 'willin.github.io',
  'speech': 'willin.github.io',
  'blockchain': 'willin.github.io',
  'antiadblock': 'js-cool.github.io',
  'noho': 'willin.github.io',
  'jen': 'dirkhe1051931999.github.io',
  'uiw': 'uiwjs.github.io',
  'xrkffgg': 'xrkffgg.github.io',
  'interview': 'front-end-interview.netlify.app',
  'xiaomeiwu':'xiaomeiwu.github.io/vue-admin',
  'ip': 'ipip.vercel.app', // noCF
  'mingyan': 'lehs8n.coding-pages.com', //noCf
  'na': 'qq.mcust.cn',
  'rx': 'willin.github.io',
  'bbx': 'appser.gitee.io',
  'mengd': 'cname.vercel-dns.com',
  'kali': '551kdx.coding-pages.com',
  'zwt': 'zwtdyhm.github.io',
  'zwtdwz': 'zwtdzh.github.io',
  'zwtdwlzd': 'zwtdwlid.github.io',
  'histcat': 'jessejeson.github.io',
  'wangdabao-resume': 'wangdabaoqq.github.io/resume-new',
  'wangdabao': 'wangdabaoqq.github.io/hexo',
  'zwtdwzym': 'zwtduserid.github.io',
  // 请在此行之上新增一行并提交 Pull Request
  // 示例：
  // 'youarname': 'username.github.io' // noCF
  // 以下为已启用的保留域名，请勿修改
  '@': 'js-cool.github.io',
  'www': 'kv6xcc.coding-pages.com', // 国内镜像
  'logo': 'js-cool.github.io'
};
<|endoftext|>


<commit_before>const webpack = require('webpack');
const path = require('path');

module.exports = {
  entry: {
    'code-de': ['babel-polyfill', './src/preload.js', './src/main.js'],
  },
  resolve: {
    // mainFields: ['module', 'main'],
    modulesDirectories: ['web_modules', 'node_modules', 'bower_components'],
    // packageMains: ['webpack', 'web', 'browserify', ['jam', 'main'], 'main'],
    alias: {
      // necessary to avoid multiple packings of backbone due to marionette
      backbone: path.join(__dirname, 'node_modules', 'backbone', 'backbone'),
      handlebars: 'handlebars/dist/handlebars.min.js',
      'opensearch-browser': 'opensearch-browser/dist',

      // Bind version of jquery
      //jquery: path.join(__dirname, 'node_modules', 'jquery'),

      // Bind version of jquery-ui
      //'jquery-ui': path.join(__dirname, 'node_modules', 'jquery-ui'),

      // jquery-ui doesn't contain a index file
      // bind module to the complete module
    },
  },
  resolveLoader: {
    root: path.join(__dirname, 'node_modules'),
  },
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].bundle.js',
    library: 'code-de',
    libraryTarget: 'umd',
  },
  devServer: {
    host: '0.0.0.0',
    inline: true
  },
  module: {
    loaders: [
      { test: /node_modules.*eoxc.*js$/, loader: 'babel-loader' },
      { test: /node_modules.*opensearch.*js$/, loader: 'babel-loader' },
      { test: /node_modules.*ol.*js$/, loader: 'babel-loader' },
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
      { test: /\.json$/, loader: 'json-loader' },
      { test: /\.coffee$/, loader: 'coffee-loader' },
      { test: /\.litcoffee$/, loader: 'coffee-loader?literate' },
      { test: /\.css$/, loaders: ['style', 'css', 'postcss'] },
      { test: /\.less$/, loaders: ['style', 'css', 'postcss', 'less'] },
      { test: /\.scss$/, loaders: ['style', 'css', 'postcss', 'sass'] },
      { test: /\.hbs$/, loader: 'handlebars-loader?helperDirs[]=' + __dirname + '/src/helpers' },

      // for anything that might be included in a css
      { test: /\.(png|woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=4000000' },
    ],
  },
  plugins: [
    new webpack.ResolverPlugin(
        new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin('.bower.json', ['main'])
    ),
    new webpack.optimize.DedupePlugin(),
    new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery',
      'window.jQuery': 'jquery',
    }),
  ],
  postcss() {
    return [
      require('autoprefixer'),
    ];
  },
  cache: true,
};
<commit_msg>Adding flag to help debugging with VMs.<commit_after>const webpack = require('webpack');
const path = require('path');

module.exports = {
  entry: {
    'code-de': ['babel-polyfill', './src/preload.js', './src/main.js'],
  },
  resolve: {
    // mainFields: ['module', 'main'],
    modulesDirectories: ['web_modules', 'node_modules', 'bower_components'],
    // packageMains: ['webpack', 'web', 'browserify', ['jam', 'main'], 'main'],
    alias: {
      // necessary to avoid multiple packings of backbone due to marionette
      backbone: path.join(__dirname, 'node_modules', 'backbone', 'backbone'),
      handlebars: 'handlebars/dist/handlebars.min.js',
      'opensearch-browser': 'opensearch-browser/dist',

      // Bind version of jquery
      //jquery: path.join(__dirname, 'node_modules', 'jquery'),

      // Bind version of jquery-ui
      //'jquery-ui': path.join(__dirname, 'node_modules', 'jquery-ui'),

      // jquery-ui doesn't contain a index file
      // bind module to the complete module
    },
  },
  resolveLoader: {
    root: path.join(__dirname, 'node_modules'),
  },
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].bundle.js',
    library: 'code-de',
    libraryTarget: 'umd',
  },
  devServer: {
    host: '0.0.0.0',
    inline: true,
    disableHostCheck: true,
  },
  module: {
    loaders: [
      { test: /node_modules.*eoxc.*js$/, loader: 'babel-loader' },
      { test: /node_modules.*opensearch.*js$/, loader: 'babel-loader' },
      { test: /node_modules.*ol.*js$/, loader: 'babel-loader' },
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
      { test: /\.json$/, loader: 'json-loader' },
      { test: /\.coffee$/, loader: 'coffee-loader' },
      { test: /\.litcoffee$/, loader: 'coffee-loader?literate' },
      { test: /\.css$/, loaders: ['style', 'css', 'postcss'] },
      { test: /\.less$/, loaders: ['style', 'css', 'postcss', 'less'] },
      { test: /\.scss$/, loaders: ['style', 'css', 'postcss', 'sass'] },
      { test: /\.hbs$/, loader: 'handlebars-loader?helperDirs[]=' + __dirname + '/src/helpers' },

      // for anything that might be included in a css
      { test: /\.(png|woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=4000000' },
    ],
  },
  plugins: [
    new webpack.ResolverPlugin(
        new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin('.bower.json', ['main'])
    ),
    new webpack.optimize.DedupePlugin(),
    new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery',
      'window.jQuery': 'jquery',
    }),
  ],
  postcss() {
    return [
      require('autoprefixer'),
    ];
  },
  cache: true,
};
<|endoftext|>


<commit_before>/*
 ***** 已使用的子域名
 * ***********************
 *
 * 目前以下子域名已经启用
 * 提交一个 PR， 添加你想使用的的域名
 *
 *
 **** 说明
 * ***********
 *
 * KEY:         你提交的域名（如：`foo` 表示自定义子域名为 `foo.js.cool`）
 *
 * VALUE:       以 Github 为例，`foo.github.io` 表示用户/组织的主页，
 *              或 `foo.github.io/bar` 表示项目主页，也可以绑定 Gitee、 CODING.NET 等其它开源托管服务商。
 *
 * CLOUDFLARE:  目前 JS.COOL 使用的 DNS 服务商为 CloudFlare。默认情况下代理状态为自动（支持 SSL），
 *              通过 HTTPS 链接（如： https://foo.js.cool ）进行访问。
 *              但如果你不希望通过 CloudFlare 加速，可以选择 `仅限 DNS` 选项，
 *              只需要在你提交的代码后面添加 `// noCF` 注释即可。
 */
module.exports = {
  // 请在此处区域内添加自定义域名
  'cnchar': 'theajack.github.io',
  'leader': 'willin.github.io',
  'codewars': 'js-cool.github.io',
  'dataloader': 'shiwangme.github.io',
  'hyperapp': 'willin.github.io',
  'anime': 'js-cool.github.io',
  'learn': 'hosting.gitbook.com',
  'vchart': 'willin.github.io',
  'graphql': 'willin.github.io',
  'speech': 'willin.github.io',
  'antiadblock': 'js-cool.github.io',
  'noho': 'willin.github.io',
  'jen': 'dirkhe1051931999.github.io',
  'uiw': 'uiwjs.github.io',
  'xrkffgg': 'xrkffgg.github.io',
  'interview': 'front-end-interview.netlify.app',
  'xiaomeiwu':'xiaomeiwu.github.io/vue-admin',
  'ip': 'ipip.vercel.app', // noCF
  'mingyan': 'lehs8n.coding-pages.com', //noCf
  'na':'qq.mcust.cn',
  'bbx': 'appser.gitee.io',
  'mengd': 'cname.vercel-dns.com',
  'kali': 'kali65536.gitee.io', // noCF
  // 请在此行之上新增一行并提交 Pull Request
  // 示例：
  // 'youarname': 'username.github.io' // noCF
  // 以下为已启用的保留域名，请勿修改
  '@': 'js-cool.github.io',
  'www': 'kv6xcc.coding-pages.com', // 国内镜像
  'logo': 'js-cool.github.io'
};
<commit_msg>Update active_cname.js (#23)<commit_after>/*
 ***** 已使用的子域名
 * ***********************
 *
 * 目前以下子域名已经启用
 * 提交一个 PR， 添加你想使用的的域名
 *
 *
 **** 说明
 * ***********
 *
 * KEY:         你提交的域名（如：`foo` 表示自定义子域名为 `foo.js.cool`）
 *
 * VALUE:       以 Github 为例，`foo.github.io` 表示用户/组织的主页，
 *              或 `foo.github.io/bar` 表示项目主页，也可以绑定 Gitee、 CODING.NET 等其它开源托管服务商。
 *
 * CLOUDFLARE:  目前 JS.COOL 使用的 DNS 服务商为 CloudFlare。默认情况下代理状态为自动（支持 SSL），
 *              通过 HTTPS 链接（如： https://foo.js.cool ）进行访问。
 *              但如果你不希望通过 CloudFlare 加速，可以选择 `仅限 DNS` 选项，
 *              只需要在你提交的代码后面添加 `// noCF` 注释即可。
 */
module.exports = {
  // 请在此处区域内添加自定义域名
  'cnchar': 'theajack.github.io',
  'leader': 'willin.github.io',
  'codewars': 'js-cool.github.io',
  'dataloader': 'shiwangme.github.io',
  'hyperapp': 'willin.github.io',
  'anime': 'js-cool.github.io',
  'learn': 'hosting.gitbook.com',
  'vchart': 'willin.github.io',
  'graphql': 'willin.github.io',
  'speech': 'willin.github.io',
  'antiadblock': 'js-cool.github.io',
  'noho': 'willin.github.io',
  'jen': 'dirkhe1051931999.github.io',
  'uiw': 'uiwjs.github.io',
  'xrkffgg': 'xrkffgg.github.io',
  'interview': 'front-end-interview.netlify.app',
  'xiaomeiwu':'xiaomeiwu.github.io/vue-admin',
  'ip': 'ipip.vercel.app', // noCF
  'mingyan': 'lehs8n.coding-pages.com', //noCf
  'na':'qq.mcust.cn',
  'bbx': 'appser.gitee.io',
  'mengd': 'cname.vercel-dns.com',
  'kali': '551kdx.coding-pages.com',
  // 请在此行之上新增一行并提交 Pull Request
  // 示例：
  // 'youarname': 'username.github.io' // noCF
  // 以下为已启用的保留域名，请勿修改
  '@': 'js-cool.github.io',
  'www': 'kv6xcc.coding-pages.com', // 国内镜像
  'logo': 'js-cool.github.io'
};
<|endoftext|>


<commit_before>module.exports = {
  env: {
    'browser': true,
    'commonjs': true,
    'node': true,
  },
  extends: 'eslint:recommended',
  rules: {
  	'comma-dangle': 'off',
    'no-console': 'off',
    'no-constant-condition': 'off',
    'no-redeclare': 'off',
    'no-unused-vars': 'off',

    'array-bracket-spacing': 'error',
    'block-spacing': 'error',
    'brace-style': 'error',
    'comma-spacing': 'error',
    'comma-style': 'error',
    'eol-last': 'error',
    'indent': ['error', 2],
  },
};
<commit_msg>ESLint: Enable "key-spacing" rule<commit_after>module.exports = {
  env: {
    'browser': true,
    'commonjs': true,
    'node': true,
  },
  extends: 'eslint:recommended',
  rules: {
  	'comma-dangle': 'off',
    'no-console': 'off',
    'no-constant-condition': 'off',
    'no-redeclare': 'off',
    'no-unused-vars': 'off',

    'array-bracket-spacing': 'error',
    'block-spacing': 'error',
    'brace-style': 'error',
    'comma-spacing': 'error',
    'comma-style': 'error',
    'eol-last': 'error',
    'indent': ['error', 2],
    'key-spacing': 'error',
  },
};
<|endoftext|>


<commit_before>//Globals
var map;

require([
  "esri/map",
  "esri/dijit/Search",
  "esri/layers/ArcGISTiledMapServiceLayer",
  "esri/symbols/SimpleMarkerSymbol",
  "esri/graphic",
  "dojo",
  "dojo/domReady!"
 ],

function (
  mapDiv
){

  /* Map */
  map = mapDiv ("map", {
    center: [-93.5, 46.5],
    zoom: 6,
    attributionWidth: 0.15,
    logo: false
  });

  /* Search */
   var search = esri.dijit.Search({
     map: map
   }, "search");
   search.startup();

  /* Add Aerial Reference Tile Services */
  var aerialReference = esri.layers.ArcGISTiledMapServiceLayer("//services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer");
  var aerial = esri.layers.ArcGISTiledMapServiceLayer("//services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
  map.addLayers([aerial, aerialReference]);

  //TODO: Move this outside the Esri JS Loop BS
  var latLngGraphic = esri.symbol.SimpleMarkerSymbol({
    "color": [255,0,0,100],
    "size": 8,
    "type": "esriSMS",
    "style": "esriSMSCircle",
    "outline": {
      "color": [255,0,0,255],
      "width": 1
    }
  });

  map.on("load", function() {
    map.on("click", showCoordinates);
    map.infoWindow.resize(200,100);
    //TODO: Move this outside the Esri JS Loop BS
    map.on("click", function(mapClick) {
      map.graphics.clear();
      map.graphics.add(esri.Graphic(mapClick.mapPoint, latLngGraphic));
    })
  });

});

function showCoordinates(event) {
  var latitude = event.mapPoint.getLatitude();
  var longitude = event.mapPoint.getLongitude();
  map.infoWindow.setTitle("Coordinates");
  map.infoWindow.setContent(
    "Latitude: " + latitude.toFixed(4) +
    "
Longitude: " + longitude.toFixed(4) +
    "
<a href='mailto:?subject=Latitude/Longitude&body=Latitude: " + latitude.toFixed(4) + " %0D%0ALongitude: " + longitude.toFixed(4) + "'" +
    "

E-mail Coordinates"
  );
  map.infoWindow.show(event.mapPoint, map.getInfoWindowAnchor(event.screenPoint));
}
<commit_msg>Add Anne's email address<commit_after>//Globals
var map;

require([
  "esri/map",
  "esri/dijit/Search",
  "esri/layers/ArcGISTiledMapServiceLayer",
  "esri/symbols/SimpleMarkerSymbol",
  "esri/graphic",
  "dojo",
  "dojo/domReady!"
 ],

function (
  mapDiv
){

  /* Map */
  map = mapDiv ("map", {
    center: [-93.5, 46.5],
    zoom: 6,
    attributionWidth: 0.15,
    logo: false
  });

  /* Search */
   var search = esri.dijit.Search({
     map: map
   }, "search");
   search.startup();

  /* Add Aerial Reference Tile Services */
  var aerialReference = esri.layers.ArcGISTiledMapServiceLayer("//services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer");
  var aerial = esri.layers.ArcGISTiledMapServiceLayer("//services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
  map.addLayers([aerial, aerialReference]);

  //TODO: Move this outside the Esri JS Loop BS
  var latLngGraphic = esri.symbol.SimpleMarkerSymbol({
    "color": [255,0,0,100],
    "size": 8,
    "type": "esriSMS",
    "style": "esriSMSCircle",
    "outline": {
      "color": [255,0,0,255],
      "width": 1
    }
  });

  map.on("load", function() {
    map.on("click", showCoordinates);
    map.infoWindow.resize(200,100);
    //TODO: Move this outside the Esri JS Loop BS
    map.on("click", function(mapClick) {
      map.graphics.clear();
      map.graphics.add(esri.Graphic(mapClick.mapPoint, latLngGraphic));
    })
  });

});

function showCoordinates(event) {
  var latitude = event.mapPoint.getLatitude();
  var longitude = event.mapPoint.getLongitude();
  map.infoWindow.setTitle("Coordinates");
  map.infoWindow.setContent(
    "Latitude: " + latitude.toFixed(4) +
    "
Longitude: " + longitude.toFixed(4) +
    "
<a href='mailto:anne.morris@state.mn.us?subject=Latitude/Longitude&body=Latitude: " + latitude.toFixed(4) + " %0D%0ALongitude: " + longitude.toFixed(4) + "'" +
    "

E-mail Coordinates"
  );
  map.infoWindow.show(event.mapPoint, map.getInfoWindowAnchor(event.screenPoint));
}
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var routes = require('./server/routes.json');
var buildEnv = require('./src/environment.js');

// Prepare all entry points
var entry = {
    session: './src/session.js',
    main: './src/main.jsx'
};
routes.forEach(function (route) {
    if ( ! route.static ) {
        entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
    }
});

// Config
module.exports = {
    entry: entry,
    devtool: 'source-map',
    externals: {
        'react': 'React',
        'react/addons': 'React'
    },
    output: {
        path: path.resolve(__dirname, 'build/js'),
        filename: '[name].bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.jsx$/,
                loader: 'jsx-loader',
                include: path.resolve(__dirname, 'src')
            },
            {
                test: /\.json$/,
                loader: 'json-loader',
                include: path.resolve(__dirname, 'src')
            },
            {
                test: /\.scss$/,
                loader: 'style!css!autoprefixer-loader?browsers=last 3 versions!sass'
            },
            {
                test: /\.(png|jpg|gif|eot|svg|ttf|woff)$/,
                loader: 'url-loader'
            }
        ]
    },
    node: {
        fs: 'empty'
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env': buildEnv
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        }),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.DedupePlugin()
    ]
};
<commit_msg>Minor clean-up of environment var name in webpack config<commit_after>var path = require('path');
var webpack = require('webpack');

var environment = require('./src/environment.js');
var routes = require('./server/routes.json');

// Prepare all entry points
var entry = {
    session: './src/session.js',
    main: './src/main.jsx'
};
routes.forEach(function (route) {
    if ( ! route.static ) {
        entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
    }
});

// Config
module.exports = {
    entry: entry,
    devtool: 'source-map',
    externals: {
        'react': 'React',
        'react/addons': 'React'
    },
    output: {
        path: path.resolve(__dirname, 'build/js'),
        filename: '[name].bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.jsx$/,
                loader: 'jsx-loader',
                include: path.resolve(__dirname, 'src')
            },
            {
                test: /\.json$/,
                loader: 'json-loader',
                include: path.resolve(__dirname, 'src')
            },
            {
                test: /\.scss$/,
                loader: 'style!css!autoprefixer-loader?browsers=last 3 versions!sass'
            },
            {
                test: /\.(png|jpg|gif|eot|svg|ttf|woff)$/,
                loader: 'url-loader'
            }
        ]
    },
    node: {
        fs: 'empty'
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env': environment
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        }),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.DedupePlugin()
    ]
};
<|endoftext|>


<commit_before>var scores = null;
var serverUrlBase = 'https://iidx12.tk';
var login = false;
var user = {}
var timeout = 100
$.ajaxSetup({ xhrFields: { withCredentials: true } });

// TODO: konamiのメンテナンス時間とログインしていない場合の対応
// TODO: konamiにログインしていない場合の対応

function getUserInfo() {
  $.ajax({
    type: 'get',
    url: 'http://p.eagate.573.jp/game/2dx/24/p/djdata/status.html',
    async: false,
    success: function(data) {
      canvas = document.createElement('canvas');
      qpros = $(data).find('img').filter(function(index, element) {
        return element.attributes.src.value.includes('img_qpro.html') }
      );
      qpro = qpros[0];
      canvas.width = qpro.width;
      canvas.height = qpro.height;

      ctx = canvas.getContext('2d');
      ctx.drawImage(qpro, 0, 0);
      setTimeout(function() { user.image = canvas.toDataURL('image/png'); }, timeout);
      user.djname = $($(data).find('table#dj_data_table > tbody > tr')[0]).find('td').text();
      user.grade = $($(data).find('td.point')[5]).text();
    },
  });
}

function checkStatus() {
  $.ajax({
    type: 'get',
    url: serverUrlBase + '/api/v1/users/status',
    async: false,
    dataType: 'json',
    success: function(data) { login = data.status ? true : false; }
  });
}

function getCsv() {
  $.ajax({
    type: 'post',
    url: 'http://p.eagate.573.jp/game/2dx/24/p/djdata/score_download.html',
    async: false,
    data: { style: 0 },
    success: function(data) { scores = $(data).find('#score_data').text() }
  });
}

function putData() {
  $.ajax({
    type: 'post',
    url: serverUrlBase + '/api/v1/scores/sync/official',
    contentType: 'application/json',
    data: JSON.stringify({ scores: scores, user: user }),
    success: function(data) { alert('success'); },
    error: function(response) { alert(response.statusText); }
  });
}

checkStatus();
if (login) {
  getUserInfo();
  getCsv();
  setTimeout(putData, timeout);
} else {
  alert('please login: https://iidx12.tk');
}
<commit_msg>change schema<commit_after>var scores = null;
var serverUrlBase = 'https://iidx12.tk';
var login = false;
var user = {}
var timeout = 100
$.ajaxSetup({ xhrFields: { withCredentials: true } });

// TODO: konamiのメンテナンス時間とログインしていない場合の対応
// TODO: konamiにログインしていない場合の対応

function getUserInfo() {
  $.ajax({
    type: 'get',
    url: 'https://p.eagate.573.jp/game/2dx/24/p/djdata/status.html',
    async: false,
    success: function(data) {
      canvas = document.createElement('canvas');
      qpros = $(data).find('img').filter(function(index, element) {
        return element.attributes.src.value.includes('img_qpro.html') }
      );
      qpro = qpros[0];
      canvas.width = qpro.width;
      canvas.height = qpro.height;

      ctx = canvas.getContext('2d');
      ctx.drawImage(qpro, 0, 0);
      setTimeout(function() { user.image = canvas.toDataURL('image/png'); }, timeout);
      user.djname = $($(data).find('table#dj_data_table > tbody > tr')[0]).find('td').text();
      user.grade = $($(data).find('td.point')[5]).text();
    },
  });
}

function checkStatus() {
  $.ajax({
    type: 'get',
    url: serverUrlBase + '/api/v1/users/status',
    async: false,
    dataType: 'json',
    success: function(data) { login = data.status ? true : false; }
  });
}

function getCsv() {
  $.ajax({
    type: 'post',
    url: 'https://p.eagate.573.jp/game/2dx/24/p/djdata/score_download.html',
    async: false,
    data: { style: 0 },
    success: function(data) { scores = $(data).find('#score_data').text() }
  });
}

function putData() {
  $.ajax({
    type: 'post',
    url: serverUrlBase + '/api/v1/scores/sync/official',
    contentType: 'application/json',
    data: JSON.stringify({ scores: scores, user: user }),
    success: function(data) { alert('success'); },
    error: function(response) { alert(response.statusText); }
  });
}

checkStatus();
if (login) {
  getUserInfo();
  getCsv();
  setTimeout(putData, timeout);
} else {
  alert('please login: https://iidx12.tk');
}
<|endoftext|>


<commit_before>function ChannelTopic() {
	this.onAppStart = function onAppStart() {
		var channel = KnuddelsServer.getChannel();

		// Nachricht
		var topic = '°#W+0020°_Herzlich Willkommen in unserem _°BB>_hChannel ' + channel.getChannelName() + '|/info ' + channel.getChannelName() + '<W°_.°#°Wir wünschen dir viel Spaß in unserem Dice-Channel!°##12°';

		// Mein Konto
		topic += '°+0020>{button}Mein Konto||call|/KnuddelAccount list:' + KnuddelsServer.getDefaultBotUser().getNick() + '|icon|features/archaeologie/ft_11-09__medallion-smal_chattext.png|color|clearWhite|my|2<°';

		// Topliste
		topic += '°+0020>{button}Topliste||call|/AppTop|icon|quests/reward.png|color|clearWhite|my|2<°';

		// Readme
		topic += '°+0020>{button}Readme||call|/readme Hi|icon|sm_classic_00.gif|color|clearWhite|my|2<°';

		// Hilfe
		topic += '°+0020>{button}Hilfe||call|/helper|icon|bingo/buttonHelp.png|color|clearWhite|my|2<°';

		// Benachrichtigungen
		topic += '°>{button}Benachrichtigungen||call|/notifications|icon|bingo/buttonSoundOn.png|color|clearWhite|my|2<°';

		channel.getChannelConfiguration().getChannelInformation().setTopic(topic);
	};
};<commit_msg>change ChannelTopic to graphics for mobile displays<commit_after>function ChannelTopic() {
	this.onAppStart = function onAppStart() {
		var channel	= KnuddelsServer.getChannel();
		var topic	= '°#W+0020°_Herzlich Willkommen in unserem _°BB>_hChannel ' + channel.getChannelName() + '|/info ' + channel.getChannelName() + '<W°_.°#°Wir wünschen dir viel Spaß in unserem Dice-Channel!°##12°';

		/*
			INFO:
				Das hier sind die Original-Buttons.
				Wir ersetzten diese aber durch Grafiken (Siehe PSD "Topic-Buttons.psd"),
				damit diese auf den unterschiedlichen Endgeräten gleich aussehen!

			// Mein Konto
			topic += '°+0020>{button}Mein Konto||call|/KnuddelAccount list:' + KnuddelsServer.getDefaultBotUser().getNick() + '|icon|features/archaeologie/ft_11-09__medallion-smal_chattext.png|color|clearWhite|my|2<°';

			// Topliste
			topic += '°+0020>{button}Topliste||call|/AppTop|icon|quests/reward.png|color|clearWhite|my|2<°';

			// Readme
			topic += '°+0020>{button}Readme||call|/readme Hi|icon|sm_classic_00.gif|color|clearWhite|my|2<°';

			// Hilfe
			topic += '°+0020>{button}Hilfe||call|/helper|icon|bingo/buttonHelp.png|color|clearWhite|my|2<°';

			// Benachrichtigungen
			topic += '°>{button}Benachrichtigungen||call|/notifications|icon|bingo/buttonSoundOn.png|color|clearWhite|my|2<°';
		*/

		// Nachricht
		topic += '°+0020>' + KnuddelsServer.getFullImagePath('assets/buttons/bank...nopush.png') + '|' + KnuddelsServer.getFullImagePath('assets/buttons/bank_hover...nopush.png') + '<>|/KnuddelAccount list:' + KnuddelsServer.getDefaultBotUser().getNick() + '<° ';

		// Topliste
		topic += '°+0020>' + KnuddelsServer.getFullImagePath('assets/buttons/toplist...nopush.png') + '|' + KnuddelsServer.getFullImagePath('assets/buttons/toplist_hover...nopush.png') + '<>|/AppTop<° ';

		// Readme
		topic += '°+0020>' + KnuddelsServer.getFullImagePath('assets/buttons/readme...nopush.png') + '|' + KnuddelsServer.getFullImagePath('assets/buttons/readme_hover...nopush.png') + '<>|/readme Hi<° ';

		// Hilfe
		topic += '°+0020>' + KnuddelsServer.getFullImagePath('assets/buttons/help...nopush.png') + '|' + KnuddelsServer.getFullImagePath('assets/buttons/help_hover...nopush.png') + '<>|/helper<° ';

		// Benachrichtigungen
		topic += '°+0020>' + KnuddelsServer.getFullImagePath('assets/buttons/notifications...nopush.png') + '|' + KnuddelsServer.getFullImagePath('assets/buttons/notifications_hover...nopush.png') + '<>|/notifications<° ';

		channel.getChannelConfiguration().getChannelInformation().setTopic(topic);
	};
};<|endoftext|>


<commit_before>module.exports = {
    "env": {
        "browser": true,
        "es6": true,
        "node": true,
        "commonjs": true
    },
    "extends": "eslint:recommended",
    "installedESLint": true,
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true,
            "arrowFunctions": true,
            "classes": true,
            "modules": true,
            "defaultParams": true
        },
        "sourceType": "module"
    },
    "parser": "babel-eslint",
    "plugins": [
        "react"
    ],
    "rules": {
        "linebreak-style": [
            "error",
            "unix"
        ],
        "semi": [
            "error",
            "always"
        ],
        "no-empty": 0,
        "comma-dangle": 0,
        "no-unused-vars": 0,
        "no-console": 0,

        "no-const-assign": 2,
        "no-dupe-class-members": 2,
        "no-duplicate-case": 2,
        "no-extra-parens": [2, "functions"],
        "no-self-compare": 2,
        "accessor-pairs": 2,
        "comma-spacing": [2, {
            "before": false,
            "after": true
        }],
        "constructor-super": 2,
        "new-cap": [2, {
            "newIsCap": true,
            "capIsNew": false
        }],
        "new-parens": 2,
        "no-array-constructor": 2,
        "no-class-assign": 2,
        "no-cond-assign": 2
    }
};
<commit_msg>.eslintrc.js<commit_after>module.exports = {
    "env": {
        "browser": true,
        "es6": true,
        "node": true,
        "commonjs": true
    },
    "extends": "eslint:recommended",
    "installedESLint": true,
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true,
            "arrowFunctions": true,
            "classes": true,
            "modules": true,
            "defaultParams": true
        },
        "sourceType": "module"
    },
    "parser": "babel-eslint",
    "plugins": [
        "react"
    ],
    "rules": {
        "linebreak-style": [
            "error",
            "unix"
        ],
        "semi": [
            "error",
            "always"
        ],
        "no-empty": 0,
        "comma-dangle": 0,
        "no-undef": 0,
        "no-unused-vars": 0,
        "no-console": 0,

        "no-const-assign": 2,
        "no-dupe-class-members": 2,
        "no-duplicate-case": 2,
        "no-extra-parens": [2, "functions"],
        "no-self-compare": 2,
        "accessor-pairs": 2,
        "comma-spacing": [2, {
            "before": false,
            "after": true
        }],
        "constructor-super": 2,
        "new-cap": [2, {
            "newIsCap": true,
            "capIsNew": false
        }],
        "new-parens": 2,
        "no-array-constructor": 2,
        "no-class-assign": 2,
        "no-cond-assign": 2
    }
};
<|endoftext|>


<commit_before>var webpack = require('webpack')

function getConfig() {
    var env = process.env.CONFIG_FILE_ENV
    if (env) {
        var configFile = 'config_' + env + '.js'
    } else {
        var configFile = 'config.js'
    }
    console.log("Using this config file: ", configFile)
    return __dirname + '/configs/' + configFile
}

module.exports = {
    cache: true,
    resolve: { alias: {config: getConfig(),
                       assets: __dirname + '/assets/'} },
    entry: {
      app: './src/index.js',
      vendor: './src/vendor.js',
    },
    output: {
        path: './dist/',
        publicPath: '/dist/',
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            // { test: /\.png$/, include: /assets/, loader: "file" },
            // { test: /\.(png|otf|svg)$/, loader: "file" },
            { test: /\.css$/, loader: 'style!css' },
            { test: /\.scss$/, include: /src/, loader: 'style!css!sass' },
            { test: /\.sass$/, include: /src/, loader: 'style!css!sass?indentedSyntax' },
            { test: /\.html$/, include: /src/, loader: 'riotjs' },
            { test: /\.js$/,
              exclude: /\.es5\.js$/,
              // include: /src/,
              include: [ /configs/, /src/ ],
              loader: 'babel',
              query: {
                  modules: 'common',
                  // loose: ['es6.classes'],
                  // loose: ['all'],
                  // optional: 'runtime',
              }
            },
            { test: /\.(png|otf|svg)$/, include: /src\/css/, loader: "url?limit=25000" }
        ]
    },
    plugins: [
      new webpack.ProvidePlugin({
          riot: 'riot',
          leaflet: 'leaflet',
          regeneratorRuntime: 'regeneratorRuntime',
          // TODO: carregar como os outros polyfills
          // fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
      }),
      new webpack.optimize.CommonsChunkPlugin(
          /* chunkName= */"vendor",
          /* filename= */"vendor.bundle.js")
    ],
    devServer: {
        port: 5001
    },
    // devtool: "source-map"
    devtool: "source-map"
}
<commit_msg>allow modules to require pngs (like leaflet does)<commit_after>var webpack = require('webpack')

function getConfig() {
    var env = process.env.CONFIG_FILE_ENV
    if (env) {
        var configFile = 'config_' + env + '.js'
    } else {
        var configFile = 'config.js'
    }
    console.log("Using this config file: ", configFile)
    return __dirname + '/configs/' + configFile
}

module.exports = {
    cache: true,
    resolve: { alias: {config: getConfig(),
                       assets: __dirname + '/assets/'} },
    entry: {
      app: './src/index.js',
      vendor: './src/vendor.js',
    },
    output: {
        path: './dist/',
        publicPath: '/dist/',
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            // { test: /\.png$/, include: /assets/, loader: "file" },
            { test: /\.png$/, include: /node_modules/, loader: "file" },
            // { test: /\.(png|otf|svg)$/, loader: "file" },
            { test: /\.css$/, loader: 'style!css' },
            { test: /\.scss$/, include: /src/, loader: 'style!css!sass' },
            { test: /\.sass$/, include: /src/, loader: 'style!css!sass?indentedSyntax' },
            { test: /\.html$/, include: /src/, loader: 'riotjs' },
            { test: /\.js$/,
              exclude: /\.es5\.js$/,
              // include: /src/,
              include: [ /configs/, /src/ ],
              loader: 'babel',
              query: {
                  modules: 'common',
                  // loose: ['es6.classes'],
                  // loose: ['all'],
                  // optional: 'runtime',
              }
            },
            { test: /\.(png|otf|svg)$/, include: /src\/css/, loader: "url?limit=25000" }
        ]
    },
    plugins: [
      new webpack.ProvidePlugin({
          riot: 'riot',
          leaflet: 'leaflet',
          regeneratorRuntime: 'regeneratorRuntime',
          // TODO: carregar como os outros polyfills
          // fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
      }),
      new webpack.optimize.CommonsChunkPlugin(
          /* chunkName= */"vendor",
          /* filename= */"vendor.bundle.js")
    ],
    devServer: {
        port: 5001
    },
    // devtool: "source-map"
    devtool: "source-map"
}
<|endoftext|>


<commit_before>var Class = require('../../utils/Class');
var BaseSound = require('../BaseSound');
//  Phaser.Sound.WebAudioSound
// TODO support webkitAudioContext implementation differences
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Porting_webkitAudioContext_code_to_standards_based_AudioContext
var WebAudioSound = new Class({
    Extends: BaseSound,
    initialize: function WebAudioSound(manager, key, config) {
        if (config === void 0) { config = {}; }
        /**
         * [description]
         *
         * @private
         * @property {AudioBuffer} audioBuffer
         */
        this.audioBuffer = manager.game.cache.audio.get(key);
        if (!this.audioBuffer) {
            console.error('No audio loaded in cache with key: \'' + key + '\'!');
            return;
        }
        /**
         * [description]
         *
         * @private
         * @property {AudioBufferSourceNode} source
         */
        this.source = null;
        /**
         * [description]
         *
         * @private
         * @property {AudioBufferSourceNode} loopSource
         */
        this.loopSource = null;
        /**
         * [description]
         *
         * @private
         * @property {GainNode} muteNode
         */
        this.muteNode = manager.context.createGain();
        /**
         * [description]
         *
         * @private
         * @property {GainNode} volumeNode
         */
        this.volumeNode = manager.context.createGain();
        /**
         * The time at which the sound should have started from the beginning.
         * Based on BaseAudioContext.currentTime value.
         *
         * @private
         * @property {number} playTime
         */
        this.playTime = 0;
        /**
         * The time at which the sound source should actually start playback.
         * Based on BaseAudioContext.currentTime value.
         *
         * @private
         * @property {number} startTime
         */
        this.startTime = 0;
        /**
         * An array where we keep track of all rate updates during playback.
         *
         * @private
         * @property {{ time: number, rate: number }[]} rateUpdates
         */
        this.rateUpdates = [];
        /**
         * Used for keeping track when sound source playback has ended
         * so it's state can be updated accordingly.
         *
         * @private
         * @property {boolean} hasEnded
         */
        this.hasEnded = false;
        /**
         * Used for keeping track when sound source has looped
         * so it's state can be updated accordingly.
         *
         * @private
         * @property {boolean} hasLooped
         */
        this.hasLooped = false;
        this.muteNode.connect(this.volumeNode);
        this.volumeNode.connect(manager.destination);
        this.duration = this.audioBuffer.duration;
        this.totalDuration = this.audioBuffer.duration;
        BaseSound.call(this, manager, key, config);
    },
    play: function (markerName, config) {
        if (!BaseSound.prototype.play.call(this, markerName, config)) {
            return null;
        }
        //  \/\/\/ isPlaying = true, isPaused = false \/\/\/
        this.stopAndRemoveBufferSource();
        this.createAndStartBufferSource();
        return this;
    },
    pause: function () {
        if (this.manager.context.currentTime < this.startTime) {
            return false;
        }
        if (!BaseSound.prototype.pause.call(this)) {
            return false;
        }
        //  \/\/\/ isPlaying = false, isPaused = true \/\/\/
        this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time
        this.stopAndRemoveBufferSource();
        return true;
    },
    resume: function () {
        if (this.manager.context.currentTime < this.startTime) {
            return false;
        }
        if (!BaseSound.prototype.resume.call(this)) {
            return false;
        }
        //  \/\/\/ isPlaying = true, isPaused = false \/\/\/
        this.createAndStartBufferSource();
        return true;
    },
    stop: function () {
        if (!BaseSound.prototype.stop.call(this)) {
            return false;
        }
        //  \/\/\/ isPlaying = false, isPaused = false \/\/\/
        this.stopAndRemoveBufferSource();
        return true;
    },
    /**
     * Used internally to do what the name says.
     *
     * @private
     */
    createAndStartBufferSource: function () {
        var seek = this.currentConfig.seek;
        var delay = this.currentConfig.delay;
        var when = this.manager.context.currentTime + delay;
        var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek;
        var duration = this.duration - seek;
        this.playTime = when - seek;
        this.startTime = when;
        this.source = this.createBufferSource();
        this.applyConfig();
        this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration));
        this.resetConfig();
    },
    /**
     * @private
     */
    createBufferSource: function () {
        var _this = this;
        var source = this.manager.context.createBufferSource();
        source.buffer = this.audioBuffer;
        source.connect(this.muteNode);
        source.onended = function (ev) {
            if (ev.target === _this.source) {
                // sound ended
                if (_this.currentConfig.loop) {
                    _this.hasLooped = true;
                }
                else {
                    _this.hasEnded = true;
                }
            }
            // else was stopped
        };
        return source;
    },
    /**
     * Used internally to do what the name says.
     *
     * @private
     */
    stopAndRemoveBufferSource: function () {
        if (this.source) {
            this.source.stop();
            this.source = null;
        }
        this.playTime = 0;
        this.startTime = 0;
    },
    /**
     * @protected
     */
    applyConfig: function () {
        this.rateUpdates.length = 0;
        this.rateUpdates.push({
            time: 0,
            rate: 1
        });
        BaseSound.prototype.applyConfig.call(this);
    },
    /**
     * Update method called on every game step.
     *
     * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
     * @param {number} delta - The delta time elapsed since the last frame.
     */
    update: function (time, delta) {
        if (this.hasEnded) {
            this.hasEnded = false;
            this.stop();
        }
        else if (this.hasLooped) {
            this.hasLooped = false;
            // TODO handle looping
        }
    },
    destroy: function () {
        BaseSound.prototype.destroy.call(this);
        this.audioBuffer = null;
        this.stopAndRemoveBufferSource();
        this.muteNode.disconnect();
        this.muteNode = null;
        this.volumeNode.disconnect();
        this.volumeNode = null;
        this.rateUpdates = null;
    },
    /**
     * @private
     */
    setRate: function () {
        BaseSound.prototype.setRate.call(this);
        if (this.source) {
            this.source.playbackRate.setValueAtTime(this.totalRate, 0);
        }
        if (this.isPlaying) {
            this.rateUpdates.push({
                time: Math.max(this.startTime, this.manager.context.currentTime) - this.playTime,
                rate: this.totalRate
            });
        }
    },
    /**
     * @private
     */
    getCurrentTime: function () {
        var currentTime = 0;
        for (var i = 0; i < this.rateUpdates.length; i++) {
            var nextTime = void 0;
            if (i < this.rateUpdates.length - 1) {
                nextTime = this.rateUpdates[i + 1].time;
            }
            else {
                nextTime = this.manager.context.currentTime - this.playTime;
            }
            currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate;
        }
        return currentTime;
    }
});
/**
 * Mute setting.
 * @property {boolean} mute
 */
Object.defineProperty(WebAudioSound.prototype, 'mute', {
    get: function () {
        return this.muteNode.gain.value === 0;
    },
    set: function (value) {
        this.currentConfig.mute = value;
        this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0);
    }
});
/**
 * Volume setting.
 * @property {number} volume
 */
Object.defineProperty(WebAudioSound.prototype, 'volume', {
    get: function () {
        return this.volumeNode.gain.value;
    },
    set: function (value) {
        this.currentConfig.volume = value;
        this.volumeNode.gain.setValueAtTime(value, 0);
    }
});
/**
 * Playback rate.
 * @property {number} rate
 */
Object.defineProperty(WebAudioSound.prototype, 'rate', {
    get: function () {
        return this.currentConfig.rate;
    },
    set: function (value) {
        this.currentConfig.rate = value;
        this.setRate();
    }
});
/**
 * Detuning of sound.
 * @property {number} detune
 */
Object.defineProperty(WebAudioSound.prototype, 'detune', {
    get: function () {
        return this.currentConfig.detune;
    },
    set: function (value) {
        this.currentConfig.detune = value;
        this.setRate();
    }
});
/**
 * Current position of playing sound.
 * @property {number} seek
 */
Object.defineProperty(WebAudioSound.prototype, 'seek', {
    get: function () {
        if (this.isPlaying) {
            if (this.manager.context.currentTime < this.startTime) {
                return this.startTime - this.playTime;
            }
            return this.getCurrentTime();
        }
        else if (this.isPaused) {
            return this.currentConfig.seek;
        }
        else {
            return 0;
        }
    },
    set: function (value) {
        if (this.manager.context.currentTime < this.startTime) {
            return;
        }
        if (this.isPlaying || this.isPaused) {
            value = Math.min(Math.max(0, value), this.duration);
            this.currentConfig.seek = value;
        }
        if (this.isPlaying) {
            this.stopAndRemoveBufferSource();
            this.createAndStartBufferSource();
        }
    }
});
/**
 * Property indicating whether or not
 * the sound or current sound marker will loop.
 *
 * @property {boolean} loop
 */
Object.defineProperty(WebAudioSound.prototype, 'loop', {
    get: function () {
        return this.currentConfig.loop;
    },
    set: function (value) {
        this.currentConfig.loop = value;
        if(this.isPlaying) {
            if(value) {
                var lastRateUpdateCurrentTime = 0;
                for (var i = 0; i < this.rateUpdates.length - 1; i++) {
                    lastRateUpdateCurrentTime +=
                        (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate;
                }
                var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1];
                var when = this.playTime + lastRateUpdate.time
                    + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate;
                var offset = this.currentMarker ? this.currentMarker.start : 0;
                var duration = this.duration;
                this.loopSource = this.createBufferSource();
                this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration));
            }
        }
    }
});
module.exports = WebAudioSound;
<commit_msg>Moved loop buffer source creation and starting logic into separate method<commit_after>var Class = require('../../utils/Class');
var BaseSound = require('../BaseSound');
//  Phaser.Sound.WebAudioSound
// TODO support webkitAudioContext implementation differences
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Porting_webkitAudioContext_code_to_standards_based_AudioContext
var WebAudioSound = new Class({
    Extends: BaseSound,
    initialize: function WebAudioSound(manager, key, config) {
        if (config === void 0) { config = {}; }
        /**
         * [description]
         *
         * @private
         * @property {AudioBuffer} audioBuffer
         */
        this.audioBuffer = manager.game.cache.audio.get(key);
        if (!this.audioBuffer) {
            console.error('No audio loaded in cache with key: \'' + key + '\'!');
            return;
        }
        /**
         * [description]
         *
         * @private
         * @property {AudioBufferSourceNode} source
         */
        this.source = null;
        /**
         * [description]
         *
         * @private
         * @property {AudioBufferSourceNode} loopSource
         */
        this.loopSource = null;
        /**
         * [description]
         *
         * @private
         * @property {GainNode} muteNode
         */
        this.muteNode = manager.context.createGain();
        /**
         * [description]
         *
         * @private
         * @property {GainNode} volumeNode
         */
        this.volumeNode = manager.context.createGain();
        /**
         * The time at which the sound should have started from the beginning.
         * Based on BaseAudioContext.currentTime value.
         *
         * @private
         * @property {number} playTime
         */
        this.playTime = 0;
        /**
         * The time at which the sound source should actually start playback.
         * Based on BaseAudioContext.currentTime value.
         *
         * @private
         * @property {number} startTime
         */
        this.startTime = 0;
        /**
         * An array where we keep track of all rate updates during playback.
         *
         * @private
         * @property {{ time: number, rate: number }[]} rateUpdates
         */
        this.rateUpdates = [];
        /**
         * Used for keeping track when sound source playback has ended
         * so it's state can be updated accordingly.
         *
         * @private
         * @property {boolean} hasEnded
         */
        this.hasEnded = false;
        /**
         * Used for keeping track when sound source has looped
         * so it's state can be updated accordingly.
         *
         * @private
         * @property {boolean} hasLooped
         */
        this.hasLooped = false;
        this.muteNode.connect(this.volumeNode);
        this.volumeNode.connect(manager.destination);
        this.duration = this.audioBuffer.duration;
        this.totalDuration = this.audioBuffer.duration;
        BaseSound.call(this, manager, key, config);
    },
    play: function (markerName, config) {
        if (!BaseSound.prototype.play.call(this, markerName, config)) {
            return null;
        }
        //  \/\/\/ isPlaying = true, isPaused = false \/\/\/
        this.stopAndRemoveBufferSource();
        this.createAndStartBufferSource();
        return this;
    },
    pause: function () {
        if (this.manager.context.currentTime < this.startTime) {
            return false;
        }
        if (!BaseSound.prototype.pause.call(this)) {
            return false;
        }
        //  \/\/\/ isPlaying = false, isPaused = true \/\/\/
        this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time
        this.stopAndRemoveBufferSource();
        return true;
    },
    resume: function () {
        if (this.manager.context.currentTime < this.startTime) {
            return false;
        }
        if (!BaseSound.prototype.resume.call(this)) {
            return false;
        }
        //  \/\/\/ isPlaying = true, isPaused = false \/\/\/
        this.createAndStartBufferSource();
        return true;
    },
    stop: function () {
        if (!BaseSound.prototype.stop.call(this)) {
            return false;
        }
        //  \/\/\/ isPlaying = false, isPaused = false \/\/\/
        this.stopAndRemoveBufferSource();
        return true;
    },
    /**
     * Used internally to do what the name says.
     *
     * @private
     */
    createAndStartBufferSource: function () {
        var seek = this.currentConfig.seek;
        var delay = this.currentConfig.delay;
        var when = this.manager.context.currentTime + delay;
        var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek;
        var duration = this.duration - seek;
        this.playTime = when - seek;
        this.startTime = when;
        this.source = this.createBufferSource();
        this.applyConfig();
        this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration));
        this.resetConfig();
    },
    /**
     * Used internally to do what the name says.
     *
     * @private
     */
    createAndStartLoopBufferSource: function () {
        var lastRateUpdateCurrentTime = 0;
        for (var i = 0; i < this.rateUpdates.length - 1; i++) {
            lastRateUpdateCurrentTime +=
                (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate;
        }
        var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1];
        var when = this.playTime + lastRateUpdate.time
            + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate;
        var offset = this.currentMarker ? this.currentMarker.start : 0;
        var duration = this.duration;
        this.loopSource = this.createBufferSource();
        this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration));
    },
    /**
     * @private
     */
    createBufferSource: function () {
        var _this = this;
        var source = this.manager.context.createBufferSource();
        source.buffer = this.audioBuffer;
        source.connect(this.muteNode);
        source.onended = function (ev) {
            if (ev.target === _this.source) {
                // sound ended
                if (_this.currentConfig.loop) {
                    _this.hasLooped = true;
                }
                else {
                    _this.hasEnded = true;
                }
            }
            // else was stopped
        };
        return source;
    },
    /**
     * Used internally to do what the name says.
     *
     * @private
     */
    stopAndRemoveBufferSource: function () {
        if (this.source) {
            this.source.stop();
            this.source = null;
        }
        this.playTime = 0;
        this.startTime = 0;
    },
    /**
     * @protected
     */
    applyConfig: function () {
        this.rateUpdates.length = 0;
        this.rateUpdates.push({
            time: 0,
            rate: 1
        });
        BaseSound.prototype.applyConfig.call(this);
    },
    /**
     * Update method called on every game step.
     *
     * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
     * @param {number} delta - The delta time elapsed since the last frame.
     */
    update: function (time, delta) {
        if (this.hasEnded) {
            this.hasEnded = false;
            this.stop();
        }
        else if (this.hasLooped) {
            this.hasLooped = false;
            // TODO handle looping
        }
    },
    destroy: function () {
        BaseSound.prototype.destroy.call(this);
        this.audioBuffer = null;
        this.stopAndRemoveBufferSource();
        this.muteNode.disconnect();
        this.muteNode = null;
        this.volumeNode.disconnect();
        this.volumeNode = null;
        this.rateUpdates = null;
    },
    /**
     * @private
     */
    setRate: function () {
        BaseSound.prototype.setRate.call(this);
        if (this.source) {
            this.source.playbackRate.setValueAtTime(this.totalRate, 0);
        }
        if (this.isPlaying) {
            this.rateUpdates.push({
                time: Math.max(this.startTime, this.manager.context.currentTime) - this.playTime,
                rate: this.totalRate
            });
        }
    },
    /**
     * @private
     */
    getCurrentTime: function () {
        var currentTime = 0;
        for (var i = 0; i < this.rateUpdates.length; i++) {
            var nextTime = void 0;
            if (i < this.rateUpdates.length - 1) {
                nextTime = this.rateUpdates[i + 1].time;
            }
            else {
                nextTime = this.manager.context.currentTime - this.playTime;
            }
            currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate;
        }
        return currentTime;
    }
});
/**
 * Mute setting.
 * @property {boolean} mute
 */
Object.defineProperty(WebAudioSound.prototype, 'mute', {
    get: function () {
        return this.muteNode.gain.value === 0;
    },
    set: function (value) {
        this.currentConfig.mute = value;
        this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0);
    }
});
/**
 * Volume setting.
 * @property {number} volume
 */
Object.defineProperty(WebAudioSound.prototype, 'volume', {
    get: function () {
        return this.volumeNode.gain.value;
    },
    set: function (value) {
        this.currentConfig.volume = value;
        this.volumeNode.gain.setValueAtTime(value, 0);
    }
});
/**
 * Playback rate.
 * @property {number} rate
 */
Object.defineProperty(WebAudioSound.prototype, 'rate', {
    get: function () {
        return this.currentConfig.rate;
    },
    set: function (value) {
        this.currentConfig.rate = value;
        this.setRate();
    }
});
/**
 * Detuning of sound.
 * @property {number} detune
 */
Object.defineProperty(WebAudioSound.prototype, 'detune', {
    get: function () {
        return this.currentConfig.detune;
    },
    set: function (value) {
        this.currentConfig.detune = value;
        this.setRate();
    }
});
/**
 * Current position of playing sound.
 * @property {number} seek
 */
Object.defineProperty(WebAudioSound.prototype, 'seek', {
    get: function () {
        if (this.isPlaying) {
            if (this.manager.context.currentTime < this.startTime) {
                return this.startTime - this.playTime;
            }
            return this.getCurrentTime();
        }
        else if (this.isPaused) {
            return this.currentConfig.seek;
        }
        else {
            return 0;
        }
    },
    set: function (value) {
        if (this.manager.context.currentTime < this.startTime) {
            return;
        }
        if (this.isPlaying || this.isPaused) {
            value = Math.min(Math.max(0, value), this.duration);
            this.currentConfig.seek = value;
        }
        if (this.isPlaying) {
            this.stopAndRemoveBufferSource();
            this.createAndStartBufferSource();
        }
    }
});
/**
 * Property indicating whether or not
 * the sound or current sound marker will loop.
 *
 * @property {boolean} loop
 */
Object.defineProperty(WebAudioSound.prototype, 'loop', {
    get: function () {
        return this.currentConfig.loop;
    },
    set: function (value) {
        this.currentConfig.loop = value;
        if (this.isPlaying) {
            if (value) {
                this.createAndStartLoopBufferSource();
            }
        }
    }
});
module.exports = WebAudioSound;
<|endoftext|>


<commit_before>
String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

function urlForSubreddits(subreddits, after ) {

	// http://www.reddit.com/r/starcraft/.json?jsonp=?&after=t3_yjbu1
	redditsURLBase = "http://www.reddit.com/r/"
	redditURLJsonEnding = "/.json?jsonp=?"

	url = redditsURLBase
	url = url + subreddits.join("+")
	url = url + redditURLJsonEnding
	if( after.length > 0 )
		url = url + "&after=" + after

	console.log("URL=", url)
	return url
}

function getImage(item) {

	if( !item.url.endsWith("png") && !item.url.endsWith("jpg") && !item.url.endsWith("jpeg") )
		return undefined

	return item
}

redditAfterTag = ""

seenURLs = {}
cbURLs = {}

function createImage( listView, img ) {

	// moving into its own function seems to have resolved an issue where img would become undefined in the CB
	if(undefined == img || undefined != seenURLs[img.url])
		return undefined;

	seenURLs[img.url] = true;

	console.log("adding2: ", img.url)
	// Insert preloaded image after it finishes loading
	$('')
	    .attr('src', img.url)
	    .load(function(){

	    		// TOOD: Better jQuery way to construct/add this?
	    		listView.append($(	'

' +
									'
' + img.title + '
'+
									'' +
									'

' ))

				if( undefined != cbURLs[img.url] ) { console.log( img.url, ": in the callback after loading - duplicate seen!: ", img.url); }
				cbURLs[img.url] = true;
	    });
}

function getReddits(subreddits, listView ) {
	url = urlForSubreddits(subreddits, redditAfterTag)
	console.log("sending the json - after = ", redditAfterTag )
	$.getJSON(url, function(data) {
		redditAfterTag = data.data.after;
		// TODO: possible for after to become empty after a while ... "after": null, "before": null

		console.log( "Got data! #= ", data.data.children.length )

	    $.each(data.data.children, function(i,item){
	    	here = item.data
	    	var img = getImage( here )
	    	createImage(listView, img)
	    });
    })
}<commit_msg>Scale images to width of our screen<commit_after>
String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

function urlForSubreddits(subreddits, after ) {

	// http://www.reddit.com/r/starcraft/.json?jsonp=?&after=t3_yjbu1
	redditsURLBase = "http://www.reddit.com/r/"
	redditURLJsonEnding = "/.json?jsonp=?"

	url = redditsURLBase
	url = url + subreddits.join("+")
	url = url + redditURLJsonEnding
	if( after.length > 0 )
		url = url + "&after=" + after

	console.log("URL=", url)
	return url
}

function getImage(item) {

	if( !item.url.endsWith("png") && !item.url.endsWith("jpg") && !item.url.endsWith("jpeg") )
		return undefined

	return item
}

redditAfterTag = ""

seenURLs = {}
cbURLs = {}

function createImage( listView, img ) {

	// moving into its own function seems to have resolved an issue where img would become undefined in the CB
	if(undefined == img || undefined != seenURLs[img.url])
		return undefined;

	seenURLs[img.url] = true;

	console.log("adding2: ", img.url)
	// Insert preloaded image after it finishes loading
	$('')
	    .attr('src', img.url)
	    .load(function(){
	    		imgTag = '';
	    		// TOOD: Better jQuery way to construct/add this?
	    		listView.append($(	'

' +
									'
' + img.title + '
'+
									imgTag +
									'

' ))

				if( undefined != cbURLs[img.url] ) { console.log( img.url, ": in the callback after loading - duplicate seen!: ", img.url); }
				cbURLs[img.url] = true;
	    });
}

function getReddits(subreddits, listView ) {
	url = urlForSubreddits(subreddits, redditAfterTag)
	console.log("sending the json - after = ", redditAfterTag )
	$.getJSON(url, function(data) {
		redditAfterTag = data.data.after;
		// TODO: possible for after to become empty after a while ... "after": null, "before": null

		console.log( "Got data! #= ", data.data.children.length )

	    $.each(data.data.children, function(i,item){
	    	here = item.data
	    	var img = getImage( here )
	    	createImage(listView, img)
	    });
    })
}<|endoftext|>


<commit_before>import Color from '../core/math/Color.js';

export default class InputColorElement extends HTMLElement {
  static get observedAttributes() {
    return ['value', 'disabled'];
  }

  constructor() {
    super();

    this.attachShadow({ mode: 'open' }).innerHTML = `
      <style>
        :host {
          display: inline-flex;
          align-items: center;
        }
        input {
          flex: 1;
          width: 100%;
        }
        input[type=color] {
          box-sizing: border-box;
          height: 20px;
        }
      </style>
      <input type="color">
      <input type="text">
    `;

    this._colorInput = this.shadowRoot.querySelector('input[type=color]');
    this._textInput = this.shadowRoot.querySelector('input[type=text]');

    this._colorInput.addEventListener('input', (event) => {
      event.stopPropagation();
      this.value = this._colorInput.value;
    });

    this._textInput.addEventListener('input', (event) => {
      event.stopPropagation();
      this.value = this._textInput.value;
    });
  }

  attributeChangedCallback(name, oldValue, newValue) {
    switch (name) {
      case 'value':
        try {
          this.value = new Function(`return ${newValue}`).apply(this);
        } catch (error) {
          this.value = newValue;
        }
        break;
      case 'disabled':
        this._colorInput.disabled = this.disabled;
        this._textInput.disabled = this.disabled;
        break;
    }
  }

  get disabled() {
    return this.hasAttribute('disabled');
  }

  set disabled(value) {
    if (value) {
      this.setAttribute('disabled', '');
    } else {
      this.removeAttribute('disabled');
    }
  }

  get value() {
    return this._value;
  }

  set value(value) {
    const hexValue = this._valueToHexadecimal(value);

    if (typeof this._value === 'object' && typeof value === 'string') {
      const RGBA = Color.styleToRGBA(hexValue);
      if (this._value.r !== undefined) {
        [this._value.r, this._value.g, this._value.b] = [RGBA[0], RGBA[1], RGBA[2]];
      } else if (this._value.x !== undefined) {
        [this._value.x, this._value.y, this._value.z] = [RGBA[0], RGBA[1], RGBA[2]];
      } else {
        [this._value[0], this._value[1], this._value[2]] = [RGBA[0], RGBA[1], RGBA[2]];
      }
    } else if (typeof this._value === 'object' && typeof value === 'object') {
      if (this._value.r !== undefined) {
        [this._value.r, this._value.g, this._value.b] = [value.r, value.g, value.b];
      } else if (this._value.x !== undefined) {
        [this._value.x, this._value.y, this._value.z] = [value.x, value.y, value.z];
      } else {
        [this._value[0], this._value[1], this._value[2]] = [value[0], value[1], value[2]];
      }
    } else {
      this._value = value;
    }

    this._textInput.value = typeof value === 'string' ? value : hexValue;
    this._colorInput.value = hexValue;

    this.dispatchEvent(new Event('input', {
      bubbles: true,
    }));
  }

  _valueToHexadecimal(value) {
    let RGBA;

    if (typeof value === 'string') {
      RGBA = Color.styleToRGBA(value);
    } else if (value.r !== undefined) {
      RGBA = [value.r, value.g, value.b, 1];
    } else if (value.x !== undefined) {
      RGBA = [value.x, value.y, value.z, 1];
    } else {
      RGBA = [value[0], value[1], value[2], 1];
    }

    return `#${Math.floor(RGBA[0] * 255).toString(16).padStart(2, '0')}${Math.floor(RGBA[1] * 255).toString(16).padStart(2, '0')}${Math.floor(RGBA[2] * 255).toString(16).padStart(2, '0')}`;
  }
}
<commit_msg>input-color: fix input event<commit_after>import Color from '../core/math/Color.js';

export default class InputColorElement extends HTMLElement {
  static get observedAttributes() {
    return ['value', 'disabled'];
  }

  constructor() {
    super();

    this.attachShadow({ mode: 'open' }).innerHTML = `
      <style>
        :host {
          display: inline-flex;
          align-items: center;
        }
        input {
          flex: 1;
          width: 100%;
        }
        input[type=color] {
          box-sizing: border-box;
          height: 20px;
        }
      </style>
      <input type="color">
      <input type="text">
    `;

    this._colorInput = this.shadowRoot.querySelector('input[type=color]');
    this._textInput = this.shadowRoot.querySelector('input[type=text]');

    this._colorInput.addEventListener('input', (event) => {
      event.stopPropagation();
      this.value = this._colorInput.value;
      this.dispatchEvent(new Event('input', {
        bubbles: true,
      }));
    });

    this._textInput.addEventListener('input', (event) => {
      event.stopPropagation();
      this.value = this._textInput.value;
      this.dispatchEvent(new Event('input', {
        bubbles: true,
      }));
    });
  }

  attributeChangedCallback(name, oldValue, newValue) {
    switch (name) {
      case 'value':
        try {
          this.value = new Function(`return ${newValue}`).apply(this);
        } catch (error) {
          this.value = newValue;
        }
        break;
      case 'disabled':
        this._colorInput.disabled = this.disabled;
        this._textInput.disabled = this.disabled;
        break;
    }
  }

  get disabled() {
    return this.hasAttribute('disabled');
  }

  set disabled(value) {
    if (value) {
      this.setAttribute('disabled', '');
    } else {
      this.removeAttribute('disabled');
    }
  }

  get value() {
    return this._value;
  }

  set value(value) {
    const hexValue = this._valueToHexadecimal(value);

    if (typeof this._value === 'object' && typeof value === 'string') {
      const RGBA = Color.styleToRGBA(hexValue);
      if (this._value.r !== undefined) {
        [this._value.r, this._value.g, this._value.b] = [RGBA[0], RGBA[1], RGBA[2]];
      } else if (this._value.x !== undefined) {
        [this._value.x, this._value.y, this._value.z] = [RGBA[0], RGBA[1], RGBA[2]];
      } else {
        [this._value[0], this._value[1], this._value[2]] = [RGBA[0], RGBA[1], RGBA[2]];
      }
    } else if (typeof this._value === 'object' && typeof value === 'object') {
      if (this._value.r !== undefined) {
        [this._value.r, this._value.g, this._value.b] = [value.r, value.g, value.b];
      } else if (this._value.x !== undefined) {
        [this._value.x, this._value.y, this._value.z] = [value.x, value.y, value.z];
      } else {
        [this._value[0], this._value[1], this._value[2]] = [value[0], value[1], value[2]];
      }
    } else {
      this._value = value;
    }

    this._textInput.value = typeof value === 'string' ? value : hexValue;
    this._colorInput.value = hexValue;

    this.dispatchEvent(new Event('change', {
      bubbles: true,
    }));
  }

  _valueToHexadecimal(value) {
    let RGBA;

    if (typeof value === 'string') {
      RGBA = Color.styleToRGBA(value);
    } else if (value.r !== undefined) {
      RGBA = [value.r, value.g, value.b, 1];
    } else if (value.x !== undefined) {
      RGBA = [value.x, value.y, value.z, 1];
    } else {
      RGBA = [value[0], value[1], value[2], 1];
    }

    return `#${Math.floor(RGBA[0] * 255).toString(16).padStart(2, '0')}${Math.floor(RGBA[1] * 255).toString(16).padStart(2, '0')}${Math.floor(RGBA[2] * 255).toString(16).padStart(2, '0')}`;
  }
}
<|endoftext|>


<commit_before>module.exports = {
  "env": {
    "browser": true,
    "jquery": true,
    "jest": true,
    "node": true,
    "serviceworker": true
  },
  "extends": [
    "airbnb",
    "prettier",
    "prettier/react"
  ],
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 2018,
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "impliedStrict": true,
      "classes": true
    }
  },
  "plugins": [
    "html",
    "prettier",
    "react-hooks"
  ],
  "rules": {
    "arrow-body-style": [
      2,
      "as-needed"
    ],
    "comma-dangle": 0,
    "consistent-return": 0,
    "curly": 2,
    "dot-notation": 2,
    "func-names": 0,
    "id-length": [
      2,
      {
        "exceptions": ["i","a","b"]
      }
    ],
    "import": 0,
    "import/extensions": 0,
    "import/no-unresolved": [
      2,
      { "caseSensitive": false }
   ],
    "import/prefer-default-export": 0,
    "jsx-a11y/accessible-emoji": 0,
    "jsx-a11y/anchor-is-valid": [
      "warn",
      {
        "aspects": [
          "invalidHref"
        ]
      }
    ],
    "jsx-a11y/href-no-hash": "off",
    "linebreak-style": 0,
    "no-alert": 0,
    "no-await-in-loop": 0,
    "no-console": 0,
    "no-debugger": 0,
    "no-nested-ternary": "off",
    "no-param-reassign": [
      2,
      {
        "props": false
      }
    ],
    "no-restricted-syntax": [
      2,
      "ForInStatement",
      "LabeledStatement",
      "WithStatement"
    ],
    "no-return-assign": [
      "error",
      "except-parens"
    ],
    "no-shadow": [
      2,
      {
        "hoist": "all",
        "allow": [
          "resolve",
          "reject",
          "done",
          "next",
          "err",
          "error"
        ]
      }
    ],
    "no-underscore-dangle": 0,
    "no-unneeded-ternary": 2,
    "no-unused-expressions": [
      2,
      {
        "allowTaggedTemplates": true
      }
    ],
    "no-unused-vars": [
      1,
      {
        "ignoreSiblings": true,
        "argsIgnorePattern": "res|next|^err"
      }
    ],
    "no-useless-return": 2,
    "no-var": 2,
    "max-len": 0,
    "one-var": [
      2,
      "never"
    ],
    "prefer-arrow-callback": 2,
    "prefer-const": [
      "error",
      {
        "destructuring": "all",
      }
    ],
    "prefer-promise-reject-errors": 2,
    "prettier/prettier": [
      "error",
      {
        "arrowParens": "avoid",
        "bracketSpacing": false,
        "endOfLine": "auto",
        "jsxBracketSameLine": false,
        "printWidth": 80,
        "proseWrap": "preserve",
        "requirePragma": false,
        "semi": true,
        "singleQuote": true,
        "tabWidth": 2,
        "trailingComma": "es5",
        "useTabs": false,
      }
    ],
    "quotes": [
      2,
      "single",
      {
        "avoidEscape": true,
        "allowTemplateLiterals": true
      }
    ],
    "radix": 0,
    "react-hooks/exhaustive-deps": "warn",
    "react-hooks/rules-of-hooks": "error",
    "react/display-name": 1,
    "react/forbid-prop-types": 0,
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [
          ".js",
          ".jsx"
        ]
      }
    ],
    "react/no-array-index-key": 0,
    "react/no-unescaped-entities": 0,
    "react/prefer-stateless-function": 0,
    "react/react-in-jsx-scope": 0,
    "react/require-default-props": 0,
    "sort-imports": 2,
    "sort-keys": [
      2,
      "asc",
      {
        "caseSensitive": true,
        "natural": true
      }
    ],
    "sort-vars": 2,
    "space-before-function-paren": 0,
    "strict": [2, "global"]
  }
}<commit_msg>ESLint updates<commit_after>module.exports = {
  "env": {
    "browser": true,
    "jquery": true,
    "jest": true,
    "node": true,
    "serviceworker": true
  },
  "extends": [
    "airbnb",
    "prettier",
    "prettier/react"
  ],
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 2018,
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "impliedStrict": true,
      "classes": true
    }
  },
  "plugins": [
    "html",
    "prettier",
    "react-hooks"
  ],
  "rules": {
    "arrow-body-style": [
      2,
      "as-needed"
    ],
    "comma-dangle": 0,
    "consistent-return": 0,
    "curly": 2,
    "dot-notation": 2,
    "func-names": 0,
    "id-length": [
      2,
      {
        "exceptions": ["i","a","b"]
      }
    ],
    "import": 0,
    "import/extensions": 0,
    "import/no-unresolved": [
      2,
      { "caseSensitive": false }
   ],
    "import/prefer-default-export": 0,
    "jsx-a11y/accessible-emoji": 0,
    "jsx-a11y/anchor-is-valid": [
      "warn",
      {
        "aspects": [
          "invalidHref"
        ]
      }
    ],
    "jsx-a11y/href-no-hash": "off",
    "linebreak-style": 0,
    "no-alert": 0,
    "no-await-in-loop": 0,
    "no-console": 0,
    "no-debugger": 0,
    "no-nested-ternary": "off",
    "no-param-reassign": [
      2,
      {
        "props": false
      }
    ],
    "no-restricted-syntax": [
      2,
      "ForInStatement",
      "LabeledStatement",
      "WithStatement"
    ],
    "no-return-assign": [
      "error",
      "except-parens"
    ],
    "no-shadow": [
      2,
      {
        "hoist": "all",
        "allow": [
          "resolve",
          "reject",
          "done",
          "next",
          "err",
          "error"
        ]
      }
    ],
    "no-underscore-dangle": 0,
    "no-unneeded-ternary": 2,
    "no-unused-expressions": [
      2,
      {
        "allowTaggedTemplates": true
      }
    ],
    "no-unused-vars": [
      1,
      {
        "ignoreSiblings": true,
        "argsIgnorePattern": "res|next|^err"
      }
    ],
    "no-useless-return": 2,
    "no-var": 2,
    "max-len": 0,
    "one-var": [
      2,
      "never"
    ],
    "prefer-arrow-callback": 2,
    "prefer-const": [
      "error",
      {
        "destructuring": "all",
      }
    ],
    "prefer-promise-reject-errors": 2,
    "prettier/prettier": [
      "error",
      {
        "arrowParens": "avoid",
        "bracketSpacing": false,
        "endOfLine": "auto",
        "jsxBracketSameLine": false,
        "printWidth": 80,
        "proseWrap": "preserve",
        "requirePragma": false,
        "semi": true,
        "singleQuote": true,
        "tabWidth": 2,
        "trailingComma": "es5",
        "useTabs": false,
      }
    ],
    "quotes": [
      2,
      "single",
      'backtick',
      {
        "avoidEscape": true,
        "allowTemplateLiterals": true
      }
    ],
    "radix": 0,
    "react-hooks/exhaustive-deps": "warn",
    "react-hooks/rules-of-hooks": "error",
    "react/display-name": 1,
    "react/forbid-prop-types": 0,
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [
          ".js",
          ".jsx"
        ]
      }
    ],
    "react/no-array-index-key": 0,
    "react/no-unescaped-entities": 0,
    "react/prefer-stateless-function": 0,
    "react/react-in-jsx-scope": 0,
    "react/require-default-props": 0,
    "sort-imports": 2,
    "sort-keys": [
      2,
      "asc",
      {
        "caseSensitive": true,
        "natural": true
      }
    ],
    "sort-vars": 2,
    "space-before-function-paren": 0,
    "strict": [2, "global"]
  }
}<|endoftext|>


<commit_before>$.get("/get/username", function(data) {
    parsedData = JSON.parse(data);
    $("#loggedIn").attr("uid", parsedData.username);
    $("#loggedIn").html("" + parsedData.username + "");
    //$("#logout").html("<form method=\"post\" action=\"/logout\"><button type=\"submit\">Logout</button></form>");
    $("#login").hide();
    $("#signup").hide();
    $("#loggedIn").show();
});

window.onload = function() {

  // Get references to elements on the page.
  var form = document.getElementById('message-form');
  var messageField = document.getElementById('message');
  var messagesList = document.getElementById('messages');
  //var socketStatus = document.getElementById('status');

  // Create a new WebSocket.
  var socket = new WebSocket('ws://ipp.chtr.us');

  // // Handle any errors that occur.
  // socket.onerror = function(error) {
  //   console.log('WebSocket Error: ' + error);
  // };

  // // Show a connected message when the WebSocket is opened.
  // socket.onopen = function(event) {
  //   socketStatus.innerHTML = 'Connected to: ws://ipp.chtr.us';
  //   socketStatus.className = 'open';
  // };

  // Handle messages sent by the server.
  socket.onmessage = function(event) {
    var value = JSON.parse(event.data);
    messagesList.innerHTML += '

' +
                               value.message + '
'+value.username+'| 23rd June at 5:00pm

';
  };

  // // Show a disconnected message when the WebSocket is closed.
  // socket.onclose = function(event) {
  //   socketStatus.innerHTML = 'Disconnected from WebSocket.';
  //   socketStatus.className = 'closed';
  // };

  // Send a message when the form is submitted.
  form.onsubmit = function(e) {
    e.preventDefault();

    // Retrieve the message from the textarea.
    var json = {
        "message": messageField.value,
        "username": document.getElementById('loggedIn').getAttribute('uid'),
        "type": messageField.value
    };
    var message = JSON.stringify(json);

    // Send the message through the WebSocket.
    socket.send(message);

    // Add the message to the messages list.
    //messagesList.innerHTML += '
Sent:' + message +
                              //'
';

    // Clear out the message field.
    messageField.value = '';

    return false;
  };

};
<commit_msg>Date and Time<commit_after>$.get("/get/username", function(data) {
    parsedData = JSON.parse(data);
    $("#loggedIn").attr("uid", parsedData.username);
    $("#loggedIn").html("" + parsedData.username + "");
    //$("#logout").html("<form method=\"post\" action=\"/logout\"><button type=\"submit\">Logout</button></form>");
    $("#login").hide();
    $("#signup").hide();
    $("#loggedIn").show();
});

window.onload = function() {

  // Get references to elements on the page.
  var form = document.getElementById('message-form');
  var messageField = document.getElementById('message');
  var messagesList = document.getElementById('messages');
  //var socketStatus = document.getElementById('status');

  // Create a new WebSocket.
  var socket = new WebSocket('ws://ipp.chtr.us');

  // // Handle any errors that occur.
  // socket.onerror = function(error) {
  //   console.log('WebSocket Error: ' + error);
  // };

  // // Show a connected message when the WebSocket is opened.
  // socket.onopen = function(event) {
  //   socketStatus.innerHTML = 'Connected to: ws://ipp.chtr.us';
  //   socketStatus.className = 'open';
  // };

  // Handle messages sent by the server.
  socket.onmessage = function(event) {
    var value = JSON.parse(event.data);
    messagesList.innerHTML += '

' +
                               value.message + '
'+value.username+'| '+new Date($.now());+'

';
  };

  // // Show a disconnected message when the WebSocket is closed.
  // socket.onclose = function(event) {
  //   socketStatus.innerHTML = 'Disconnected from WebSocket.';
  //   socketStatus.className = 'closed';
  // };

  // Send a message when the form is submitted.
  form.onsubmit = function(e) {
    e.preventDefault();

    // Retrieve the message from the textarea.
    var json = {
        "message": messageField.value,
        "username": document.getElementById('loggedIn').getAttribute('uid'),
        "type": messageField.value
    };
    var message = JSON.stringify(json);

    // Send the message through the WebSocket.
    socket.send(message);

    // Add the message to the messages list.
    //messagesList.innerHTML += '
Sent:' + message +
                              //'
';

    // Clear out the message field.
    messageField.value = '';

    return false;
  };

};
<|endoftext|>


<commit_before>module.exports = {
  parser: "babel-eslint",
  extends: ["eslint:recommended", "airbnb-base"]
}
<commit_msg>chore: fix linting<commit_after>module.exports = {
  parser: 'babel-eslint',
  extends: ['eslint:recommended', 'airbnb-base'],
};
<|endoftext|>


<commit_before>(function() {
	var $urls = $('#urls'),
		$list = $('section .list'),
		urlRegEx = /http(s)?\:\/\/(www.)?instagram\.com\/p\/[A-Za-z0-9_-]+/gim;

	$urls.on('blur', function() {
		var value = this.value;
		var urls = (typeof value === 'string' && value.match(urlRegEx) || []);

		$list.empty();

		if (urls && urls.length > 0) {
			$.getJSON('/images', {urls: urls}, function(response) {
				if (response && response.length > 0) {
					$list.append($.map(response, function(o) {
						return $('<img>').attr({src: o, class: 'block instant'});
					}));
				}
			});
		}
	});
})();
<commit_msg>add download link to each image<commit_after>(function() {
	var $urls = $('#urls'),
		$list = $('section .list'),
		urlRegEx = /http(s)?\:\/\/(www.)?instagram\.com\/p\/[A-Za-z0-9_-]+/gim;

	$urls.on('blur', function() {
		var value = this.value;
		var urls = (typeof value === 'string' && value.match(urlRegEx) || []);

		$list.empty();

		if (urls && urls.length > 0) {
			$.getJSON('/images', {urls: urls}, function(response) {
				if (response && response.length > 0) {
					$list.append($.map(response, function(o) {
						$img = $('<img>').attr({src: o, class: 'block instant'});
						return $('<a>').attr({href: o, download: ''}).append($img);
					}));
				}
			});
		}
	});
})();
<|endoftext|>


<commit_before>$(document).ready(function(){
  var $columnArray = $(".column")

  //flip last row in each column face-up to start game
  $columnArray.each(function(col){
    $(this).children().last().removeClass("faceDown");
  })

  //select card on click
  $(".card").on("click", function(){
    var $this = $(this);

    if(!$this.hasClass("faceDown")){
      //select card and cards below
      $this.addClass("selected");
      $this.nextAll().addClass("selected");
    }
  });

});<commit_msg>separate out events for if there is a selection or not, and add logic to move cards between columns and flip cards face-up<commit_after>$(document).ready(function(){
  var $columnArray = $(".column")

  //flip last row in each column face-up to start game
  $columnArray.each(function(col){
    $(this).children().last().removeClass("faceDown");
  })

  //select card on click
  $(".card").on("click", function(){
    var $this = $(this);
    var $selected = $(".selected");

    if(!$this.hasClass("faceDown") && !$this.hasClass("blocked")){
      //for when nothing has been selected
      if($selected.length == 0){
        //select card and cards below
        $this.addClass("selected");
        $this.nextAll().addClass("selected");
      } else {
      // for when cards have been selected
        if($this.hasClass("selected")){
          //remove selected if clicked on selected
          $selected.removeClass("selected");
        } else {
          //move selected card to new column
          $selected.prev().removeClass("faceDown");
          $selected.appendTo($this.parent());
          $(".card").removeClass("selected");

        }
      }
    }
  });

});

//need to make reserve not-selectable<|endoftext|>


<commit_before>
module.exports = {
  "parser": "babel-eslint",
  "extends": [
    "airbnb"
  ],
  "plugins": [
    "babel",
    "react",
    "promise"
  ],
  "env": {
    "browser": true,
    "jest": true
  },
  "rules": {
    "arrow-parens": [1, "always"],
    "arrow-body-style": [1, "always"],
    "key-spacing": 0,
    "no-mixed-operators": 0,
    "no-param-reassign": 0,
    'prefer-destructuring': 0,
    'jsx-a11y/click-events-have-key-events': 0,
    'jsx-a11y/no-noninteractive-element-interactions': 0,
    'jsx-a11y/anchor-is-valid': 0,
    'jsx-a11y/label-has-for': 0,
    'jsx-a11y/label-has-associated-control': 0,

    // This rule transforms things like this
    // {seatsRemaining} / {seatsCapacity}
    // into this
    // {seatsRemaining}
    // /
    // {seatsCapacity}
    // which is less readable. If they allow it to keep short elements or inline elements on the same line, might re-enable in the future.
    'react/jsx-one-expression-per-line': 0,

    // Allow for-of loops.
    "no-restricted-syntax": [
      'error',
      {
        selector: 'LabeledStatement',
        message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
      },
      {
        selector: 'WithStatement',
        message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
      },
    ],

    // This rule requires that all class methods use this.
    // Disabling this allows making class methods that do not reference "this", which is helpful for private helper functions.
    "class-methods-use-this": 0,

    // The default ESLint rule here is to put propTypes below the class,
    // eg, EmailInput.propTypes = {...}
    // this rule change enforces that the are kept as static properties in the class.
    "react/static-property-placement": ["error", "static public field", {
      propTypes: "static public field",
    }],

    // The default for airbnb-eslint is to require the state to be above the constructor.
    // This changes the rule to ensure the state is always initiated in the constructore
    "react/state-in-constructor": [2, "always"],

    // This config disallows if(true) but allows while(true)
    "no-constant-condition": ["error", { "checkLoops": false }],
    "no-cond-assign": ["error", "except-parens"],
    "no-plusplus": [0, {
      "allowForLoopAfterthoughts": true
    }],

    // Prevents using variables before they are defined.
    "no-use-before-define": 1,
    "jsx-quotes": [2, "prefer-single"],
    "max-len": [2, 5000, 2],
    "object-shorthand": ["error", "never"],
    "object-curly-spacing": [2, "always"],
    "react/forbid-prop-types": 0,
    "react/no-danger": 1,
    "no-continue": 0,
    'react/destructuring-assignment': 0,

    // This rule always triggers on Windows...
    "import/no-unresolved": Number(process.env.OS !== 'Windows_NT') * 2,
    "spaced-comment": 0,
    "react/prefer-stateless-function": [1],
    "react/jsx-filename-extension": [1, {
      "extensions": [".js", ".jsx"]
    }],
    "react/jsx-curly-spacing": [2, "always", {
      "spacing": {
        "objectLiterals": "never"
      }
    }]
  }
}
<commit_msg>so far only domutils, amplitude, and airbnb eslint upgraded<commit_after>
module.exports = {
  "parser": "babel-eslint",
  "extends": [
    "airbnb"
  ],
  "plugins": [
    "babel",
    "react",
    "promise"
  ],
  "env": {
    "browser": true,
    "jest": true
  },
  "rules": {
    "arrow-parens": [1, "always"],
    "arrow-body-style": [1, "always"],
    "key-spacing": 0,
    "no-mixed-operators": 0,
    "no-param-reassign": 0,
    'prefer-destructuring': 0,
    'jsx-a11y/click-events-have-key-events': 0,
    'jsx-a11y/no-noninteractive-element-interactions': 0,
    'jsx-a11y/anchor-is-valid': 0,
    'jsx-a11y/label-has-for': 0,
    'jsx-a11y/label-has-associated-control': 0,

    // This rule transforms things like this
    // {seatsRemaining} / {seatsCapacity}
    // into this
    // {seatsRemaining}
    // /
    // {seatsCapacity}
    // which is less readable. If they allow it to keep short elements or inline elements on the same line, might re-enable in the future.
    'react/jsx-one-expression-per-line': 0,

    // Allow for-of loops.
    "no-restricted-syntax": [
      'error',
      {
        selector: 'LabeledStatement',
        message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
      },
      {
        selector: 'WithStatement',
        message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
      },
    ],

    // This rule requires that all class methods use this.
    // Disabling this allows making class methods that do not reference "this", which is helpful for private helper functions.
    "class-methods-use-this": 0,

    // The default ESLint rule here is to put propTypes below the class,
    // eg, EmailInput.propTypes = {...}
    // this rule change enforces that the are kept as static properties in the class.
    "react/static-property-placement": ["error", "static public field", {
      propTypes: "static public field",
    }],

    // The default for airbnb-eslint is to require the state to be above the constructor.
    // This changes the rule to ensure the state is always initiated in the constructore
    "react/state-in-constructor": [2, "always"],

    // This config disallows if(true) but allows while(true)
    "no-constant-condition": ["error", { "checkLoops": false }],
    "no-cond-assign": ["error", "except-parens"],
    "no-plusplus": [0, {
      "allowForLoopAfterthoughts": true
    }],

    // Prevents using variables before they are defined.
    "no-use-before-define": 1,
    "jsx-quotes": [2, "prefer-single"],
    "max-len": [2, 5000, 2],
    "object-shorthand": ["error", "never"],
    "object-curly-spacing": [2, "always"],
    "react/forbid-prop-types": 0,
    "react/no-danger": 1,
    "no-continue": 0,
    'react/destructuring-assignment': 0,

    // This rule always triggers on Windows...
    "import/no-unresolved": Number(process.env.OS !== 'Windows_NT') * 2,
    "spaced-comment": 0,
    "react/prefer-stateless-function": [1],
    "react/jsx-filename-extension": [1, {
      "extensions": [".js", ".jsx"]
    }],
    "react/jsx-curly-spacing": [2, "always", {
      "spacing": {
        "objectLiterals": "never"
      }
    }]
  }
}
<|endoftext|>


<commit_before>'use strict';

/*
 * Bootstrap Tanura.
 *
 * This script will bootstrap Tanura into an application.
 */

(function() {
    var baseUrl = /.*\//.exec(document.currentScript.src)[0];
    var request = new XMLHttpRequest();
    request.addEventListener('load', function() {
        var replaceScriptNodes = node => {
            if (node.tagName === 'SCRIPT') {
                var script  = document.createElement('script');
                script.text = node.innerHTML;
                for(var i = node.attributes.length - 1; i >= 0; i--) {
                    script.setAttribute(
                        node.attributes[i].name, node.attributes[i].value);
                }
                node.parentNode.replaceChild(script, node);
            } else {
                var childs = node.childNodes;
                for (var i = 0; i < childs.length; i++) {
                    replaceScriptNodes(childs[i]);
                }
            }
        }

        document.getElementsByTagName('body')[0].innerHTML += this.responseText;

        // Regenerate all script nodes in the new content, since they will not
        // be loaded otherwise.
        replaceScriptNodes(document.getElementById('tanura-src'));
    });
    request.responseType = 'text';
    request.open(
        'GET', baseUrl + 'tanura.html.frag?base=' + baseUrl);
    request.send();
})()

<commit_msg>Export essential information in tanura object.<commit_after>'use strict';

/*
 * Bootstrap Tanura.
 *
 * This script will bootstrap Tanura into an application.
 */

var tanura = {
    url: /.*\//.exec(document.currentScript.src)[0]
};

(function() {
    var request = new XMLHttpRequest();
    request.addEventListener('load', function() {
        var replaceScriptNodes = node => {
            if (node.tagName === 'SCRIPT') {
                var script  = document.createElement('script');
                script.text = node.innerHTML;
                for(var i = node.attributes.length - 1; i >= 0; i--) {
                    script.setAttribute(
                        node.attributes[i].name, node.attributes[i].value);
                }
                node.parentNode.replaceChild(script, node);
            } else {
                var childs = node.childNodes;
                for (var i = 0; i < childs.length; i++) {
                    replaceScriptNodes(childs[i]);
                }
            }
        }

        document.getElementsByTagName('body')[0].innerHTML += this.responseText;

        // Regenerate all script nodes in the new content, since they will not
        // be loaded otherwise.
        replaceScriptNodes(document.getElementById('tanura-src'));
    });
    request.responseType = 'text';
    request.open(
        'GET', tanura.url + 'tanura.html.frag?base=' + tanura.url);
    request.send();
})()

<|endoftext|>