Bitcoin Forum
May 28, 2024, 01:22:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Help us with a little Javascript (Payment .2 BTC)  (Read 1282 times)
BitcoinMoxy (OP)
Member
**
Offline Offline

Activity: 119
Merit: 100


BitcoinMoxy.com


View Profile WWW
July 23, 2013, 09:04:55 PM
 #1

We know it's not an awful lot but we can pay no more at this point. Only do this if you have the spare time!

Take a look at BitcoinMoxy.com. We just added the Bitcoinity minicharts to the page, using a simple script you can switch between the different currencies (USD/EUR/GBP/CAD). Works like a charm, so far so good!

Now we want the charts on display to refresh every 5 or so minutes without reloading the entire page (which is annoying for browsing and it resets the Twitter news feed below). Most people suggest using Ajax for this but we think this can be done using Javascript only.


Something like this or similar:
Code:
<script langauge="javascript">  
            var counter = 0;  
            window.setInterval("refreshDiv()", 1000);  
            function refreshDiv(){  
                counter = counter + 1;  
                document.getElementById("test").innerHTML = "Testing " + counter;
            }  
        </script>

The script below (index.html) calls a function in minicharts.js to insert the image links for the default currency USD.
Code:
<!-- BITCOINITY CHARTS ************************************************************** -->
<div id="minicharts"></div>
<script src="./js/minicharts.js"></script>
<script>minichartsUSD()</script>
 <!-- END BITCOINITY CHARTS ********************************************************* -->

Within each function in minicharts.js there's onclick events that switch to another function (another set of charts, i.e. the anchors to USD,EUR,etc.).

We want this functionality preserved with a simple script (like the one on top) calling the "active" function again with a timer. For this I think every function, when called, should set a global variable to the respective currency and the reload timer should then call that specific function for the currency in the variable.

If I got the theory right, this should reload the images without reloading the page.

Personally, I fail at setting the global variable.. it returns 'undefined', so I give up Smiley

PM or comment below.

Daniel

BitcoinMoxy.com - Your Gateway into the World of Bitcoin for Newcomers, Day Traders, Advertisers.
Service updates: https://bitcointalk.org/index.php?topic=254631.0
conaner
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
July 23, 2013, 10:29:18 PM
 #2

Can this help you:

http://stackoverflow.com/questions/4572193/how-to-reload-img-every-5-second-using-javascript

Essentially assign a junk parameter to the url so the cache treats it differently and grabs the new data.

You might need to keep 4 id's of images and not rewrite the html inside the div. Directly reference the img tags by id.
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
July 23, 2013, 11:37:10 PM
 #3

Can you post the lines of code where you:

1) set the global variable
2) access the global variable (ie, where it returns undefined)

That would help me help you more Smiley

In general, I'd consider doing an AJAX request to reload the image, I have some code that updates part of a page without reloading the whole thing, I can send it to you.

12d2dfgi1cz77mxFkHA5Gf9PdpwLVzfGKK
Jaxkr
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
July 23, 2013, 11:50:33 PM
Last edit: July 24, 2013, 12:19:49 AM by Jaxkr
 #4

Here. Try this:
Code:
var currencies = ['USD', 'EUR', 'GBP', 'CAD'];
var currentCurrency = 0;
var refreshDiv = function() {
currentCurrency++;
if (!(currentCurreny > 3)) {
functionName = 'minicharts' + currencies[currentCurrency];
} else {
currentCurrency = 0;
functionName = 'minicharts' + currencies[0];
}
window[functionName];
}
window.setInterval(refreshDiv, 1000);

If it doesn't work let me know and I'll fix it. If it does, my address is 18Kz7Sh1AX1UhRxC2Muwhxr7BxjCEwVF8o.
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
July 24, 2013, 12:00:43 AM
 #5

Yah, for me, this code works fine to refresh image.png, image1.png, image2.png without any ajax.

I hope this helps:

Code:
<html>
<script language="javascript">
  var counter=0;
  window.setInterval("refreshImg()", 3000);
  function refreshImg(){
    counter = counter+1;
    document.getElementById("test").innerHTML = "Testing "+counter;
    if (counter%2==0) {
      document.getElementById('im').src = "./image1.png";
    } else {
      document.getElementById('im').src = "./image2.png";
    }
  }
</script>
<body>
<div>
<p id="test"></p>
<img id="im" src="image.png"><img>
</div>
</body>
</html>

I was just testing the 'refresh' factor.  Overwritting .src on the img element works fine to update without refreshing the whole document.  I guess in your case, you just do the trick the others were saying about using Date() to generate a random url string after the image so that the browser treats it as a new value for .src

12d2dfgi1cz77mxFkHA5Gf9PdpwLVzfGKK
Drug5bitz
Full Member
***
Offline Offline

Activity: 123
Merit: 100



View Profile
July 24, 2013, 01:01:45 AM
 #6

Wish I knew enough about Java to help.  Sad

If you would like to donate to my jalapeno mods, or just buy me a b33r it's all appreciated.

BTC Address 1DX24XAojH2qjAgFzbME81o9BD3yDjfGLR
BitcoinMoxy (OP)
Member
**
Offline Offline

Activity: 119
Merit: 100


BitcoinMoxy.com


View Profile WWW
July 24, 2013, 07:04:43 PM
 #7


Thanks guys, I'm having a look at these now..


BitcoinMoxy.com - Your Gateway into the World of Bitcoin for Newcomers, Day Traders, Advertisers.
Service updates: https://bitcointalk.org/index.php?topic=254631.0
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
July 25, 2013, 12:29:08 AM
 #8


Thanks guys, I'm having a look at these now..




Ok, I'm happy to help further if you need it.  Looking forward to earning my first btc for helping with code. Smiley

PM me an email and we can look at the actual files you have, I'm pretty good at debugging javascript.
BitcoinMoxy (OP)
Member
**
Offline Offline

Activity: 119
Merit: 100


BitcoinMoxy.com


View Profile WWW
July 25, 2013, 05:31:22 PM
 #9

Alright, got it to work by simplifying the code Jaxkr provided. Thanks Bro! Money sent.



Can this help you:

http://stackoverflow.com/questions/4572193/how-to-reload-img-every-5-second-using-javascript

Essentially assign a junk parameter to the url so the cache treats it differently and grabs the new data.

You might need to keep 4 id's of images and not rewrite the html inside the div. Directly reference the img tags by id.



Thanks for the info. It seems a workaround to image caching isn't necessary in this case because the URLs used aren't referencing an actual image file. So from what I can tell it doesn't cache the images anyway.



BitcoinMoxy.com - Your Gateway into the World of Bitcoin for Newcomers, Day Traders, Advertisers.
Service updates: https://bitcointalk.org/index.php?topic=254631.0
BitcoinMoxy (OP)
Member
**
Offline Offline

Activity: 119
Merit: 100


BitcoinMoxy.com


View Profile WWW
July 25, 2013, 05:31:42 PM
 #10


Thanks guys, I'm having a look at these now..




Ok, I'm happy to help further if you need it.  Looking forward to earning my first btc for helping with code. Smiley

PM me an email and we can look at the actual files you have, I'm pretty good at debugging javascript.

There'll be plenty to do yet Smiley



BitcoinMoxy.com - Your Gateway into the World of Bitcoin for Newcomers, Day Traders, Advertisers.
Service updates: https://bitcointalk.org/index.php?topic=254631.0
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
July 25, 2013, 08:52:38 PM
 #11


Thanks guys, I'm having a look at these now..




Ok, I'm happy to help further if you need it.  Looking forward to earning my first btc for helping with code. Smiley

PM me an email and we can look at the actual files you have, I'm pretty good at debugging javascript.

There'll be plenty to do yet Smiley


Not sure how motivated I'll be to help.  You could change that (small donation for work already done).

Feeling slightly shafted because I spent time considering your problem (refreshing images in a div without resetting the page), testing your problem with a minimal example of hand written code (works to implement the refresh image on a timer without resetting the page (tested on gnu-linux/apache2/firefox and chromium)).   Wrote to you to ask for more info about how to integrate my solution with your needs ... and ... you paid the other guy who just said 'try this' without any explanation. 

No disresepct to Jaxr intended, I'm just feeling like a small (a couple btms?) good faith donation would be in order for my efforts.  Ball's in your court, of course, but I felt like I had to say this. 
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
July 25, 2013, 09:31:57 PM
 #12


Thanks guys, I'm having a look at these now..




Ok, I'm happy to help further if you need it.  Looking forward to earning my first btc for helping with code. Smiley

PM me an email and we can look at the actual files you have, I'm pretty good at debugging javascript.

There'll be plenty to do yet Smiley


Not sure how motivated I'll be to help.  You could change that (small donation for work already done).

Feeling slightly shafted because I spent time considering your problem (refreshing images in a div without resetting the page), testing your problem with a minimal example of hand written code (works to implement the refresh image on a timer without resetting the page (tested on gnu-linux/apache2/firefox and chromium)).   Wrote to you to ask for more info about how to integrate my solution with your needs ... and ... you paid the other guy who just said 'try this' without any explanation. 

No disresepct to Jaxr intended, I'm just feeling like a small (a couple btms?) good faith donation would be in order for my efforts.  Ball's in your court, of course, but I felt like I had to say this. 

Uhmm deal with it, it said bounty, and Jaxr did the correct solution that works. Now don't be an idiot and demand money cause you put more time into it then someone else and didn't get the bounty. Instead of whinning post a job ad and move on.
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
July 25, 2013, 09:36:55 PM
 #13

Quote
There'll be plenty to do yet:)

Not sure how motivated I'll be to help.  You could change that (small donation for work already done).

Feeling slightly shafted because I spent time considering your problem (refreshing images in a div without resetting the page), testing your problem with a minimal example of hand written code (works to implement the refresh image on a timer without resetting the page (tested on gnu-linux/apache2/firefox and chromium)).   Wrote to you to ask for more info about how to integrate my solution with your needs ... and ... you paid the other guy who just said 'try this' without any explanation.  

No disresepct to Jaxr intended, I'm just feeling like a small (a couple btms?) good faith donation would be in order for my efforts.  Ball's in your court, of course, but I felt like I had to say this.  

Uhmm deal with it, it said bounty, and Jaxr did the correct solution that works. Now don't be an idiot and demand money cause you put more time into it then someone else and didn't get the bounty. Instead of whinning post a job ad and move on.

Oh yes, I see now.  gweedo you have enlightened me with your edifying comment.

In fact, *I* posted code that worked but it was ignored.  In fact, I have made no demands.  I simply state in reply to an offer from original poster that 'there's more work to be done' that I'm not sure how motivated I'll be given my experience here.   That's fair.  It's not a demand, it's a statement of my assessment of my likelihood to put any further effort towards projects from BitcoinMoxy.  I also provide a solution, offer a few btms for my good faith contributions.  To be honest, gweedo, it's hard to see how you're involved here at all.

Finally, here's some free advice for you: don't run around calling people idiots, it's not the way to make friends.

tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
July 25, 2013, 09:54:58 PM
 #14

Quote
Quote
Here's some free advice for you: don't run around calling people idiots, it's not the way to make friends.

Your still an idiot cause you don't understand what a bounty is. Here let me spell it out for you. I means the the OP makes the decision to send the money to who he wants. You didn't get the money, you are an idiot for demanding, have fun being poor Wink

Hmm, some people just have a hard time learning how to behave, I guess.  At least there's an 'ignore' button for angry teenage flamers these days.

PS:  Spelling things right isn't a reflection of your intelligence, but it does tend to correlate with quality and professionalism in most fields.  Note these in your last post.
 
"Your" -> "You're"
"I means" -> "It means"

Best
dree12
Legendary
*
Offline Offline

Activity: 1246
Merit: 1077



View Profile
July 25, 2013, 10:06:13 PM
Last edit: July 26, 2013, 11:42:46 PM by dree12
 #15

There is no language attribute for script.

"javascript" isn't a MIME type. You need type="application/javascript" or type="text/javascript".
Jaxkr
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
July 25, 2013, 10:43:30 PM
 #16

There is no language attribute for script.

"javascript" isn't a MIME type. You need type="application/javascript" or type="text/javascript".
With HTML5 you don't need anything. Just <script> works.
dree12
Legendary
*
Offline Offline

Activity: 1246
Merit: 1077



View Profile
July 25, 2013, 10:46:31 PM
Last edit: July 26, 2013, 11:43:32 PM by dree12
 #17

There is no language attribute for script.

"javascript" isn't a MIME type. You need type="application/javascript" or type="text/javascript".
With HTML5 you don't need anything. Just <script> works.

Of course not, but it's always good to have it, as some browsers do not support HTML5. With HTML5 you don't need many things: the textContent of <canvas> comes to mind. But that doesn't mean you should forgo them.
BitcoinMoxy (OP)
Member
**
Offline Offline

Activity: 119
Merit: 100


BitcoinMoxy.com


View Profile WWW
July 26, 2013, 06:20:05 PM
 #18

Hey what happened? You shouldn't be calling each other idiots..

I gave Jaxkr the money because at first glance his code looked like it offered the best possible route to go. We discussed it briefly in private, I worked on it over night and it's now up and functional.

His contribution provided the key to helping me find the most efficient solution. So he deserves it.


Daniel



BitcoinMoxy.com - Your Gateway into the World of Bitcoin for Newcomers, Day Traders, Advertisers.
Service updates: https://bitcointalk.org/index.php?topic=254631.0
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
July 26, 2013, 06:53:16 PM
 #19

Hey what happened? You shouldn't be calling each other idiots..

I gave Jaxkr the money because at first glance his code looked like it offered the best possible route to go. We discussed it briefly in private, I worked on it over night and it's now up and functional.

His contribution provided the key to helping me find the most efficient solution. So he deserves it.


Daniel




Daniel,

That's absolutely fine.  For the record, I'm emphasizing that I wasn't calling anyone anything.  I did end up having to put gweedo on ignore.  He really went after me when I asked for a donation...
pakss
Newbie
*
Offline Offline

Activity: 21
Merit: 1


View Profile
July 26, 2013, 11:19:18 PM
 #20

You need some help yet dude? Happy mining to all
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!