Commit 54759405 authored by Ryan Herbert's avatar Ryan Herbert

tips.js load range of tips

Add the possibility to specify the ids of tips that should be loaded.
Allows for delayed release of tips without having to update the tips
file.
parent e82d6959
function TipsOfTheDay(data, decorator) {
function TipsOfTheDay(data, decorator, ids) {
this.storage_key = "vidjil.tips.seen";
this.tips = data;
this.tips = this.load(data, ids);
this.seen = this.get_seen_ids();
this.cur_unseen = -1;
this.unseen = this.get_unseen_ids();
......@@ -10,6 +10,17 @@ function TipsOfTheDay(data, decorator) {
TipsOfTheDay.prototype = {
load: function(data, ids) {
if (typeof ids === "undefined") {
return data;
}
var tips = {};
for (var i = 0; i < ids.length; i++) {
tips[ids[i]] = data[ids[i]];
}
return tips;
},
get_seen_ids: function() {
var storage = window.localStorage;
var seen_string = storage.getItem(this.storage_key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment