-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from sanghunjlee/dev
Dev
- Loading branch information
Showing
17 changed files
with
472 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,55 @@ | ||
/.venv | ||
/.vscode | ||
**/__pycache__ | ||
# environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# vs code | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
.history | ||
|
||
# django | ||
/project | ||
/static | ||
*.log | ||
*.pot | ||
*.pyc | ||
__pycache__ | ||
db.sqlite3 | ||
media | ||
|
||
# python | ||
*.py[cod] | ||
*$py.class | ||
|
||
# js | ||
node_modules | ||
package-lock.json | ||
|
||
# distribution / packaging | ||
.Python build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
*.manifest | ||
*.spec | ||
|
||
# backup | ||
*.bak | ||
|
||
# build | ||
*.egg-info | ||
/build | ||
/dist | ||
README_*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function doOper(op, a, b) { | ||
switch (op) { | ||
case '+': | ||
return (parseFloat(a) + parseFloat(b)).toFixed(4); | ||
case '-': | ||
return (parseFloat(a) - parseFloat(b)).toFixed(4); | ||
case '*': | ||
return (parseFloat(a) * parseFloat(b)).toFixed(4); | ||
case '/': | ||
return (parseFloat(a) / parseFloat(b)).toFixed(4); | ||
default: | ||
return null; | ||
} | ||
} | ||
function doEval(s) { | ||
// Evaluate equations with operators: +, -, *, / | ||
// Any other operator will cause incorrect calculation or an error | ||
|
||
var numbers = s.split(new RegExp('[\\+\\-\\/\\*]')); | ||
var operators = s.split(new RegExp('[.0-9]')).filter(function (op) { | ||
return op !== ''; | ||
}); | ||
|
||
while (operators.length > 0) { | ||
let index = operators.findIndex(function (op) { | ||
return op === '*' || op ==='/'; | ||
}); | ||
if (index == -1) { | ||
index = operators.findIndex(function (op) { | ||
return op === '+' || op === '-'; | ||
}); | ||
} | ||
if (index == -1) { | ||
break; | ||
} | ||
let result = doOper(operators[index], numbers[index], numbers[index+1]); | ||
numbers[index] = result; | ||
numbers.splice(index+1, 1); | ||
operators.splice(index, 1); | ||
} | ||
return parseFloat(numbers.join('')).toFixed(3); | ||
} | ||
|
||
function autoCalc () { | ||
const totalAmount = document.getElementById("total-amount").value; | ||
const itemAmountDivs = document.getElementsByClassName("f-amount"); | ||
if (itemAmountDivs.length > 0) { | ||
const autoAmount = (parseFloat(totalAmount) / (itemAmountDivs.length - 1 )).toFixed(2); | ||
for (let itemAmountDiv of itemAmountDivs) { | ||
let itemAmountElems = itemAmountDiv.getElementsByTagName("input"); | ||
if (itemAmountElems.length > 0) { | ||
itemAmountElems[0].value = autoAmount; | ||
} | ||
} | ||
} | ||
} | ||
|
||
exports._test = { | ||
doEval: doEval | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.