Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: firstRun.js

Issue 8403145: First attempt at creating a first-run page (Closed)
Left Patch Set: Created Sept. 27, 2012, 8:47 p.m.
Right Patch Set: Created Oct. 17, 2012, 2:44 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « firstRun.html ('k') | skin/firstRun.css » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 var backgroundPage = chrome.extension.getBackgroundPage(); 1 var backgroundPage = chrome.extension.getBackgroundPage();
2 var require = backgroundPage.require; 2 var require = backgroundPage.require;
3 var Prefs = require("prefs").Prefs; 3 var Prefs = require("prefs").Prefs;
4 var Utils = require("utils").Utils; 4 var Utils = require("utils").Utils;
5 5
6 function init() 6 function init()
7 { 7 {
8 // Choose a share text variant randomly
9 var variant = Math.floor(Math.random() * 2) + 1;
10 document.documentElement.setAttribute("share-variant", variant);
11
8 // Set up page title 12 // Set up page title
9 var titleId = (backgroundPage.isFirstRun ? "firstRun_title_install" : "firstRu n_title_update"); 13 var titleId = (backgroundPage.isFirstRun ? "firstRun_title_install" : "firstRu n_title_update");
10 var pageTitle = chrome.i18n.getMessage(titleId); 14 var pageTitle = chrome.i18n.getMessage(titleId);
11 document.title = document.getElementById("title").textContent = pageTitle; 15 document.title = document.getElementById("title-main").textContent = pageTitle ;
16
17 // Only show changelog link on the update page
18 if (backgroundPage.isFirstRun)
19 document.getElementById("title-changelog").style.display = "none";
12 20
13 // Set up URLs 21 // Set up URLs
14 var versionID = chrome.app.getDetails().version.split(".").slice(0, 2).join("" ); 22 var versionId = chrome.app.getDetails().version.split(".").slice(0, 2).join("" );
15 setLinks("improvementsFeature", "https://adblockplus.org/releases/adblock-plus -" + versionID + "-for-google-chrome-released"); 23 setLinks("title-changelog", "https://adblockplus.org/releases/adblock-plus-" + versionId + "-for-google-chrome-released");
16 setLinks("acceptableAdsExplanation", getDocLink("acceptable_ads"), 24 setLinks("acceptableAdsExplanation", getDocLink("acceptable_ads", "criteria"),
17 getDocLink("acceptable_ads", "criteria"), backgroundPage.openOptions) ; 25 backgroundPage.openOptions);
26
27 var facebookLinks = document.getElementsByClassName("share-facebook");
28 for (var i = 0; i < facebookLinks.length; i++)
29 facebookLinks[i].href = getDocLink("facebook") + "&variant=" + variant;
30
31 var twitterLinks = document.getElementsByClassName("share-twitter");
32 for (var i = 0; i < twitterLinks.length; i++)
33 twitterLinks[i].href = getDocLink("twitter") + "&variant=" + variant;
34
35 var donateLink = document.getElementById("share-donate");
36 donateLink.href = getDocLink("donate") + "&variant=" + variant;
18 } 37 }
19 window.addEventListener("load", init, false); 38 window.addEventListener("load", init, false);
20 39
21 function setLinks(id) 40 function setLinks(id)
22 { 41 {
23 var element = document.getElementById(id); 42 var element = document.getElementById(id);
24 if (!element) 43 if (!element)
25 return; 44 return;
26 45
27 var links = element.getElementsByTagName("a"); 46 var links = element.getElementsByTagName("a");
(...skipping 11 matching lines...) Expand all
39 } 58 }
40 } 59 }
41 } 60 }
42 61
43 function getDocLink(page, anchor) 62 function getDocLink(page, anchor)
44 { 63 {
45 return Prefs.documentation_link 64 return Prefs.documentation_link
46 .replace(/%LINK%/g, page) 65 .replace(/%LINK%/g, page)
47 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" ); 66 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" );
48 } 67 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld