Permalink
Browse files

fixing shits, removed socket in algo eight, bite me

  • Loading branch information...
1 parent 1bd54e2 commit 22b672bd2ecb1ce95e437a6bfb2e0012402f0820 @ivivekyadav committed Feb 17, 2017
Showing with 61 additions and 33 deletions.
  1. +37 −0 app.js
  2. +22 −32 currencyohol.html
  3. +1 −1 my_modules/calculations.js
  4. +1 −0 upload.html
View
@@ -2207,7 +2207,44 @@
Promise.all([getEquity]).then(values => {
calculation().algoTen(res, values[0], plusvalue, inputquan, addMul, addQuan, firstQuan, 0);
});
+ });
+
+ app.post('/currencyohol/:filename/:inputquan/:addMul/:addQuan/:symbol/:firstQuan', function(req, res) {
+
+ console.log("Coming here in currency ohol");
+
+ var filename = req.params.filename;
+ var plusvalue = req.params.plusValue;
+ var inputquan = req.params.inputQuan;
+ var addMul = req.params.addMul;
+ var addQuan = req.params.addQuan;
+ var firstQuan = req.params.firstQuan;
+
+ var dir = './tmp/';
+
+ switch (path.extname(filename)) {
+ case ".csv":
+ var Converter = require("csvtojson").Converter;
+ var converter = new Converter({});
+ converter.fromFile(dir + filename, function(err, result) {
+ calculation().algoEight(res, result, plusvalue, inputquan, addMul, addQuan, firstQuan, 1);
+ });
+ break;
+ case ".xlsx":
+ var randomjson = Math.floor(Math.random() * 1000000) + ".json";
+ xlsxj({
+ input: dir + filename,
+ output: dir + randomjson
+ }, function(err, result) {
+ if (err) {
+ console.error(err);
+ } else {
+ calculation().algoEight(res, result, plusvalue, inputquan, addMul, addQuan, firstQuan, 1);
+ }
+ });
+ break;
+ }
});
app.post('/ohold/:filename/:plusvalue/:inputquan/:addMul/:addQuan/:firstQuan', function(req, res) {
View
@@ -136,17 +136,16 @@
span {
font-weight: 600;
}
-
+
#addQuan {
margin-top: 5px;
text-align: center;
}
-
+
#firstQuan {
margin-top: 5px;
text-align: center;
}
-
</style>
<title>Upload a CSV</title>
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
@@ -264,27 +263,10 @@
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- <script src="https://cdn.socket.io/socket.io-1.4.5.js">
- </script>
+ <script src="https://cdn.socket.io/socket.io-1.4.5.js">
+ </script>
<script>
- var socket = io();
-
- //THINGS TO GET FILE AND SHIT USING SOCKET
-
- socket.on('takeName', function(filename) {
- console.log("Take name called");
- location.href = '/download/' + filename;
- $('.upload-btn').removeAttr('disabled');
- ri('serverresponse').innerHTML = "";
- });
-
- socket.on('progressLane', function(data) {
- ri('serverresponse').innerHTML = data;
- });
-
- //THINGS TO GET FILE AND SHIT USING SOCKET
-
$(".method").change(function() {
$('.four').css('display', 'none');
var elem = parseInt($("select.method option:selected").val());
@@ -358,18 +340,26 @@
processData: false,
contentType: false,
success: function(firstfilename) {
- console.log("Coming name is "+firstfilename);
- var oholData = {
- filename : firstfilename,
- plusValue : plusValue,
- inputQuan : inputQuan,
- addMul : addMul,
- firstQuan : firstQuan,
- addQuan : addQuan
+
+ $.ajax({
+ url: "/currencyohol/" + firstfilename + "/" + plusValue + "/" + inputQuan + "/" + addMul + "/" + firstQuan + "/" + addQuan,
+ type: 'POST',
+ processData: false,
+ contentType: false,
+ success: function(finalfilename) {
+ location.href = '/download/' + finalfilename;
+ $('.upload-btn').removeAttr('disabled');
+ },
+ statusCode: {
+ 404: function(response) {
+ ri('serverresponse').innerHTML = response.responseText;
+ },
+ 503: function(response) {
+ ri('serverresponse').innerHTML = "Server Error or Something wrong with code.";
+ }
}
+ });
- console.log("OHOL Data is "+oholData);
- socket.emit('giveOHOL', oholData);
},
statusCode: {
404: function(response) {
@@ -8275,7 +8275,7 @@ module.exports = function(res, fs, result, plusvalue, inputQuan, benchMark, com,
i = i + looper;
}
}
- if (typ == 1) {
+ if (typ == 2) {
createFile(finalArray, 2);
} else {
createFile(finalArray, 1);
View
@@ -360,6 +360,7 @@
}
}
});
+
});
</script>

0 comments on commit 22b672b

Please sign in to comment.