commit 2f38fdb634e900799f36c79dedafb252ec013141 Author: Joe L. Wroten Date: Sun Nov 1 22:36:49 2015 -0600 Working calculator with basic functions diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01a80cf --- /dev/null +++ b/.gitignore @@ -0,0 +1,87 @@ +# Created by https://www.gitignore.io/api/windows,osx,node,bower + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### OSX ### +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Node ### +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git +node_modules + + +### Bower ### +bower_components +.bower-cache +.bower-registry +.bower-tmp diff --git a/app.css b/app.css new file mode 100644 index 0000000..5613bdc --- /dev/null +++ b/app.css @@ -0,0 +1,12 @@ + +.btn-raised { line-height: 100%; } + +#calculator .btn-raised { margin-right: -5rem; } + +#calculator .btn-warning { margin-top: 4rem; } + +#calculator .btn-danger { margin-top: -1rem; } + +#calculator table button { + font-size: 1.5em; +} diff --git a/app.js b/app.js new file mode 100644 index 0000000..dbce150 --- /dev/null +++ b/app.js @@ -0,0 +1,42 @@ +$(document).ready(function() { + // This command is used to initialize some elements and make them work properly + $.material.init(); +}); + +new Vue({ + el: '#calculator', + data: { + result: 0, + previousResult: NaN, + calculation: '' + }, + methods: { + clear: function() { + this.result = 0; + this.previousResult = NaN; + this.calculation = ''; + }, + calcAdd: function(thing) { + this.calculation += thing; + this.result = this.calculation; + }, + calcRemove: function() { + if (typeof this.calculation === 'string' && this.calculation.length) { + this.calculation = this.calculation.slice(0, -1); + this.result = this.calculation; + } + }, + equals: function() { + // Strip out any non-numeric character or simple math expressions + var calcSafe = this.calculation.replace(/[^0-9\+\-\*\/]/g, ''); + if (isNaN(calcSafe.charAt(0))) calcSafe = this.previousResult + calcSafe; + try { + this.result = Math.round(eval(calcSafe)); // Eval is safe here because of the above regex + this.previousResult = this.result; + this.calculation = ''; + } catch (e) { + console.warn('Invalid Calculation'); + } + } + } +}); diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..1c0291e --- /dev/null +++ b/bower.json @@ -0,0 +1,24 @@ +{ + "name": "roman-numeral-calculator", + "description": "Sample Project for Q2E Interview", + "main": "index.html", + "authors": [ + "Joe L. Wroten" + ], + "license": "ISC", + "moduleType": [], + "homepage": "", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "vue": "~1.0.4", + "bootstrap": "~3.3.5", + "bootstrap-material-design": "~0.3.0" + } +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..6dc47db --- /dev/null +++ b/index.html @@ -0,0 +1,79 @@ + + + + + + + + + + + +
+ +
+
+
+ + +
+ + + Whole Numbers + Roman Numerals +
+

{{ result }}

+

IV

+
+ + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+
+
+ + + + + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..be428c7 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "roman-numeral-calculator", + "version": "1.0.0", + "description": "Sample Project for Q2E Interview", + "main": "index.html", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Joe L. Wroten", + "license": "ISC" +}