Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 document.documentElement.className = classList.join(" "); | 129 document.documentElement.className = classList.join(" "); |
130 | 130 |
131 initTranslations(); | 131 initTranslations(); |
132 initSocialLinks(variant); | 132 initSocialLinks(variant); |
133 setLinks("aa-text", getDocLink("acceptable_ads_criteria"), "index.html"); | 133 setLinks("aa-text", getDocLink("acceptable_ads_criteria"), "index.html"); |
134 | 134 |
135 var donateLink = document.getElementById("share-donate"); | 135 var donateLink = document.getElementById("share-donate"); |
136 donateLink.href = getDocLink("donate") + "&variant=" + variant; | 136 donateLink.href = getDocLink("donate") + "&variant=" + variant; |
137 } | 137 } |
138 | 138 |
139 // Inserts i18n strings into matching elements. Any inner HTML already in the el ement is | 139 // Inserts i18n strings into matching elements. Any inner HTML already in the |
Felix Dahlke
2014/07/24 09:04:49
Should wrap at 80 columns.
| |
140 // parsed as JSON and used as parameters to substitute into placeholders in the i18n | 140 // element is parsed as JSON and used as parameters to substitute into |
141 // message. | 141 // placeholders in the i18n message. |
142 setElementText = function(element, elementHtml) | 142 setElementText = function(element, elementHtml) |
143 { | 143 { |
144 function processString(str, element) | 144 function processString(str, element) |
145 { | 145 { |
146 var match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(str); | 146 var match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(str); |
147 if (match) | 147 if (match) |
148 { | 148 { |
149 processString(match[1], element); | 149 processString(match[1], element); |
150 | 150 |
151 var e = document.createElement(match[2]); | 151 var e = document.createElement(match[2]); |
(...skipping 15 matching lines...) Expand all Loading... | |
167 function setLinks(id) | 167 function setLinks(id) |
168 { | 168 { |
169 var element = document.getElementById(id); | 169 var element = document.getElementById(id); |
170 if (!element) | 170 if (!element) |
171 { | 171 { |
172 return; | 172 return; |
173 } | 173 } |
174 | 174 |
175 var links = element.getElementsByTagName("a"); | 175 var links = element.getElementsByTagName("a"); |
176 | 176 |
177 for (var i = 0; i < links.length; i++) | 177 for (var i = 0; i < links.length && i < arguments.length - 1; i++) |
178 { | 178 { |
179 if (i >= (arguments.length - 1)) | |
Felix Dahlke
2014/07/24 09:04:49
Why not add it to the for condition? Cleaner that
| |
180 return; | |
181 var curArg = arguments[i + 1]; | 179 var curArg = arguments[i + 1]; |
182 if (typeof curArg == "string") | 180 if (typeof curArg == "string") |
183 { | 181 { |
184 links[i].href = curArg; | 182 links[i].href = curArg; |
185 links[i].setAttribute("target", "_blank"); | 183 links[i].setAttribute("target", "_blank"); |
186 } | 184 } |
187 else if (typeof curArg == "function") | 185 else if (typeof curArg == "function") |
188 { | 186 { |
189 links[i].href = "javascript:void(0);"; | 187 links[i].href = "javascript:void(0);"; |
190 links[i].addEventListener("click", curArg, false); | 188 links[i].addEventListener("click", curArg, false); |
191 } | 189 } |
192 } | 190 } |
193 } | 191 } |
194 | 192 |
195 window.addEventListener("load", init); | 193 window.addEventListener("load", init); |
LEFT | RIGHT |