Pages:
Author

Topic: [In-Development] BitPrice.link - Live Bitcoin/Crypto Calculator! [Open-Source] (Read 2675 times)

legendary
Activity: 1232
Merit: 1029
give me your cryptos
Hey @Decoded,

it seems like semantic-UI has something to do with this. Most likely it's UI is updated after your getprices() function is called. In addition, the reload() function in update.js is not triggerred in intervals, making it unusable. The fastest I could do to try and fix this can be seen in this commit: commit

I'm not sure if the code is intended to be run like this, and I would advise to remove the interval altogether, and at least use something native to semantic UI - check here. Also, cleanup would come in very handy. There is a lot of unneeded code there, and a mix of a lot of technologies (php, sh, py, js, whole node_modules etc). I had to go through a lot of files to make sure it's safe to run it.
Bingo. I haven't made the push to GitHub yet, but I'm working on an entirely new drop down, without Semantic UI. What I found was that there was a lag after you clicked the button and until the div actually changed its contents.
newbie
Activity: 1
Merit: 0
Hey @Decoded,

it seems like semantic-UI has something to do with this. Most likely it's UI is updated after your getprices() function is called. In addition, the reload() function in update.js is not triggerred in intervals, making it unusable. The fastest I could do to try and fix this can be seen in this commit: commit

I'm not sure if the code is intended to be run like this, and I would advise to remove the interval altogether, and at least use something native to semantic UI - check here. Also, cleanup would come in very handy. There is a lot of unneeded code there, and a mix of a lot of technologies (php, sh, py, js, whole node_modules etc). I had to go through a lot of files to make sure it's safe to run it.



legendary
Activity: 1232
Merit: 1029
give me your cryptos
Why not use a a href for the menu items?


I was going to get onto that, but I'm currently using a Semantic UI, which uses mainly divs.

Currently have yearlies, once they're over I'll start working on this again.
sr. member
Activity: 410
Merit: 257
Why not use a a href for the menu items?
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Could I get some help? I can't seem to understand what is wrong. Loaded straight from github, when I change the currency, I have to click it EUR three times before it changes the value. Same with changing back to USD.

Live test - bitprice.herokuapp.com
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Er... i've got it working for now, however it's still primitive, it get's the value after every keypress.

Looks to be working for the BTC/USD. Only one direction, it doesn't reverse if the user enters in a USD amount.

Here's a very simple version that just uses javascript for everything and runs on the client side.
https://jsfiddle.net/yb4ot795/
Seems pretty fast without having to cache or store anything in a database.  

I've updated github. Will push to my VPS. At the moment, i've done alot on my c9.io test site. Will update when bitprice.link is updated.

I also have acquired bitprice.info, so that's a plus too!

EDIT - Site is live. First page load may take about one second to get the prices, then after that the prices are cached until you refresh the page. Currently only works on USD, and will get it to auto-refresh prices.
legendary
Activity: 1442
Merit: 1179
Er... i've got it working for now, however it's still primitive, it get's the value after every keypress.

Looks to be working for the BTC/USD. Only one direction, it doesn't reverse if the user enters in a USD amount.

Here's a very simple version that just uses javascript for everything and runs on the client side.
https://jsfiddle.net/yb4ot795/
Seems pretty fast without having to cache or store anything in a database. 
full member
Activity: 140
Merit: 100
A few more general observations: Checking dependencies into version control is unnecessary outside of a few exceptions and even considered bad practice. With Node.js, dependencies are often platform-specific, so they may not even be functional on architectures besides your own. Instead, specify your Node.js dependencies in a package.json file. Analogous tools exist for other languages and platforms.

The same goes for files such as logs, stack traces, configuration files and databases. These files are only meaningful in a narrow context, e.g. in a bug report, and therefore should not be checked in. You can use a .gitignore file to prevent these files from being shown in git and being accidentally committed.
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Speed. The back end retrieves the exchange rates, crops of the unnecessary information, while the frontend simply gets it from the server and multiplies it by the amount.

Those are relatively inexpensive operations. Letting the client handle them would not lead to any noticeable performance losses.

It does significantly simplify your project and allow you to easily host it for free, however.

You make a compelling case. Another reason is that i'm much much more familiar with PHP than JavaScript. In fact, everything I know about it I just crammed in three hours.

I've made a push to github. After some testing, I can see that it's successfully querying the /api/btc/usd.php page, however the output shows NaN.

After further testing, it seems that what the js is returning from the page is [object Object]... working on this now.

Er... i've got it working for now, however it's still primitive, it get's the value after every keypress.
full member
Activity: 140
Merit: 100
Speed. The back end retrieves the exchange rates, crops of the unnecessary information, while the frontend simply gets it from the server and multiplies it by the amount.

Those are relatively inexpensive operations. Letting the client handle them would not lead to any noticeable performance losses.

It does significantly simplify your project and allow you to easily host it for free, however.
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Here's a jsfiddle I put together. The best way to do this is to get the value to keep updating from a page, right?

http://jsfiddle.net/T7cZU/121/

There are two errors in that example. See a corrected version here. In general periodically polling for price updates is fine, but every 1.5 seconds is likely too frequent and might get you throttled.

What purpose does the back end fulfill? It seems you could forgo that and do everything you want to do on the client.

Speed. The back end retrieves the exchange rates, crops of the unnecessary information, while the frontend simply gets it from the server and multiplies it by the amount.

I've already moved onto the live site, almost done with the live updating.
full member
Activity: 140
Merit: 100
Here's a jsfiddle I put together. The best way to do this is to get the value to keep updating from a page, right?

http://jsfiddle.net/T7cZU/121/

There are two errors in that example. See a corrected version here. In general periodically polling for price updates is fine, but every 1.5 seconds is likely too frequent and might get you throttled.

What purpose does the back end fulfill? It seems you could forgo that and do everything you want to do on the client.
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
        response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd')
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";


I figured as much. I was told by a friend that PHP when compared to others is extremely slow, so I figured i'd make the base site out of php, then use javascript for clientside.

My python bot basically saves the output into a json. I could make a PHP bot but essentially it would be the same thing.

I know how to change the value of the input, but i've tried putting it into a function and getting json to call it repeatedly. It doesnt work. Maybe i'm missing something? Would you like me to make a jsfiddle?

Yea if you can put it in a JSfiddle I can help you get it working.

Here's a jsfiddle I put together. The best way to do this is to get the value to keep updating from a page, right?

http://jsfiddle.net/T7cZU/121/
legendary
Activity: 1442
Merit: 1179
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
        response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd')
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";


I figured as much. I was told by a friend that PHP when compared to others is extremely slow, so I figured i'd make the base site out of php, then use javascript for clientside.

My python bot basically saves the output into a json. I could make a PHP bot but essentially it would be the same thing.

I know how to change the value of the input, but i've tried putting it into a function and getting json to call it repeatedly. It doesnt work. Maybe i'm missing something? Would you like me to make a jsfiddle?

Yea if you can put it in a JSfiddle I can help you get it working.
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
        response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd')
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";


I figured as much. I was told by a friend that PHP when compared to others is extremely slow, so I figured i'd make the base site out of php, then use javascript for clientside.

My python bot basically saves the output into a json. I could make a PHP bot but essentially it would be the same thing.

I know how to change the value of the input, but i've tried putting it into a function and getting json to call it repeatedly. It doesnt work. Maybe i'm missing something? Would you like me to make a jsfiddle?
sr. member
Activity: 410
Merit: 257
I wrote something similar a while ago to run as an app (should also work on a server, since it's using phonegap):

https://bitcointalksearch.org/topic/collab-for-phonegap-app-for-btc-e-135392

Just some JS to fetch the data and create a HTML table from it.
legendary
Activity: 1442
Merit: 1179
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
        response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd')
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Holy smokes! Python, PHP and NodeJS? There really is no reason to have 3 different server-side languages running at once. If you want one of your features to be "faster than preev" you'll need to cut down on the bloat. For example your node_modules directory is full of modules you aren't using.

What are you most experienced in? I'm guessing PHP based on the current source... My suggestion is you pick one server-side language and go with that, don't jump back and forth.

You can create one file that grabs all the necessary prices every N seconds and then stores them in a database. Then when doing the calculations for the users just pull from the database. You'll have the speed you want, and you won't have to worry about exceeding API request limits with the exchanges you are hitting.

Quote
I know the js to get the price to auto-update into a div, however for me it refuses it auto-update in the input box

For updating a div you typically do something like:

Code:
var myTarget = document.getElementById("myDiv");
myTarget.innerHTML = "My Text";

For updating an input box you need to change it from innerhtml to value.

Code:
var myTarget = document.getElementById("myInputBox");
myInputBox.value = "My Text";
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd')
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.

Not SirLagsalot, but Sir_Lagsalot.

I do agree that currently the system for getting the exchange rate is primitive. It was just a test to get the JavaScript working. I aim to have all the processing and retrieving done on the backend and not using an external api.
legendary
Activity: 1750
Merit: 1115
Providing AI/ChatGpt Services - PM!
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Bro,literally you've too much of dependencies for a app as simple as this.Correct me if I'm wrong but what are the node modules for ? Perhaps the python lib for the price ticker that is
Code:
         response = urllib2.urlopen('https://api.cryptonator.com/api/ticker/btc-usd')
is more than enough,no ? I'd suggest you we start from scratch again.Are you connected with the account SirLagsAlot anyway ? Nevermind your gh,says that.
legendary
Activity: 1232
Merit: 1029
give me your cryptos
Added source to OP. Please feel free to make a pull request! What I really need most is help with JavaScript!

(If you have any ideas at all, please suggest! Don't care if they're bad!)
Pages:
Jump to: