| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a8da604 commit e8cd030
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,13 +19,7 @@ type Campaign = { | |||
| 19 | 19 | fields: CampaignFields, | |
| 20 | 20 | }; | |
| 21 | 21 | ||
| 22 | - // campaign settings: most of it will come from the targeting tool | ||
| 23 | 22 | const campaignId: string = 'test-survey'; | |
| 24 | - // survey starts on Aug 23, 2017 | ||
| 25 | - const startOfSurvey: Date = new Date('2017-08-23'); | ||
| 26 | - const endOfSurvey: number = startOfSurvey.setMonth( | ||
| 27 | - startOfSurvey.getMonth() + 1 | ||
| 28 | - ); | ||
| 29 | 23 | ||
| 30 | 24 | /* Generate a [from .. to[ range */ | |
| 31 | 25 | const range = (from: number, to: number): number[] => { | |
@@ -76,14 +70,14 @@ const save = ( | |||
| 76 | 70 | as: Answer[], | |
| 77 | 71 | q: Question, | |
| 78 | 72 | answer: Answer, | |
| 79 | - why: ?string | ||
| 73 | + why?: string | ||
| 80 | 74 | ) => { | |
| 81 | 75 | const hasSnippet: boolean = !!document.getElementsByClassName( | |
| 82 | 76 | 'explainer-snippet' | |
| 83 | 77 | ).length; | |
| 84 | 78 | ||
| 85 | 79 | as[q] = answer; | |
| 86 | - localStorage.set('gu.jtbd.answers', as, { expires: endOfSurvey }); | ||
| 80 | + localStorage.set('gu.jtbd-updated.answers', as); | ||
| 87 | 81 | ||
| 88 | 82 | submitComponentEvent( | |
| 89 | 83 | 'VOTE', | |
@@ -109,7 +103,7 @@ const shouldIGo = (): boolean => { | |||
| 109 | 103 | // on a 1.5% sample of PVs | |
| 110 | 104 | rand < 1.5 && | |
| 111 | 105 | // if the user hasn't already seen the survey | |
| 112 | - sessionStorage.get('gu.jtbd.seen') !== true | ||
| 106 | + sessionStorage.get('gu.jtbd-updated.seen') !== true | ||
| 113 | 107 | ); | |
| 114 | 108 | }; | |
| 115 | 109 | ||
@@ -125,11 +119,11 @@ const init = (): void => { | |||
| 125 | 119 | return; | |
| 126 | 120 | } | |
| 127 | 121 | ||
| 128 | - sessionStorage.set('gu.jtbd.seen', true); | ||
| 122 | + sessionStorage.set('gu.jtbd-updated.seen', true); | ||
| 129 | 123 | ||
| 130 | 124 | const allQuestions = campaign.fields.questions; | |
| 131 | - const qs = localStorage.get('gu.jtbd.questions') || draw(allQuestions); | ||
| 132 | - const as = localStorage.get('gu.jtbd.answers') || qs.map(() => -1); | ||
| 125 | + const qs = localStorage.get('gu.jtbd-updated.questions') || draw(allQuestions); | ||
| 126 | + const as = localStorage.get('gu.jtbd-updated.answers') || qs.map(() => -1); | ||
| 133 | 127 | const q = selectQuestion(qs, as); | |
| 134 | 128 | ||
| 135 | 129 | if (q === -1) { | |
@@ -139,9 +133,7 @@ const init = (): void => { | |||
| 139 | 133 | ||
| 140 | 134 | mediator.emit('journalism:modules:jtbd', true); | |
| 141 | 135 | ||
| 142 | - localStorage.setIfNotExists('gu.jtbd.questions', qs, { | ||
| 143 | - expires: endOfSurvey, | ||
| 144 | - }); | ||
| 136 | + localStorage.setIfNotExists('gu.jtbd-updated.questions', qs); | ||
| 145 | 137 | ||
| 146 | 138 | initSurvey(allQuestions[qs[q]].question, allQuestions[qs[q]].askWhy) | |
| 147 | 139 | .then(({ answer, why }) => save(qs, as, q, answer, why)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments