Clean some code and add documentation

This commit is contained in:
Saivann 2013-10-21 23:45:57 -04:00
parent 06685bbe13
commit 9b05a0bc8e
15 changed files with 208 additions and 140 deletions

View file

@ -49,9 +49,9 @@ menu:
</li>
</ul>
<a id="logo" href="/{{ page.lang }}/"><img src="/img/logotop.svg" alt="Bitcoin"></a>
<a href="#" id="menumobile" onclick="mobileshow(event);"></a>
<a href="#" id="menumobile" onclick="mobileMenuShow(event);"></a>
<ul id="menusimple">
<li><a href="#" onclick="mobilehover(event);">{% translate menu-intro layout %}</a>
<li><a href="#" onclick="mobileMenuHover(event);">{% translate menu-intro layout %}</a>
<ul>
<li{% if page.id == 'bitcoin-for-individuals' %} class="active"{% endif %}><a href="/{{ page.lang }}/{% translate bitcoin-for-individuals url %}">{% translate menu-bitcoin-for-individuals layout %}</a></li>
<li{% if page.id == 'bitcoin-for-businesses' %} class="active"{% endif %}><a href="/{{ page.lang }}/{% translate bitcoin-for-businesses url %}">{% translate menu-bitcoin-for-businesses layout %}</a></li>
@ -69,7 +69,7 @@ menu:
<li{% if page.id == 'you-need-to-know' %} class="active"{% endif %}><a href="/{{ page.lang }}/{% translate you-need-to-know url %}">{% translate menu-you-need-to-know layout %}</a></li>
</ul>
</li>
<li><a href="#" onclick="mobilehover(event);">{% translate menu-resources layout %}</a>
<li><a href="#" onclick="mobileMenuHover(event);">{% translate menu-resources layout %}</a>
<ul>
<li{% if page.id == 'resources' %} class="active"{% endif %}><a href="/{{ page.lang }}/{% translate resources url %}">{% translate menu-resources layout %}</a></li>
<li{% if page.id == 'community' %} class="active"{% endif %}><a href="/{{ page.lang }}/{% translate community url %}">{% translate menu-community layout %}</a></li>
@ -120,7 +120,7 @@ menu:
<span>{% translate footer layout %}</span>
</div></div>
</div>
<script type="text/javascript">svgfallback();</script>
<script type="text/javascript">fallbackSVG();</script>
</body>
</html>

View file

@ -1,3 +1,18 @@
#alerts.rb generates alert pages using files in _alerts
#and assign them the 'alert' category.
#This is later used to loop through site.pages in order
#to display the alert's list in chronological order, both
#on the "Alerts" page and RSS file.
#If "banner" variable is set in one alert file, site.ALERT
#variable is set, allowing a clickable alert banner to be
#displayed in _layouts/base.html .
#If "alias" variable is set in one alert file, a short alias
#file for the alert (like /android.html) is generated for
#Bitcoin-Qt non-clickable alerts.
require 'yaml'
module Jekyll

View file

@ -1,13 +1,17 @@
require 'yaml'
require 'ffi-icu'
#alphab_for allows to loop in an array sorted by the translated value of
#each key using appropriate collation for the current language. Example :
#each key using appropriate collation for the current language. In short,
#this is used to generate translated table of contents.
#Example:
#{% alphab_for v in page.voc %}
# ..
#{% endalphab_for %}
require 'yaml'
require 'ffi-icu'
module Jekyll
module AlphabForImpl
def render(context)
#load translations files
@ -61,7 +65,6 @@ module Jekyll
class AlphabForTag < Liquid::For
include AlphabForImpl
def collection_to_sort(context)
return context[@collection_name].dup
end
@ -70,6 +73,7 @@ module Jekyll
'endalphab_for'
end
end
end
Liquid::Template.register_tag('alphab_for', Jekyll::AlphabForTag)

View file

@ -1,57 +1,61 @@
#contributors.rb fetches Bitcoin-Qt contributors list and set
#site.project.contributors array. This is later used to
#display the list of contributors on the "Development" page.
require 'open-uri'
require 'json'
require 'yaml'
module Jekyll
class CategoryGenerator < Generator
def fetch_contributors
contributors = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/contributors","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
class CategoryGenerator < Generator
def fetch_contributors
contributors = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/contributors","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
contributors.map do |x|
x['name'] = x['login'] unless x.has_key?('name')
x['name'] = x['login'] if x['name'] == ""
contributors.map do |x|
x['name'] = x['login'] unless x.has_key?('name')
x['name'] = x['login'] if x['name'] == ""
x
end
end
x
end
end
def merge_contributors(contributors, aliases)
contributors = contributors.map do |c|
c['name'] = aliases[c['name']] if aliases.has_key?(c['name'])
def merge_contributors(contributors, aliases)
contributors = contributors.map do |c|
c['name'] = aliases[c['name']] if aliases.has_key?(c['name'])
c
end
c
end
hoaoh = contributors.reduce({}) do |result, item|
result.merge({ item['name'] => [item] }) { |key, old, new| old[0]['contributions'] += new[0]['contributions']; old }
end
hoaoh = contributors.reduce({}) do |result, item|
result.merge({ item['name'] => [item] }) { |key, old, new| old[0]['contributions'] += new[0]['contributions']; old }
end
hoaoh.values.map { |sublist|
sublist.reduce({}) do |merged,h|
merged.merge(h) do |key,old,new| (key=='name' ? old : old+new) end
end
}.flatten
end
hoaoh.values.map { |sublist|
sublist.reduce({}) do |merged,h|
merged.merge(h) do |key,old,new| (key=='name' ? old : old+new) end
end
}.flatten
end
def generate(site)
class << site
attr_accessor :primary_devs, :contributors
def generate(site)
class << site
attr_accessor :primary_devs, :contributors
def site_payload
result = super
result['site']['project'] = {
"primary_devs" => self.primary_devs,
"contributors" => self.contributors
}
result
end
end
def site_payload
result = super
result['site']['project'] = {
"primary_devs" => self.primary_devs,
"contributors" => self.contributors
}
result
end
end
site.primary_devs = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/collaborators","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
site.contributors = merge_contributors(fetch_contributors(), site.config['aliases']).sort_by{|c| - c['contributions']}
end
site.primary_devs = JSON.parse(open("https://api.github.com/repos/bitcoin/bitcoin/collaborators","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
site.contributors = merge_contributors(fetch_contributors(), site.config['aliases']).sort_by{|c| - c['contributions']}
end
end
end
end

View file

@ -1,3 +1,10 @@
#events.rb generates blank hidden event pages using files
#in _events and assign them the 'event' category.
#This is later used to loop through site.pages in order
#to display the event's list in chronological order, both
#on the events RSS file and translated events pages.
require 'yaml'
module Jekyll
@ -17,7 +24,6 @@ module Jekyll
class EventPageGenerator < Generator
def generate(site)
#generate each event page
Dir.foreach('_events') do |file|
next if file == '.' or file == '..'
date = file.split('-')

View file

@ -1,10 +1,13 @@
#filter_for allows to loop in site.pages sorted and filtered
#by custom page variables. Example :
#by custom page variables.
#Example:
#{% filter_for p in site.pages sort_by:date category:release lang:{{page.lang}} %}
# ..
#{% endfilter_for %}
module Jekyll
module SortedForImpl
def render(context)
sorted_collection = collection_to_sort context
@ -52,6 +55,7 @@ module Jekyll
'endfilter_for'
end
end
end
Liquid::Template.register_tag('filter_for', Jekyll::SortedForTag)

View file

@ -1,3 +1,17 @@
#releases.rb generates release pages using files in _releases
#and assign them the 'release' category.
#This is later used to loop through site.pages in order
#to display the release's list in chronological order, both
#on the "Version history" page and RSS file.
#This plugin also set site.DOWNLOAD_VERSION to the latest
#available version of Bitcoin-QT, which is used everywhere
#in the download page.
#Alias redirection pages are generated in /releases to avoid
#breaking previous links in various websites.
require 'yaml'
module Jekyll

View file

@ -1,3 +1,6 @@
#sitemap.rb generates a sitemap.xml file, which also includes
#alternate hreflang for each translated version of each page.
require 'yaml'
require 'cgi'
@ -11,7 +14,6 @@ module Jekyll
class SitemapGenerator < Generator
def generate(site)
#Load translations
locs = {}
Dir.foreach('_translations') do |file|
@ -110,7 +112,6 @@ module Jekyll
sitemap.puts '</urlset>'
end
site.static_files << SitemapFile.new(site, site.source, '', 'sitemap.xml')
end
end

View file

@ -1,3 +1,6 @@
#svg.rb is a workaround to allow built-in jekyll server
#to serve svg files with jekyll --server.
require 'webrick'
include WEBrick

View file

@ -1,13 +1,13 @@
require 'yaml'
require 'cgi'
#This plugin generates all translated pages using templates in
#templates.rb generates all translated pages using templates in
#_templates. The final file name of each page is defined in
#the url section of each translations in _translations.
#If a page is defined in _redirects.yml, this plugin will
#If a page is defined in _redirects, this plugin will
#generate a redirection instead of using the template.
require 'yaml'
require 'cgi'
module Jekyll
class TranslatePage < Page

View file

@ -1,6 +1,3 @@
require 'yaml'
require 'cgi'
#translate( id [,category ,lang] )
#Return translated string using translations files
@ -17,7 +14,11 @@ require 'cgi'
#/en/vocabulary#wallet when the page is in english or
#/fr/vocabulaire#porte-monnaie when the page is in french.
require 'yaml'
require 'cgi'
module Jekyll
class TranslateTag < Liquid::Tag
def initialize(tag_name, id, tokens)
@ -82,6 +83,7 @@ module Jekyll
text
end
end
end
Liquid::Template.register_tag('translate', Jekyll::TranslateTag)

View file

@ -97,7 +97,7 @@ id: choose-your-wallet
<h2>{% translate wallettrustinfo %}</h2>
<span></span>
<p>{% translate wallettrustinfotxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -130,7 +130,7 @@ id: choose-your-wallet
<h2>{% translate wallettrustinfo %}</h2>
<span></span>
<p>{% translate wallettrustinfotxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -146,7 +146,7 @@ id: choose-your-wallet
<h2>{% translate walletwebwarning %}</h2>
<span></span>
<p>{% translate walletwebwarningtxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -160,7 +160,7 @@ id: choose-your-wallet
<h2>{% translate wallettrustinfo %}</h2>
<span></span>
<p>{% translate wallettrustinfotxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -174,7 +174,7 @@ id: choose-your-wallet
<h2>{% translate walletwebwarning %}</h2>
<span></span>
<p>{% translate walletwebwarningtxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -192,7 +192,7 @@ id: choose-your-wallet
<h2>{% translate walletwebwarning %}</h2>
<span></span>
<p>{% translate walletwebwarningtxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -206,7 +206,7 @@ id: choose-your-wallet
<h2>{% translate wallettrustinfo %}</h2>
<span></span>
<p>{% translate wallettrustinfotxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -220,7 +220,7 @@ id: choose-your-wallet
<h2>{% translate walletwebwarning %}</h2>
<span></span>
<p>{% translate walletwebwarningtxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>
@ -233,7 +233,7 @@ id: choose-your-wallet
<h2>{% translate walletwebwarning %}</h2>
<span></span>
<p>{% translate walletwebwarningtxt %}</p>
<p><a href="#" onclick="walletshow(event);">{% translate walletwebwarningok %}</a></p>
<p><a href="#" onclick="walletShow(event);">{% translate walletwebwarningok %}</a></p>
</div>
<div class="b3"></div>
</div>

View file

@ -51,7 +51,7 @@ id: secure-your-wallet
<p>{% translate offlinetxt %}</p>
<div class="box boxexpand">
<h3><a href="#" onclick="boxshow(event);">{% translate offlinetx %}</a></h3>
<h3><a href="#" onclick="boxShow(event);">{% translate offlinetx %}</a></h3>
<p>{% translate offlinetxtxt1 %}</p>
<ol>
<li>{% translate offlinetxtxt2 %}</li>
@ -66,7 +66,7 @@ id: secure-your-wallet
{% else %}
<br>
<div class="box boxexpand">
<h3><a href="#" onclick="boxshow(event);">{% translate hardwarewallet %}</a></h3>
<h3><a href="#" onclick="boxShow(event);">{% translate hardwarewallet %}</a></h3>
<p>{% translate hardwarewallettxt %}</p>
<p>{% translate hardwarewalletsoon %}</p>
<p>

View file

@ -9,7 +9,7 @@ dialogs:
pagetitle: "Bitcoin Press Center"
summary: "Find potential interviewees and high quality press materials."
volunteer: "Contact Potential Interviewees"
volunteerdiscl: "Bitcoin has no official organization, individuals with authority, nor spokespeople. <a href=\"#\" onclick=\"disclaimershow(event);\">Read more</a>"
volunteerdiscl: "Bitcoin has no official organization, individuals with authority, nor spokespeople. <a href=\"#\" onclick=\"disclaimerShow(event);\">Read more</a>"
volunteerdiscltext: "The Bitcoin project is open-source and, likewise, no one can speak with authority for Bitcoin. The Bitcoin community contains individuals who hold a wide spectrum of business experience or involvement, political ideas, personal opinions, technical competency, and style. This list of potential interviewees has been curated by Bitcoin community members with the intent to include individuals possessing a wide spectrum of experience, ideas, and geography. The individuals listed have been involved in the Bitcoin community for a significant period making tangible contributions, have demonstrated competence and professionalism when discussing Bitcoin, are flexible and willing to assist members of the press in both objective and persuasive ways, and are generally respected by other members of the Bitcoin community. However, an individual's appearance here should not be misconstrued as a general endorsement, either by the Bitcoin community or any particular individuals with, regards to potential interviewees and any businesses they may operate, nor any political or personal ideas they may expound, including prognostications about Bitcoin or the price or any other topic."
faq: "Facts, FAQs and Myths"
faqmore: "To learn more about Bitcoin, please visit the complete <a href=\"/en/faq\">FAQ</a> or the <a href=\"https://en.bitcoin.it/wiki/FAQ\">Bitcoin Wiki</a>."
@ -164,26 +164,26 @@ dialogs:
<div class="press-faq">
<div>
<a href="#" onclick="faqshow(event);">{% translate whatisbitcoin faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate whatisbitcoin faq %}</a>
<div>
<p>{% translate whatisbitcointxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate howitworks faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate howitworks faq %}</a>
<div>
<p>{% translate howitworkstxt1 faq %}</p>
<p>{% translate howitworkstxt2 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate whatismining faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate whatismining faq %}</a>
<div>
<p>{% translate whatisminingtxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate acquire faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate acquire faq %}</a>
<div>
<ul>
<li>{% translate acquireli1 faq %}</li>
@ -195,7 +195,7 @@ dialogs:
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate used faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate used faq %}</a>
<div>
<p>{% translate usedtxt1 faq %}</p>
<p>
@ -204,14 +204,14 @@ dialogs:
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate makepayment faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate makepayment faq %}</a>
<div>
<p>{% translate makepaymenttxt1 faq %}</p>
<p><img src="/img/faq/mobile_send.png" style="height:325px;width:190px;" alt="Screenshot"><img src="/img/faq/mobile_receive.png" style="height:325px;width:190px;" alt="Screenshot"></p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate advantages faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate advantages faq %}</a>
<div>
<ul>
<li>{% translate advantagesli1 faq %}</li>
@ -223,7 +223,7 @@ dialogs:
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate disadvantages faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate disadvantages faq %}</a>
<div>
<ul>
<li>{% translate disadvantagesli1 faq %}</li>
@ -233,13 +233,13 @@ dialogs:
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate secure faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate secure faq %}</a>
<div>
<p>{% translate securetxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate islegal faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate islegal faq %}</a>
<div>
<p>{% translate islegaltxt1 faq %}</p>
<p>{% translate islegaltxt2 faq %}</p>
@ -250,13 +250,13 @@ dialogs:
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate taxes faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate taxes faq %}</a>
<div>
<p>{% translate taxestxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate illegalactivities faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate illegalactivities faq %}</a>
<div>
<p>{% translate illegalactivitiestxt1 faq %}</p>
<p>{% translate illegalactivitiestxt2 faq %}</p>
@ -264,51 +264,51 @@ dialogs:
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate bubble faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate bubble faq %}</a>
<div>
<p>{% translate bubbletxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate whyvalue faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate whyvalue faq %}</a>
<div>
<p>{% translate whyvaluetxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate ponzi faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate ponzi faq %}</a>
<div>
<p>{% translate ponzitxt1 faq %}</p>
<p>{% translate ponzitxt2 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate creator faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate creator faq %}</a>
<div>
<p>{% translate creatortxt1 faq %}</p>
<p>{% translate creatortxt2 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate worthless faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate worthless faq %}</a>
<div>
<p>{% translate worthlesstxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate virtual faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate virtual faq %}</a>
<div>
<p>{% translate virtualtxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate trust faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate trust faq %}</a>
<div>
<p>{% translate trusttxt1 faq %}</p>
</div>
</div>
<div>
<a href="#" onclick="faqshow(event);">{% translate anonymous faq %}</a>
<a href="#" onclick="faqShow(event);">{% translate anonymous faq %}</a>
<div>
<p>{% translate anonymoustxt1 faq %}</p>
<p>{% translate anonymoustxt2 faq %}</p>
@ -345,7 +345,7 @@ dialogs:
<a href="https://docs.google.com/uc?export=view&amp;id=0Bxtcokiuvb4fcVQzWkNHYm5jbE0" target="_blank"><img src="/img/press/picture/bitcoin_logo_3d_wood.png" alt="Bitcoin 3D" title="3D Bitcoin arwork by Eivind Nag"></a>
<a href="https://docs.google.com/uc?export=view&amp;id=0BwnE6HIoU4a4NjlNLVM2dzJXLUk" target="_blank"><img src="/img/press/picture/bitcoin_casascius_holograph.png" alt="Bitcoin holograph coin"></a>
</div>
<a href="#" onclick="materialshow(event);">{{ page.dialogs.materialpicturemore }}</a>
<a href="#" onclick="materialShow(event);">{{ page.dialogs.materialpicturemore }}</a>
</div>
<div>
@ -360,7 +360,7 @@ dialogs:
<p>{{ page.dialogs.quotetylerwinklevoss }}</p>
<p>{{ page.dialogs.quotemaxkeiser }}</p>
</div>
<a href="#" onclick="materialshow(event);">{{ page.dialogs.materialquotemore }}</a>
<a href="#" onclick="materialShow(event);">{{ page.dialogs.materialquotemore }}</a>
</div>
</div>

View file

@ -1,37 +1,39 @@
function addEvent(a,b,c){return (a.addEventListener)?a.addEventListener(b,c,false):(a.attachEvent)?a.attachEvent('on'+b,c):false;}
function removeEvent(a,b,c){return (a.removeEventListener)?a.removeEventListener(b,c,false):(a.detachEvent)?a.detachEvent('on'+b,c):false;}
function cancelEvent(e){if(!e)var e=window.event;(e.preventDefault)?e.preventDefault():e.returnValue=false;}
function getEventTarget(e){if(!e)var e=window.event;return (e.target&&e.target.nodeType==3)?e.target.parentNode:(e.target)?e.target:e.srcElement;}
function supportsSVG(){
//Old FF 3.5 and Safari 3 versions have a very poor svg support
//http://www.w3.org/TR/SVG11/feature#Image Defeat FF 3.5 only
//http://www.w3.org/TR/SVG11/feature#Animation Defeat Saf 3 but also returns false in IE9
//http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute Defeat Saf 3 but also returns false in Chrome and safari4
//http://www.w3.org/TR/SVG11/feature#Text Defeat Saf 3 but also returns false in FF and safari4
if(!document.createElementNS||!document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect)return false;
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1"))return false;
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute","1.1")&&!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Animation","1.1")&&!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Text","1.1"))return false;
return true;
function addEvent(a,b,c){
//Attach event to a DOM node.
//Ex. addEvent(node,'click',function);
return (a.addEventListener)?a.addEventListener(b,c,false):(a.attachEvent)?a.attachEvent('on'+b,c):false;
}
function removeEvent(a,b,c){
//Detach event from a DOM node.
//Ex. removeEvent(node,'click',function);
return (a.removeEventListener)?a.removeEventListener(b,c,false):(a.detachEvent)?a.detachEvent('on'+b,c):false;
}
function cancelEvent(e){
//Cancel current event.
//Ex. cancelEvent(event);
if(!e)var e=window.event;(e.preventDefault)?e.preventDefault():e.returnValue=false;
}
function getEventTarget(e){
//Return target DOM node on which the event is triggered.
//Ex. getEventTarget(event);
if(!e)var e=window.event;return (e.target&&e.target.nodeType==3)?e.target.parentNode:(e.target)?e.target:e.srcElement;
}
function getStyle(a,b){
//Return the value of the computed style on a DOM node.
//Ex. getStyle(node,'padding-bottom');
if(window.getComputedStyle)return document.defaultView.getComputedStyle(a,null).getPropertyValue(b);
var n=b.indexOf('-');
if(n!==-1)b=b.substr(0,n)+b.substr(n+1,1).toUpperCase()+b.substr(n+2);
return a.currentStyle[b];
}
function getWidth(a){
//Return the integer value of the computed width of a DOM node.
//Ex. getWidth(node);
var w=getStyle(a,'width');
if(w.indexOf('px')!==-1)return parseInt(w.replace('px',''));
var p=[getStyle(a,'padding-top'),getStyle(a,'padding-right'),getStyle(a,'padding-bottom'),getStyle(a,'padding-left')];
@ -42,8 +44,9 @@ for(var i=0;i<4;i++){
return Math.max(0,a.offsetWidth-p[1]-p[3]);
}
function getHeight(a){
//Return the integer value of the computed height of a DOM node.
//Ex. getHeight(node);
var h=getStyle(a,'height');
if(h.indexOf('px')!==-1)return parseInt(h.replace('px',''));
var p=[getStyle(a,'padding-top'),getStyle(a,'padding-right'),getStyle(a,'padding-bottom'),getStyle(a,'padding-left')];
@ -54,8 +57,22 @@ for(var i=0;i<4;i++){
return Math.max(0,a.offsetHeight-p[0]-p[2]);
}
function supportsSVG(){
//Return true if the browser supports SVG.
//Ex. if(!supportsSVG()){..apply png fallback..}
//Old FF 3.5 and Safari 3 versions have svg support, but a very poor one
//http://www.w3.org/TR/SVG11/feature#Image Defeat FF 3.5 only
//http://www.w3.org/TR/SVG11/feature#Animation Defeat Saf 3 but also returns false in IE9
//http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute Defeat Saf 3 but also returns false in Chrome and safari4
//http://www.w3.org/TR/SVG11/feature#Text Defeat Saf 3 but also returns false in FF and safari4
if(!document.createElementNS||!document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect)return false;
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1"))return false;
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute","1.1")&&!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Animation","1.1")&&!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Text","1.1"))return false;
return true;
}
function svgfallback(){
function fallbackSVG(){
//Replace all images extensions from .svg to .png if browser doesn't support SVG files.
if(supportsSVG())return;
for(var i=0,nd=document.getElementsByTagName('*'),n=nd.length;i<n;i++){
if(nd[i].nodeName=='IMG'&&/.*\.svg$/.test(nd[i].src))nd[i].src=nd[i].src.slice(0,-3)+'png';
@ -64,8 +81,8 @@ for(var i=0,nd=document.getElementsByTagName('*'),n=nd.length;i<n;i++){
}
}
function walletshow(e){
function walletShow(e){
//Replace a wallet disclaimer by the wallet description in the "Choose your wallet" page when the user click the button.
var t=getEventTarget(e);
while(t.getAttribute('data-id')===null||t.getAttribute('data-id')=='')t=t.parentNode;
var d=t.getElementsByTagName('DIV')[0];
@ -85,8 +102,8 @@ dd.innerHTML=ss.innerHTML;
cancelEvent(e);
}
function mobileshow(e){
function mobileMenuShow(e){
//Show the mobile menu when the visitors touch the menu icon.
var mm=document.getElementById('menusimple');
var ml=document.getElementById('langselect');
var t=document.getElementById('menumobile');
@ -96,8 +113,7 @@ t.parentNode.removeChild(t);
cancelEvent(e);
}
function mobilehover(e){
function mobileMenuHover(e){
//Add a delay before hidding menu for mobiles to prevent accidental clicks
var t=getEventTarget(e);
while(t.nodeName!='LI'||!t.parentNode.id)t=t.parentNode;
@ -112,8 +128,8 @@ for(var i=0,nd=t.parentNode.getElementsByTagName('UL'),n=nd.length;i<n;i++){
cancelEvent(e);
}
function boxshow(e){
function boxShow(e){
//Display the box content when the user click a box on the "Secure your wallet" page.
var p=t=getEventTarget(e);
while(p.nodeName!='DIV')p=p.parentNode;
var sh=getHeight(p);
@ -131,8 +147,8 @@ setTimeout(function(){
cancelEvent(e);
}
function faqshow(e){
function faqShow(e){
//Display the content of a question in the FAQ at user request.
var p=t=getEventTarget(e);
while(p.nodeType!=1||p.nodeName!='DIV')p=p.nextSibling;
var pp=p.cloneNode(true);
@ -146,8 +162,8 @@ else p.style.height=nhe+'px';
cancelEvent(e);
}
function materialshow(e){
function materialShow(e){
//Display more materials on the "Press center" page at user request.
var p=t=getEventTarget(e);
while(p.nodeType!=1||p.nodeName!='DIV')p=p.previousSibling;
var pp=p.cloneNode(true);
@ -162,8 +178,8 @@ t.style.display='none';
cancelEvent(e);
}
function disclaimershow(e){
function disclaimerShow(e){
//Display the complete interviewees disclaimer on the "Press center" page at user request.
var p=t=getEventTarget(e);
while(p.nodeType!=1||p.nodeName!='P')p=p.parentNode;
p=p.nextSibling;
@ -176,8 +192,8 @@ t.parentNode.removeChild(t);
cancelEvent(e);
}
function librariesShow(e){
//Display more open source projects on the "Development" page at user request.
var p=t=getEventTarget(e);
while(p.nodeType!=1||p.nodeName!='UL')p=p.parentNode;
var sh=getHeight(p);
@ -194,16 +210,15 @@ setTimeout(function(){
cancelEvent(e);
}
function freenodeShow(e){
//Display freenode chat window on the "Development" page at user request.
document.getElementById('chatbox').innerHTML='<iframe style=width:98%;min-width:400px;height:600px src="http://webchat.freenode.net/?channels=bitcoin-dev" />';
cancelEvent(e);
}
function makeEditable(e){
//This function allows translators and writers to preview their work.
//It works as an easter egg that makes the page editable when user hold their mouse button for one second.
//An easter egg that makes the page editable when user click on the page and hold their mouse button for one second.
//This trick allows translators and writers to preview their work.
if(!e)var e=window.event;
switch(e.type){
case 'mousedown':