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

Side by Side Diff: firstRun.js

Issue 8403145: First attempt at creating a first-run page (Closed)
Patch Set: Now with two sets of Share buttons Created Sept. 28, 2012, 8:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « firstRun.html ('k') | i18n.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 var backgroundPage = chrome.extension.getBackgroundPage();
2 var require = backgroundPage.require;
3 var Prefs = require("prefs").Prefs;
4 var Utils = require("utils").Utils;
5
6 function init()
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
12 // Set up page title
13 var titleId = (backgroundPage.isFirstRun ? "firstRun_title_install" : "firstRu n_title_update");
14 var pageTitle = chrome.i18n.getMessage(titleId);
15 document.title = document.getElementById("title").textContent = pageTitle;
16
17 // Set up URLs
18 var versionID = chrome.app.getDetails().version.split(".").slice(0, 2).join("" );
19 setLinks("improvementsFeature", "https://adblockplus.org/releases/adblock-plus -" + versionID + "-for-google-chrome-released");
20 setLinks("acceptableAdsExplanation", getDocLink("acceptable_ads"),
21 getDocLink("acceptable_ads", "criteria"), backgroundPage.openOptions) ;
22
23 var facebookLinks = document.getElementsByClassName("share-facebook");
24 for (var i = 0; i < facebookLinks.length; i++)
25 facebookLinks[i].href = getDocLink("facebook") + "&variant=" + variant;
26
27 var twitterLinks = document.getElementsByClassName("share-twitter");
28 for (var i = 0; i < twitterLinks.length; i++)
29 twitterLinks[i].href = getDocLink("twitter") + "&variant=" + variant;
30
31 var donateLink = document.getElementById("share-donate");
32 donateLink.href = getDocLink("donate") + "&variant=" + variant;
33 }
34 window.addEventListener("load", init, false);
35
36 function setLinks(id)
37 {
38 var element = document.getElementById(id);
39 if (!element)
40 return;
41
42 var links = element.getElementsByTagName("a");
43 for (var i = 0; i < links.length; i++)
44 {
45 if (typeof arguments[i + 1] == "string")
46 {
47 links[i].href = arguments[i + 1];
48 links[i].setAttribute("target", "_blank");
49 }
50 else if (typeof arguments[i + 1] == "function")
51 {
52 links[i].href = "javascript:void(0);";
53 links[i].addEventListener("click", arguments[i + 1], false);
54 }
55 }
56 }
57
58 function getDocLink(page, anchor)
59 {
60 return Prefs.documentation_link
61 .replace(/%LINK%/g, page)
62 .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "" );
63 }
OLDNEW
« no previous file with comments | « firstRun.html ('k') | i18n.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld