mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
Add an easter egg to allow contributors to preview their work easily
This commit is contained in:
parent
4c90b4b8cb
commit
242285c0ba
2 changed files with 46 additions and 8 deletions
15
README.md
15
README.md
|
@ -1,4 +1,10 @@
|
||||||
# Requirements
|
# Usage
|
||||||
|
|
||||||
|
**Easy preview**: Simple changes in the texts can be previewed live on bitcoin.org with any recent browser. You only need to click anywhere on the page and hold your mouse button for one second. You'll then be able to edit the page just like a document. Changes will be lost as soon as the page is refreshed.
|
||||||
|
|
||||||
|
**Real preview**: Install dependencies, edit the files, run jekyll (or "jekyll build" on older setups), and copy the output files from _site/ at the root of your web server. If you have no web server, run jekyll --server (or "jekyll serve" on older setups). This server requires you to add a trailing ".html" by hand in your browser window.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
Installing dependencies on Ubuntu 12.10
|
Installing dependencies on Ubuntu 12.10
|
||||||
|
|
||||||
|
@ -10,13 +16,6 @@ Installing dependencies on older Ubuntu and Debian distributions
|
||||||
sudo apt-get install rubygems ruby1.9.1-dev build-essential
|
sudo apt-get install rubygems ruby1.9.1-dev build-essential
|
||||||
sudo gem install jekyll json less therubyracer ffi-icu
|
sudo gem install jekyll json less therubyracer ffi-icu
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
* Run jekyll (or "jekyll build" on older setups)
|
|
||||||
* Output will be in \_site/
|
|
||||||
|
|
||||||
If you have no http server, you can run jekyll --server (or "jekyll serve" on older setups). This server does not support clean urls and requires you to add a trailing ".html" by hand in your browser window.
|
|
||||||
|
|
||||||
## Translation
|
## Translation
|
||||||
|
|
||||||
### How to translate
|
### How to translate
|
||||||
|
|
39
js/main.js
39
js/main.js
|
@ -1,3 +1,9 @@
|
||||||
|
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 cancelEvent(e){if(!e)var e=window.event;(e.preventDefault)?e.preventDefault():e.returnValue=false;}
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,3 +212,36 @@ function freenodeShow(e){
|
||||||
document.getElementById('chatbox').innerHTML='<iframe style=width:98%;min-width:400px;height:600px src="http://webchat.freenode.net/?channels=bitcoin-dev" />';
|
document.getElementById('chatbox').innerHTML='<iframe style=width:98%;min-width:400px;height:600px src="http://webchat.freenode.net/?channels=bitcoin-dev" />';
|
||||||
cancelEvent(e);
|
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.
|
||||||
|
switch(e.type){
|
||||||
|
case 'mousedown':
|
||||||
|
addEvent(document.body,'mouseup',makeEditable);
|
||||||
|
addEvent(document.body,'mousemove',makeEditable);
|
||||||
|
document.body.setAttribute('timeoutEdit',setTimeout(function(){
|
||||||
|
removeEvent(document.body,'mouseup',makeEditable);
|
||||||
|
removeEvent(document.body,'mousemove',makeEditable);
|
||||||
|
var c=document.getElementById('content');
|
||||||
|
c.contentEditable=true;
|
||||||
|
c.style.borderColor='#bfbfbf';
|
||||||
|
setTimeout(function(){c.style.borderColor='';},200);
|
||||||
|
},1000));
|
||||||
|
break;
|
||||||
|
case 'mouseup':
|
||||||
|
case 'mousemove':
|
||||||
|
removeEvent(document.body,'mouseup',makeEditable);
|
||||||
|
removeEvent(document.body,'mousemove',makeEditable);
|
||||||
|
clearTimeout(document.body.getAttribute('timeoutEdit'));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add makeEditable event listener
|
||||||
|
var xint=setInterval(function(){
|
||||||
|
if(!document.body)return;
|
||||||
|
addEvent(document.body,'mousedown',makeEditable);
|
||||||
|
clearInterval(xint);
|
||||||
|
},200);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue