<commit_before>(function(global) {
    'use strict';
    var CanvasVault = function() {
        this.canvas = null;
        this.canvasContext = null;
    };

    var Canvas   = function(settings) {
        settings = settings || {};
        this.settings = {
            height: 750,
            width:  750,
            backgroundColor: 'rgba(255, 255, 255, 1)',
            style: 'border: 1px solid #fff'
        };

        for(var attrName in settings) {
            this.settings[attrName] = settings[attrName];
        }

        this.canvasElement = null;
        this.canvasContext = null;
        this.setupCanvas();
    };

    Canvas.prototype.setupCanvas  = function() {
        this.canvasElement        = global.document.createElement('canvas');
        this.canvasElement.width  = this.settings.width;
        this.canvasElement.height = this.settings.height;
        this.canvasElement.style  = this.settings.style;

        this.canvasContext        = this.canvasElement.getContext('2d');

        this.canvasContext.fillStyle = this.backgroundColor;
        this.canvasContext.fillRect(0, 0, this.settings.width, this.settings.height);
    };

    Canvas.prototype.isEmpty = function(x, y, width, height) {
        height = height || 1;
        width  = width  || 1;
        var available = true;

        var colors = this.canvasContext.getImageData(x, y, width, height).data;
        var _i;
        for(_i=0; _i<colors.length-1; _i+=4) {
            if(colors[_i] !== 255 || colors[_i+1] !== 255 || colors[_i+2] !== 255) {
                return false;
            }
        }

        return true;
    };

    Canvas.prototype.clearPixels = function(x, y, width, height) {
        width  = width  || 1;
        height = height || 1;
        this.canvasContext.fillStyle = 'rgb(255, 255, 255, 1)';
        this.canvasContext.fillRect(x, y, width, height);
    };

    if(typeof global.xEvolution === 'undefined') {
        Object.defineProperty(global, 'xEvolution', {
            writable : false,
            enumerable : false,
            configurable : false,
            value: {}
        });
    }
    Object.defineProperty(global.xEvolution, 'Canvas', {
        writable : false,
        enumerable : false,
        configurable : false,
        value: {}
    });
    Object.defineProperty(global.xEvolution.Canvas, 'getInstance', {
        writable : false,
        enumerable : false,
        configurable : false,
        value: function(settings) {
            settings = settings || {};

            if(typeof this.instance === 'undefined') {
                Object.defineProperty(global.xEvolution.Canvas, 'instance', {
                    writable : false,
                    enumerable : false,
                    configurable : false,
                    value: new Canvas(settings)
                });
            }

            return this.instance;
        }
    });

})(window);<commit_msg>Some private canvas variables to protect them<commit_after>(function(global) {
    'use strict';
    var CanvasVault = function() {
        this.canvas = null;
        this.canvasContext = null;
    };
    var vault = new CanvasVault();

    var Canvas   = function(settings) {
        settings = settings || {};
        this.settings = {
            height: 750,
            width:  750,
            backgroundColor: 'rgba(255, 255, 255, 1)',
            style: 'border: 1px solid #fff'
        };

        for(var attrName in settings) {
            this.settings[attrName] = settings[attrName];
        }

        this.setupCanvas();
    };

    Canvas.prototype.setupCanvas  = function() {
        vault.canvas        = global.document.createElement('canvas');
        vault.canvas.width  = this.settings.width;
        vault.canvas.height = this.settings.height;
        vault.canvas.style  = this.settings.style;

        vault.canvasContext        = vault.canvas.getContext('2d');

        vault.canvasContext.fillStyle = this.settings.backgroundColor;
        vault.canvasContext.fillRect(0, 0, this.settings.width, this.settings.height);
    };

    Canvas.prototype.isEmpty = function(x, y, width, height) {
        height = height || 1;
        width  = width  || 1;
        var available = true;

        var colors = vault.canvasContext.getImageData(x, y, width, height).data;
        var _i;
        for(_i=0; _i<colors.length-1; _i+=4) {
            if(colors[_i] !== 255 || colors[_i+1] !== 255 || colors[_i+2] !== 255) {
                return false;
            }
        }

        return true;
    };

    Canvas.prototype.clearPixels = function(x, y, width, height) {
        width  = width  || 1;
        height = height || 1;
        vault.canvasContext.fillStyle = 'rgb(255, 255, 255, 1)';
        vault.canvasContext.fillRect(x, y, width, height);
    };

    Canvas.prototype.getCanvas = function() {
        return vault.canvas;
    };

    Canvas.prototype.getCanvasContext = function() {
        return vault.canvasContext;
    };

    if(typeof global.xEvolution === 'undefined') {
        Object.defineProperty(global, 'xEvolution', {
            writable : false,
            enumerable : false,
            configurable : false,
            value: {}
        });
    }
    Object.defineProperty(global.xEvolution, 'Canvas', {
        writable : false,
        enumerable : false,
        configurable : false,
        value: {}
    });
    Object.defineProperty(global.xEvolution.Canvas, 'getInstance', {
        writable : false,
        enumerable : false,
        configurable : false,
        value: function(settings) {
            settings = settings || {};

            if(typeof this.instance === 'undefined') {
                Object.defineProperty(global.xEvolution.Canvas, 'instance', {
                    writable : false,
                    enumerable : false,
                    configurable : false,
                    value: new Canvas(settings)
                });
            }

            return this.instance;
        }
    });

})(window);<|endoftext|>


<commit_before> document.getElementById("id_logic_level_version").innerHTML = "Logic level version: 2017.11.01.1";

 var canvas = document.getElementById("id_canvas");
 var context = canvas.getContext("2d");

 context.beginPath();
 context.moveTo(10, 10);
 context.lineTo(100, 200);
 context.lineTo(200, 100);
 context.closePath();
 context.stroke();
<commit_msg>desenare cerc<commit_after> document.getElementById("id_logic_level_version").innerHTML = "Logic level version: 2017.11.01.2";

 var canvas = document.getElementById("id_canvas");
 var context = canvas.getContext("2d");

 context.beginPath();
 var w = canvas.getAttribute("width");
 var h = canvas.getAttribute("height");

 context.arc(w / 2, h / 2, 10, 0, 2 * Math.PI);

 context.stroke();
<|endoftext|>


<commit_before>function changeCipherBasic() {
  var cipherText = document.getElementById("ciphertext").value;
  document.getElementById("reverse").value = reverse(cipherText);
  document.getElementById("atbash").value = atbash(cipherText);
  document.getElementById("odd").value = extractAlternatingChars(cipherText, 0);
  document.getElementById("even").value = extractAlternatingChars(cipherText, 1);
  document.getElementById("filter-uppercase").value = removeCharRange(cipherText, "uppercase");
  document.getElementById("filter-lowercase").value = removeCharRange(cipherText, "lowercase");
  document.getElementById("filter-numbers").value = removeCharRange(cipherText, "numbers");
}
/**
 * Converts the input text to its reverse.
 * @param {string} the string to be reversed.
 * @return {string} returns the reversed string.
 */
function reverse(text) {
  return reversedString = text.split("").reverse().join("");
}
/**
 * Extracts even/odd characters from input text
 * @param {string} text - text to be extracted from.
 * @param {integer} parity - shift for parity. use 0 to extract odd characters and 1 for even.
 * @return {string} - returns extracted text.
 * @author - Cyan
 */
function extractAlternatingChars(text, parity) {
  var i = 0;
  var outputtext = "";
  if (parity==1 || parity==0) {
    i = parity;
  } else {
    return "WTF is this? Wrong args!!";
  }
  for (i; i < text.length; i=i+2) {
    outputtext = outputtext + text.charAt(i);
  }
  return outputtext;
}

/**
 * Removes a range of characters from input text
 * @param {string} text - text to be extracted from.
 * @param {integer} range - shift for for the character range to be removed. valid values are "uppercase", "lowercase", and "numbers".
 * @return {string} - returns extracted text.
 * @author - Cyan
 */
function removeCharRange(text, range) {
  var outputtext = "";

  function createOutput(cipherText, minLimit, maxLimit) {
    for (i = 0; i < cipherText.length; i++) {
      character = text.charCodeAt(i);
      if (character < minLimit || character > maxLimit) {
        outputtext = outputtext + cipherText.charAt(i);
      }
    }
  }

  switch (range) {
    case "uppercase":
      createOutput(text, 65, 90) //remove uppercase characters
      break;
    case "lowercase":
      createOutput(text, 97, 122) //remove lowercase characters
      break;
    case "numbers":
      createOutput(text, 48, 57) //remove number characters (0-9)
      break;
    default:
      outputtext = "This shit is not implemented yet!";
  }

  return outputtext;
}
/**
 * Converts the input text in to an atbash cipher using an alphabet [a-z] and [A-Z].
 * Numbers and all other characters are left as they are.
 * @param {string} text - text to be atbashed.
 * @return {string} - returns atbash converted string of the input.
 * @todo - Currently this function uses a pure a-z alphabet and uses the ASCII offset
 * to find the atbash. Will not work with anything outside the a-z alphabet OR numbers.
 * @author - KJ <kulendra@gmail.com>
 */
function atbash(text) {

  var i = 0;
  var character = "";
  var outputchar = "";
  var outputtext = "";
  for (i = 0; i < text.length; i++) {
    character = text.charCodeAt(i);
    if (character >= 65 && character <= 90) {
      outputchar = String.fromCharCode(155 - character);
    } else if (character >= 97 && character <= 122) {
      outputchar = String.fromCharCode(219 - character);
    } else {
      outputchar = String.fromCharCode(character);
    }
    outputtext = outputtext + outputchar;
  }
  return outputtext;
}
/**
 * Converts the input text using caesar cipher using an alphabet [a-z] and [A-Z].
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} n - shift for caesar.
 * @param {integer} flag - 0: for encrypt 1: for decrypt
 * @return {string} - returns caesar encrypted/decrypted text.
 */
function caesar(text, n, flag) {

  var i = 0;
  var character = "";
  var outputchar = "";
  var outputtext = "";
  for (i = 0; i < text.length; i++) {
    character = text.charCodeAt(i);
    if (character >= 65 && character <= 90) {
      outputchar = String.fromCharCode(65 + ((character + n) % 91)%65);
    } else if (character >= 97 && character <= 122) {
      outputchar = String.fromCharCode(97 + ((character + n) % 123)%97);
    } else {
      outputchar = String.fromCharCode(character);
    }
    outputtext = outputtext + outputchar;
  }
  return outputtext;
}

/**
 * Converts the input text using a columnar transposition.
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} n - number of columns.
 * @param {integer} flag - 0: top-bottom LR 1: top-bottom RL 2:bottom-top LR 3:bottom-top RL
 * @param {integer} type - 1: snake algorithm 0/ommitted/null: regular
 * @return {string} - returns columnar encrypted/decrypted text.
 * @author - KJ <kulendra@gmail.com>
 */
function columnar_transposition(text, n, flag, type) {
  var character = "";
  var outputchar = "";
  var outputtext = "";
  var rowtext = "";
  var dir = 1;

  var i = 0;
  var j = i;
  var maxrow = Math.ceil(text.length/n);
  var maxcol = n;

  // read columnwise left-right
  if(flag == 0){
	  for(j=0;j<maxcol;j++){
	  	rowtext = "";
	  	for(i=0;i<maxrow;i++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read columnwise right-left
  if (flag == 1){
	  for(j=maxcol-1;j>=0;j--){
	  	rowtext="";
	  	for(i=0;i<maxrow;i++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read columnwise bottom-top left-right
  if (flag == 2){
	  for(j=0;j<maxcol;j++){
	  	rowtext="";
	  	for(i=maxrow-1;i>=0;i--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read columnwise bottom-up right-left
  if (flag == 3){
	  for(j=maxcol-1;j>=0;j--){
	  	rowtext="";
	  	for(i=maxrow-1;i>=0;i--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read rowwise right-left top-bottom
  if (flag == 4){
	  for(i=0;i<maxrow;i++){
	  	rowtext="";
	  	for(j=maxcol-1;j>=0;j--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read rowwise right-left bottom-up
  if (flag == 5){
	  for(i=maxrow-1;i>=0;i--){
	  	rowtext="";
	  	for(j=maxcol-1;j>=0;j--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read rowwise left-right top-bottom
  if(flag==6){
	  for(i=0;i<maxrow;i++){
		rowtext="";
	  	for(j=0;j<maxcol;j++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }
  //read rowwise left-right bottom-top
  if(flag==7){
	  for(i=maxrow-1;i>=0;i--){
	  	rowtext="";
	  	for(j=0;j<maxcol;j++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }
}

/**
 * Converts the input text into their Ascii values
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} flag - 0: number to letter 1: letter to number 2: Ascii to characters 3: char to Ascii
 *                         4: hex to char 5: char to hex 6: b64 to char 7:char to b64
 * @return {string} - returns the converted text.
 * @todo - The ASCII and Hex conversions assume that it will be all doublets. I can't think of a better alternative.
 * @author - KJ <kulendra@gmail.com>
 */
function numText(text,flag){
  var character="";
  var output="";
  var i=0;
  for(i=0;i<text.length;i++){
  	if(flag==0){
		// 0->a
		if(!isNaN(parseInt(text.charAt(i)))){
			output = output + String.fromCharCode(97+parseInt(text.charAt(i)));
		}
		else{
			output = output + text.charAt(i);
		}

  	}
  	else if(flag==1){
		// a->0
  		text = text.toLowerCase();
		if(isNaN(parseInt(text.charAt(i)))){
			output = output + (parseInt(text.charCodeAt(i)) - 97);
		}
		else{
			output = output + text.charAt(i);
		}

  	}
  	else if(flag==2){
		// ASC -> A
  		// Assumes that the characters will be in lower case range and a two character code.
  		output = output + String.fromCharCode(text.charAt(i)+text.charAt(i+1));
  		i++;
  	}
  	else if(flag==3){
		// A->ASC
  		output = output + text.charCodeAt(i);
  	}
  	else if(flag==4){
		// Hex->A
  		character = text.charAt(i)+text.charAt(i+1);
  		output = output + String.fromCharCode(parseInt(character,16));
  		i++;
  	}
  	else if(flag==5){
		// A->Hex
  		output = output + text.charCodeAt(i).toString(16);
  	}
  }
  if(flag==6){
  	// B64->A
  	output = atob(text);
  }
  else if(flag==7){
  	// A->B64
  	output = btoa(text);
  }

  return output;
}

/**
 * Converts the input text using caesar cipher using an alphabet [a-z] and [A-Z].
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} a - shift for a.
 * @param {integer} b - shift for b.
 * @param {integer} flag - 0: for encrypt 1: for decrypt
 * @return {string} - returns caesar encrypted/decrypted text.
 */
function affine(text, a, b, flag){
	var output_text = "";
	for (i=0;i<text.length;i++){
		char = text.charCodeAt(i);
		if(char>=65 && char <= 90){
			c = 65 + (((char + 91 - b))%91 /a % 26);
		}
		if(char>=97 && char <= 122){
			c = 97 + (((char + 123 - b))%123 )/a % 26);
		}
		output_text = output_text + c;
	}
	return output_text;
}

/**
 * Converts the case of the text. Leaves non alphabetic characters as it is.
 * @param {string} text - text to be converted.
 * @return {string} - returns the converted text.
 * @author - KJ <kulendra@gmail.com>
 */
function caseSwitch(text){
	var output = "";
	for(i=0;i<text.length;i++){
		c = text.CharAt(i);
		if(c==c.toUpperCase()){
			output = output+c.toLowerCase();
		}
		else if(c==c.toLowerCase()){
			output = output+c.toUpperCase();
		}
		else{
			output = output + c;
		}
	}
}
<commit_msg>Update affine()<commit_after>function changeCipherBasic() {
  var cipherText = document.getElementById("ciphertext").value;
  document.getElementById("reverse").value = reverse(cipherText);
  document.getElementById("atbash").value = atbash(cipherText);
  document.getElementById("odd").value = extractAlternatingChars(cipherText, 0);
  document.getElementById("even").value = extractAlternatingChars(cipherText, 1);
  document.getElementById("filter-uppercase").value = removeCharRange(cipherText, "uppercase");
  document.getElementById("filter-lowercase").value = removeCharRange(cipherText, "lowercase");
  document.getElementById("filter-numbers").value = removeCharRange(cipherText, "numbers");
}
/**
 * Converts the input text to its reverse.
 * @param {string} the string to be reversed.
 * @return {string} returns the reversed string.
 */
function reverse(text) {
  return reversedString = text.split("").reverse().join("");
}
/**
 * Extracts even/odd characters from input text
 * @param {string} text - text to be extracted from.
 * @param {integer} parity - shift for parity. use 0 to extract odd characters and 1 for even.
 * @return {string} - returns extracted text.
 * @author - Cyan
 */
function extractAlternatingChars(text, parity) {
  var i = 0;
  var outputtext = "";
  if (parity==1 || parity==0) {
    i = parity;
  } else {
    return "WTF is this? Wrong args!!";
  }
  for (i; i < text.length; i=i+2) {
    outputtext = outputtext + text.charAt(i);
  }
  return outputtext;
}

/**
 * Removes a range of characters from input text
 * @param {string} text - text to be extracted from.
 * @param {integer} range - shift for for the character range to be removed. valid values are "uppercase", "lowercase", and "numbers".
 * @return {string} - returns extracted text.
 * @author - Cyan
 */
function removeCharRange(text, range) {
  var outputtext = "";

  function createOutput(cipherText, minLimit, maxLimit) {
    for (i = 0; i < cipherText.length; i++) {
      character = text.charCodeAt(i);
      if (character < minLimit || character > maxLimit) {
        outputtext = outputtext + cipherText.charAt(i);
      }
    }
  }

  switch (range) {
    case "uppercase":
      createOutput(text, 65, 90) //remove uppercase characters
      break;
    case "lowercase":
      createOutput(text, 97, 122) //remove lowercase characters
      break;
    case "numbers":
      createOutput(text, 48, 57) //remove number characters (0-9)
      break;
    default:
      outputtext = "This shit is not implemented yet!";
  }

  return outputtext;
}
/**
 * Converts the input text in to an atbash cipher using an alphabet [a-z] and [A-Z].
 * Numbers and all other characters are left as they are.
 * @param {string} text - text to be atbashed.
 * @return {string} - returns atbash converted string of the input.
 * @todo - Currently this function uses a pure a-z alphabet and uses the ASCII offset
 * to find the atbash. Will not work with anything outside the a-z alphabet OR numbers.
 * @author - KJ <kulendra@gmail.com>
 */
function atbash(text) {

  var i = 0;
  var character = "";
  var outputchar = "";
  var outputtext = "";
  for (i = 0; i < text.length; i++) {
    character = text.charCodeAt(i);
    if (character >= 65 && character <= 90) {
      outputchar = String.fromCharCode(155 - character);
    } else if (character >= 97 && character <= 122) {
      outputchar = String.fromCharCode(219 - character);
    } else {
      outputchar = String.fromCharCode(character);
    }
    outputtext = outputtext + outputchar;
  }
  return outputtext;
}
/**
 * Converts the input text using caesar cipher using an alphabet [a-z] and [A-Z].
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} n - shift for caesar.
 * @param {integer} flag - 0: for encrypt 1: for decrypt
 * @return {string} - returns caesar encrypted/decrypted text.
 */
function caesar(text, n, flag) {

  var i = 0;
  var character = "";
  var outputchar = "";
  var outputtext = "";
  for (i = 0; i < text.length; i++) {
    character = text.charCodeAt(i);
    if (character >= 65 && character <= 90) {
      outputchar = String.fromCharCode(65 + ((character + n) % 91)%65);
    } else if (character >= 97 && character <= 122) {
      outputchar = String.fromCharCode(97 + ((character + n) % 123)%97);
    } else {
      outputchar = String.fromCharCode(character);
    }
    outputtext = outputtext + outputchar;
  }
  return outputtext;
}

/**
 * Converts the input text using a columnar transposition.
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} n - number of columns.
 * @param {integer} flag - 0: top-bottom LR 1: top-bottom RL 2:bottom-top LR 3:bottom-top RL
 * @param {integer} type - 1: snake algorithm 0/ommitted/null: regular
 * @return {string} - returns columnar encrypted/decrypted text.
 * @author - KJ <kulendra@gmail.com>
 */
function columnar_transposition(text, n, flag, type) {
  var character = "";
  var outputchar = "";
  var outputtext = "";
  var rowtext = "";
  var dir = 1;

  var i = 0;
  var j = i;
  var maxrow = Math.ceil(text.length/n);
  var maxcol = n;

  // read columnwise left-right
  if(flag == 0){
	  for(j=0;j<maxcol;j++){
	  	rowtext = "";
	  	for(i=0;i<maxrow;i++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read columnwise right-left
  if (flag == 1){
	  for(j=maxcol-1;j>=0;j--){
	  	rowtext="";
	  	for(i=0;i<maxrow;i++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read columnwise bottom-top left-right
  if (flag == 2){
	  for(j=0;j<maxcol;j++){
	  	rowtext="";
	  	for(i=maxrow-1;i>=0;i--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read columnwise bottom-up right-left
  if (flag == 3){
	  for(j=maxcol-1;j>=0;j--){
	  	rowtext="";
	  	for(i=maxrow-1;i>=0;i--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read rowwise right-left top-bottom
  if (flag == 4){
	  for(i=0;i<maxrow;i++){
	  	rowtext="";
	  	for(j=maxcol-1;j>=0;j--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read rowwise right-left bottom-up
  if (flag == 5){
	  for(i=maxrow-1;i>=0;i--){
	  	rowtext="";
	  	for(j=maxcol-1;j>=0;j--){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }

  //read rowwise left-right top-bottom
  if(flag==6){
	  for(i=0;i<maxrow;i++){
		rowtext="";
	  	for(j=0;j<maxcol;j++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }
  //read rowwise left-right bottom-top
  if(flag==7){
	  for(i=maxrow-1;i>=0;i--){
	  	rowtext="";
	  	for(j=0;j<maxcol;j++){
			outputchar = text.charAt(i*n+j);
			rowtext = rowtext+outputchar;
		}
		if(dir == -1 && type==1){
			rowtext = reverse(rowtext);
		}
		dir=dir*(-1);
		outputtext = outputtext+rowtext;
	  }
	  return outputtext;
  }
}

/**
 * Converts the input text into their Ascii values
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} flag - 0: number to letter 1: letter to number 2: Ascii to characters 3: char to Ascii
 *                         4: hex to char 5: char to hex 6: b64 to char 7:char to b64
 * @return {string} - returns the converted text.
 * @todo - The ASCII and Hex conversions assume that it will be all doublets. I can't think of a better alternative.
 * @author - KJ <kulendra@gmail.com>
 */
function numText(text,flag){
  var character="";
  var output="";
  var i=0;
  for(i=0;i<text.length;i++){
  	if(flag==0){
		// 0->a
		if(!isNaN(parseInt(text.charAt(i)))){
			output = output + String.fromCharCode(97+parseInt(text.charAt(i)));
		}
		else{
			output = output + text.charAt(i);
		}

  	}
  	else if(flag==1){
		// a->0
  		text = text.toLowerCase();
		if(isNaN(parseInt(text.charAt(i)))){
			output = output + (parseInt(text.charCodeAt(i)) - 97);
		}
		else{
			output = output + text.charAt(i);
		}

  	}
  	else if(flag==2){
		// ASC -> A
  		// Assumes that the characters will be in lower case range and a two character code.
  		output = output + String.fromCharCode(text.charAt(i)+text.charAt(i+1));
  		i++;
  	}
  	else if(flag==3){
		// A->ASC
  		output = output + text.charCodeAt(i);
  	}
  	else if(flag==4){
		// Hex->A
  		character = text.charAt(i)+text.charAt(i+1);
  		output = output + String.fromCharCode(parseInt(character,16));
  		i++;
  	}
  	else if(flag==5){
		// A->Hex
  		output = output + text.charCodeAt(i).toString(16);
  	}
  }
  if(flag==6){
  	// B64->A
  	output = atob(text);
  }
  else if(flag==7){
  	// A->B64
  	output = btoa(text);
  }

  return output;
}

/**
 * Converts the input text using caesar cipher using an alphabet [a-z] and [A-Z].
 * @param {string} text - text to be encrypted/decrypted.
 * @param {integer} a - shift for a.
 * @param {integer} b - shift for b.
 * @param {integer} flag - 0: for encrypt 1: for decrypt
 * @return {string} - returns caesar encrypted/decrypted text.
 */
function affine(text, a, b, flag){
	var output_text = "";
	for (i=0;i<text.length;i++){
		char = text.charCodeAt(i);
		if(char>=65 && char <= 90){
			c = 65 + ((char + 91 - b)%91 /a % 26);
		}
		if(char>=97 && char <= 122){
			c = 97 + ((char + 123 - b)%123 )/a % 26);
		}
		output_text = output_text + c;
	}
	return output_text;
}

/**
 * Converts the case of the text. Leaves non alphabetic characters as it is.
 * @param {string} text - text to be converted.
 * @return {string} - returns the converted text.
 * @author - KJ <kulendra@gmail.com>
 */
function caseSwitch(text){
	var output = "";
	for(i=0;i<text.length;i++){
		c = text.CharAt(i);
		if(c==c.toUpperCase()){
			output = output+c.toLowerCase();
		}
		else if(c==c.toLowerCase()){
			output = output+c.toUpperCase();
		}
		else{
			output = output + c;
		}
	}
}
<|endoftext|>


<commit_before>"use strict";

//  ---------------------------------------------------------------------------

const Exchange = require ('./base/Exchange');
const { ExchangeError, InsufficientFunds, OrderNotFound, InvalidOrder, AuthenticationError } = require ('./base/errors');

//  ---------------------------------------------------------------------------

module.exports = class coinex extends Exchange {

    describe () {
        return this.deepExtend (super.describe (), {
            'id': 'coinex',
            'name': 'CoinEx',
            'countries': 'CN',
            'rateLimit': 1000,
            'has': {
                'fetchTickers': true,
                'fetchOHLCV': true,
                'fetchOpenOrders': true,
                'fetchClosedOrders': true,
            },
            'timeframes': {
                '1m': '1min',
                '3m': '3min',
                '5m': '5min',
                '15m': '15min',
                '30m': '30min',
                '1h': '1hour',
                '2h': '2hour',
                '4h': '4hour',
                '6h': '6hour',
                '12h': '12hour',
                '1d': '1day',
                '3d': '3day',
                '1w': '1week',
            },
            'urls': {
                'logo': 'https://www.coinex.com/_nuxt/img/coin-ex-logo-white.abfd6af.svg',
                'api': 'https://api.coinex.com/v1',
                'www': 'https://www.coinex.com/',
                'doc': 'https://github.com/coinexcom/coinex_exchange_api/wiki',
                'fees': 'https://www.coinex.com/fees',
            },
            'api': {
                'public': {
                    'get': [
                        'market/list',
                        'market/ticker',
                        'market/ticker/all',
                        'market/depth',
                        'market/deals',
                        'market/kline',
                    ],
                },
                'private': {
                    'get': [
                        'balance',
                        'order',
                        'order/pending',
                        'order/finished',
                        'order/finished/{id}',
                    ],
                    'post': [
                        'order/limit',
                        'order/market',
                    ],
                    'delete': [
                        'order/pending',
                    ],
                },
            },
            'fees': {
                'trading': {
                    'maker': 0.0,
                    'taker': 0.001,
                },
                'funding': {
                    'withdraw': {
                        'BCH': 0.0,
                        'BTC': 0.001,
                        'LTC': 0.001,
                        'ETH': 0.001,
                        'ZEC': 0.0001,
                        'DASH': 0.0001,
                    },
                },
            },
            'limits': {
                'amount': {
                    'min': 0.001,
                    'max': undefined,
                },
            },
            'precision': {
                'amount': 8,
                'price': 8,
            },
        });
    }

    commonCurrencyCode (currency) {
        return currency;
    }

    async fetchMarkets () {
        let markets = await this.publicGetMarketList ();
        let result = [];
        for (let i = 0; i < markets.length; i++) {
            let id = markets[i];
            let base = id.slice (-3);
            let quote = id.slice (0, -3);
            let symbol = base + '/' + quote;
            result.push ({
                'id': id,
                'symbol': symbol,
                'base': base,
                'quote': quote,
                'active': true,
                'lot': this.limits['amount']['min'],
                'info': id,
            });
        }
        return result;
    }

    parseTicker (ticker, market = undefined) {
        let timestamp = ticker['date'];
        let symbol = market['symbol'];
        ticker = ticker['ticker'];
        return {
            'symbol': symbol,
            'timestamp': timestamp,
            'datetime': this.iso8601 (timestamp),
            'high': parseFloat (ticker['high']),
            'low': parseFloat (ticker['low']),
            'bid': parseFloat (ticker['buy']),
            'ask': parseFloat (ticker['sell']),
            'vwap': undefined,
            'open': undefined,
            'close': undefined,
            'first': undefined,
            'last': parseFloat (ticker['last']),
            'change': undefined,
            'percentage': undefined,
            'average': undefined,
            'baseVolume': undefined,
            'quoteVolume': parseFloat (ticker['vol']),
            'info': ticker,
        };
    }

    async fetchTicker (symbol, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let ticker = await this.publicGetMarketTicker (this.extend ({
            'market': market['id'],
        }, params));
        return this.parseTicker (ticker, market);
    }

    async fetchTickers (symbols = undefined, params = {}) {
        await this.loadMarkets ();
        let tickers = await this.publicGetMarketTickerAll (params);
        let timestamp = tickers['date'];
        tickers = tickers['ticker'];
        let ids = Object.keys (tickers);
        let result = {};
        for (let i = 0; i < ids.length; i++) {
            let id = ids[i];
            let market = this.markets_by_id[id];
            let symbol = market['symbol'];
            let ticker = {
                'date': timestamp,
                'ticker': tickers[id],
            };
            result[symbol] = this.parseTicker (ticker, market);
        }
        return result;
    }

    async fetchOrderBook (symbol, params = {}) {
        await this.loadMarkets ();
        let orderbook = await this.publicGetMarketDepth (this.extend ({
            'market': this.marketId (symbol),
            'merge': '0.00000001',
        }, params));
        return this.parseOrderBook (orderbook);
    }

    parseTrade (trade, market = undefined) {
        let timestamp = trade['date_ms'];
        let price = parseFloat (trade['price']);
        let amount = parseFloat (trade['amount']);
        let symbol = market['symbol'];
        let cost = parseFloat (this.costToPrecision (symbol, price * amount));
        return {
            'info': trade,
            'timestamp': timestamp,
            'datetime': this.iso8601 (timestamp),
            'symbol': symbol,
            'id': this.safeString (trade, 'id'),
            'order': undefined,
            'type': 'limit',
            'side': trade['type'],
            'price': price,
            'amount': amount,
            'cost': cost,
            'fee': undefined,
        };
    }

    async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let trades = await this.publicGetMarketDeals (this.extend ({
            'market': market['id'],
        }, params));
        return this.parseTrades (trades, market, since, limit);
    }

    parseOHLCV (ohlcv, market = undefined, timeframe = '5m', since = undefined, limit = undefined) {
        return [
            ohlcv[0],
            parseFloat (ohlcv[1]),
            parseFloat (ohlcv[3]),
            parseFloat (ohlcv[4]),
            parseFloat (ohlcv[2]),
            parseFloat (ohlcv[5]),
        ];
    }

    async fetchOHLCV (symbol, timeframe = '5m', since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let response = await this.publicGetMarketKline (this.extend ({
            'market': market['id'],
            'type': this.timeframes[timeframe],
        }, params));
        return this.parseOHLCVs (response, market, timeframe, since, limit);
    }

    async fetchBalance (params = {}) {
        await this.loadMarkets ();
        let balances = await this.privateGetBalance (params);
        let result = { 'info': balances };
        let currencies = Object.keys (balances);
        for (let i = 0; i < currencies.length; i++) {
            let id = currencies[i];
            let balance = balances[id];
            let currency = this.commonCurrencyCode (id);
            let account = {
                'free': parseFloat (balance['available']),
                'used': parseFloat (balance['frozen']),
                'total': 0.0,
            };
            account['total'] = this.sum (account['free'], account['used']);
            result[currency] = account;
        }
        return this.parseBalance (result);
    }

    parseOrder (order, market = undefined) {
        // TODO: check if it's actually milliseconds, since examples were in seconds
        let timestamp = this.safeInteger (order, 'create_time') * 1000;
        let price = parseFloat (order['price']);
        let cost = this.safeFloat (order, 'deal_money');
        let amount = this.safeFloat (order, 'amount');
        let filled = this.safeFloat (order, 'deal_amount');
        let symbol = market['symbol'];
        let remaining = this.amountToPrecision (symbol, amount - filled);
        let status = order['status'];
        if (status == 'done') {
            status = 'closed';
        } else {
            // not_deal
            // part_deal
            status = 'open';
        }
        return {
            'id': this.safeString (order, 'id'),
            'datetime': this.iso8601 (timestamp),
            'timestamp': timestamp,
            'status': status,
            'symbol': symbol,
            'type': order['order_type'],
            'side': order['type'],
            'price': price,
            'cost': cost,
            'amount': amount,
            'filled': filled,
            'remaining': remaining,
            'trades': undefined,
            'fee': {
                'currency': market['quote'],
                'cost': parseFloat (order['deal_fee']),
            },
            'info': order,
        };
    }

    parseOrders (orders, market, result = []) {
        for (let i = 0; i < orders.length; i++) {
            let order = orders[i];
            result.push (this.parseOrder (order, market));
        }
        return result;
    }

    async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
        await this.loadMarkets ();
        let method = 'privatePostOrder' + this.capitalize (type);
        let market = this.market (symbol);
        amount = parseFloat (amount);
        let request = {
            'market': market['id'],
            'amount': this.amountToPrecision (symbol, amount),
            'type': side,
        };
        if (type == 'limit') {
            price = parseFloat (price);
            request['price'] = this.priceToPrecision (symbol, price);
        }
        let response = await this[method] (this.extend (request, params));
        let order = this.parseOrder (response, market);
        let id = order['id'];
        this.orders[id] = order;
        return order;
    }

    async cancelOrder (id, symbol = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let result = await this.privateDeleteOrderPending (this.extend ({
            'id': id,
            'market': market['id'],
        }, params));
        return this.parseOrder (result, market);
    }

    async fetchOrder (id, symbol = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let order = await this.privateGetOrder (this.extend ({
            'id': id,
            'market': market['id'],
        }, params));
        return this.parseOrder (order, market);
    }

    async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let request = {
            'market': market['id'],
        };
        if (limit)
            request['limit'] = limit;
        let orders = await this.privateGetOrderPending (this.extend (request, params));
        return this.parseOrders (orders['data'], market);
    }

    async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let request = {
            'market': market['id'],
        };
        if (limit)
            request['limit'] = limit;
        let orders = await this.privateGetOrderFinished (this.extend (request, params));
        return this.parseOrders (orders['data'], market);
    }
    //
    // async fetchOrderTrades (id, symbol = undefined, params = {}) {
    //     await this.loadMarkets ();
    //     let market = this.market (symbol);
    //     let trades = await this.privateGetOrderFinishedId (this.extend ({
    //         'id': id,
    //         'market': market['id'],
    //         'page': 1,
    //         'limit': 100,
    //     }, params));
    //     return trades['data'];
    // }
    //
    nonce () {
        return this.milliseconds ();
    }

    sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
        let url = this.urls['api'] + '/' + this.implodeParams (path, params);
        let query = this.omit (params, this.extractParams (path));
        if (api == 'public') {
            if (Object.keys (query).length)
                url += '?' + this.urlencode (query);
        } else {
            this.checkRequiredCredentials ();
            let nonce = this.nonce ();
            query = this.extend ({
                'access_id': this.apiKey,
                'tonce': nonce.toString (),
            }, query);
            query = this.keysort (query);
            let encQuery = this.urlencode (query);
            let signature = this.hash (encQuery + '&secret_key=' + this.secret);
            headers = {
                'Authorization': signature.toUpperCase (),
                'Content-Type': 'application/json',
            };
            if (method == 'GET') {
                url += '?' + encQuery;
            } else {
                body = this.json (query);
            }
        }
        return { 'url': url, 'method': method, 'body': body, 'headers': headers };
    }

    async request (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
        let response = await this.fetch2 (path, api, method, params, headers, body);
        let code = this.safeString (response, 'code');
        if (code != '0' || !this.safeValue (response, 'data')) {
            let responseCodes = {
                '24': AuthenticationError,
                '25': AuthenticationError,
                '107': InsufficientFunds,
                '600': OrderNotFound,
                '601': InvalidOrder,
                '602': InvalidOrder,
                '606': InvalidOrder,
            };
            let errorClass = this.safeValue (responseCodes, code, ExchangeError);
            throw new errorClass (response['message']);
        }
        // code and message will always be the same here (0, 'Ok'), so ignore them
        return response['data'];
    }
}
<commit_msg>coinex: eslint<commit_after>'use strict';

//  ---------------------------------------------------------------------------

const Exchange = require ('./base/Exchange');
const { ExchangeError, InsufficientFunds, OrderNotFound, InvalidOrder, AuthenticationError } = require ('./base/errors');

//  ---------------------------------------------------------------------------

module.exports = class coinex extends Exchange {

    describe () {
        return this.deepExtend (super.describe (), {
            'id': 'coinex',
            'name': 'CoinEx',
            'countries': 'CN',
            'rateLimit': 1000,
            'has': {
                'fetchTickers': true,
                'fetchOHLCV': true,
                'fetchOpenOrders': true,
                'fetchClosedOrders': true,
            },
            'timeframes': {
                '1m': '1min',
                '3m': '3min',
                '5m': '5min',
                '15m': '15min',
                '30m': '30min',
                '1h': '1hour',
                '2h': '2hour',
                '4h': '4hour',
                '6h': '6hour',
                '12h': '12hour',
                '1d': '1day',
                '3d': '3day',
                '1w': '1week',
            },
            'urls': {
                'logo': 'https://www.coinex.com/_nuxt/img/coin-ex-logo-white.abfd6af.svg',
                'api': 'https://api.coinex.com/v1',
                'www': 'https://www.coinex.com/',
                'doc': 'https://github.com/coinexcom/coinex_exchange_api/wiki',
                'fees': 'https://www.coinex.com/fees',
            },
            'api': {
                'public': {
                    'get': [
                        'market/list',
                        'market/ticker',
                        'market/ticker/all',
                        'market/depth',
                        'market/deals',
                        'market/kline',
                    ],
                },
                'private': {
                    'get': [
                        'balance',
                        'order',
                        'order/pending',
                        'order/finished',
                        'order/finished/{id}',
                    ],
                    'post': [
                        'order/limit',
                        'order/market',
                    ],
                    'delete': [
                        'order/pending',
                    ],
                },
            },
            'fees': {
                'trading': {
                    'maker': 0.0,
                    'taker': 0.001,
                },
                'funding': {
                    'withdraw': {
                        'BCH': 0.0,
                        'BTC': 0.001,
                        'LTC': 0.001,
                        'ETH': 0.001,
                        'ZEC': 0.0001,
                        'DASH': 0.0001,
                    },
                },
            },
            'limits': {
                'amount': {
                    'min': 0.001,
                    'max': undefined,
                },
            },
            'precision': {
                'amount': 8,
                'price': 8,
            },
        });
    }

    commonCurrencyCode (currency) {
        return currency;
    }

    async fetchMarkets () {
        let markets = await this.publicGetMarketList ();
        let result = [];
        for (let i = 0; i < markets.length; i++) {
            let id = markets[i];
            let base = id.slice (-3);
            let quote = id.slice (0, -3);
            let symbol = base + '/' + quote;
            result.push ({
                'id': id,
                'symbol': symbol,
                'base': base,
                'quote': quote,
                'active': true,
                'lot': this.limits['amount']['min'],
                'info': id,
            });
        }
        return result;
    }

    parseTicker (ticker, market = undefined) {
        let timestamp = ticker['date'];
        let symbol = market['symbol'];
        ticker = ticker['ticker'];
        return {
            'symbol': symbol,
            'timestamp': timestamp,
            'datetime': this.iso8601 (timestamp),
            'high': parseFloat (ticker['high']),
            'low': parseFloat (ticker['low']),
            'bid': parseFloat (ticker['buy']),
            'ask': parseFloat (ticker['sell']),
            'vwap': undefined,
            'open': undefined,
            'close': undefined,
            'first': undefined,
            'last': parseFloat (ticker['last']),
            'change': undefined,
            'percentage': undefined,
            'average': undefined,
            'baseVolume': undefined,
            'quoteVolume': parseFloat (ticker['vol']),
            'info': ticker,
        };
    }

    async fetchTicker (symbol, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let ticker = await this.publicGetMarketTicker (this.extend ({
            'market': market['id'],
        }, params));
        return this.parseTicker (ticker, market);
    }

    async fetchTickers (symbols = undefined, params = {}) {
        await this.loadMarkets ();
        let tickers = await this.publicGetMarketTickerAll (params);
        let timestamp = tickers['date'];
        tickers = tickers['ticker'];
        let ids = Object.keys (tickers);
        let result = {};
        for (let i = 0; i < ids.length; i++) {
            let id = ids[i];
            let market = this.markets_by_id[id];
            let symbol = market['symbol'];
            let ticker = {
                'date': timestamp,
                'ticker': tickers[id],
            };
            result[symbol] = this.parseTicker (ticker, market);
        }
        return result;
    }

    async fetchOrderBook (symbol, params = {}) {
        await this.loadMarkets ();
        let orderbook = await this.publicGetMarketDepth (this.extend ({
            'market': this.marketId (symbol),
            'merge': '0.00000001',
        }, params));
        return this.parseOrderBook (orderbook);
    }

    parseTrade (trade, market = undefined) {
        let timestamp = trade['date_ms'];
        let price = parseFloat (trade['price']);
        let amount = parseFloat (trade['amount']);
        let symbol = market['symbol'];
        let cost = parseFloat (this.costToPrecision (symbol, price * amount));
        return {
            'info': trade,
            'timestamp': timestamp,
            'datetime': this.iso8601 (timestamp),
            'symbol': symbol,
            'id': this.safeString (trade, 'id'),
            'order': undefined,
            'type': 'limit',
            'side': trade['type'],
            'price': price,
            'amount': amount,
            'cost': cost,
            'fee': undefined,
        };
    }

    async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let trades = await this.publicGetMarketDeals (this.extend ({
            'market': market['id'],
        }, params));
        return this.parseTrades (trades, market, since, limit);
    }

    parseOHLCV (ohlcv, market = undefined, timeframe = '5m', since = undefined, limit = undefined) {
        return [
            ohlcv[0],
            parseFloat (ohlcv[1]),
            parseFloat (ohlcv[3]),
            parseFloat (ohlcv[4]),
            parseFloat (ohlcv[2]),
            parseFloat (ohlcv[5]),
        ];
    }

    async fetchOHLCV (symbol, timeframe = '5m', since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let response = await this.publicGetMarketKline (this.extend ({
            'market': market['id'],
            'type': this.timeframes[timeframe],
        }, params));
        return this.parseOHLCVs (response, market, timeframe, since, limit);
    }

    async fetchBalance (params = {}) {
        await this.loadMarkets ();
        let balances = await this.privateGetBalance (params);
        let result = { 'info': balances };
        let currencies = Object.keys (balances);
        for (let i = 0; i < currencies.length; i++) {
            let id = currencies[i];
            let balance = balances[id];
            let currency = this.commonCurrencyCode (id);
            let account = {
                'free': parseFloat (balance['available']),
                'used': parseFloat (balance['frozen']),
                'total': 0.0,
            };
            account['total'] = this.sum (account['free'], account['used']);
            result[currency] = account;
        }
        return this.parseBalance (result);
    }

    parseOrder (order, market = undefined) {
        // TODO: check if it's actually milliseconds, since examples were in seconds
        let timestamp = this.safeInteger (order, 'create_time') * 1000;
        let price = parseFloat (order['price']);
        let cost = this.safeFloat (order, 'deal_money');
        let amount = this.safeFloat (order, 'amount');
        let filled = this.safeFloat (order, 'deal_amount');
        let symbol = market['symbol'];
        let remaining = this.amountToPrecision (symbol, amount - filled);
        let status = order['status'];
        if (status === 'done') {
            status = 'closed';
        } else {
            // not_deal
            // part_deal
            status = 'open';
        }
        return {
            'id': this.safeString (order, 'id'),
            'datetime': this.iso8601 (timestamp),
            'timestamp': timestamp,
            'status': status,
            'symbol': symbol,
            'type': order['order_type'],
            'side': order['type'],
            'price': price,
            'cost': cost,
            'amount': amount,
            'filled': filled,
            'remaining': remaining,
            'trades': undefined,
            'fee': {
                'currency': market['quote'],
                'cost': parseFloat (order['deal_fee']),
            },
            'info': order,
        };
    }

    parseOrders (orders, market, result = []) {
        for (let i = 0; i < orders.length; i++) {
            let order = orders[i];
            result.push (this.parseOrder (order, market));
        }
        return result;
    }

    async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
        await this.loadMarkets ();
        let method = 'privatePostOrder' + this.capitalize (type);
        let market = this.market (symbol);
        amount = parseFloat (amount);
        let request = {
            'market': market['id'],
            'amount': this.amountToPrecision (symbol, amount),
            'type': side,
        };
        if (type === 'limit') {
            price = parseFloat (price);
            request['price'] = this.priceToPrecision (symbol, price);
        }
        let response = await this[method] (this.extend (request, params));
        let order = this.parseOrder (response, market);
        let id = order['id'];
        this.orders[id] = order;
        return order;
    }

    async cancelOrder (id, symbol = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let result = await this.privateDeleteOrderPending (this.extend ({
            'id': id,
            'market': market['id'],
        }, params));
        return this.parseOrder (result, market);
    }

    async fetchOrder (id, symbol = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let order = await this.privateGetOrder (this.extend ({
            'id': id,
            'market': market['id'],
        }, params));
        return this.parseOrder (order, market);
    }

    async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let request = {
            'market': market['id'],
        };
        if (limit)
            request['limit'] = limit;
        let orders = await this.privateGetOrderPending (this.extend (request, params));
        return this.parseOrders (orders['data'], market);
    }

    async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        let market = this.market (symbol);
        let request = {
            'market': market['id'],
        };
        if (limit)
            request['limit'] = limit;
        let orders = await this.privateGetOrderFinished (this.extend (request, params));
        return this.parseOrders (orders['data'], market);
    }
    //
    // async fetchOrderTrades (id, symbol = undefined, params = {}) {
    //     await this.loadMarkets ();
    //     let market = this.market (symbol);
    //     let trades = await this.privateGetOrderFinishedId (this.extend ({
    //         'id': id,
    //         'market': market['id'],
    //         'page': 1,
    //         'limit': 100,
    //     }, params));
    //     return trades['data'];
    // }
    //
    nonce () {
        return this.milliseconds ();
    }

    sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
        let url = this.urls['api'] + '/' + this.implodeParams (path, params);
        let query = this.omit (params, this.extractParams (path));
        if (api === 'public') {
            if (Object.keys (query).length)
                url += '?' + this.urlencode (query);
        } else {
            this.checkRequiredCredentials ();
            let nonce = this.nonce ();
            query = this.extend ({
                'access_id': this.apiKey,
                'tonce': nonce.toString (),
            }, query);
            query = this.keysort (query);
            let encQuery = this.urlencode (query);
            let signature = this.hash (encQuery + '&secret_key=' + this.secret);
            headers = {
                'Authorization': signature.toUpperCase (),
                'Content-Type': 'application/json',
            };
            if (method === 'GET') {
                url += '?' + encQuery;
            } else {
                body = this.json (query);
            }
        }
        return { 'url': url, 'method': method, 'body': body, 'headers': headers };
    }

    async request (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
        let response = await this.fetch2 (path, api, method, params, headers, body);
        let code = this.safeString (response, 'code');
        if (code !== '0' || !this.safeValue (response, 'data')) {
            let responseCodes = {
                '24': AuthenticationError,
                '25': AuthenticationError,
                '107': InsufficientFunds,
                '600': OrderNotFound,
                '601': InvalidOrder,
                '602': InvalidOrder,
                '606': InvalidOrder,
            };
            let ErrorClass = this.safeValue (responseCodes, code, ExchangeError);
            throw new ErrorClass (response['message']);
        }
        // code and message will always be the same here (0, 'Ok'), so ignore them
        return response['data'];
    }
};
<|endoftext|>


<commit_before>
/********************************************************************
 Copyright (c) 2013-2015 - Kazuichi Takashiro

 This file is part of Orchard Hut.

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

 takashiro@qq.com
*********************************************************************/

function getcookie(Name){
	Name = cookiepre + Name;

	var search = Name + "=";
	if(document.cookie.length > 0){
		offset = document.cookie.indexOf(search);
		if(offset != -1){
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if(end == -1){
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(offset, end));
		}
	}

	return "";
}

function setcookie(name, value){
	name = cookiepre + name;

	var argv = setcookie.arguments;
	var argc = setcookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : 9999;
	if(expires != null){
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));
}

function in_array(needle, arr){
	for(var i = 0; i < arr.length; i++){
		if(needle == arr[i]){
			return true;
		}
	}

	return false;
}

function popup_message(title, message){
	var popup_message = $('

');
	popup_message.addClass('popup_message');

	var header = $('');
	var h4 = $('

');
	h4.html(title);
	var remove_button = $('<button></button>');
	remove_button.attr('type', 'button');
	remove_button.addClass('remove');
	header.append(h4);
	header.append(remove_button);

	var content = $('

');
	content.addClass('content');
	content.html(message);

	popup_message.append(header);
	popup_message.append(content);

	var wrapper = $('

');
	wrapper.addClass('popup_message_wrapper');
	popup_message.appendTo(wrapper);

	remove_button.click(function(){
		wrapper.remove();
	});

	wrapper.click(function(){
		$(this).remove();
	});

	$('body').append(wrapper);

	wrapper.fadeIn();
}

(function($){
	$.fn.numbernotice = function(val){
		this.text(val);
		if(val == 0){
			this.hide();
		}else{
			this.css('display', 'inline');
		}
	}
})(jQuery);

$(function(){
	var button_increase = $.parseHTML('<button class="increase"></button>');
	var button_decrease = $.parseHTML('<button class="decrease"></button>');
	var number_input = $.parseHTML('<input type="text" />');
	$('.numberbox').append(button_decrease);
	$('.numberbox').append(number_input);
	$('.numberbox').append(button_increase);

	$('.numberbox').on('click', '.increase', function(e){
		var button = $(e.target);
		var box = button.parent();
		var input = box.children('input');
		var number = parseInt(input.val(), 10);
		if(isNaN(number)){
			number = 1;
		}else{
			number = parseInt(number, 10);
			number++;
		}
		input.val(number);
		input.change();
	});

	$('.numberbox').on('click', '.decrease', function(e){
		var button = $(e.target);
		var box = button.parent();
		var input = box.children('input');
		var number = parseInt(input.val(), 10);
		if(!isNaN(number) && number > 1){
			number--;
		}else{
			number = '';
		}
		input.val(number);
		input.change();
	});

	$('.tselect').on('change', 'select', function(e){
		var cur = $(e.target);
		var child = cur.next();
		var tselect = cur.parent();

		var input = tselect.children('.value');

		var address = [];
		tselect.children('select').each(function(){
			address.push($(this).val());
		});
		var ext = tselect.children('.ext');
		if(ext.length > 0){
			address.push(ext.val());
		}
		input.val(address.join(','));

		if(child.length < 1 || !child.is('select')){
			return false;
		}

		var div = $($.parseHTML('

'));
		if(child.data('hidden_children') != undefined){
			div.html(child.data('hidden_children'));
		}

		child.children().each(function(){
			var parentid = $(this).data('parentid');
			if(parentid != '0' && parentid != cur.val()){
				$(this).appendTo(div);
			}
		});

		div.children().each(function(){
			var parentid = $(this).data('parentid');
			if(parentid == '0' || parentid == cur.val()){
				$(this).appendTo(child);
			}
		});

		child.data('hidden_children', div.html());
	});

	$('.tselect .ext').blur(function(e){
		var ext = $(e.target);
		var tselect = ext.parent();

		var input = tselect.children('.value');
		var address = [];
		tselect.children('select').each(function(){
			address.push($(this).val());
		});
		var ext = tselect.children('.ext');
		if(ext.length > 0){
			address.push(ext.val());
		}
		input.val(address.join(','));
	});

	$('.tselect select').change();

	$('.mselect').on('click', 'li', function(e){
		var li = $(e.target);
		var radio = li.children('input');
		var mselect = li.parent();

		mselect.children('li').removeClass('checked');
		li.addClass('checked');

		radio.click();
	});
});
<commit_msg>余额不足时禁止选择钱包余额支付<commit_after>
/********************************************************************
 Copyright (c) 2013-2015 - Kazuichi Takashiro

 This file is part of Orchard Hut.

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

 takashiro@qq.com
*********************************************************************/

function getcookie(Name){
	Name = cookiepre + Name;

	var search = Name + "=";
	if(document.cookie.length > 0){
		offset = document.cookie.indexOf(search);
		if(offset != -1){
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if(end == -1){
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(offset, end));
		}
	}

	return "";
}

function setcookie(name, value){
	name = cookiepre + name;

	var argv = setcookie.arguments;
	var argc = setcookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : 9999;
	if(expires != null){
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));
}

function in_array(needle, arr){
	for(var i = 0; i < arr.length; i++){
		if(needle == arr[i]){
			return true;
		}
	}

	return false;
}

function popup_message(title, message){
	var popup_message = $('

');
	popup_message.addClass('popup_message');

	var header = $('');
	var h4 = $('

');
	h4.html(title);
	var remove_button = $('<button></button>');
	remove_button.attr('type', 'button');
	remove_button.addClass('remove');
	header.append(h4);
	header.append(remove_button);

	var content = $('

');
	content.addClass('content');
	content.html(message);

	popup_message.append(header);
	popup_message.append(content);

	var wrapper = $('

');
	wrapper.addClass('popup_message_wrapper');
	popup_message.appendTo(wrapper);

	remove_button.click(function(){
		wrapper.remove();
	});

	wrapper.click(function(){
		$(this).remove();
	});

	$('body').append(wrapper);

	wrapper.fadeIn();
}

(function($){
	$.fn.numbernotice = function(val){
		this.text(val);
		if(val == 0){
			this.hide();
		}else{
			this.css('display', 'inline');
		}
	}
})(jQuery);

$(function(){
	var button_increase = $.parseHTML('<button class="increase"></button>');
	var button_decrease = $.parseHTML('<button class="decrease"></button>');
	var number_input = $.parseHTML('<input type="text" />');
	$('.numberbox').append(button_decrease);
	$('.numberbox').append(number_input);
	$('.numberbox').append(button_increase);

	$('.numberbox').on('click', '.increase', function(e){
		var button = $(e.target);
		var box = button.parent();
		var input = box.children('input');
		var number = parseInt(input.val(), 10);
		if(isNaN(number)){
			number = 1;
		}else{
			number = parseInt(number, 10);
			number++;
		}
		input.val(number);
		input.change();
	});

	$('.numberbox').on('click', '.decrease', function(e){
		var button = $(e.target);
		var box = button.parent();
		var input = box.children('input');
		var number = parseInt(input.val(), 10);
		if(!isNaN(number) && number > 1){
			number--;
		}else{
			number = '';
		}
		input.val(number);
		input.change();
	});

	$('.tselect').on('change', 'select', function(e){
		var cur = $(e.target);
		var child = cur.next();
		var tselect = cur.parent();

		var input = tselect.children('.value');

		var address = [];
		tselect.children('select').each(function(){
			address.push($(this).val());
		});
		var ext = tselect.children('.ext');
		if(ext.length > 0){
			address.push(ext.val());
		}
		input.val(address.join(','));

		if(child.length < 1 || !child.is('select')){
			return false;
		}

		var div = $($.parseHTML('

'));
		if(child.data('hidden_children') != undefined){
			div.html(child.data('hidden_children'));
		}

		child.children().each(function(){
			var parentid = $(this).data('parentid');
			if(parentid != '0' && parentid != cur.val()){
				$(this).appendTo(div);
			}
		});

		div.children().each(function(){
			var parentid = $(this).data('parentid');
			if(parentid == '0' || parentid == cur.val()){
				$(this).appendTo(child);
			}
		});

		child.data('hidden_children', div.html());
	});

	$('.tselect .ext').blur(function(e){
		var ext = $(e.target);
		var tselect = ext.parent();

		var input = tselect.children('.value');
		var address = [];
		tselect.children('select').each(function(){
			address.push($(this).val());
		});
		var ext = tselect.children('.ext');
		if(ext.length > 0){
			address.push(ext.val());
		}
		input.val(address.join(','));
	});

	$('.tselect select').change();

	$('.mselect').on('click', 'li', function(e){
		var li = $(e.target);
		var radio = li.children('input');
		if (!radio.is(':disabled')){
			var mselect = li.parent();
			mselect.children('li').removeClass('checked');
			li.addClass('checked');
		}
		radio.click();
	});
});
<|endoftext|>


<commit_before>/**
 * RequireJS config which maps out where files are and shims
 * any non-compliant libraries.
 */
require.config({
  // Hack around jQuery.  This does not seem to work with Highcharts
  // (or possibly with other jquery plugins)
  /*
  map: {
    '*': {
      'jquery': 'jquery-noconflict'
    },
    'jquery-noconflict': {
      'jquery': 'jquery'
    }
  },
  */
  shim: {
    'highcharts': {
      exports: 'Highcharts',
      deps: ['jquery']
    },
    'highchartsMore': {
      deps: ['highcharts']
    },
    'datatables': {
      deps: ['jquery']
    },
    'lazyload': {
      exports: 'LazyLoad'
    }
  },
  baseUrl: 'js',
  paths: {
    'requirejs': '../bower_components/requirejs/require',
    'almond': '../bower_components/almond/almond',
    'text': '../bower_components/text/text',
    'jquery': '../bower_components/jquery/dist/jquery',
    'underscore': '../bower_components/underscore/underscore',
    'backbone': '../bower_components/backbone/backbone',
    'lazyload': '../bower_components/rgrove-lazyload/lazyload',
    'ractive': '../bower_components/ractive/ractive-legacy',
    'ractive-backbone': '../bower_components/ractive-backbone/ractive-adaptors-backbone',
    'ractive-events-tap': '../bower_components/ractive-events-tap/ractive-events-tap',
    'leaflet': '../bower_components/leaflet/dist/leaflet-src',
    'highcharts': '../bower_components/highcharts-release/highcharts.src',
    'highchartsMore': '../bower_components/highcharts-release/highcharts-more.src',
    'chroma': '../bower_components/chroma-js/chroma',
    'mpConfig': '../bower_components/minnpost-styles/dist/minnpost-styles.config',
    'mpFormatters': '../bower_components/minnpost-styles/dist/minnpost-styles.formatters',
    'mpHighcharts': '../bower_components/minnpost-styles/dist/minnpost-styles.highcharts',
    'mpMaps': '../bower_components/minnpost-styles/dist/minnpost-styles.maps',
    'jquery-noconflict': 'build/jquery-noconflict'
  }
});
<commit_msg>Minor require config as having issues with browser stack.<commit_after>/**
 * RequireJS config which maps out where files are and shims
 * any non-compliant libraries.
 */
require.config({
  // Hack around jQuery.  This does not seem to work with Highcharts
  // (or possibly with other jquery plugins)
  /*
  map: {
    '*': {
      'jquery': 'jquery-noconflict'
    },
    'jquery-noconflict': {
      'jquery': 'jquery'
    }
  },
  */
  waitSeconds: 10,
  shim: {
    'highcharts': {
      exports: 'Highcharts',
      deps: ['jquery']
    },
    'highchartsMore': {
      deps: ['highcharts']
    },
    'datatables': {
      deps: ['jquery']
    },
    'lazyload': {
      exports: 'LazyLoad'
    }
  },
  baseUrl: 'js',
  paths: {
    'requirejs': '../bower_components/requirejs/require',
    'almond': '../bower_components/almond/almond',
    'text': '../bower_components/text/text',
    'jquery': '../bower_components/jquery/dist/jquery',
    'underscore': '../bower_components/underscore/underscore',
    'backbone': '../bower_components/backbone/backbone',
    'lazyload': '../bower_components/rgrove-lazyload/lazyload',
    'ractive': '../bower_components/ractive/ractive-legacy',
    'ractive-backbone': '../bower_components/ractive-backbone/ractive-adaptors-backbone',
    'ractive-events-tap': '../bower_components/ractive-events-tap/ractive-events-tap',
    'leaflet': '../bower_components/leaflet/dist/leaflet-src',
    'highcharts': '../bower_components/highcharts-release/highcharts.src',
    'highchartsMore': '../bower_components/highcharts-release/highcharts-more.src',
    'chroma': '../bower_components/chroma-js/chroma',
    'mpConfig': '../bower_components/minnpost-styles/dist/minnpost-styles.config',
    'mpFormatters': '../bower_components/minnpost-styles/dist/minnpost-styles.formatters',
    'mpHighcharts': '../bower_components/minnpost-styles/dist/minnpost-styles.highcharts',
    'mpMaps': '../bower_components/minnpost-styles/dist/minnpost-styles.maps',
    'jquery-noconflict': 'build/jquery-noconflict'
  }
});
<|endoftext|>


<commit_before>/*
 * whip-o-matic
 * https://github.com/brianshumate/whip-o-matic
 * Based on:
 *
 * WTF Engine
 * Copyright 2011, Justin Windle
 * http://blog.soulwire.co.uk/
 * Code Licensed under the MIT licence.
 * https://github.com/soulwire/WTFEngine/blob/master/MIT-LICENSE.txt
 *
 * Concept based on WTFSIMFD
 * http://whatthefuckshouldimakefordinner.com/
 * by Zach Golden
 * http://www.zachgolden.com/
 *
 */

var templates = [
  "@adjective @propernoun was perfect",
  "@amount people appeared at the @adjective jam session in @place at @time",
  "He picked up a @noun and hit me upside the @noun once and in the @noun @amount times",
  "I also @pastverb in front of a @adjective @noun",
  "I love you like @noun",
  "I @pastverb a lot of @noun",
  "I saw @propernoun jamming live to a crowd of @amount in @place at @time on @date",
  "I then got off the @adjective @noun and @pastverb like a @adjective @noun",
  "I whipped @propernoun's ass",
  "I whipped @propernoun's ass for @durations on @day",
  "It whipped a @noun's ass",
  "It whipped a @noun's ass for @durations",
  "It whipped a @noun's ass real good",
  "@name can really jam hard like a @adjective @noun",
  "@name was mad as @noun",
  "@name threatened my life with a @weapon",
  "@name tried to @verb my @adjective @noun at least @amount times",
  "@name pointed a @weapon at me in @place at @time on @date",
  "Rock the @noun on @noun",
  "Stop the @noun",
  "Suddenly, @noun and @noun went to @place and rocked the @noun",
  "The @adjective joyride transformed into a @adjective @noun",
  "The @adjective @noun was out of this world",
  "The @adjective @noun weighed @mass at @time",
  "The @noun is the reason why people @verb you",
  "The @noun was whipping the @noun's ass",
  "The year was @year and I had a @adjective @noun with @propernoun",
  "Tree my @noun and @verb me off my @noun",
  "When I went to @place that same @day, I picked up a @noun",
  "You can really @verb with @name's @noun",
  "You are the most dangerous @noun that I have ever felt",
  "You used to be the @adjective @noun of the @noun",
  "Your @adjective @noun is the @noun to our @noun"
];

var phrases = [
  "About to take you on a joyride...",
  "A magical joyride appears...",
	"This is a random joyride...",
  "This joyride brought to you by entropy..."
];

var labels = [
	"WHIP IT"
];

corpus = {};

corpus.address = ["737 New Hampshire Street", "4358 South Cottage Grove Avenue"];

corpus.adjective = ["affordable", "artistic", "awesome", "12-gauge", "40-minute", "beautiful", "black", "chronic", "dead", "drunk", "early", "everlasting", "fabulous", "fat", "fatal", "fatty", "filthy", "first-degree", "freaking", "fucking", "good", "good-for-nothing", "good time", "greatest", "healthy", "high", "life-threatening", "little", "lowdown", "loving", "merry", "metal", "miserable", "nasty", "no-good", "poor", "psychotic", "punk", "rock and roll", "rotten", "shitty", "smelly", "stupid"];

corpus.adverb = ["vulgarly"];

corpus.age = ["thirty", "35", "46", "47", "52"];

corpus.anadjective = ["affordable", "artistic", "awesome"];

corpus.amount = ["14", "200", "800", "900", "950", "1400", "4,000", "5,000", "35,000", "50,000", "100,000", "300,000", "one thousand", "six", "ten million", "twenty"];

corpus.date = ["April 2nd", "April 4th", "August 31st", "February 5th", "March 5th", "March 9th", "March 10th"];

corpus.day = ["Monday", "Wednesday", "Friday", "Saturday", "Sunday"];

corpus.distance = ["326 miles"];

corpus.duration = ["40-minute", "three-hour"];

corpus.durations = ["18 years", "25 years", "five days", "thirty minutes"];

corpus.exclamatoin = ["Amen!", "punk!"];

corpus.height = ["35,000 feet"];

corpus.mass = ["26 grams", "28 grams", "360 pounds", "397 pounds"];

corpus.name = ["Aftab Noorani", "Al Capone", "Alanis Morissette", "Arnold Schwarzenegger", "Ben Wigman", "Bill Clinton", "Bon Jovi", "Carla Winterbottom", "Clarence Weeks", "Courtney Love", "Dale Meiners", "Dave Grohl", "Eazy E", "Elvis Presley", "Jello Biafra", "Jim Simm", "John Cook", "Johnny Depp", "John Dillard", "Johnny Inkslinger", "John Pole", "Johnny Rotten", "John Snap", "Kris Kringle", "Kurt Cobain", "Larry Nevers", "Liz Phair", "Louie Griff", "Louis Farrakhan", "Malice Green", "Michael Jackson", "Officer James Dudley", "O.J. Simpson", "Oprah Winfrey", "Reverend Henry E. Miller", "Reverend Richard Price", "Rick Sims", "Rodney King", "Saddam Hussein", "Trooper D. R. Johnson", "Walter Willis Shabazz", "Wesley Willis", "William Bell"];

corpus.noun = ["addict", "agent", "airplane", "alcohol", "album", "antelope shit", "artwork", "ass", "ass crack", "asshole", "baboon", "band", "beating", "blood", "booty hole", "brother", "buffalo", "bullshit", "bus", "bus ride", "camel", "cannabis", "car", "caribou", "chain", "cheetah", "chicken", "church", "clink", "city", "cityscape", "cocaine", "cow", "crack", "crack rock", "creep", "daddy", "death metal", "demon", "dick", "dog", "dog shit", "dope", "drug", "dumpster", "electric eel", "face", "family", "friend", "gangster", "ghetto", "godfather", "godson", "grave", "head", "hell", "hell ride", "holiday", "hospital", "house", "hyena", "inkpen", "jackoff", "jam", "jerk", "job", "joyride", "keyboard", "kiss", "law", "life", "light", "lion", "llama", "loser", "love", "magikist", "man", "metal band", "millionaire", "milkshake", "dollar", "mother", "motherfucker", "mule shit", "mullet", "music joyride", "music", "oil change", "outburst", "panda bear", "paraphernalia pipe", "person", "police", "policeman", "prison", "pulpit", "reindeer", "scalawag", "schizophrenia", "schmuck", "sedative", "session", "show", "skull", "skyscraper", "song", "stage", "star", "star ship", "snow leopard", "state police", "stoplight", "sweetheart", "tiger", "time", "trooper", "unit", "vampire", "van", "violence", "vulture", "wagon", "war hell ride", "weed", "whiskey", "woman", "woolly mammoth"];

corpus.pastverb = ["ate", "beat", "blasted", "brandished", "burned", "busted", "cracked", "cursed", "cut", "discharged", "drove", "felt", "filled", "fucked", "hit", "knocked", "kicked", "killed", "kissed", "loved", "made", "murdered", "persecuted", "played", "pulled", "rode", "roared", "rocked", "ran", "sang", "screwed", "shot", "slashed", "slimmed", "smoked", "stabbed", "sucked", "threw", "turned", "whipped", "yelled"];

corpus.place = ["America", "Aragon Ballroom", "Bottleneck", "California", "Chapel A.M.E. Zion Church", "Chicago", "Des Moines", "Detroit", "East Orange", "Europe", "Fort Dodge", "Hollywood", "Illinois", "Iowa", "jail", "Kansas", "Lawrence", "Los Angeles", "New Jersey", "Russia", "San Diego", "Seattle", "Texas", "the City Centre Theater", "Washington", "Wrigley Field"];

corpus.propernoun = ["88.1 KICB", "Agent Orange", "Alice in Chains", "Batman", "Big Mac", "Birdman", "Bolt Thrower", "Burger King", "Bushwick Bill", "CTA Bus", "Carquest", "Chevrolet", "Christmas", "CompUSA", "Dead Kennedys", "Earth", "El Dorado", "Electra 225", "FBI", "Folgers", "Ford Windstar", "Greyhound", "Harpo Studios", "Illinois State Police", "In Utero", "Jadroplov", "Knights of Columbus", "Lincoln Town Car", "Maverick", "McDonalds", "Milk Bone", "Miracle Whip", "Mitsubishi", "Nirvana", "Northwest Airlines", "Packard Bell", "Pantera", "Pontiac", "Quarter Pounder", "Raid", "Smith & Wesson", "Sprint", "Sports Authority", "Subway", "Superman", "Technics KN3000 keyboard", "Taco Bell", "The Empty Bottle", "The Foo Fighters", "The Frogs", "The Home Depot", "The Metro", "The Wesley Willis Fiasco", "Western Union", "Viper Room", "Walgreens", "Westone",  "Wheaties", "White Castle", "WMFU", "Xerox"];

corpus.speed = ["90 miles per hour", "150 miles per hour"];

corpus.time = ["1:30 AM", "2:10 AM", "11:20 AM", "11:30 AM", "11:55 AM", "1:55 PM", "2:30 PM", "4:30 PM", "6:00 PM", "6:30 PM", "7:30 PM", "8:55 PM", "9:30 PM", "10:00 PM", "midnight"];

corpus.verb = ["beat", "blast", "brandish", "burn", "bust", "crack", "curse", "cut", "discharge", "drive", "duke", "eat", "eject", "feel", "fill", "fuck", "hit", "knock", "kick", "kill", "kiss", "love", "make", "murder", "persecute", "play", "pull", "ride", "roar", "rock", "run", "screw", "shoot", "sing", "slim", "smash", "smoke", "stab", "suck", "throw", "turn", "whip", "whip", "yell at"];

corpus.weapon = [".357 Magnum", ".38", ".38 caliber revolver", "12-gauge",  "baseball bat", "beating stick", "billy club", "box cutter", "gun", "handgun", "karate stick", "pistol", "semi-automatic", "Uzi submachine gun"];

corpus.year = ["1930", "1987", "1990", "1991", "1992", "1996", "1997"];

<commit_msg>corpus finagle<commit_after>/*
 * whip-o-matic
 * https://github.com/brianshumate/whip-o-matic
 * Based on:
 *
 * WTF Engine
 * Copyright 2011, Justin Windle
 * http://blog.soulwire.co.uk/
 * Code Licensed under the MIT licence.
 * https://github.com/soulwire/WTFEngine/blob/master/MIT-LICENSE.txt
 *
 * Concept based on WTFSIMFD
 * http://whatthefuckshouldimakefordinner.com/
 * by Zach Golden
 * http://www.zachgolden.com/
 *
 */

var templates = [
  "@adjective @propernoun was perfect",
  "@amount people appeared at the @adjective jam session in @place at @time",
  "He picked up a @noun and hit me upside the @noun once and in the @noun @amount times",
  "I also @pastverb in front of a @adjective @noun",
  "I love you like @noun",
  "I @pastverb a lot of @noun",
  "I saw @propernoun jamming live to a crowd of @amount in @place at @time on @date",
  "I then got off the @adjective @noun and @pastverb like a @adjective @noun",
  "I whipped @propernoun's ass",
  "I whipped @propernoun's ass for @durations on @day",
  "It whipped a @noun's ass",
  "It whipped a @noun's ass for @durations",
  "It whipped a @noun's ass real good",
  "@name can really jam hard like a @adjective @noun",
  "@name was mad as a @noun",
  "@name threatened my life with a @weapon",
  "@name tried to @verb my @adjective @noun at least @amount times",
  "@name pointed a @weapon at me in @place at @time on @date",
  "Rock the @noun on @noun",
  "Stop the @noun",
  "Suddenly, @noun and @noun went to @place and rocked the @noun",
  "The @adjective joyride transformed into a @adjective @noun",
  "The @adjective @noun was out of this world",
  "The @adjective @noun weighed @mass at @time",
  "The @noun is the reason why people @verb you",
  "The @noun was whipping the @noun's ass",
  "The year was @year and I had a @adjective @noun with @propernoun",
  "Tree my @noun and @verb me off my @noun",
  "When I went to @place that same @day, I picked up a @noun",
  "You can really @verb with @name's @noun",
  "You are the most dangerous @noun that I have ever felt",
  "You used to be the @adjective @noun of the @noun",
  "Your @adjective @noun is the @noun to our @noun"
];

var phrases = [
  "About to take you on a joyride...",
  "A magical joyride appears...",
	"This is a random joyride...",
  "This joyride brought to you by entropy..."
];

var labels = [
	"WHIP IT"
];

corpus = {};

corpus.address = ["737 New Hampshire Street", "4358 South Cottage Grove Avenue"];

corpus.adjective = ["affordable", "artistic", "awesome", "12-gauge", "40-minute", "beautiful", "black", "chronic", "dead", "drunk", "early", "everlasting", "fabulous", "fat", "fatal", "fatty", "filthy", "first-degree", "freaking", "fucking", "good", "good-for-nothing", "good time", "greatest", "healthy", "high", "life-threatening", "little", "lowdown", "loving", "merry", "metal", "miserable", "nasty", "no-good", "poor", "psychotic", "punk", "rock and roll", "rotten", "shitty", "smelly", "stupid"];

corpus.adverb = ["vulgarly"];

corpus.age = ["thirty", "35", "46", "47", "52"];

corpus.anadjective = ["affordable", "artistic", "awesome"];

corpus.amount = ["14", "200", "800", "900", "950", "1400", "4,000", "5,000", "35,000", "50,000", "100,000", "300,000", "one thousand", "six", "ten million", "twenty"];

corpus.date = ["April 2nd", "April 4th", "August 31st", "February 5th", "March 5th", "March 9th", "March 10th"];

corpus.day = ["Monday", "Wednesday", "Friday", "Saturday", "Sunday"];

corpus.distance = ["326 miles"];

corpus.duration = ["40-minute", "three-hour"];

corpus.durations = ["18 years", "25 years", "five days", "thirty minutes"];

corpus.exclamatoin = ["Amen!", "punk!"];

corpus.height = ["35,000 feet"];

corpus.mass = ["26 grams", "28 grams", "360 pounds", "397 pounds"];

corpus.name = ["Aftab Noorani", "Al Capone", "Alanis Morissette", "Arnold Schwarzenegger", "Ben Wigman", "Bill Clinton", "Bon Jovi", "Carla Winterbottom", "Clarence Weeks", "Courtney Love", "Dale Meiners", "Dave Grohl", "Eazy E", "Elvis Presley", "Jello Biafra", "Jim Simm", "John Cook", "Johnny Depp", "John Dillard", "Johnny Inkslinger", "John Pole", "Johnny Rotten", "John Snap", "Kris Kringle", "Kurt Cobain", "Larry Nevers", "Liz Phair", "Louie Griff", "Louis Farrakhan", "Malice Green", "Michael Jackson", "Officer James Dudley", "O.J. Simpson", "Oprah Winfrey", "Reverend Henry E. Miller", "Reverend Richard Price", "Rick Sims", "Rodney King", "Saddam Hussein", "Trooper D. R. Johnson", "Walter Willis Shabazz", "Wesley Willis", "William Bell"];

corpus.noun = ["addict", "agent", "airplane", "alcohol", "album", "antelope shit", "artwork", "ass", "ass crack", "asshole", "baboon", "band", "beating", "blood", "booty hole", "brother", "buffalo", "bullshit", "bus", "bus ride", "camel", "cannabis", "car", "caribou", "chain", "cheetah", "chicken", "church", "clink", "city", "cityscape", "cocaine", "cow", "crack", "crack rock", "creep", "daddy", "death metal", "demon", "dick", "dog", "dog shit", "dope", "drug", "dumpster", "electric eel", "face", "family", "friend", "gangster", "ghetto", "godfather", "godson", "grave", "head", "hell", "hell ride", "holiday", "hospital", "house", "hyena", "inkpen", "jackoff", "jam", "jerk", "job", "joyride", "keyboard", "kiss", "law", "life", "light", "lion", "llama", "loser", "love", "magikist", "man", "metal band", "millionaire", "milkshake", "dollar", "mother", "motherfucker", "mule shit", "mullet", "music joyride", "music", "oil change", "outburst", "panda bear", "paraphernalia pipe", "person", "police", "policeman", "prison", "pulpit", "reindeer", "scalawag", "schizophrenia", "schmuck", "sedative", "session", "show", "skull", "skyscraper", "song", "stage", "star", "star ship", "snow leopard", "state police", "stoplight", "sweetheart", "tiger", "time", "trooper", "unit", "vampire", "van", "violence", "vulture", "wagon", "war hell ride", "weed", "whiskey", "woman", "woolly mammoth"];

corpus.pastverb = ["ate", "beat", "blasted", "brandished", "burned", "busted", "cracked", "cursed", "cut", "discharged", "drove", "felt", "filled", "fucked", "hit", "knocked", "kicked", "killed", "kissed", "loved", "made", "murdered", "persecuted", "played", "pulled", "rode", "roared", "rocked", "ran", "sang", "screwed", "shot", "slashed", "slimmed", "smoked", "stabbed", "sucked", "threw", "turned", "whipped", "yelled"];

corpus.place = ["America", "Aragon Ballroom", "Bottleneck", "California", "Chapel A.M.E. Zion Church", "Chicago", "Des Moines", "Detroit", "East Orange", "Europe", "Fort Dodge", "Hollywood", "Illinois", "Iowa", "jail", "Kansas", "Lawrence", "Los Angeles", "New Jersey", "Russia", "San Diego", "Seattle", "Texas", "the City Centre Theater", "Washington", "Wrigley Field"];

corpus.propernoun = ["88.1 KICB", "Agent Orange", "Alice in Chains", "Batman", "Big Mac", "Birdman", "Bolt Thrower", "Burger King", "Bushwick Bill", "CTA Bus", "Carquest", "Chevrolet", "Christmas", "CompUSA", "Dead Kennedys", "Earth", "El Dorado", "Electra 225", "FBI", "Folgers", "Ford Windstar", "Greyhound", "Harpo Studios", "Illinois State Police", "In Utero", "Jadroplov", "Knights of Columbus", "Lincoln Town Car", "Maverick", "McDonalds", "Milk Bone", "Miracle Whip", "Mitsubishi", "Nirvana", "Northwest Airlines", "Packard Bell", "Pantera", "Pontiac", "Quarter Pounder", "Raid", "Smith & Wesson", "Sprint", "Sports Authority", "Subway", "Superman", "Technics KN3000 keyboard", "Taco Bell", "The Empty Bottle", "The Foo Fighters", "The Frogs", "The Home Depot", "The Metro", "The Wesley Willis Fiasco", "Western Union", "Viper Room", "Walgreens", "Westone",  "Wheaties", "White Castle", "WMFU", "Xerox"];

corpus.speed = ["90 miles per hour", "150 miles per hour"];

corpus.time = ["1:30 AM", "2:10 AM", "11:20 AM", "11:30 AM", "11:55 AM", "1:55 PM", "2:30 PM", "4:30 PM", "6:00 PM", "6:30 PM", "7:30 PM", "8:55 PM", "9:30 PM", "10:00 PM", "midnight"];

corpus.verb = ["beat", "blast", "brandish", "burn", "bust", "crack", "curse", "cut", "discharge", "drive", "duke", "eat", "eject", "feel", "fill", "fuck", "hit", "knock", "kick", "kill", "kiss", "love", "make", "murder", "persecute", "play", "pull", "ride", "roar", "rock", "run", "screw", "shoot", "sing", "slim", "smash", "smoke", "stab", "suck", "throw", "turn", "whip", "whip", "yell at"];

corpus.weapon = [".357 Magnum", ".38", ".38 caliber revolver", "12-gauge",  "baseball bat", "beating stick", "billy club", "box cutter", "gun", "handgun", "karate stick", "pistol", "semi-automatic", "Uzi submachine gun"];

corpus.year = ["1930", "1987", "1990", "1991", "1992", "1996", "1997"];

<|endoftext|>


<commit_before>import {Form} from 'widget/form/form'
import {msg} from 'translate'
import PropTypes from 'prop-types'
import React from 'react'

export default class AssetSection extends React.Component {
    render() {
        const {input, onChange} = this.props
        return (
            <Form.Input
                label={msg('process.classification.panel.inputImagery.form.asset.label')}
                autoFocus
                input={input}
                placeholder={msg('process.classification.panel.inputImagery.form.asset.placeholder')}
                spellCheck={false}
                errorMessage
                onBlur={e => onChange(e.target.value)}
            />
        )
    }
}

AssetSection.propTypes = {
    input: PropTypes.object.isRequired
}
<commit_msg>Fixed classification asset change detection.<commit_after>import {Form} from 'widget/form/form'
import {msg} from 'translate'
import PropTypes from 'prop-types'
import React from 'react'

export default class AssetSection extends React.Component {
    render() {
        const {input, onChange} = this.props
        return (
            <Form.Input
                label={msg('process.classification.panel.inputImagery.form.asset.label')}
                autoFocus
                input={input}
                placeholder={msg('process.classification.panel.inputImagery.form.asset.placeholder')}
                spellCheck={false}
                errorMessage
                onChangeDebounced={value => onChange(value)}
            />
        )
    }
}

AssetSection.propTypes = {
    input: PropTypes.object.isRequired
}
<|endoftext|>