<commit_before>import React, { PropTypes } from 'react';
import { Link } from 'react-router';
import _ from 'lodash';

import ProductDetailBanner from 'components/product/ProductDetailBanner';
import ProductDetailCart from 'components/product/ProductDetailCart';

import brandUtil from 'commons/utils/brandUtil';
import productUtil from 'commons/utils/productUtil';
import numberUtil from 'commons/utils/numberUtil';

export default React.createClass({
  propTypes: {
    product: PropTypes.object,
    images: PropTypes.array,
    variants: PropTypes.array,
    showCart: PropTypes.bool.isRequired,
    toggleCart: PropTypes.func.isRequired,
    colors: PropTypes.array,
    sizes: PropTypes.array,
    currentColor: PropTypes.string,
    currentSize: PropTypes.string,
    currentVariant: PropTypes.string,
    setColor: PropTypes.func.isRequired,
    setSize: PropTypes.func.isRequired,
    addCart: PropTypes.func.isRequired,
    buyNow: PropTypes.func.isRequired,
    addWish: PropTypes.func.isRequired,
    addFavorite: PropTypes.func.isRequired,
  },
  contextTypes: {
    activeLocale: PropTypes.string,
    activeCurrency: PropTypes.string,
    currencySign: PropTypes.object,
  },
  getInitialState() {
    return {};
  },
  handleFavorite(brandId) {
    this.props.addFavorite(brandId);
    $('.add-favorite').addClass('active');
  },
  render() {
    const { product, images, showCart, variants, colors, sizes,
      currentColor, currentSize, currentVariant } = this.props;
    const { activeCurrency, currencySign } = this.context;
    if (!product || !Object.keys(product).length) {
      return (

        );
    }

    const renderBrand = () => {
      if (product && product.brand && product.brand.data) {
        return (

          <Link to={`/brands/${product.brand.id}`}>
            {brandUtil.getName(product.brand)}

              {brandUtil.getBuildingInfo(product.brand)}

            { /*

              94.7% positive feedback the past

 */ }
          </Link>

 this.handleFavorite(product.brand.id)}>단골 브랜드

        );
      }
      return null;
    };
    const setColor = (color) => {
      if (currentColor !== color.color) {
        (images || []).forEach((image, index) => {
          if (image.url === _.get(color.variant, 'appImages.default[0].url')) {
            // does not work
            // $('.owl-carousel').trigger('owl.goTo', index);
            // this.refs.carousel.goTo(3);
            // 2016. 06. 07. [heekyu] does not work without timeout
            setTimeout(() => {
              // this.refs.banner.goTo(index);
              $('.owl-carousel').trigger('owl.goTo', index);
            }, 100);
          }
        });
      }
      this.props.setColor(color.color);
    };

    return (

        <ProductDetailBanner ref="banner" images={images} addWish={this.props.addWish} />

{productUtil.getName(product)}

            {numberUtil.formatPrice(product[activeCurrency], activeCurrency, currencySign)}

        {renderBrand()}

        <ProductDetailCart show={showCart} toggle={this.props.toggleCart} images={images}
          currentColor={currentColor} currentSize={currentSize} currentVariant={currentVariant}
          variants={variants} colors={colors} sizes={sizes} setColor={setColor} setSize={this.props.setSize}
          addCart={this.props.addCart} buyNow={this.props.buyNow} product={product}
        />

    );
  },
});
<commit_msg>m - i18n<commit_after>import React, { PropTypes } from 'react';
import { Link } from 'react-router';
import _ from 'lodash';

import ProductDetailBanner from 'components/product/ProductDetailBanner';
import ProductDetailCart from 'components/product/ProductDetailCart';

import brandUtil from 'commons/utils/brandUtil';
import productUtil from 'commons/utils/productUtil';
import numberUtil from 'commons/utils/numberUtil';
import i18n from 'commons/utils/i18n';

export default React.createClass({
  propTypes: {
    product: PropTypes.object,
    images: PropTypes.array,
    variants: PropTypes.array,
    showCart: PropTypes.bool.isRequired,
    toggleCart: PropTypes.func.isRequired,
    colors: PropTypes.array,
    sizes: PropTypes.array,
    currentColor: PropTypes.string,
    currentSize: PropTypes.string,
    currentVariant: PropTypes.string,
    setColor: PropTypes.func.isRequired,
    setSize: PropTypes.func.isRequired,
    addCart: PropTypes.func.isRequired,
    buyNow: PropTypes.func.isRequired,
    addWish: PropTypes.func.isRequired,
    addFavorite: PropTypes.func.isRequired,
  },
  contextTypes: {
    activeLocale: PropTypes.string,
    activeCurrency: PropTypes.string,
    currencySign: PropTypes.object,
  },
  getInitialState() {
    return {};
  },
  handleFavorite(brandId) {
    this.props.addFavorite(brandId);
    $('.add-favorite').addClass('active');
  },
  render() {
    const { product, images, showCart, variants, colors, sizes,
      currentColor, currentSize, currentVariant } = this.props;
    const { activeCurrency, currencySign } = this.context;
    if (!product || !Object.keys(product).length) {
      return (

        );
    }

    const renderBrand = () => {
      if (product && product.brand && product.brand.data) {
        return (

          <Link to={`/brands/${product.brand.id}`}>
            {brandUtil.getName(product.brand)}

              {brandUtil.getBuildingInfo(product.brand)}

            { /*

              94.7% positive feedback the past

 */ }
          </Link>

 this.handleFavorite(product.brand.id)}>{i18n.get('pcItemDetail.favoriteBrands')}

        );
      }
      return null;
    };
    const setColor = (color) => {
      if (currentColor !== color.color) {
        (images || []).forEach((image, index) => {
          if (image.url === _.get(color.variant, 'appImages.default[0].url')) {
            // does not work
            // $('.owl-carousel').trigger('owl.goTo', index);
            // this.refs.carousel.goTo(3);
            // 2016. 06. 07. [heekyu] does not work without timeout
            setTimeout(() => {
              // this.refs.banner.goTo(index);
              $('.owl-carousel').trigger('owl.goTo', index);
            }, 100);
          }
        });
      }
      this.props.setColor(color.color);
    };

    return (

        <ProductDetailBanner ref="banner" images={images} addWish={this.props.addWish} />

{productUtil.getName(product)}

            {numberUtil.formatPrice(product[activeCurrency], activeCurrency, currencySign)}

        {renderBrand()}

        <ProductDetailCart show={showCart} toggle={this.props.toggleCart} images={images}
          currentColor={currentColor} currentSize={currentSize} currentVariant={currentVariant}
          variants={variants} colors={colors} sizes={sizes} setColor={setColor} setSize={this.props.setSize}
          addCart={this.props.addCart} buyNow={this.props.buyNow} product={product}
        />

    );
  },
});
<|endoftext|>


<commit_before>// =================================================================
// Logtalk - Object oriented extension to Prolog
// Release 2.19.2
//
// Copyright (c) 1998-2004 Paulo Moura.  All Rights Reserved.
// =================================================================

var WshSysEnv = WshShell.Environment("SYSTEM");
var WshUserEnv = WshShell.Environment("USER");

if (!WshSysEnv.Item("LOGTALKHOME") && !WshUserEnv.Item("LOGTALKHOME")) {
	WScript.Echo("The environment variable LOGTALKHOME must be defined first!");
	WScript.Quit;
}

var html_xslt = WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\lgthtml.xsl";
var xhtml_xslt = WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\lgtxhtml.xsl";
var xslt;

var format = "xhtml";
// var format = "html";

var WshShell = WScript.CreateObject("WScript.Shell");
var directory = WshShell.CurrentDirectory;

var index_file = "index.html";
var title = "Entity documentation index";

var processor = "xsltproc";
// var processor = "xalan";
// var processor = "sabcmd";

var arguments = WScript.Arguments.Unnamed;

if (arguments.Exists("help")) {
	usage_help();
}

arguments = WScript.Arguments.Named;

if (arguments.Exists("f"))
	format = arguments.Item("f");

if (arguments.Exists("d"))
	directory = arguments.Item("d");

if (arguments.Exists("i"))
	index_file = arguments.Item("i");

if (arguments.Exists("t"))
	title = arguments.Item("t");

if (arguments.Exists("p"))
	processor = arguments.Item("p");

if (format = "xhtml")
	xslt = xhtml_xslt;
else if (format = "html")
	xslt = html_xslt;
else {
	WScript.Echo("unsupported output format: " + format);
	usage_help;
	WScript.Quit(1);
}

if (processor != "xsltproc" && processor != "xalan" && processor != "sabcmd") {
	WScript.Echo("unsupported XSLT processor:" + processor);
	WScript.Echo("");
	WScript.Quit(1);
}

var fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CopyFile(WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\logtalk.dtd", WshShell.CurrentDirectory);
fso.CopyFile(WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\logtalk.xsd", WshShell.CurrentDirectory);
fso.CopyFile(WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\logtalk.css", directory);

WScript.Echo("");
WScript.Echo("converting XML files...");

var files = WshShell.CurrentDirectory.Files;

for (file in files)
	if (file.Extension = ".xml") {
		WScript.Echo("  converting" + file.Name);
		switch (processor) {
			case "xsltproc" :
				WshShell.Run(xsltproc + " -o " + directory + "\\" + file.FileName + ".html" + xslt + " "+ file.Name, true);
			case "xalan" :
				WshShell.Run(xalan + " -o " +  + directory + "\\" + file.FileName + ".html" + " " + xslt, true);
			case "sabcmd" :
				WshShell.Run(sabcmd + " " + xslt + " " + file + " " + directory + "\\" + file.FileName + ".html", true);
	}

WScript.Echo("conversion done");
WScript.Echo("");
WScript.Echo("generating index file...");

index_file = directory + "\\" + index_file;

switch (format) {
	case "xhtml" :	xhtml_index_file();
	case "html" :	html_index_file();
}

WScript.Echo("index file generated");
WScript.Echo("");

fso.DeleteFile("logtalk.dtd");
fso.DeleteFile("logtalk.xsd");

WScript.Quit(0);

function usage_help() {
	WScript.Echo("");
	WScript.Echo("This script converts all Logtalk XML files documenting files in the");
	WScript.Echo("current directory to XHTML or HTML files");
	WScript.Echo("");
	WScript.Echo("Usage: " + WScript.Name + " [help] [/f:format] [/o:directory] [/i:index] [/t:title] [/p:processor]");
	WScript.Echo("");
	WScript.Echo("Optional arguments:");
	WScript.Echo("  f - output file format (either xhtml or html; default is " + format + ")");
	WScript.Echo("  o - output directory for the generated files (default is " + directory + ")");
	WScript.Echo("  i - name of the index file (default is " + index_file + ")");
	WScript.Echo("  t - title to be used on the index file (default is " + title + ")");
	WScript.Echo("  p - XSLT processor (xsltproc, xalan, or sabcmd; default is " + processor + ")");
	WScript.Echo("  help - print usage help");
	WScript.Echo("");
	WScript.Quit(1);
}

function xhtml_index_file() {

	var f = fso.CreateTextFile(directory + "\\" + index_file, true);

	f.WriteLine("<?xml version=\"1.0\"?>");
	f.WriteLine("<?xml-stylesheet href=\"logtalk.css\" type=\"text/css\"?>");
	f.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("    <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>");
	f.WriteLine("    <title>" + title + "</title>");
	f.WriteLine("    <link rel=\"stylesheet\" href=\"logtalk.css\" type=\"text/css\"/>");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("
" + title + "
");
	f.WriteLine("
");

	var files = WshShell.CurrentDirectory.Files;
	var file;

	for (file in files)
		if (file.Extension = ".xml") {
			WScript.Echo("  indexing" + file.FileName + ".html");
			f.WriteLine("
" + file.FileName + "
");
		}

	f.WriteLine("
");

	var today = new Date();
	var year  = today.getFullYear();
	var month = today.getMonth() + 1;
	if (month < 10) {
        month = "0" + month;
	};
	day   = today.getDate();
	if (day < 10) {
        day = "0" + day;
	};
	strToday = year + "/" + month + "/" + day;
	f.WriteLine("
Generated on " + strToday + "
");

	f.WriteLine("");
	f.WriteLine("");

	f.Close();
}

function html_index_file() {

	var a = fso.CreateTextFile(directory + "\\" + index_file, true);

	f.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
	f.WriteLine("    <title>"$title"</title>");
	f.WriteLine("    <link rel=\"stylesheet\" href=\"logtalk.css\" type=\"text/css\">");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("
"$title"
");
	f.WriteLine("
");

	var files = WshShell.CurrentDirectory.Files;
	var file;

	for (file in files)
		if (file.Extension = ".xml") {
			WScript.Echo("  indexing" + file.FileName + ".html");
			f.WriteLine("
" + file.FileName + "
");
		}

	f.WriteLine("
");

	var today = new Date();
	var year  = today.getFullYear();
	var month = today.getMonth() + 1;
	if (month < 10) {
        month = "0" + month;
	};
	var day   = today.getDate();
	if (day < 10) {
        day = "0" + day;
	};
	var strToday = year + "/" + month + "/" + day;
	f.WriteLine("
Generated on " + strToday + "
");

	f.WriteLine("");
	f.WriteLine("");

	f.Close();
}
<commit_msg>More syntax fixes.<commit_after>// =================================================================
// Logtalk - Object oriented extension to Prolog
// Release 2.19.2
//
// Copyright (c) 1998-2004 Paulo Moura.  All Rights Reserved.
// =================================================================

var WshSysEnv = WshShell.Environment("SYSTEM");
var WshUserEnv = WshShell.Environment("USER");

if (!WshSysEnv.Item("LOGTALKHOME") && !WshUserEnv.Item("LOGTALKHOME")) {
	WScript.Echo("The environment variable LOGTALKHOME must be defined first!");
	WScript.Quit;
}

var html_xslt = WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\lgthtml.xsl";
var xhtml_xslt = WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\lgtxhtml.xsl";
var xslt;

var format = "xhtml";
// var format = "html";

var WshShell = WScript.CreateObject("WScript.Shell");
var directory = WshShell.CurrentDirectory;

var index_file = "index.html";
var title = "Entity documentation index";

var processor = "xsltproc";
// var processor = "xalan";
// var processor = "sabcmd";

var arguments = WScript.Arguments.Unnamed;

if (arguments.Exists("help")) {
	usage_help();
}

arguments = WScript.Arguments.Named;

if (arguments.Exists("f"))
	format = arguments.Item("f");

if (arguments.Exists("d"))
	directory = arguments.Item("d");

if (arguments.Exists("i"))
	index_file = arguments.Item("i");

if (arguments.Exists("t"))
	title = arguments.Item("t");

if (arguments.Exists("p"))
	processor = arguments.Item("p");

if (format = "xhtml")
	xslt = xhtml_xslt;
else if (format = "html")
	xslt = html_xslt;
else {
	WScript.Echo("unsupported output format: " + format);
	usage_help;
	WScript.Quit(1);
}

if (processor != "xsltproc" && processor != "xalan" && processor != "sabcmd") {
	WScript.Echo("unsupported XSLT processor:" + processor);
	WScript.Echo("");
	WScript.Quit(1);
}

var fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CopyFile(WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\logtalk.dtd", WshShell.CurrentDirectory);
fso.CopyFile(WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\logtalk.xsd", WshShell.CurrentDirectory);
fso.CopyFile(WshShell.ExpandEnvironmentStrings("%LOGTALKHOME%") + "\\xml\\logtalk.css", directory);

WScript.Echo("");
WScript.Echo("converting XML files...");

var files = WshShell.CurrentDirectory.Files;

for (file in files)
	if (file.Extension = ".xml") {
		WScript.Echo("  converting" + file.Name);
		switch (processor) {
			case "xsltproc" :
				WshShell.Run(xsltproc + " -o " + directory + "\\" + file.FileName + ".html" + xslt + " "+ file.Name, true);
			case "xalan" :
				WshShell.Run(xalan + " -o " +  + directory + "\\" + file.FileName + ".html" + " " + xslt, true);
			case "sabcmd" :
				WshShell.Run(sabcmd + " " + xslt + " " + file + " " + directory + "\\" + file.FileName + ".html", true);
	}

WScript.Echo("conversion done");
WScript.Echo("");
WScript.Echo("generating index file...");

index_file = directory + "\\" + index_file;

switch (format) {
	case "xhtml" :	xhtml_index_file();
	case "html" :	html_index_file();
}

WScript.Echo("index file generated");
WScript.Echo("");

fso.DeleteFile("logtalk.dtd");
fso.DeleteFile("logtalk.xsd");

WScript.Quit(0);

function usage_help() {
	WScript.Echo("");
	WScript.Echo("This script converts all Logtalk XML files documenting files in the");
	WScript.Echo("current directory to XHTML or HTML files");
	WScript.Echo("");
	WScript.Echo("Usage: " + WScript.Name + " [help] [/f:format] [/o:directory] [/i:index] [/t:title] [/p:processor]");
	WScript.Echo("");
	WScript.Echo("Optional arguments:");
	WScript.Echo("  f - output file format (either xhtml or html; default is " + format + ")");
	WScript.Echo("  o - output directory for the generated files (default is " + directory + ")");
	WScript.Echo("  i - name of the index file (default is " + index_file + ")");
	WScript.Echo("  t - title to be used on the index file (default is " + title + ")");
	WScript.Echo("  p - XSLT processor (xsltproc, xalan, or sabcmd; default is " + processor + ")");
	WScript.Echo("  help - print usage help");
	WScript.Echo("");
	WScript.Quit(1);
}

function xhtml_index_file() {

	var f = fso.CreateTextFile(directory + "\\" + index_file, true);

	f.WriteLine("<?xml version=\"1.0\"?>");
	f.WriteLine("<?xml-stylesheet href=\"logtalk.css\" type=\"text/css\"?>");
	f.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("    <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>");
	f.WriteLine("    <title>" + title + "</title>");
	f.WriteLine("    <link rel=\"stylesheet\" href=\"logtalk.css\" type=\"text/css\"/>");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("
" + title + "
");
	f.WriteLine("
");

	var files = WshShell.CurrentDirectory.Files;
	var file;

	for (file in files)
		if (file.Extension = ".xml") {
			WScript.Echo("  indexing" + file.FileName + ".html");
			f.WriteLine("
" + file.FileName + "
");
		}

	f.WriteLine("
");

	var today = new Date();
	var year  = today.getFullYear();
	var month = today.getMonth() + 1;
	if (month < 10) {
        month = "0" + month;
	};
	day   = today.getDate();
	if (day < 10) {
        day = "0" + day;
	};
	strToday = year + "/" + month + "/" + day;
	f.WriteLine("
Generated on " + strToday + "
");

	f.WriteLine("");
	f.WriteLine("");

	f.Close();
}

function html_index_file() {

	var a = fso.CreateTextFile(directory + "\\" + index_file, true);

	f.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
	f.WriteLine("    <title>" + title + "</title>");
	f.WriteLine("    <link rel=\"stylesheet\" href=\"logtalk.css\" type=\"text/css\">");
	f.WriteLine("");
	f.WriteLine("");
	f.WriteLine("
" + title + "
");
	f.WriteLine("
");

	var files = WshShell.CurrentDirectory.Files;
	var file;

	for (file in files)
		if (file.Extension = ".xml") {
			WScript.Echo("  indexing" + file.FileName + ".html");
			f.WriteLine("
" + file.FileName + "
");
		}

	f.WriteLine("
");

	var today = new Date();
	var year  = today.getFullYear();
	var month = today.getMonth() + 1;
	if (month < 10) {
        month = "0" + month;
	};
	var day   = today.getDate();
	if (day < 10) {
        day = "0" + day;
	};
	var strToday = year + "/" + month + "/" + day;
	f.WriteLine("
Generated on " + strToday + "
");

	f.WriteLine("");
	f.WriteLine("");

	f.Close();
}
<|endoftext|>


<commit_before>'use strict';

var path = require('path');

module.exports = function(grunt) {
  grunt.registerMultiTask('vjslanguages', 'A Grunt plugin for compiling VideoJS language assets.', function() {

    this.files.forEach(function(f) {
      var languageName = path.basename(f.src, '.json');
      var languageData = grunt.file.readJSON(f.src);
      var jsTemplate = 'videojs.addLanguage("' + languageName + '",' + JSON.stringify(languageData,null,' ') + ');';
      var jsFilePath = path.join(f.dest, languageName + '.js');
      grunt.file.write(jsFilePath, jsTemplate);
      grunt.log.writeln('- [' + languageName +'] Language Built. File "' + jsFilePath + '" created.');
    });
  });
};
<commit_msg>add array support<commit_after>'use strict';

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

module.exports = function(grunt) {
  grunt.registerMultiTask('vjslanguages', 'A Grunt plugin for compiling VideoJS language assets.', function() {
    this.files.forEach(function(f) {
      var languageName, languageData, jsTemplate, jsFilePath;
      // Multiple Files Case
      if(util.isArray(f.src)){
        for(var i =0; i < f.src.length; i++) {
          console.log('-', f.src[i], f.dest);
          languageName = path.basename(f.src[i], '.json');
          languageData = grunt.file.readJSON(f.src[i]);
          jsTemplate = 'videojs.addLanguage("' + languageName + '",' + JSON.stringify(languageData,null,' ') + ');';
          jsFilePath = path.join(f.dest, languageName + '.js');
          grunt.file.write(jsFilePath, jsTemplate);
          grunt.log.writeln('- [' + languageName +'] Language Built. File "' + jsFilePath + '" created.');
        }
      }
      // Singular File Case
      else {
        languageName = path.basename(f.src, '.json');
        languageData = grunt.file.readJSON(f.src);
        jsTemplate = 'videojs.addLanguage("' + languageName + '",' + JSON.stringify(languageData,null,' ') + ');';
        jsFilePath = path.join(f.dest, languageName + '.js');
        grunt.file.write(jsFilePath, jsTemplate);
        grunt.log.writeln('- [' + languageName +'] Language Built. File "' + jsFilePath + '" created.');
      }
    });
  });
};<|endoftext|>


<commit_before>"use strict";

window.SVGURL = "http://www.w3.org/2000/svg";

class gsuiPeriodicWave {
	constructor( svg ) {
		const root = svg || document.createElementNS( SVGURL, "svg" );

		this.rootElement = root;
		root.setAttribute( "preserveAspectRatio", "none" );
		root.classList.add( "gsuiPeriodicWave" );
		this.polyline = root.querySelector( "polyline" );
		if ( !this.polyline ) {
			this.polyline = document.createElementNS( SVGURL, "polyline" );
			root.appendChild( this.polyline );
		}
		this.amplitude = 1;
		this.frequency = 1;
		this.attack = 0;
	}

	remove() {
		delete this._attached;
		this.rootElement.remove();
	}
	attached() {
		this._attached = true;
		this.resized();
	}
	resized() {
		const bcr = this.rootElement.getBoundingClientRect();

		this.rootElement.setAttribute( "viewBox", `0 0 ${
			this.width = ~~bcr.width } ${
			this.height = ~~bcr.height }` );
		if ( this.type ) {
			this.draw();
		}
	}
	draw() {
		const w = this.width,
			h2 = this.height / 2,
			hz = this.frequency,
			amp = -this.amplitude * h2,
			attEnd = w / hz * this.attack,
			wave = gsuiPeriodicWave.cache[ this.type ],
			pts = new Float32Array( w * 2 );

		if ( !wave ) {
			console.error( `ERROR: gsuiPeriodicWave: the wave "${ this.type }" is undefined...` );
		} else if ( this._attached ) {
			for ( let x = 0; x < w; ++x ) {
				pts[ x * 2 ] = x;
				pts[ x * 2 + 1 ] = h2 + wave[ ~~( x / w * 256 * hz % 256 ) ]
					* amp * ( x < attEnd ? x / attEnd : 1 );
			}
			this.polyline.setAttribute( "points", pts.join( " " ) );
		}
	}

	// static:
	static getXFromWave( a, b, t ) {
		return a.reduce( ( val, ak, k ) => {
			const tmp = Math.PI * 2 * k * t;

			return val + ak * Math.cos( tmp ) + b[ k ] * Math.sin( tmp );
		}, 0 );
	}
	static addWave( name, real, imag ) {
		const cache = gsuiPeriodicWave.cache;

		if ( !cache[ name ] ) {
			const arr = [],
				fn = gsuiPeriodicWave.getXFromWave.bind( null, real, imag );

			for ( let x = 0; x < 256; ++x ) {
				arr.push( fn( x / 256 ) );
			}
			cache[ name ] = arr;
		}
	}
}

gsuiPeriodicWave.cache = {};
<commit_msg>gsuiPeriodicWave: no more window.SVGURL<commit_after>"use strict";

class gsuiPeriodicWave {
	constructor( svg ) {
		const root = svg || document.createElementNS( "http://www.w3.org/2000/svg", "svg" );

		this.rootElement = root;
		root.setAttribute( "preserveAspectRatio", "none" );
		root.classList.add( "gsuiPeriodicWave" );
		this.polyline = root.querySelector( "polyline" );
		if ( !this.polyline ) {
			this.polyline = document.createElementNS( "http://www.w3.org/2000/svg", "polyline" );
			root.appendChild( this.polyline );
		}
		this.amplitude = 1;
		this.frequency = 1;
		this.attack = 0;
	}

	remove() {
		delete this._attached;
		this.rootElement.remove();
	}
	attached() {
		this._attached = true;
		this.resized();
	}
	resized() {
		const bcr = this.rootElement.getBoundingClientRect();

		this.rootElement.setAttribute( "viewBox", `0 0 ${
			this.width = ~~bcr.width } ${
			this.height = ~~bcr.height }` );
		if ( this.type ) {
			this.draw();
		}
	}
	draw() {
		const w = this.width,
			h2 = this.height / 2,
			hz = this.frequency,
			amp = -this.amplitude * h2,
			attEnd = w / hz * this.attack,
			wave = gsuiPeriodicWave.cache[ this.type ],
			pts = new Float32Array( w * 2 );

		if ( !wave ) {
			console.error( `ERROR: gsuiPeriodicWave: the wave "${ this.type }" is undefined...` );
		} else if ( this._attached ) {
			for ( let x = 0; x < w; ++x ) {
				pts[ x * 2 ] = x;
				pts[ x * 2 + 1 ] = h2 + wave[ ~~( x / w * 256 * hz % 256 ) ]
					* amp * ( x < attEnd ? x / attEnd : 1 );
			}
			this.polyline.setAttribute( "points", pts.join( " " ) );
		}
	}

	// static:
	static getXFromWave( a, b, t ) {
		return a.reduce( ( val, ak, k ) => {
			const tmp = Math.PI * 2 * k * t;

			return val + ak * Math.cos( tmp ) + b[ k ] * Math.sin( tmp );
		}, 0 );
	}
	static addWave( name, real, imag ) {
		const cache = gsuiPeriodicWave.cache;

		if ( !cache[ name ] ) {
			const arr = [],
				fn = gsuiPeriodicWave.getXFromWave.bind( null, real, imag );

			for ( let x = 0; x < 256; ++x ) {
				arr.push( fn( x / 256 ) );
			}
			cache[ name ] = arr;
		}
	}
}

gsuiPeriodicWave.cache = {};
<|endoftext|>


<commit_before>var LoggedInHandler = (function() {
    "use strict";

    var init = function() {
        parent.window['is_logging_in'] = 1; // this flag is used in base.js to prevent auto-reloading this page
        var redirect_url;
        try {
            var tokens  = storeTokens(),
                loginid = $.cookie('loginid');

            if(!$.cookie('loginid')) { // redirected to another domain (e.g. github.io) so those cookie are not accessible here
                var loginids = Object.keys(tokens);
                var loginid_list = '';
                loginids.map(function(id) {
                    loginid_list += (loginid_list ? '+' : '') + id + ':' + (/^V/i.test(id) ? 'V' : 'R') + ':E'; // since there is not any data source to check, so assume all are enabled, disabled accounts will be handled on authorize
                });
                loginid = loginids[0];
                // set cookies
                page.client.set_cookie('loginid'     , loginid);
                page.client.set_cookie('loginid_list', loginid_list);
            }
            page.client.set_cookie('login', tokens[loginid]);

            // set flags
            sessionStorage.setItem('check_tnc', '1');
            if (!$('body').hasClass('BlueTopBack')) localStorage.setItem('risk_classification', 'check');
            GTM.set_login_flag();

            // redirect url
            redirect_url = sessionStorage.getItem('redirect_url');
            sessionStorage.removeItem('redirect_url');
        } catch(e) {console.log('storage is not supported');}

        // redirect back
        var set_default = true;
        if(redirect_url) {
            var do_not_redirect = ['reset_passwordws', 'lost_passwordws', 'change_passwordws', 'home'];
            var reg = new RegExp(do_not_redirect.join('|'), 'i');
            if(!reg.test(redirect_url) && page.url.url_for('') !== redirect_url) {
                set_default = false;
            }
        }
        if(set_default) {
            redirect_url = page.url.default_redirect_url();
            var lang_cookie = $.cookie('language');
            if(lang_cookie && lang_cookie !== page.language()) {
                redirect_url = redirect_url.replace(new RegExp('\/' + page.language() + '\/', 'i'), '/' + lang_cookie.toLowerCase() + '/');
            }
        }
        document.getElementById('loading_link').setAttribute('href', redirect_url);
        window.location.href = redirect_url;
    };

    var storeTokens = function() {
        // Parse hash for loginids and tokens returned by OAuth
        var hash = window.location.search.substr(1).split('&');
        var tokens = {};
        for(var i = 0; i < hash.length; i += 2) {
            var loginid = getHashValue(hash[i], 'acct');
            var token = getHashValue(hash[i+1], 'token');
            if(loginid && token) {
                tokens[loginid] = token;
            }
        }
        if(Object.keys(tokens).length > 0) {
            page.client.set_storage_value('tokens', JSON.stringify(tokens));
        }
        return tokens;
    };

    var getHashValue = function(source, key) {
        var match = new RegExp('^' + key);
        return source && source.length > 0 ? (match.test(source.split('=')[0]) ? source.split('=')[1] : '') : '';
    };

    return {
        init: init,
    };
}());
<commit_msg>Maintain compatibility for both versions<commit_after>var LoggedInHandler = (function() {
    "use strict";

    var init = function() {
        parent.window['is_logging_in'] = 1; // this flag is used in base.js to prevent auto-reloading this page
        var redirect_url;
        try {
            var tokens  = storeTokens(),
                loginid = $.cookie('loginid');

            if(!$.cookie('loginid')) { // redirected to another domain (e.g. github.io) so those cookie are not accessible here
                var loginids = Object.keys(tokens);
                var loginid_list = '';
                loginids.map(function(id) {
                    loginid_list += (loginid_list ? '+' : '') + id + ':' + (/^V/i.test(id) ? 'V' : 'R') + ':E'; // since there is not any data source to check, so assume all are enabled, disabled accounts will be handled on authorize
                });
                loginid = loginids[0];
                // set cookies
                page.client.set_cookie('loginid'     , loginid);
                page.client.set_cookie('loginid_list', loginid_list);
            }
            page.client.set_cookie('login', tokens[loginid]);

            // set flags
            sessionStorage.setItem('check_tnc', '1');
            if (!$('body').hasClass('BlueTopBack')) localStorage.setItem('risk_classification', 'check');
            GTM.set_login_flag();

            // redirect url
            redirect_url = sessionStorage.getItem('redirect_url');
            sessionStorage.removeItem('redirect_url');
        } catch(e) {console.log('storage is not supported');}

        // redirect back
        var set_default = true;
        if(redirect_url) {
            var do_not_redirect = ['reset_passwordws', 'lost_passwordws', 'change_passwordws', 'home'];
            var reg = new RegExp(do_not_redirect.join('|'), 'i');
            if(!reg.test(redirect_url) && page.url.url_for('') !== redirect_url) {
                set_default = false;
            }
        }
        if(set_default) {
            redirect_url = page.url.default_redirect_url();
            var lang_cookie = $.cookie('language');
            if(lang_cookie && lang_cookie !== page.language()) {
                redirect_url = redirect_url.replace(new RegExp('\/' + page.language() + '\/', 'i'), '/' + lang_cookie.toLowerCase() + '/');
            }
        }
        document.getElementById('loading_link').setAttribute('href', redirect_url);
        window.location.href = redirect_url;
    };

    var storeTokens = function() {
        // Parse hash for loginids and tokens returned by OAuth
        var hash = (/acct1/i.test(window.location.hash) ? window.location.hash : window.location.search).substr(1).split('&'); // to maintain compatibility till backend change released
        var tokens = {};
        for(var i = 0; i < hash.length; i += 2) {
            var loginid = getHashValue(hash[i], 'acct');
            var token = getHashValue(hash[i+1], 'token');
            if(loginid && token) {
                tokens[loginid] = token;
            }
        }
        if(Object.keys(tokens).length > 0) {
            page.client.set_storage_value('tokens', JSON.stringify(tokens));
        }
        return tokens;
    };

    var getHashValue = function(source, key) {
        var match = new RegExp('^' + key);
        return source && source.length > 0 ? (match.test(source.split('=')[0]) ? source.split('=')[1] : '') : '';
    };

    return {
        init: init,
    };
}());
<|endoftext|>


<commit_before>class CheckValues {
  static isEmpty(value) {
    return value === '' || value === null || typeof value === undefined
  }

  static isEmail(value) {
    if (this.isEmpty(value)) {
      return false
    }
    return value.match(/^[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)
  }

  static isPhone(value) {
    if (this.isEmpty(value)) {
      return false
    }
    return (value.replace(/[^\d]/g, '').length == 10)
  }

  static randomId() {
    return (Math.random().toString(36) + '00000000000000000').slice(2, 10)
  }
}

export default CheckValues
<commit_msg>added isurl function<commit_after>class CheckValues {
  static isEmpty(value) {
    return value === '' || value === null || typeof value === undefined
  }

  static isEmail(value) {
    if (this.isEmpty(value)) {
      return false
    }
    return value.match(/^[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)
  }

  static isPhone(value) {
    if (this.isEmpty(value)) {
      return false
    }
    return (value.replace(/[^\d]/g, '').length == 10)
  }

  static isUrl(value, httpRequired=false)
  {
    if (httpRequired) {
      return value.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/)
    } else {
      return value.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/)
    }
  }

  static randomId() {
    return (Math.random().toString(36) + '00000000000000000').slice(2, 10)
  }
}

export default CheckValues
<|endoftext|>


<commit_before>GameController = Class.create(Sprite, {
  initialize: function(scene) {
    Sprite.call(this, 0, 0);
    this.image = game.assets['images/square_glow.png'];
    this.x = -10;
    this.y = -10;
    this.scene = scene;

    this.level = 0;
    this.maxLevel = false;
    this.enemyChoiceTotalWeight = 0;

    this.spamming = false;
    this.spamClass = "";
    this.spamCount = 0;

    this.levels = [
      // LEVEL 0
      {
        score: 0,
        spawn_rate: 60,
        level_end_spam: ['Triangle', 7],
        enemies: [
          ['Triangle', 50],
          ['Square', 40],
          ['Worm', 90]
        ]
      },

      // LEVEL 1
      {
        score: 400,
        spawn_rate: 40,
        level_end_spam: ['Square', 5],
        enemies: [
          ['Triangle', 18],
          ['Circle', 20],
          ['Square', 40]
        ]
      },

      // LEVEL 2
      {
        score: 1400,
        spawn_rate: 40,
        level_end_spam: ['Circle', 2],
        enemies: [
          ['Triangle', 18],
          ['Circle', 20],
          ['Square', 40],
          ['Worm', 15]
        ]
      },

      // LEVEL 3
      {
        score: 2200,
        spawn_rate: 40,
        level_end_spam: ['Circle', 1],
        enemies: [
          ['Triangle', 18],
          ['Circle', 10],
          ['Square', 40],
          ['Worm', 25]
        ]
      },

      // LEVEL 4
      {
        score: 3000,
        spawn_rate: 40,
        enemies: [
          ['Triangle', 18],
          ['Circle', 30],
          ['Square', 10],
          ['Worm', 30]
        ]
      }
    ];

    this.corners = [
      [0, 0],
      [game.width, 0],
      [game.width, game.height],
      [0, game.height]
    ];

    this.setEnemyChoiceTotalWeight();
  },

  onenterframe: function() {
    // Spam if needed
    if (this.spamming) {
      if (this.age % 15 === 0)
        this.sendWave();
      return;
    }

    // Incrememnt level if needed
    if (!this.maxLevel && this.scene.score >= this.levels[this.level + 1]['score']) {
      // Spam boss enemies
      this.levelSpam(this.levels[this.level]['level_end_spam']);

      // Update level
      if (++this.level >= this.levels.length - 1) {
        this.level--;
        this.maxLevel = true;
      } else {
        newPlayer.weaponLevel++;
      }
    }

    // Check to see if it's time to spawn an enemy
    if (this.age % this.levels[this.level]['spawn_rate'] === 0 && !scene.reviving)
      this.spawnEnemy();
  },

  spawnEnemy: function() {
    var random = Math.floor(Math.random() * this.enemyChoiceTotalWeight);
    var i, cumulativeWeight = 0;
    var corner = this.randomSpawnCorner();

    for (i = 0; i < this.levels[this.level]['enemies'].length; i++) {
      cumulativeWeight += this.levels[this.level]['enemies'][i][1];

      if (random < cumulativeWeight) {
        var enemy = new window[this.levels[this.level]['enemies'][i][0]](corner[0], corner[1]);

        enemyGroup.addChild(enemy);
        return;
      }
    }
  },

  randomSpawnCorner: function() {
    var horizontalSpawn = this.randomBinary() === 0 ? 0 : game.width,
    verticalSpawn = this.randomBinary() === 0 ? 0 : game.height;

    return [ horizontalSpawn, verticalSpawn ];
  },

  setEnemyChoiceTotalWeight: function() {
    this.enemyChoiceTotalWeight = 0;

    for (var i = 0; i < this.levels[this.level]['enemies'].length; i++)
      this.enemyChoiceTotalWeight += this.levels[this.level]['enemies'][i][1];
  },

  levelSpam: function(spam) {
    this.spamming = true;
    this.spamClass = spam[0];
    this.spamCount = spam[1];
  },

  sendWave: function() {
    for (var i = 0; i < this.corners.length; i++)
      enemyGroup.addChild(new window[this.spamClass](this.corners[i][0], this.corners[i][1]));

    if (--this.spamCount <= 0)
      this.spamming = false;
  },

  randomBinary: function() {
    return Math.floor(Math.random() * 2);
  }
});
<commit_msg>forgot to take worm off of level 0<commit_after>GameController = Class.create(Sprite, {
  initialize: function(scene) {
    Sprite.call(this, 0, 0);
    this.image = game.assets['images/square_glow.png'];
    this.x = -10;
    this.y = -10;
    this.scene = scene;

    this.level = 0;
    this.maxLevel = false;
    this.enemyChoiceTotalWeight = 0;

    this.spamming = false;
    this.spamClass = "";
    this.spamCount = 0;

    this.levels = [
      // LEVEL 0
      {
        score: 0,
        spawn_rate: 60,
        level_end_spam: ['Triangle', 7],
        enemies: [
          ['Triangle', 50],
          ['Square', 40]
        ]
      },

      // LEVEL 1
      {
        score: 400,
        spawn_rate: 40,
        level_end_spam: ['Square', 5],
        enemies: [
          ['Triangle', 18],
          ['Circle', 20],
          ['Square', 40]
        ]
      },

      // LEVEL 2
      {
        score: 1400,
        spawn_rate: 40,
        level_end_spam: ['Circle', 2],
        enemies: [
          ['Triangle', 18],
          ['Circle', 20],
          ['Square', 40],
          ['Worm', 15]
        ]
      },

      // LEVEL 3
      {
        score: 2200,
        spawn_rate: 40,
        level_end_spam: ['Circle', 1],
        enemies: [
          ['Triangle', 18],
          ['Circle', 10],
          ['Square', 40],
          ['Worm', 25]
        ]
      },

      // LEVEL 4
      {
        score: 3000,
        spawn_rate: 40,
        enemies: [
          ['Triangle', 18],
          ['Circle', 30],
          ['Square', 10],
          ['Worm', 30]
        ]
      }
    ];

    this.corners = [
      [0, 0],
      [game.width, 0],
      [game.width, game.height],
      [0, game.height]
    ];

    this.setEnemyChoiceTotalWeight();
  },

  onenterframe: function() {
    // Spam if needed
    if (this.spamming) {
      if (this.age % 15 === 0)
        this.sendWave();
      return;
    }

    // Incrememnt level if needed
    if (!this.maxLevel && this.scene.score >= this.levels[this.level + 1]['score']) {
      // Spam boss enemies
      this.levelSpam(this.levels[this.level]['level_end_spam']);

      // Update level
      if (++this.level >= this.levels.length - 1) {
        this.level--;
        this.maxLevel = true;
      } else {
        newPlayer.weaponLevel++;
      }
    }

    // Check to see if it's time to spawn an enemy
    if (this.age % this.levels[this.level]['spawn_rate'] === 0 && !scene.reviving)
      this.spawnEnemy();
  },

  spawnEnemy: function() {
    var random = Math.floor(Math.random() * this.enemyChoiceTotalWeight);
    var i, cumulativeWeight = 0;
    var corner = this.randomSpawnCorner();

    for (i = 0; i < this.levels[this.level]['enemies'].length; i++) {
      cumulativeWeight += this.levels[this.level]['enemies'][i][1];

      if (random < cumulativeWeight) {
        var enemy = new window[this.levels[this.level]['enemies'][i][0]](corner[0], corner[1]);

        enemyGroup.addChild(enemy);
        return;
      }
    }
  },

  randomSpawnCorner: function() {
    var horizontalSpawn = this.randomBinary() === 0 ? 0 : game.width,
    verticalSpawn = this.randomBinary() === 0 ? 0 : game.height;

    return [ horizontalSpawn, verticalSpawn ];
  },

  setEnemyChoiceTotalWeight: function() {
    this.enemyChoiceTotalWeight = 0;

    for (var i = 0; i < this.levels[this.level]['enemies'].length; i++)
      this.enemyChoiceTotalWeight += this.levels[this.level]['enemies'][i][1];
  },

  levelSpam: function(spam) {
    this.spamming = true;
    this.spamClass = spam[0];
    this.spamCount = spam[1];
  },

  sendWave: function() {
    for (var i = 0; i < this.corners.length; i++)
      enemyGroup.addChild(new window[this.spamClass](this.corners[i][0], this.corners[i][1]));

    if (--this.spamCount <= 0)
      this.spamming = false;
  },

  randomBinary: function() {
    return Math.floor(Math.random() * 2);
  }
});
<|endoftext|>


<commit_before>	SVGDocument = null;
	var svgns = "http://www.w3.org/2000/svg";
	var d_attr = 0 ;
	var signature_started = 0 ;
	var path_elememt = 0 ;
	var path_num = 1 ;
	var rect_num = 1 ;
	var line_num = 1 ;
	var ellipse_num = 1 ;
	var rect_x = null ;
	var rect_y = null ;
	top.clear_svg = SVGclear_svg ;
	top.set_draw_mode = SVGset_draw_mode ;
	top.submit_svg = SVGsubmit_svg ;
	top.set_stroke_color = SVGset_stroke_color;
	top.set_fill_color = SVGset_fill_color;
	top.set_stroke_width = SVGset_stroke_width ;

	var current_draw_element = "path" ;
	var current_draw_element_fill = "none" ;
	var current_draw_element_stroke_width = "1px" ;
	var current_draw_element_stroke = "black" ;

	var freehandcircle_min_x = null ;
	var freehandcircle_max_x = null ;
	var freehandcircle_min_y = null ;
	var freehandcircle_max_y = null ;

function SVGset_draw_mode(ele_name) {
	current_draw_element = ele_name;
}

function SVGset_stroke_color(col_hex){
	current_draw_element_stroke = col_hex;
}

function SVGset_fill_color(col_hex){
	current_draw_element_fill = col_hex;
}

function SVGset_stroke_width(val){
	current_draw_element_stroke_width = val;
}

function Initialize(LoadEvent)
{
SVGDocument = LoadEvent.target.ownerDocument
}

function fun_mouseUP(evt)
{

signature_started = 0 ;

	switch (current_draw_element)
	{
	case "path":
		d_attr = 0 ;
		path_num = path_num + 1 ;
		break
	case "rect":
		rect_num = rect_num + 1 ;
		break
	case "line":
		line_num = line_num + 1 ;
		break
	case "ellipse":
		ellipse_num = ellipse_num + 1 ;
		break
	case "freehandcircle":
		d_attr = 0 ;
		path_num = path_num + 1 ;

		create_svg_element_by_json({
			"element": "ellipse",
			"cx": (freehandcircle_min_x + freehandcircle_max_x ) / 2,
			"cy": (freehandcircle_min_y + freehandcircle_max_y ) / 2,
			"rx": (freehandcircle_max_x - freehandcircle_min_x ) / 2 + "px",
			"ry": (freehandcircle_max_y - freehandcircle_min_y ) / 2 + "px",
			"id": "ellipse_" + ellipse_num,
			"fill": current_draw_element_fill,
			"stroke": current_draw_element_stroke,
			"strokeWidth": current_draw_element_stroke_width
		});
	}//switch

}

function fun_mouseDOWN(evt)
{

	var x = evt.pageX;
	var y = evt.pageY;

	switch (current_draw_element)
	{
	case "freehandcircle":
		d_attr = "M" + x + " " + y + " ";
		signature_started = 1 ;
		//SVG_insert_to_svg();//create element
		create_svg_element_by_json({
			"element": "path",
			"d": d_attr,
			"id": "path_" + path_num,
			"fill": "none",
			"stroke": current_draw_element_stroke,
			"strokeWidth": current_draw_element_stroke_width

		});

		freehandcircle_min_x = x ;
		freehandcircle_max_x = x ;
		freehandcircle_min_y = y ;
		freehandcircle_max_y = y ;

	break
	case "path":
		d_attr = "M" + x + " " + y + " ";
		signature_started = 1 ;
		//SVG_insert_to_svg();//create element
		create_svg_element_by_json({
			"element": "path",
			"d": d_attr,
			"id": "path_" + path_num,
			"fill": "none",
			"stroke": current_draw_element_stroke,
			"strokeWidth": current_draw_element_stroke_width

		});

	break
	case "rect":
		signature_started = 1 ;
		rect_x = x ;
		rect_y = y ;
		create_svg_element_by_json({
			"element": "rect",
			"x": x,
			"y": y,
			"width": "1px",
			"height": "1px",
			"id": "rect_" + rect_num,
			"fill": current_draw_element_fill,
			"stroke": current_draw_element_stroke,
			"strokeWidth": current_draw_element_stroke_width

		});
		break
	case "line":
		signature_started = 1 ;

		create_svg_element_by_json({
			"element": "line",
			"x1": x,
			"y1": y,
			"x2": x + 1 + "px",
			"y2": y + 1 + "px",
			"id": "line_" + line_num,
			"stroke": current_draw_element_stroke,
			"strokeWidth": current_draw_element_stroke_width

		});
		break
	case "ellipse":
		signature_started = 1 ;
		create_svg_element_by_json({
			"element": "ellipse",
			"cx": x,
			"cy": y,
			"rx": 1 + "px",
			"ry": 1 + "px",
			"id": "ellipse_" + ellipse_num,
			"fill": current_draw_element_fill,
			"stroke": current_draw_element_stroke,
			"strokeWidth": current_draw_element_stroke_width
		});
		break
	}//switch

}

function fun_mouseMOVE(evt)
{
	if (signature_started == 1 )
	{
	var x = evt.pageX;
	var y = evt.pageY;

	switch (current_draw_element)
	{
	case "path":

		d_attr = d_attr + "L" + x + " " + y + " ";
		var shape = SVGDocument.getElementById("path_" + path_num);
		shape.setAttributeNS(null, "d", d_attr);
		break

	case "rect":

		var shape = SVGDocument.getElementById("rect_" + rect_num);
		var start_x = shape.getAttributeNS(null, "x");
		var start_y = shape.getAttributeNS(null, "y");

		if(rect_x < x ){
			shape.setAttributeNS(null, "x", rect_x);
			shape.setAttributeNS(null, "width", x - rect_x);
		}else{
			shape.setAttributeNS(null, "x", x);
			shape.setAttributeNS(null, "width", rect_x - x);
		}
		if(rect_y < y ){
			shape.setAttributeNS(null, "y", rect_y);
			shape.setAttributeNS(null, "height", y - rect_y);
		}else{
			shape.setAttributeNS(null, "y", y);
			shape.setAttributeNS(null, "height", rect_y - y);
		}

	break
	case "line":
		var shape = SVGDocument.getElementById("line_" + line_num);
		shape.setAttributeNS(null, "x2", x);
		shape.setAttributeNS(null, "y2", y);
	break
	case "ellipse":
		var shape = SVGDocument.getElementById("ellipse_" + ellipse_num);
		var cx = shape.getAttributeNS(null, "cx");
		var cy = shape.getAttributeNS(null, "cy");
		var rad = Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) );

		shape.setAttributeNS(null, "rx", rad);
		shape.setAttributeNS(null, "ry", rad);
	break;

	case "freehandcircle":
		d_attr = d_attr + "L" + x + " " + y + " ";
		var shape = SVGDocument.getElementById("path_" + path_num);
		shape.setAttributeNS(null, "d", d_attr);

		freehandcircle_min_x = min_of(x , freehandcircle_min_x ) ;
		freehandcircle_max_x = max_of(x , freehandcircle_max_x ) ;
		freehandcircle_min_y = min_of(y , freehandcircle_min_y ) ;
		freehandcircle_max_y = max_of(y , freehandcircle_max_y ) ;
	break;

	}//switch

	}//if
}//function

function min_of(a ,b){
	if (a < b ) { return a ;}
	else {return b ;}
}
function max_of(a ,b){
	if (a > b ) { return a ;}
	else {return b ;}
}

	   function SVG_insert_to_svg()
	   {

		var shape = SVGDocument.createElementNS(svgns, "path");
		shape.setAttributeNS(null, "d", d_attr);
		shape.setAttributeNS(null, "id", "path_" + path_num);
		shape.setAttributeNS(null, "fill", "none");
		shape.setAttributeNS(null, "stroke", "green");
		SVGDocument.documentElement.appendChild(shape);

	   }
	function create_svg_element_by_json(data)
	{
		var shape = SVGDocument.createElementNS(svgns, data.element);

		switch (data.element)
		{
		case "freehandcircle":
		case "path":
			shape.setAttributeNS(null, "d", data.d_attr);
			shape.setAttributeNS(null, "id", data.id);
			shape.setAttributeNS(null, "fill", data.fill);
			shape.setAttributeNS(null, "stroke", data.stroke);
			shape.setAttributeNS(null, "stroke-width", data.strokeWidth);
			SVGDocument.documentElement.appendChild(shape);
			break
		case "rect":
			shape.setAttributeNS(null, "x", data.x);
			shape.setAttributeNS(null, "y", data.y);
			shape.setAttributeNS(null, "width", data.width);
			shape.setAttributeNS(null, "height", data.height);
			shape.setAttributeNS(null, "id", data.id);
			shape.setAttributeNS(null, "fill", data.fill);
			shape.setAttributeNS(null, "stroke", data.stroke);
			shape.setAttributeNS(null, "stroke-width", data.strokeWidth);
			SVGDocument.documentElement.appendChild(shape);
			break
		case "line":
			shape.setAttributeNS(null, "x1", data.x1);
			shape.setAttributeNS(null, "x2", data.x2);
			shape.setAttributeNS(null, "y1", data.y1);
			shape.setAttributeNS(null, "y2", data.y2);
			shape.setAttributeNS(null, "id", data.id);
			shape.setAttributeNS(null, "stroke", data.stroke);
			shape.setAttributeNS(null, "stroke-width", data.strokeWidth);
			SVGDocument.documentElement.appendChild(shape);
			break
		case "ellipse":
			shape.setAttributeNS(null, "cx", data.cx);
			shape.setAttributeNS(null, "cy", data.cy);
			shape.setAttributeNS(null, "rx", data.rx);
			shape.setAttributeNS(null, "ry", data.ry);
			shape.setAttributeNS(null, "id", data.id);
			shape.setAttributeNS(null, "fill", data.fill);
			shape.setAttributeNS(null, "stroke", data.stroke);
			shape.setAttributeNS(null, "stroke-width", data.strokeWidth);
			SVGDocument.documentElement.appendChild(shape);
			break
		}//switch

	}

	   function SVGclear_svg()
	   {
	   	for(var i=1; i<path_num; i++){
			var element = SVGDocument.getElementById("path_" + i);
			if(element != null ) { element.parentNode.removeChild(element); }

	        }
	        path_num = 1 ;
	   }

	var out = "", indent=0;
	function SvgToString(elem)
	{
		out = "" ;
	   if (elem)
	   {
	      var attrs = elem.attributes;
	      var attr;
	      var i;
	      var childs = elem.childNodes;

	      for (i=0; i<indent; i++) out += "  ";
	      out += "<" + elem.nodeName;

	      for (i=attrs.length-1; i>=0; i--)
	      {
	         attr = attrs.item(i);
	         out += " " + attr.nodeName + "=\"" + attr.nodeValue+ "\"";
	      }

	      if (elem.hasChildNodes())
	      {
	         out += ">\n";
	         indent++;
	         for (i=0; i<childs.length; i++)
	         {
	            if (childs.item(i).nodeType == 1) // element node ..
	               SvgToString(childs.item(i));
	            else if (childs.item(i).nodeType == 3) // text node ..
	            {
	               for (j=0; j<indent; j++) out += "  ";
	               out += childs.item(i).nodeValue + "\n";
	            }
	         }
	         indent--;
	         for (i=0; i<indent; i++) out += "  ";
	         out += "</" + elem.nodeName + ">\n";
	      }
	      else
	      {
	         out += " />\n";
	      }

	   }
	   return out;
	}

	function SVGsubmit_svg(){

		var str = "<?xml version=\"1.0\" standalone=\"no\"?> \
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"> \n  \<svg width=\"100%\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"> \n ";

		for(var i=1; i<path_num; i++){
			var element = SVGDocument.getElementById("path_" + i);
			if(element != null ) { str = str  +  SvgToString(element);}

	        }
	        str = str + "</svg>"

		top.return_str_to_html(str);

	}

<commit_msg>generalised the function "create_svg_element_by_json()"<commit_after>	SVGDocument = null;
	var svgns = "http://www.w3.org/2000/svg";
	var d_attr = "" ;
	var signature_started = 0 ;
	var path_elememt = 0 ;
	var path_num = 1 ;
	var rect_num = 1 ;
	var line_num = 1 ;
	var ellipse_num = 1 ;
	var rect_x = null ;
	var rect_y = null ;
	top.clear_svg = SVGclear_svg ;
	top.set_draw_mode = SVGset_draw_mode ;
	top.submit_svg = SVGsubmit_svg ;
	top.set_stroke_color = SVGset_stroke_color;
	top.set_fill_color = SVGset_fill_color;
	top.set_stroke_width = SVGset_stroke_width ;

	var current_draw_element = "path" ;
	var current_draw_element_fill = "none" ;
	var current_draw_element_stroke_width = "1px" ;
	var current_draw_element_stroke = "black" ;

	var freehandcircle_min_x = null ;
	var freehandcircle_max_x = null ;
	var freehandcircle_min_y = null ;
	var freehandcircle_max_y = null ;

function SVGset_draw_mode(ele_name) {
	current_draw_element = ele_name;
}

function SVGset_stroke_color(col_hex){
	current_draw_element_stroke = col_hex;
}

function SVGset_fill_color(col_hex){
	current_draw_element_fill = col_hex;
}

function SVGset_stroke_width(val){
	current_draw_element_stroke_width = val;
}

function Initialize(LoadEvent)
{
SVGDocument = LoadEvent.target.ownerDocument
}

function fun_mouseUP(evt)
{

signature_started = 0 ;

	switch (current_draw_element)
	{
	case "path":
		d_attr = 0 ;
		path_num = path_num + 1 ;
		break
	case "rect":
		rect_num = rect_num + 1 ;
		break
	case "line":
		line_num = line_num + 1 ;
		break
	case "ellipse":
		ellipse_num = ellipse_num + 1 ;
		break
	case "freehandcircle":
		d_attr = 0 ;
		path_num = path_num + 1 ;

		create_svg_element_by_json({
			"element": "ellipse",
			"Attr": {
				"cx": (freehandcircle_min_x + freehandcircle_max_x ) / 2,
				"cy": (freehandcircle_min_y + freehandcircle_max_y ) / 2,
				"rx": (freehandcircle_max_x - freehandcircle_min_x ) / 2 + "px",
				"ry": (freehandcircle_max_y - freehandcircle_min_y ) / 2 + "px",
				"id": "ellipse_" + ellipse_num,
				"fill": current_draw_element_fill,
				"stroke": current_draw_element_stroke,
				"stroke-width": current_draw_element_stroke_width
				}
		});
	}//switch

}//function

function fun_mouseDOWN(evt)
{

	var x = evt.pageX;
	var y = evt.pageY;

	switch (current_draw_element)
	{
	case "freehandcircle":
		d_attr = "M" + x + " " + y + " ";
		signature_started = 1 ;

		create_svg_element_by_json({
			"element": "path",
			"Attr": {
				"d": d_attr,
				"id": "path_" + path_num,
				"fill": "none",
				"stroke": current_draw_element_stroke,
				"stroke-width": current_draw_element_stroke_width
				}

		});

		freehandcircle_min_x = x ;
		freehandcircle_max_x = x ;
		freehandcircle_min_y = y ;
		freehandcircle_max_y = y ;

	break
	case "path":
		d_attr = "M" + x + " " + y + " ";
		signature_started = 1 ;

		create_svg_element_by_json({
			"element": "path",
			"Attr": {
				"d": d_attr,
				"id": "path_" + path_num,
				"fill": "none",
				"stroke": current_draw_element_stroke,
				"stroke-width": current_draw_element_stroke_width
				}

		});

	break
	case "rect":
		signature_started = 1 ;
		rect_x = x ;
		rect_y = y ;
		create_svg_element_by_json({
			"element": "rect",
			"Attr": {
				"x": x,
				"y": y,
				"width": "1px",
				"height": "1px",
				"id": "rect_" + rect_num,
				"fill": current_draw_element_fill,
				"stroke": current_draw_element_stroke,
				"stroke-width": current_draw_element_stroke_width
				}

		});
		break
	case "line":
		signature_started = 1 ;

		create_svg_element_by_json({
			"element": "line",
			"Attr":	{
				"x1": x,
				"y1": y,
				"x2": x + 1 + "px",
				"y2": y + 1 + "px",
				"id": "line_" + line_num,
				"stroke": current_draw_element_stroke,
				"stroke-width": current_draw_element_stroke_width
				}

		});
		break
	case "ellipse":
		signature_started = 1 ;
		create_svg_element_by_json({
			"element": "ellipse",
			"Attr": {
				"cx": x,
				"cy": y,
				"rx": 1 + "px",
				"ry": 1 + "px",
				"id": "ellipse_" + ellipse_num,
				"fill": current_draw_element_fill,
				"stroke": current_draw_element_stroke,
				"stroke-width": current_draw_element_stroke_width
				}
		});
		break
	}//switch

}

function fun_mouseMOVE(evt)
{
	if (signature_started == 1 )
	{
	var x = evt.pageX;
	var y = evt.pageY;

	switch (current_draw_element)
	{
	case "path":

		d_attr = d_attr + "L" + x + " " + y + " ";
		var shape = SVGDocument.getElementById("path_" + path_num);
		shape.setAttributeNS(null, "d", d_attr);
		break

	case "rect":

		var shape = SVGDocument.getElementById("rect_" + rect_num);
		var start_x = shape.getAttributeNS(null, "x");
		var start_y = shape.getAttributeNS(null, "y");

		if(rect_x < x ){
			shape.setAttributeNS(null, "x", rect_x);
			shape.setAttributeNS(null, "width", x - rect_x);
		}else{
			shape.setAttributeNS(null, "x", x);
			shape.setAttributeNS(null, "width", rect_x - x);
		}
		if(rect_y < y ){
			shape.setAttributeNS(null, "y", rect_y);
			shape.setAttributeNS(null, "height", y - rect_y);
		}else{
			shape.setAttributeNS(null, "y", y);
			shape.setAttributeNS(null, "height", rect_y - y);
		}

	break
	case "line":
		var shape = SVGDocument.getElementById("line_" + line_num);
		shape.setAttributeNS(null, "x2", x);
		shape.setAttributeNS(null, "y2", y);
	break
	case "ellipse":
		var shape = SVGDocument.getElementById("ellipse_" + ellipse_num);
		var cx = shape.getAttributeNS(null, "cx");
		var cy = shape.getAttributeNS(null, "cy");
		var rad = Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) );

		shape.setAttributeNS(null, "rx", rad);
		shape.setAttributeNS(null, "ry", rad);
	break;

	case "freehandcircle":
		d_attr = d_attr + "L" + x + " " + y + " ";
		var shape = SVGDocument.getElementById("path_" + path_num);
		shape.setAttributeNS(null, "d", d_attr);

		freehandcircle_min_x = min_of(x , freehandcircle_min_x ) ;
		freehandcircle_max_x = max_of(x , freehandcircle_max_x ) ;
		freehandcircle_min_y = min_of(y , freehandcircle_min_y ) ;
		freehandcircle_max_y = max_of(y , freehandcircle_max_y ) ;
	break;

	}//switch

	}//if
}//function

function min_of(a ,b){
	if (a < b ) { return a ;}
	else {return b ;}
}
function max_of(a ,b){
	if (a > b ) { return a ;}
	else {return b ;}
}

function create_svg_element_by_json(data)
{
	var shape = SVGDocument.createElementNS(svgns, data.element);
	for (i in data.Attr) {
		shape.setAttributeNS(null, i, data.Attr[i]);
	}
	SVGDocument.documentElement.appendChild(shape);

}//function

	   function SVGclear_svg()
	   {
	   	for(var i=1; i<path_num; i++){
			var element = SVGDocument.getElementById("path_" + i);
			if(element != null ) { element.parentNode.removeChild(element); }

	        }
	        path_num = 1 ;
	   }

	var out = "", indent=0;
	function SvgToString(elem)
	{
		out = "" ;
	   if (elem)
	   {
	      var attrs = elem.attributes;
	      var attr;
	      var i;
	      var childs = elem.childNodes;

	      for (i=0; i<indent; i++) out += "  ";
	      out += "<" + elem.nodeName;

	      for (i=attrs.length-1; i>=0; i--)
	      {
	         attr = attrs.item(i);
	         out += " " + attr.nodeName + "=\"" + attr.nodeValue+ "\"";
	      }

	      if (elem.hasChildNodes())
	      {
	         out += ">\n";
	         indent++;
	         for (i=0; i<childs.length; i++)
	         {
	            if (childs.item(i).nodeType == 1) // element node ..
	               SvgToString(childs.item(i));
	            else if (childs.item(i).nodeType == 3) // text node ..
	            {
	               for (j=0; j<indent; j++) out += "  ";
	               out += childs.item(i).nodeValue + "\n";
	            }
	         }
	         indent--;
	         for (i=0; i<indent; i++) out += "  ";
	         out += "</" + elem.nodeName + ">\n";
	      }
	      else
	      {
	         out += " />\n";
	      }

	   }
	   return out;
	}

	function SVGsubmit_svg(){

		var str = "<?xml version=\"1.0\" standalone=\"no\"?> \
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"> \n  \<svg width=\"100%\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"> \n ";

		for(var i=1; i<path_num; i++){
			var element = SVGDocument.getElementById("path_" + i);
			if(element != null ) { str = str  +  SvgToString(element);}

	        }
	        str = str + "</svg>"

		top.return_str_to_html(str);

	}

<|endoftext|>


<commit_before>'use strict';

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import baseStyles from './baseStyles';
import BurgerIcon from './BurgerIcon';
import CrossIcon from './CrossIcon';

export default styles => {
  class Menu extends Component {
    constructor(props) {
      super(props);
      this.state = {
        isOpen: false
      };

      if (!styles) {
        throw new Error('No styles supplied');
      }
    }

    toggleMenu(options = {}) {
      const { isOpen, noStateChange } = options;
      const newState = {
        isOpen: typeof isOpen !== 'undefined' ? isOpen : !this.state.isOpen
      };

      this.applyWrapperStyles();

      this.setState(newState, () => {
        !noStateChange && this.props.onStateChange(newState);

        if (!this.props.disableAutoFocus) {
          // For accessibility reasons, ensures that when we toggle open,
          // we focus the first menu item if one exists.
          if (newState.isOpen) {
            const firstItem = document.querySelector('.bm-item');
            if (firstItem) {
              firstItem.focus();
            }
          } else {
            if (document.activeElement) {
              document.activeElement.blur();
            } else {
              document.body.blur(); // Needed for IE
            }
          }
        }

        // Timeout ensures wrappers are cleared after animation finishes.
        this.timeoutId && clearTimeout(this.timeoutId);
        this.timeoutId = setTimeout(() => {
          this.timeoutId = null;
          if (!newState.isOpen) {
            this.applyWrapperStyles(false);
          }
        }, 500);
      });
    }

    open() {
      if (typeof this.props.onOpen === 'function') {
        this.props.onOpen();
      } else {
        this.toggleMenu();
      }
    }

    close() {
      if (typeof this.props.onClose === 'function') {
        this.props.onClose();
      } else {
        this.toggleMenu();
      }
    }

    overlayClick() {
      if (
        this.props.disableOverlayClick === true ||
        (typeof this.props.disableOverlayClick === 'function' &&
          this.props.disableOverlayClick())
      ) {
        return;
      } else {
        this.close();
      }
    }

    // Applies component-specific styles to external wrapper elements.
    applyWrapperStyles(set = true) {
      const applyClass = (el, className) =>
        el.classList[set ? 'add' : 'remove'](className);

      if (this.props.htmlClassName) {
        applyClass(document.querySelector('html'), this.props.htmlClassName);
      }
      if (this.props.bodyClassName) {
        applyClass(document.querySelector('body'), this.props.bodyClassName);
      }

      if (styles.pageWrap && this.props.pageWrapId) {
        this.handleExternalWrapper(this.props.pageWrapId, styles.pageWrap, set);
      }

      if (styles.outerContainer && this.props.outerContainerId) {
        this.handleExternalWrapper(
          this.props.outerContainerId,
          styles.outerContainer,
          set
        );
      }
    }

    // Sets or unsets styles on DOM elements outside the menu component.
    // This is necessary for correct page interaction with some of the menus.
    // Throws and returns if the required external elements don't exist,
    // which means any external page animations won't be applied.
    handleExternalWrapper(id, wrapperStyles, set) {
      const wrapper = document.getElementById(id);

      if (!wrapper) {
        console.error("Element with ID '" + id + "' not found");
        return;
      }

      const builtStyles = this.getStyle(wrapperStyles);

      for (const prop in builtStyles) {
        if (builtStyles.hasOwnProperty(prop)) {
          wrapper.style[prop] = set ? builtStyles[prop] : '';
        }
      }

      // Prevent any horizontal scroll.
      // Only set overflow-x as an inline style if htmlClassName or
      // bodyClassName is not passed in. Otherwise, it is up to the caller to
      // decide if they want to set the overflow style in CSS using the custom
      // class names.
      const applyOverflow = el =>
        (el.style['overflow-x'] = set ? 'hidden' : '');
      if (!this.props.htmlClassName) {
        applyOverflow(document.querySelector('html'));
      }
      if (!this.props.bodyClassName) {
        applyOverflow(document.querySelector('body'));
      }
    }

    // Builds styles incrementally for a given element.
    getStyles(el, index, inline) {
      const propName =
        'bm' + el.replace(el.charAt(0), el.charAt(0).toUpperCase());

      // Set base styles.
      let output = baseStyles[el] ? this.getStyle(baseStyles[el]) : {};

      // Add animation-specific styles.
      if (styles[el]) {
        output = {
          ...output,
          ...this.getStyle(styles[el], index + 1)
        };
      }

      // Add custom styles.
      if (this.props.styles[propName]) {
        output = {
          ...output,
          ...this.props.styles[propName]
        };
      }

      // Add element inline styles.
      if (inline) {
        output = {
          ...output,
          ...inline
        };
      }

      // Remove transition if required
      // (useful if rendering open initially).
      if (this.props.noTransition) {
        delete output.transition;
      }

      return output;
    }

    getStyle(style, index) {
      const { width } = this.props;
      const formattedWidth = typeof width !== 'string' ? `${width}px` : width;
      return style(this.state.isOpen, formattedWidth, this.props.right, index);
    }

    listenForClose(e) {
      e = e || window.event;

      // Close on ESC, unless disabled
      if (
        !this.props.disableCloseOnEsc &&
        this.state.isOpen &&
        (e.key === 'Escape' || e.keyCode === 27)
      ) {
        this.close();
      }
    }

    componentDidMount() {
      // Bind ESC key handler (unless custom function supplied).
      if (this.props.customOnKeyDown) {
        window.onkeydown = this.props.customOnKeyDown;
      } else {
        window.onkeydown = this.listenForClose.bind(this);
      }

      // Allow initial open state to be set by props.
      if (this.props.isOpen) {
        this.toggleMenu({ isOpen: true, noStateChange: true });
      }
    }

    componentWillUnmount() {
      window.onkeydown = null;

      this.applyWrapperStyles(false);

      // Avoid potentially attempting to update an unmounted component.
      this.timeoutId && clearTimeout(this.timeoutId);
    }

    componentDidUpdate(prevProps) {
      const wasToggled =
        typeof this.props.isOpen !== 'undefined' &&
        this.props.isOpen !== this.state.isOpen &&
        this.props.isOpen !== prevProps.isOpen;
      if (wasToggled) {
        this.toggleMenu();
        // Toggling changes SVG animation requirements, so we defer these until the next componentDidUpdate
        return;
      }

      if (styles.svg) {
        const morphShape = ReactDOM.findDOMNode(this, 'bm-morph-shape');
        const path = styles.svg.lib(morphShape).select('path');

        if (this.state.isOpen) {
          // Animate SVG path.
          styles.svg.animate(path);
        } else {
          // Reset path (timeout ensures animation happens off screen).
          setTimeout(() => {
            path.attr('d', styles.svg.pathInitial);
          }, 300);
        }
      }
    }

    render() {
      return (

          {!this.props.noOverlay && (
            <div
              className={`bm-overlay ${this.props.overlayClassName}`.trim()}
              onClick={() => this.overlayClick()}
              style={this.getStyles('overlay')}
            />
          )}
          <div
            id={this.props.id}
            className={`bm-menu-wrap ${this.props.className}`.trim()}
            style={this.getStyles('menuWrap')}
          >
            {styles.svg && (
              <div
                className={`bm-morph-shape ${this.props.morphShapeClassName}`.trim()}
                style={this.getStyles('morphShape')}
              >
                <svg
                  width="100%"
                  height="100%"
                  viewBox="0 0 100 800"
                  preserveAspectRatio="none"
                >
                  <path d={styles.svg.pathInitial} />
                </svg>

            )}
            <div
              className={`bm-menu ${this.props.menuClassName}`.trim()}
              style={this.getStyles('menu')}
            >
              <nav
                className={`bm-item-list ${this.props.itemListClassName}`.trim()}
                style={this.getStyles('itemList')}
              >
                {React.Children.map(this.props.children, (item, index) => {
                  if (item) {
                    const classList = [
                      'bm-item',
                      this.props.itemClassName,
                      item.props.className
                    ]
                      .filter(className => !!className)
                      .join(' ');
                    const extraProps = {
                      key: index,
                      className: classList,
                      style: this.getStyles('item', index, item.props.style),
                      tabIndex: this.state.isOpen ? 0 : -1
                    };
                    return React.cloneElement(item, extraProps);
                  }
                })}

            {this.props.customCrossIcon !== false && (

                <CrossIcon
                  onClick={() => this.close()}
                  styles={this.props.styles}
                  customIcon={this.props.customCrossIcon}
                  className={this.props.crossButtonClassName}
                  crossClassName={this.props.crossClassName}
                  tabIndex={this.state.isOpen ? 0 : -1}
                />

            )}

          {this.props.customBurgerIcon !== false && (

              <BurgerIcon
                onClick={() => this.open()}
                styles={this.props.styles}
                customIcon={this.props.customBurgerIcon}
                className={this.props.burgerButtonClassName}
                barClassName={this.props.burgerBarClassName}
                onIconStateChange={this.props.onIconStateChange}
              />

          )}

      );
    }
  }

  Menu.propTypes = {
    bodyClassName: PropTypes.string,
    burgerBarClassName: PropTypes.string,
    burgerButtonClassName: PropTypes.string,
    className: PropTypes.string,
    crossButtonClassName: PropTypes.string,
    crossClassName: PropTypes.string,
    customBurgerIcon: PropTypes.oneOfType([
      PropTypes.element,
      PropTypes.oneOf([false])
    ]),
    customCrossIcon: PropTypes.oneOfType([
      PropTypes.element,
      PropTypes.oneOf([false])
    ]),
    customOnKeyDown: PropTypes.func,
    disableAutoFocus: PropTypes.bool,
    disableCloseOnEsc: PropTypes.bool,
    disableOverlayClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
    htmlClassName: PropTypes.string,
    id: PropTypes.string,
    isOpen: PropTypes.bool,
    itemClassName: PropTypes.string,
    itemListClassName: PropTypes.string,
    menuClassName: PropTypes.string,
    morphShapeClassName: PropTypes.string,
    noOverlay: PropTypes.bool,
    noTransition: PropTypes.bool,
    onClose: PropTypes.func,
    onIconHoverChange: PropTypes.func,
    onOpen: PropTypes.func,
    onStateChange: PropTypes.func,
    outerContainerId:
      styles && styles.outerContainer
        ? PropTypes.string.isRequired
        : PropTypes.string,
    overlayClassName: PropTypes.string,
    pageWrapId:
      styles && styles.pageWrap
        ? PropTypes.string.isRequired
        : PropTypes.string,
    right: PropTypes.bool,
    styles: PropTypes.object,
    width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
  };

  Menu.defaultProps = {
    bodyClassName: '',
    burgerBarClassName: '',
    burgerButtonClassName: '',
    className: '',
    crossButtonClassName: '',
    crossClassName: '',
    disableAutoFocus: false,
    disableCloseOnEsc: false,
    htmlClassName: '',
    id: '',
    itemClassName: '',
    itemListClassName: '',
    menuClassName: '',
    morphShapeClassName: '',
    noOverlay: false,
    noTransition: false,
    onStateChange: () => {},
    outerContainerId: '',
    overlayClassName: '',
    pageWrapId: '',
    styles: {},
    width: 300,
    onIconHoverChange: () => {}
  };

  return Menu;
};
<commit_msg>fixed tab index order in case of customBurgerIcon<commit_after>'use strict';

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import baseStyles from './baseStyles';
import BurgerIcon from './BurgerIcon';
import CrossIcon from './CrossIcon';

export default styles => {
  class Menu extends Component {
    constructor(props) {
      super(props);
      this.state = {
        isOpen: false
      };

      if (!styles) {
        throw new Error('No styles supplied');
      }
    }

    toggleMenu(options = {}) {
      const { isOpen, noStateChange } = options;
      const newState = {
        isOpen: typeof isOpen !== 'undefined' ? isOpen : !this.state.isOpen
      };

      this.applyWrapperStyles();

      this.setState(newState, () => {
        !noStateChange && this.props.onStateChange(newState);

        if (!this.props.disableAutoFocus) {
          // For accessibility reasons, ensures that when we toggle open,
          // we focus the first menu item if one exists.
          if (newState.isOpen) {
            const firstItem = document.querySelector('.bm-item');
            if (firstItem) {
              firstItem.focus();
            }
          } else {
            if (document.activeElement) {
              document.activeElement.blur();
            } else {
              document.body.blur(); // Needed for IE
            }
          }
        }

        // Timeout ensures wrappers are cleared after animation finishes.
        this.timeoutId && clearTimeout(this.timeoutId);
        this.timeoutId = setTimeout(() => {
          this.timeoutId = null;
          if (!newState.isOpen) {
            this.applyWrapperStyles(false);
          }
        }, 500);
      });
    }

    open() {
      if (typeof this.props.onOpen === 'function') {
        this.props.onOpen();
      } else {
        this.toggleMenu();
      }
    }

    close() {
      if (typeof this.props.onClose === 'function') {
        this.props.onClose();
      } else {
        this.toggleMenu();
      }
    }

    overlayClick() {
      if (
        this.props.disableOverlayClick === true ||
        (typeof this.props.disableOverlayClick === 'function' &&
          this.props.disableOverlayClick())
      ) {
        return;
      } else {
        this.close();
      }
    }

    // Applies component-specific styles to external wrapper elements.
    applyWrapperStyles(set = true) {
      const applyClass = (el, className) =>
        el.classList[set ? 'add' : 'remove'](className);

      if (this.props.htmlClassName) {
        applyClass(document.querySelector('html'), this.props.htmlClassName);
      }
      if (this.props.bodyClassName) {
        applyClass(document.querySelector('body'), this.props.bodyClassName);
      }

      if (styles.pageWrap && this.props.pageWrapId) {
        this.handleExternalWrapper(this.props.pageWrapId, styles.pageWrap, set);
      }

      if (styles.outerContainer && this.props.outerContainerId) {
        this.handleExternalWrapper(
          this.props.outerContainerId,
          styles.outerContainer,
          set
        );
      }
    }

    // Sets or unsets styles on DOM elements outside the menu component.
    // This is necessary for correct page interaction with some of the menus.
    // Throws and returns if the required external elements don't exist,
    // which means any external page animations won't be applied.
    handleExternalWrapper(id, wrapperStyles, set) {
      const wrapper = document.getElementById(id);

      if (!wrapper) {
        console.error("Element with ID '" + id + "' not found");
        return;
      }

      const builtStyles = this.getStyle(wrapperStyles);

      for (const prop in builtStyles) {
        if (builtStyles.hasOwnProperty(prop)) {
          wrapper.style[prop] = set ? builtStyles[prop] : '';
        }
      }

      // Prevent any horizontal scroll.
      // Only set overflow-x as an inline style if htmlClassName or
      // bodyClassName is not passed in. Otherwise, it is up to the caller to
      // decide if they want to set the overflow style in CSS using the custom
      // class names.
      const applyOverflow = el =>
        (el.style['overflow-x'] = set ? 'hidden' : '');
      if (!this.props.htmlClassName) {
        applyOverflow(document.querySelector('html'));
      }
      if (!this.props.bodyClassName) {
        applyOverflow(document.querySelector('body'));
      }
    }

    // Builds styles incrementally for a given element.
    getStyles(el, index, inline) {
      const propName =
        'bm' + el.replace(el.charAt(0), el.charAt(0).toUpperCase());

      // Set base styles.
      let output = baseStyles[el] ? this.getStyle(baseStyles[el]) : {};

      // Add animation-specific styles.
      if (styles[el]) {
        output = {
          ...output,
          ...this.getStyle(styles[el], index + 1)
        };
      }

      // Add custom styles.
      if (this.props.styles[propName]) {
        output = {
          ...output,
          ...this.props.styles[propName]
        };
      }

      // Add element inline styles.
      if (inline) {
        output = {
          ...output,
          ...inline
        };
      }

      // Remove transition if required
      // (useful if rendering open initially).
      if (this.props.noTransition) {
        delete output.transition;
      }

      return output;
    }

    getStyle(style, index) {
      const { width } = this.props;
      const formattedWidth = typeof width !== 'string' ? `${width}px` : width;
      return style(this.state.isOpen, formattedWidth, this.props.right, index);
    }

    listenForClose(e) {
      e = e || window.event;

      // Close on ESC, unless disabled
      if (
        !this.props.disableCloseOnEsc &&
        this.state.isOpen &&
        (e.key === 'Escape' || e.keyCode === 27)
      ) {
        this.close();
      }
    }

    componentDidMount() {
      // Bind ESC key handler (unless custom function supplied).
      if (this.props.customOnKeyDown) {
        window.onkeydown = this.props.customOnKeyDown;
      } else {
        window.onkeydown = this.listenForClose.bind(this);
      }

      // Allow initial open state to be set by props.
      if (this.props.isOpen) {
        this.toggleMenu({ isOpen: true, noStateChange: true });
      }
    }

    componentWillUnmount() {
      window.onkeydown = null;

      this.applyWrapperStyles(false);

      // Avoid potentially attempting to update an unmounted component.
      this.timeoutId && clearTimeout(this.timeoutId);
    }

    componentDidUpdate(prevProps) {
      const wasToggled =
        typeof this.props.isOpen !== 'undefined' &&
        this.props.isOpen !== this.state.isOpen &&
        this.props.isOpen !== prevProps.isOpen;
      if (wasToggled) {
        this.toggleMenu();
        // Toggling changes SVG animation requirements, so we defer these until the next componentDidUpdate
        return;
      }

      if (styles.svg) {
        const morphShape = ReactDOM.findDOMNode(this, 'bm-morph-shape');
        const path = styles.svg.lib(morphShape).select('path');

        if (this.state.isOpen) {
          // Animate SVG path.
          styles.svg.animate(path);
        } else {
          // Reset path (timeout ensures animation happens off screen).
          setTimeout(() => {
            path.attr('d', styles.svg.pathInitial);
          }, 300);
        }
      }
    }

    render() {
      return (

          {!this.props.noOverlay && (
            <div
              className={`bm-overlay ${this.props.overlayClassName}`.trim()}
              onClick={() => this.overlayClick()}
              style={this.getStyles('overlay')}
            />
          )}
          {this.props.customBurgerIcon !== false && (

              <BurgerIcon
                onClick={() => this.open()}
                styles={this.props.styles}
                customIcon={this.props.customBurgerIcon}
                className={this.props.burgerButtonClassName}
                barClassName={this.props.burgerBarClassName}
                onIconStateChange={this.props.onIconStateChange}
              />

          )}
          <div
            id={this.props.id}
            className={`bm-menu-wrap ${this.props.className}`.trim()}
            style={this.getStyles('menuWrap')}
          >
            {styles.svg && (
              <div
                className={`bm-morph-shape ${this.props.morphShapeClassName}`.trim()}
                style={this.getStyles('morphShape')}
              >
                <svg
                  width="100%"
                  height="100%"
                  viewBox="0 0 100 800"
                  preserveAspectRatio="none"
                >
                  <path d={styles.svg.pathInitial} />
                </svg>

            )}
            <div
              className={`bm-menu ${this.props.menuClassName}`.trim()}
              style={this.getStyles('menu')}
            >
              <nav
                className={`bm-item-list ${this.props.itemListClassName}`.trim()}
                style={this.getStyles('itemList')}
              >
                {React.Children.map(this.props.children, (item, index) => {
                  if (item) {
                    const classList = [
                      'bm-item',
                      this.props.itemClassName,
                      item.props.className
                    ]
                      .filter(className => !!className)
                      .join(' ');
                    const extraProps = {
                      key: index,
                      className: classList,
                      style: this.getStyles('item', index, item.props.style),
                      tabIndex: this.state.isOpen ? 0 : -1
                    };
                    return React.cloneElement(item, extraProps);
                  }
                })}

            {this.props.customCrossIcon !== false && (

                <CrossIcon
                  onClick={() => this.close()}
                  styles={this.props.styles}
                  customIcon={this.props.customCrossIcon}
                  className={this.props.crossButtonClassName}
                  crossClassName={this.props.crossClassName}
                  tabIndex={this.state.isOpen ? 0 : -1}
                />

            )}

      );
    }
  }

  Menu.propTypes = {
    bodyClassName: PropTypes.string,
    burgerBarClassName: PropTypes.string,
    burgerButtonClassName: PropTypes.string,
    className: PropTypes.string,
    crossButtonClassName: PropTypes.string,
    crossClassName: PropTypes.string,
    customBurgerIcon: PropTypes.oneOfType([
      PropTypes.element,
      PropTypes.oneOf([false])
    ]),
    customCrossIcon: PropTypes.oneOfType([
      PropTypes.element,
      PropTypes.oneOf([false])
    ]),
    customOnKeyDown: PropTypes.func,
    disableAutoFocus: PropTypes.bool,
    disableCloseOnEsc: PropTypes.bool,
    disableOverlayClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
    htmlClassName: PropTypes.string,
    id: PropTypes.string,
    isOpen: PropTypes.bool,
    itemClassName: PropTypes.string,
    itemListClassName: PropTypes.string,
    menuClassName: PropTypes.string,
    morphShapeClassName: PropTypes.string,
    noOverlay: PropTypes.bool,
    noTransition: PropTypes.bool,
    onClose: PropTypes.func,
    onIconHoverChange: PropTypes.func,
    onOpen: PropTypes.func,
    onStateChange: PropTypes.func,
    outerContainerId:
      styles && styles.outerContainer
        ? PropTypes.string.isRequired
        : PropTypes.string,
    overlayClassName: PropTypes.string,
    pageWrapId:
      styles && styles.pageWrap
        ? PropTypes.string.isRequired
        : PropTypes.string,
    right: PropTypes.bool,
    styles: PropTypes.object,
    width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
  };

  Menu.defaultProps = {
    bodyClassName: '',
    burgerBarClassName: '',
    burgerButtonClassName: '',
    className: '',
    crossButtonClassName: '',
    crossClassName: '',
    disableAutoFocus: false,
    disableCloseOnEsc: false,
    htmlClassName: '',
    id: '',
    itemClassName: '',
    itemListClassName: '',
    menuClassName: '',
    morphShapeClassName: '',
    noOverlay: false,
    noTransition: false,
    onStateChange: () => {},
    outerContainerId: '',
    overlayClassName: '',
    pageWrapId: '',
    styles: {},
    width: 300,
    onIconHoverChange: () => {}
  };

  return Menu;
};
<|endoftext|>


<commit_before>/**
 * options.js
 */

import {isObjectNotEmpty, isString, throwErr} from "./common.js";
import {getAllStorage, sendMessage, setStorage} from "./browser.js";
import {localizeHtml} from "./localize.js";
import {EXT_INIT} from "./constant.js";

/**
 * send message
 * @param {*} msg - message
 * @returns {void}
 */
const sendMsg = async msg => {
  msg && sendMessage(msg);
};

/**
 * port init extension
 * @param {boolean} init - init
 * @returns {?AsyncFunction} - port message
 */
const portInitExt = async (init = false) =>
  init && sendMsg({
    [EXT_INIT]: !!init,
  }) || null;

/**
 * create pref
 * @param {Object} elm - element
 * @returns {Object} - pref data
 */
const createPref = async (elm = {}) => {
  const {dataset, id} = elm;
  return id && {
    [id]: {
      id,
      checked: !!elm.checked,
      value: elm.value || "",
      subItemOf: dataset && dataset.subItemOf || null,
    },
  } || null;
};

/**
 * store pref
 * @param {!Object} evt - Event
 * @returns {Promise.<Array>} - results of each handler
 */
const storePref = async evt => {
  const {target} = evt;
  const {name, type} = target;
  const func = [];
  if (type === "radio") {
    const nodes = document.querySelectorAll(`[name=${name}]`);
    if (nodes instanceof NodeList) {
      for (const node of nodes) {
        func.push(createPref(node).then(setStorage));
      }
    }
  } else {
    func.push(createPref(target).then(setStorage));
  }
  return Promise.all(func);
};

/* html */
/**
 * add event listener to init button
 * @returns {void}
 */
const addInitExtensionListener = async () => {
  const elm = document.getElementById(EXT_INIT);
  if (elm) {
    elm.addEventListener("click", evt => {
      const {currentTarget, target} = evt;
      evt.preventDefault();
      evt.stopPropagation();
      return portInitExt(currentTarget === target).catch(throwErr);
    });
  }
};

/**
 * add event listener to input elements
 * @returns {void}
 */
const addInputChangeListener = async () => {
  const nodes = document.querySelectorAll("input");
  if (nodes instanceof NodeList) {
    for (const node of nodes) {
      node.addEventListener("change", evt => storePref(evt).catch(throwErr));
    }
  }
};

/**
 * set html input value
 * @param {Object} data - storage data
 * @returns {void}
 */
const setHtmlInputValue = async (data = {}) => {
  const {checked, id, value} = data;
  const elm = id && document.getElementById(id);
  if (elm) {
    const {type} = elm;
    switch (type) {
      case "checkbox":
      case "radio":
        elm.checked = !!checked;
        break;
      case "text":
      case "url":
        elm.value = isString(value) && value || "";
        break;
      default:
    }
  }
};

/**
 * set html input values from storage
 * @returns {Promise.<Array>} - results of each handler
 */
const setValuesFromStorage = async () => {
  const func = [];
  const pref = await getAllStorage();
  if (isObjectNotEmpty(pref)) {
    const items = Object.values(pref);
    for (const item of items) {
      isObjectNotEmpty(item) && func.push(setHtmlInputValue(item));
    }
  }
  return Promise.all(func);
};

/* startup */
Promise.all([
  localizeHtml(),
  setValuesFromStorage(),
  addInputChangeListener(),
  addInitExtensionListener(),
]).catch(throwErr);
<commit_msg>Fix arg<commit_after>/**
 * options.js
 */

import {isObjectNotEmpty, isString, throwErr} from "./common.js";
import {getAllStorage, sendMessage, setStorage} from "./browser.js";
import {localizeHtml} from "./localize.js";
import {EXT_INIT} from "./constant.js";

/**
 * send message
 * @param {*} msg - message
 * @returns {void}
 */
const sendMsg = async msg => {
  msg && sendMessage(null, msg);
};

/**
 * port init extension
 * @param {boolean} init - init
 * @returns {?AsyncFunction} - port message
 */
const portInitExt = async (init = false) =>
  init && sendMsg({
    [EXT_INIT]: !!init,
  }) || null;

/**
 * create pref
 * @param {Object} elm - element
 * @returns {Object} - pref data
 */
const createPref = async (elm = {}) => {
  const {dataset, id} = elm;
  return id && {
    [id]: {
      id,
      checked: !!elm.checked,
      value: elm.value || "",
      subItemOf: dataset && dataset.subItemOf || null,
    },
  } || null;
};

/**
 * store pref
 * @param {!Object} evt - Event
 * @returns {Promise.<Array>} - results of each handler
 */
const storePref = async evt => {
  const {target} = evt;
  const {name, type} = target;
  const func = [];
  if (type === "radio") {
    const nodes = document.querySelectorAll(`[name=${name}]`);
    if (nodes instanceof NodeList) {
      for (const node of nodes) {
        func.push(createPref(node).then(setStorage));
      }
    }
  } else {
    func.push(createPref(target).then(setStorage));
  }
  return Promise.all(func);
};

/* html */
/**
 * add event listener to init button
 * @returns {void}
 */
const addInitExtensionListener = async () => {
  const elm = document.getElementById(EXT_INIT);
  if (elm) {
    elm.addEventListener("click", evt => {
      const {currentTarget, target} = evt;
      evt.preventDefault();
      evt.stopPropagation();
      return portInitExt(currentTarget === target).catch(throwErr);
    });
  }
};

/**
 * add event listener to input elements
 * @returns {void}
 */
const addInputChangeListener = async () => {
  const nodes = document.querySelectorAll("input");
  if (nodes instanceof NodeList) {
    for (const node of nodes) {
      node.addEventListener("change", evt => storePref(evt).catch(throwErr));
    }
  }
};

/**
 * set html input value
 * @param {Object} data - storage data
 * @returns {void}
 */
const setHtmlInputValue = async (data = {}) => {
  const {checked, id, value} = data;
  const elm = id && document.getElementById(id);
  if (elm) {
    const {type} = elm;
    switch (type) {
      case "checkbox":
      case "radio":
        elm.checked = !!checked;
        break;
      case "text":
      case "url":
        elm.value = isString(value) && value || "";
        break;
      default:
    }
  }
};

/**
 * set html input values from storage
 * @returns {Promise.<Array>} - results of each handler
 */
const setValuesFromStorage = async () => {
  const func = [];
  const pref = await getAllStorage();
  if (isObjectNotEmpty(pref)) {
    const items = Object.values(pref);
    for (const item of items) {
      isObjectNotEmpty(item) && func.push(setHtmlInputValue(item));
    }
  }
  return Promise.all(func);
};

/* startup */
Promise.all([
  localizeHtml(),
  setValuesFromStorage(),
  addInputChangeListener(),
  addInitExtensionListener(),
]).catch(throwErr);
<|endoftext|>


<commit_before>class DisnodePlugin {
    constructor() {

    }
    default (command) {
        var self = this;
        self.disnode.stats.updateServerMemberCount();
        self.disnode.bot.SendEmbed(command.msg.channel, {
            color: 3447003,
            author: {},
            fields: [{
                name: 'Disnode Info',
                inline: false,
                value: "Bot Info and Stats",
            }, {
                name: 'Uptime',
                inline: false,
                value: self.disnode.stats.getUptime(),
            }, {
                name: 'Total Messages',
                inline: true,
                value: self.disnode.stats.messages,
            }, {
                name: 'Commands',
                inline: true,
                value: self.disnode.stats.messagesParsed,
            }, {
                name: '   ',
                inline: true,
                value: '   ',
            }, {
                name: 'Servers',
                inline: true,
                value: self.disnode.stats.serverCount,
            }, {
                name: 'Members',
                inline: true,
                value: self.disnode.stats.memberCount,
            }, {
                name: '   ',
                inline: true,
                value: '   ',
            }, {
                name: 'Channels',
                inline: true,
                value: self.disnode.stats.channelCount,
            }, {
                name: 'Open DM\'s',
                inline: true,
                value: self.disnode.stats.directMessageCount,
            }, {
                name: '   ',
                inline: true,
                value: '   ',
            }, {
                name: 'Shard #',
                inline: true,
                value: self.disnode.bot.shardID + ' of ' + self.disnode.botConfig.shardCount,
            }, {
                name: 'Shard Mode',
                inline: true,
                value: '' + self.disnode.botConfig.shardMode,
            }, {
                name: '   ',
                inline: true,
                value: '   ',
            }],
            footer: {}
        });
    }
}
module.exports = DisnodePlugin;
<commit_msg>Changed Disnode Plugin Format<commit_after>class DisnodePlugin {
    constructor() {

    }
    default (command) {
        var self = this;
        self.disnode.stats.updateServerMemberCount();
        self.disnode.bot.SendEmbed(command.msg.channel, {
            color: 3447003,
            author: {},
            fields: [{
                name: 'Disnode Info',
                inline: false,
                value: "Bot Info and Stats",
            }, {
                name: 'Shard #',
                inline: true,
                value: self.disnode.bot.shardID + ' of ' + self.disnode.botConfig.shardCount,
            }, {
                name: 'Shard Mode',
                inline: true,
                value: '' + self.disnode.botConfig.shardMode,
            }, {
                name: 'Uptime',
                inline: true,
                value: self.disnode.stats.getUptime(),
            }, {
                name: 'Servers',
                inline: true,
                value: self.disnode.stats.serverCount,
            }, {
                name: 'Channels',
                inline: true,
                value: self.disnode.stats.channelCount,
            }, {
                name: 'Commands',
                inline: true,
                value: self.disnode.stats.messagesParsed,
            }, {
                name: 'Members',
                inline: true,
                value: self.disnode.stats.memberCount,
            }, {
                name: 'Open DM\'s',
                inline: true,
                value: self.disnode.stats.directMessageCount,
            }, {
                name: 'Total Messages',
                inline: true,
                value: self.disnode.stats.messages,
            }],
            footer: {}
        });
    }
}
module.exports = DisnodePlugin;
<|endoftext|>