/    Sign up×
Community /Pin to ProfileBookmark

How to save progressbar after refresh page.

I want to save my progress bar with text around him, when i refresh page ? I try to save session storage but without result … also i try to use “if (performance.navigation.type == 1)” but now when refresh and click some of links progress bar start from zero .. (not from saved place) Any ideas ?

HTML > [url]http://pastebin.com/ZTJJugfw[/url]

CSS > [url]http://pastebin.com/hmVLuTM0[/url]

JS > [url]http://pastebin.com/1LztBzRm[/url]

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@aeiiauthorJan 17.2017 — Maybe i need to use cookie ? but how ?
Copy linkTweet thisAlerts:
@rootJan 18.2017 — localStorage object rather than using the session storage object is a better option. Cookies are dead, try not using them.
Copy linkTweet thisAlerts:
@SempervivumJan 18.2017 — Your code is fine so far. The only thing you need to do is querying if an item in local storage is already present:
[CODE] $(document).ready(function () {

function updateProgressBar(vot) {
$('.progressbar-label').html("You are " + vot + "% complete with this training");
$('.progressbar').progressbar({ value: + vot });
}
$('.link').one("click", function (event) {
var $this = $('.link');

// store voting value in data-voting
if (!$this.data('voting'))
$this.data('voting', 0);

var voting = parseFloat($this.data('voting'), 10);
voting = voting + 100 / 13;

$this.data('voting', voting);
voting = Math.round(voting)

localStorage.setItem("votPoints", voting)

updateProgressBar(voting);

$(this).parent().siblings().last().addClass("tick");
event.preventDefault();

});

var item = localStorage.getItem('votPoints');
if (item) {
updateProgressBar(item);
} else {
updateProgressBar(0);
}
});[/CODE]
Copy linkTweet thisAlerts:
@rootJan 18.2017 — It may be fine but the post is in the wrong forum.

JQuery goes in its own forum found under JavaScript Frameworks.
Copy linkTweet thisAlerts:
@aeiiauthorJan 20.2017 — How can edint that thread ?
Copy linkTweet thisAlerts:
@TrainJan 20.2017 — Not until you get enough posts. And I have no idea what that number is.
×

Success!

Help @aeii spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...