Skip to content

Commit

Permalink
Code refactoring of JS functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbambas committed Apr 23, 2016
1 parent 1179e2a commit 1602af1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
7 changes: 2 additions & 5 deletions plugins/Readability/data/Call.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function readablilityBody(article){

function renderPage(article){
var element = document.documentElement;
if(element && !!article){
if(element && !!article && !!article.content){
element.removeChild(document.body);
element.removeChild(document.head);

Expand All @@ -97,7 +97,4 @@ function renderPage(article){
}
}

callReadability();


//todo: nejde renderovani u githubu
callReadability();
18 changes: 13 additions & 5 deletions plugins/Readability/data/Toolbar.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
%1

function readablilityToolbar(){
var div = document.createElement('div');
document.getElementById('container').appendChild(div);
div.innerHTML = '<ul visible="true" id="reader-toolbar" class="toolbar"> <li><button id="close-button" class="button close-button"></button></li> <ul id="style-dropdown" class="dropdown"> <li><button id="style-button" class="dropdown-toggle button style-button"></button></li> <li style="top: 48px;" id="reader-popup" class="dropdown-popup"> <div id="font-type-buttons"><button id="sans-serif-button" class="sans-serif-button selected"><div class="name">Aa</div><div class="description">Sans-serif</div></button><button id="serif-button" class="serif-button"><div class="name">Aa</div><div class="description">Serif</div></button></div> <hr> <div id="font-size-buttons"> <button id="font-size-minus" class="minus-button"> </button><button id="font-size-sample">Aa</button><button id="font-size-plus" class="plus-button"> </button></div> <hr> <div id="color-scheme-buttons"><button id="light-button" class="light-button"><div class="name">Light</div></button><button id="dark-button" class="dark-button"><div class="name">Dark</div></button><button id="sepia-button" class="sepia-button selected"><div class="name">Sepia</div></button></div> <div class="dropdown-arrow"> </div></li> </ul> </ul>';
renderToolbar();
addListeners();
}

function renderToolbar(){
var toolbar = document.createElement('div');
document.getElementById('container').appendChild(toolbar);

toolbar.innerHTML = '<ul visible="true" id="reader-toolbar" class="toolbar"><li><button id="close-button" class="button close-button"></button></li><ul id="style-dropdown" class="dropdown"><li><button id="style-button" class="dropdown-toggle button style-button"></button></li><li style="top: 48px;" id="reader-popup" class="dropdown-popup"><div id="font-type-buttons"><button id="sans-serif-button" class="sans-serif-button selected"><div class="name">Aa</div><div class="description">Sans-serif</div></button><button id="serif-button" class="serif-button"><div class="name">Aa</div><div class="description">Serif</div></button></div><hr><div id="font-size-buttons"><button id="font-size-minus" class="minus-button"></button><button id="font-size-sample">Aa</button><button id="font-size-plus" class="plus-button"></button></div><hr><div id="color-scheme-buttons"><button id="light-button" class="light-button"><div class="name">Light</div></button><button id="dark-button" class="dark-button"><div class="name">Dark</div></button><button id="sepia-button" class="sepia-button selected"><div class="name">Sepia</div></button></div><div class="dropdown-arrow"></div></li></ul></ul>';
}

function addListeners(){
document.getElementById('close-button').addEventListener("click", closeReadability);
document.getElementById('style-button').addEventListener("click", toolbarService);

Expand Down Expand Up @@ -101,7 +109,7 @@ function fontSizePlus(){
incrementedSize = parseInt(size) + 1;
} else return;
container.classList.remove(container.classList[i]);
container.classList.add('font-size'+incrementedSize);
container.classList.add('font-size' + incrementedSize);
return;
}
}
Expand All @@ -117,7 +125,7 @@ function fontSizeMinus(){
incrementedSize = parseInt(size) - 1;
} else return;
container.classList.remove(container.classList[i]);
container.classList.add('font-size'+incrementedSize);
container.classList.add('font-size' + incrementedSize);
return;
}
}
Expand Down

0 comments on commit 1602af1

Please sign in to comment.