Update Ranking Javascript SetInterval Only Works the First Execution












0















This is for a ranking leaderboard update. It changes the values and temporarily the color. It works perfect the first time the value is changed, but barely noticeable the second and thereafter executions.



channel.bind('amount_update', function(data) {
document.getElementById('active-tokens-' + data.owner).innerHTML = data.active_tokens;
document.getElementById('active-capital-' + data.owner).innerHTML = '$' + (data.active_tokens*.9).toFixed(2);
document.getElementById('historical-tokens-' + data.owner).innerHTML = data.historical_tokens;
document.getElementById('ranking-' + data.owner).innerHTML = (data.ranking).toFixed(2);

function Update() {
document.getElementById('active-tokens-' + data.owner).style.color = "#23cc96";
document.getElementById('active-capital-' + data.owner).style.color = "#23cc96";
document.getElementById('historical-tokens-' + data.owner).style.color = "#23cc96";
}

Update();
function OriginalColor(){
document.getElementById('active-tokens-' + data.owner).style.color = "grey";
document.getElementById('active-capital-' + data.owner).style.color = "grey";
document.getElementById('historical-tokens-' + data.owner).style.color = "grey";
}
c = setInterval(OriginalColor, 2000);
});









share|improve this question























  • Why do call OriginalColor in the setInterval. It only set the color as grey, so no change.

    – Dominique Fortin
    Nov 20 '18 at 2:13











  • @DominiqueFortin I call Update which changes the color and then call Original Color to change the color back to grey after 2 seconds. I thought this would be an appropriate solution for creating a timer, almost inversely.

    – Ty C
    Nov 20 '18 at 2:15













  • Could you make small code snippet to see what you mean?

    – Dominique Fortin
    Nov 20 '18 at 2:27











  • @DominiqueFortin I included it in the question above.

    – Ty C
    Nov 20 '18 at 2:36











  • A Code snippet is like what you can see on JSFiddle. This make a working code that can be executed. When you edit, click on the [<>] button to make one. If add some HTML with the right IDs, I could test your problem with you.

    – Dominique Fortin
    Nov 20 '18 at 2:39


















0















This is for a ranking leaderboard update. It changes the values and temporarily the color. It works perfect the first time the value is changed, but barely noticeable the second and thereafter executions.



channel.bind('amount_update', function(data) {
document.getElementById('active-tokens-' + data.owner).innerHTML = data.active_tokens;
document.getElementById('active-capital-' + data.owner).innerHTML = '$' + (data.active_tokens*.9).toFixed(2);
document.getElementById('historical-tokens-' + data.owner).innerHTML = data.historical_tokens;
document.getElementById('ranking-' + data.owner).innerHTML = (data.ranking).toFixed(2);

function Update() {
document.getElementById('active-tokens-' + data.owner).style.color = "#23cc96";
document.getElementById('active-capital-' + data.owner).style.color = "#23cc96";
document.getElementById('historical-tokens-' + data.owner).style.color = "#23cc96";
}

Update();
function OriginalColor(){
document.getElementById('active-tokens-' + data.owner).style.color = "grey";
document.getElementById('active-capital-' + data.owner).style.color = "grey";
document.getElementById('historical-tokens-' + data.owner).style.color = "grey";
}
c = setInterval(OriginalColor, 2000);
});









share|improve this question























  • Why do call OriginalColor in the setInterval. It only set the color as grey, so no change.

    – Dominique Fortin
    Nov 20 '18 at 2:13











  • @DominiqueFortin I call Update which changes the color and then call Original Color to change the color back to grey after 2 seconds. I thought this would be an appropriate solution for creating a timer, almost inversely.

    – Ty C
    Nov 20 '18 at 2:15













  • Could you make small code snippet to see what you mean?

    – Dominique Fortin
    Nov 20 '18 at 2:27











  • @DominiqueFortin I included it in the question above.

    – Ty C
    Nov 20 '18 at 2:36











  • A Code snippet is like what you can see on JSFiddle. This make a working code that can be executed. When you edit, click on the [<>] button to make one. If add some HTML with the right IDs, I could test your problem with you.

    – Dominique Fortin
    Nov 20 '18 at 2:39
















0












0








0








This is for a ranking leaderboard update. It changes the values and temporarily the color. It works perfect the first time the value is changed, but barely noticeable the second and thereafter executions.



channel.bind('amount_update', function(data) {
document.getElementById('active-tokens-' + data.owner).innerHTML = data.active_tokens;
document.getElementById('active-capital-' + data.owner).innerHTML = '$' + (data.active_tokens*.9).toFixed(2);
document.getElementById('historical-tokens-' + data.owner).innerHTML = data.historical_tokens;
document.getElementById('ranking-' + data.owner).innerHTML = (data.ranking).toFixed(2);

function Update() {
document.getElementById('active-tokens-' + data.owner).style.color = "#23cc96";
document.getElementById('active-capital-' + data.owner).style.color = "#23cc96";
document.getElementById('historical-tokens-' + data.owner).style.color = "#23cc96";
}

Update();
function OriginalColor(){
document.getElementById('active-tokens-' + data.owner).style.color = "grey";
document.getElementById('active-capital-' + data.owner).style.color = "grey";
document.getElementById('historical-tokens-' + data.owner).style.color = "grey";
}
c = setInterval(OriginalColor, 2000);
});









share|improve this question














This is for a ranking leaderboard update. It changes the values and temporarily the color. It works perfect the first time the value is changed, but barely noticeable the second and thereafter executions.



channel.bind('amount_update', function(data) {
document.getElementById('active-tokens-' + data.owner).innerHTML = data.active_tokens;
document.getElementById('active-capital-' + data.owner).innerHTML = '$' + (data.active_tokens*.9).toFixed(2);
document.getElementById('historical-tokens-' + data.owner).innerHTML = data.historical_tokens;
document.getElementById('ranking-' + data.owner).innerHTML = (data.ranking).toFixed(2);

function Update() {
document.getElementById('active-tokens-' + data.owner).style.color = "#23cc96";
document.getElementById('active-capital-' + data.owner).style.color = "#23cc96";
document.getElementById('historical-tokens-' + data.owner).style.color = "#23cc96";
}

Update();
function OriginalColor(){
document.getElementById('active-tokens-' + data.owner).style.color = "grey";
document.getElementById('active-capital-' + data.owner).style.color = "grey";
document.getElementById('historical-tokens-' + data.owner).style.color = "grey";
}
c = setInterval(OriginalColor, 2000);
});






javascript pusher






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 2:07









Ty CTy C

399




399













  • Why do call OriginalColor in the setInterval. It only set the color as grey, so no change.

    – Dominique Fortin
    Nov 20 '18 at 2:13











  • @DominiqueFortin I call Update which changes the color and then call Original Color to change the color back to grey after 2 seconds. I thought this would be an appropriate solution for creating a timer, almost inversely.

    – Ty C
    Nov 20 '18 at 2:15













  • Could you make small code snippet to see what you mean?

    – Dominique Fortin
    Nov 20 '18 at 2:27











  • @DominiqueFortin I included it in the question above.

    – Ty C
    Nov 20 '18 at 2:36











  • A Code snippet is like what you can see on JSFiddle. This make a working code that can be executed. When you edit, click on the [<>] button to make one. If add some HTML with the right IDs, I could test your problem with you.

    – Dominique Fortin
    Nov 20 '18 at 2:39





















  • Why do call OriginalColor in the setInterval. It only set the color as grey, so no change.

    – Dominique Fortin
    Nov 20 '18 at 2:13











  • @DominiqueFortin I call Update which changes the color and then call Original Color to change the color back to grey after 2 seconds. I thought this would be an appropriate solution for creating a timer, almost inversely.

    – Ty C
    Nov 20 '18 at 2:15













  • Could you make small code snippet to see what you mean?

    – Dominique Fortin
    Nov 20 '18 at 2:27











  • @DominiqueFortin I included it in the question above.

    – Ty C
    Nov 20 '18 at 2:36











  • A Code snippet is like what you can see on JSFiddle. This make a working code that can be executed. When you edit, click on the [<>] button to make one. If add some HTML with the right IDs, I could test your problem with you.

    – Dominique Fortin
    Nov 20 '18 at 2:39



















Why do call OriginalColor in the setInterval. It only set the color as grey, so no change.

– Dominique Fortin
Nov 20 '18 at 2:13





Why do call OriginalColor in the setInterval. It only set the color as grey, so no change.

– Dominique Fortin
Nov 20 '18 at 2:13













@DominiqueFortin I call Update which changes the color and then call Original Color to change the color back to grey after 2 seconds. I thought this would be an appropriate solution for creating a timer, almost inversely.

– Ty C
Nov 20 '18 at 2:15







@DominiqueFortin I call Update which changes the color and then call Original Color to change the color back to grey after 2 seconds. I thought this would be an appropriate solution for creating a timer, almost inversely.

– Ty C
Nov 20 '18 at 2:15















Could you make small code snippet to see what you mean?

– Dominique Fortin
Nov 20 '18 at 2:27





Could you make small code snippet to see what you mean?

– Dominique Fortin
Nov 20 '18 at 2:27













@DominiqueFortin I included it in the question above.

– Ty C
Nov 20 '18 at 2:36





@DominiqueFortin I included it in the question above.

– Ty C
Nov 20 '18 at 2:36













A Code snippet is like what you can see on JSFiddle. This make a working code that can be executed. When you edit, click on the [<>] button to make one. If add some HTML with the right IDs, I could test your problem with you.

– Dominique Fortin
Nov 20 '18 at 2:39







A Code snippet is like what you can see on JSFiddle. This make a working code that can be executed. When you edit, click on the [<>] button to make one. If add some HTML with the right IDs, I could test your problem with you.

– Dominique Fortin
Nov 20 '18 at 2:39














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385212%2fupdate-ranking-javascript-setinterval-only-works-the-first-execution%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385212%2fupdate-ranking-javascript-setinterval-only-works-the-first-execution%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)