From b0523a608bb5008d58e62dbc3c1f19082154151c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 16 Nov 2016 16:49:57 -0800 Subject: [PATCH] Adding dynamic values. --- scripts/command.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/command.js b/scripts/command.js index 8dbebcb..5687b79 100644 --- a/scripts/command.js +++ b/scripts/command.js @@ -1,6 +1,30 @@ function Command(content) { - this.content = content; + this.content = raster(content); + + // Raster + + function raster(array) // @ {50w}x100 + { + var str = array.join(" "); + + var m = str.replace(/(\{(.*)\})/g, function(a) { + var parts = a.split(/[{}]/); + for(var e = 0; e < parts.length; e++) { + if(str.indexOf("{"+parts[e]+"}") == -1){ continue; } + str = str.replace("{"+parts[e]+"}",converter(parts[e])); + } + }); + return str.split(" "); + } + + function converter(str) + { + if(str == "50w"){ return "123"; } + return str; + } + + // Parser this.any = function() {