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

Unified Diff: firstRun.js

Issue 8403145: First attempt at creating a first-run page (Closed)
Patch Set: Created Sept. 27, 2012, 8:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « firstRun.html ('k') | i18n.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: firstRun.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/firstRun.js
@@ -0,0 +1,48 @@
+var backgroundPage = chrome.extension.getBackgroundPage();
+var require = backgroundPage.require;
+var Prefs = require("prefs").Prefs;
+var Utils = require("utils").Utils;
+
+function init()
+{
+ // Set up page title
+ var titleId = (backgroundPage.isFirstRun ? "firstRun_title_install" : "firstRun_title_update");
+ var pageTitle = chrome.i18n.getMessage(titleId);
+ document.title = document.getElementById("title").textContent = pageTitle;
+
+ // Set up URLs
+ var versionID = chrome.app.getDetails().version.split(".").slice(0, 2).join("");
+ setLinks("improvementsFeature", "https://adblockplus.org/releases/adblock-plus-" + versionID + "-for-google-chrome-released");
+ setLinks("acceptableAdsExplanation", getDocLink("acceptable_ads"),
+ getDocLink("acceptable_ads", "criteria"), backgroundPage.openOptions);
+}
+window.addEventListener("load", init, false);
+
+function setLinks(id)
+{
+ var element = document.getElementById(id);
+ if (!element)
+ return;
+
+ var links = element.getElementsByTagName("a");
+ for (var i = 0; i < links.length; i++)
+ {
+ if (typeof arguments[i + 1] == "string")
+ {
+ links[i].href = arguments[i + 1];
+ links[i].setAttribute("target", "_blank");
+ }
+ else if (typeof arguments[i + 1] == "function")
+ {
+ links[i].href = "javascript:void(0);";
+ links[i].addEventListener("click", arguments[i + 1], false);
+ }
+ }
+}
+
+function getDocLink(page, anchor)
+{
+ return Prefs.documentation_link
+ .replace(/%LINK%/g, page)
+ .replace(/%LANG%/g, Utils.appLocale) + (anchor ? "#" + anchor : "");
+}
« no previous file with comments | « firstRun.html ('k') | i18n.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld