Skip to content

Commit

Permalink
Incorporation of comments from pull request.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbambas committed Apr 24, 2016
1 parent 7775ee4 commit 8174995
Show file tree
Hide file tree
Showing 46 changed files with 373 additions and 2,052 deletions.
142 changes: 71 additions & 71 deletions plugins/Readability/data/Call.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
%2

function callReadability(){
var loc = document.location;
var uri = {
spec: loc.href,
host: loc.host,
prePath: loc.protocol + "//" + loc.host,
scheme: loc.protocol.substr(0, loc.protocol.indexOf(":")),
pathBase: loc.protocol + "//" + loc.host + loc.pathname.substr(0, loc.pathname.lastIndexOf("/") + 1)
};
var article = new Readability(uri, document).parse();
renderPage(article);
var loc = document.location;
var uri = {
spec: loc.href,
host: loc.host,
prePath: loc.protocol + "//" + loc.host,
scheme: loc.protocol.substr(0, loc.protocol.indexOf(":")),
pathBase: loc.protocol + "//" + loc.host + loc.pathname.substr(0, loc.pathname.lastIndexOf("/") + 1)
};
var article = new Readability(uri, document).parse();
renderPage(article);
}

function readabilityHead(article){
var head = document.createElement('head');
document.documentElement.appendChild(head);
var head = document.createElement('head');
document.documentElement.appendChild(head);

var title = document.createElement('title');
title.innerHTML = article.title;
head.appendChild(title);
var title = document.createElement('title');
title.innerHTML = article.title;
head.appendChild(title);

var css = document.createElement('style');
css.innerHTML = '%3';
head.appendChild(css);
head.appendChild(css);

var meta = document.createElement('meta');
var meta = document.createElement('meta');
meta.content = "text/html; charset=UTF-8";
meta.httpEquiv = 'content-type';
head.appendChild(meta);
Expand All @@ -38,63 +38,63 @@ function readabilityHead(article){
}

function readablilityBody(article){
var body = document.createElement('body');
body.className = 'loaded sans-serif sepia';
document.documentElement.appendChild(body);

var container = document.createElement('div');
container.className = 'container font-size5';
container.id = 'container';
body.appendChild(container);

var header = document.createElement('div');
header.className = 'header';
header.id = 'reader-header';
header.style.display = 'block';
container.appendChild(header);

var domain = document.createElement('a');
domain.id = 'reader-domain';
domain.className = 'domain';
domain.href = article.uri.spec;
domain.innerHTML = article.uri.host;
header.appendChild(domain);

var h1 = document.createElement('h1');
h1.id = 'reader-title';
h1.innerHTML = article.title;
header.appendChild(h1);

var credit = document.createElement('div');
credit.id = 'reader-credits';
credit.className = 'credits';
credit.innerHTML = article.byline;
header.appendChild(credit);

var content = document.createElement('div');
content.className = 'content';
container.appendChild(content);

var reader_content = document.createElement('div');
reader_content.id = 'moz-reader-content';
reader_content.style.display = 'block';
reader_content.innerHTML = article.content;
content.appendChild(reader_content);
var body = document.createElement('body');
body.className = 'loaded sans-serif sepia';
document.documentElement.appendChild(body);

var container = document.createElement('div');
container.className = 'container font-size5';
container.id = 'container';
body.appendChild(container);

var header = document.createElement('div');
header.className = 'header';
header.id = 'reader-header';
header.style.display = 'block';
container.appendChild(header);

var domain = document.createElement('a');
domain.id = 'reader-domain';
domain.className = 'domain';
domain.href = article.uri.spec;
domain.innerHTML = article.uri.host;
header.appendChild(domain);

var h1 = document.createElement('h1');
h1.id = 'reader-title';
h1.innerHTML = article.title;
header.appendChild(h1);

var credit = document.createElement('div');
credit.id = 'reader-credits';
credit.className = 'credits';
credit.innerHTML = article.byline;
header.appendChild(credit);

var content = document.createElement('div');
content.className = 'content';
container.appendChild(content);

var reader_content = document.createElement('div');
reader_content.id = 'moz-reader-content';
reader_content.style.display = 'block';
reader_content.innerHTML = article.content;
content.appendChild(reader_content);
}

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

readabilityHead(article);
readablilityBody(article);

readablilityToolbar();
} else {
alert("No content to transform.");
}
var element = document.documentElement;
if(element && !!article && !!article.content){
element.removeChild(document.body);
element.removeChild(document.head);

readabilityHead(article);
readablilityBody(article);

readablilityToolbar();
} else {
alert("No content to transform.");
}
}

callReadability();
178 changes: 89 additions & 89 deletions plugins/Readability/data/Toolbar.js
Original file line number Diff line number Diff line change
@@ -1,127 +1,127 @@
function readablilityToolbar(){
renderToolbar();
addListeners();
renderToolbar();
addListeners();
}

function renderToolbar(){
var toolbar = document.createElement('div');
document.getElementById('container').appendChild(toolbar);
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>';
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);

var lightButton = document.getElementById('light-button');
lightButton.addEventListener("click", function(){switchToLight(lightButton);});
var sepiaButton = document.getElementById('sepia-button');
sepiaButton.addEventListener("click", function(){switchToSepia(sepiaButton);});
var darkButton = document.getElementById('dark-button');
darkButton.addEventListener("click", function(){switchToDark(darkButton);});

var serifButton = document.getElementById('serif-button');
serifButton.addEventListener("click", function(){switchToSerif(serifButton);});
var sansSerifButton = document.getElementById('sans-serif-button');
sansSerifButton.addEventListener("click", function(){switchToSansSerif(sansSerifButton);});

var fontSizePlusButton = document.getElementById('font-size-plus');
fontSizePlusButton.addEventListener("click", fontSizePlus);
var fontSizeMinusButton = document.getElementById('font-size-minus');
fontSizeMinusButton.addEventListener("click", fontSizeMinus);
document.getElementById('close-button').addEventListener("click", closeReadability);
document.getElementById('style-button').addEventListener("click", toolbarService);

var lightButton = document.getElementById('light-button');
lightButton.addEventListener("click", function(){switchToLight(lightButton);});
var sepiaButton = document.getElementById('sepia-button');
sepiaButton.addEventListener("click", function(){switchToSepia(sepiaButton);});
var darkButton = document.getElementById('dark-button');
darkButton.addEventListener("click", function(){switchToDark(darkButton);});

var serifButton = document.getElementById('serif-button');
serifButton.addEventListener("click", function(){switchToSerif(serifButton);});
var sansSerifButton = document.getElementById('sans-serif-button');
sansSerifButton.addEventListener("click", function(){switchToSansSerif(sansSerifButton);});

var fontSizePlusButton = document.getElementById('font-size-plus');
fontSizePlusButton.addEventListener("click", fontSizePlus);
var fontSizeMinusButton = document.getElementById('font-size-minus');
fontSizeMinusButton.addEventListener("click", fontSizeMinus);
}

function closeReadability(){
location.reload();
location.reload();
}

function toolbarService(){
var element = document.getElementById('style-dropdown');
var element = document.getElementById('style-dropdown');

if(element.classList.contains('open')){
element.classList.remove('open');
} else {
element.classList.add('open');
if(element.classList.contains('open')){
element.classList.remove('open');
} else {
element.classList.add('open');

}
}
}

function switchToLight(item){
document.body.classList.remove('sepia', 'dark');
document.body.classList.add('light');

var items = document.getElementById('color-scheme-buttons').children;
for (var j = items.length - 1; j >= 0; j--) {
items[j].classList.remove("selected");
}
item.classList.add('selected');
document.body.classList.remove('sepia', 'dark');
document.body.classList.add('light');

var items = document.getElementById('color-scheme-buttons').children;
for (var j = items.length - 1; j >= 0; j--) {
items[j].classList.remove("selected");
}
item.classList.add('selected');
}

function switchToSepia(item){
document.body.classList.remove('light', 'dark');
document.body.classList.add('sepia');

var items = document.getElementById('color-scheme-buttons').children;
for (var j = items.length - 1; j >= 0; j--) {
items[j].classList.remove("selected");
}
item.classList.add('selected');
document.body.classList.remove('light', 'dark');
document.body.classList.add('sepia');

var items = document.getElementById('color-scheme-buttons').children;
for (var j = items.length - 1; j >= 0; j--) {
items[j].classList.remove("selected");
}
item.classList.add('selected');
}

function switchToDark(item){
document.body.classList.remove('sepia', 'light');
document.body.classList.add('dark');

var items = document.getElementById('color-scheme-buttons').children;
for (var j = items.length - 1; j >= 0; j--) {
items[j].classList.remove("selected");
}
item.classList.add('selected');
document.body.classList.remove('sepia', 'light');
document.body.classList.add('dark');

var items = document.getElementById('color-scheme-buttons').children;
for (var j = items.length - 1; j >= 0; j--) {
items[j].classList.remove("selected");
}
item.classList.add('selected');
}

function switchToSerif(item){
document.body.classList.remove('sans-serif');
document.body.classList.add('serif');
document.getElementById('sans-serif-button').classList.remove('selected');
item.classList.add('selected');
document.body.classList.remove('sans-serif');
document.body.classList.add('serif');
document.getElementById('sans-serif-button').classList.remove('selected');
item.classList.add('selected');
}

function switchToSansSerif(item){
document.body.classList.remove('serif');
document.body.classList.add('sans-serif');
document.getElementById('serif-button').classList.remove('selected');
item.classList.add('selected');
document.body.classList.remove('serif');
document.body.classList.add('sans-serif');
document.getElementById('serif-button').classList.remove('selected');
item.classList.add('selected');
}

function fontSizePlus(){
var container = document.getElementById('container');
var incrementedSize = 0;
for (var i = 0; i < container.classList.length; i++){
if(container.classList[i].indexOf('font-size') > -1){
var size = container.classList[i].substr(-1, 1);
if(parseInt(size) < 9){
incrementedSize = parseInt(size) + 1;
} else return;
container.classList.remove(container.classList[i]);
container.classList.add('font-size' + incrementedSize);
return;
}
}
var container = document.getElementById('container');
var incrementedSize = 0;
for (var i = 0; i < container.classList.length; i++){
if(container.classList[i].indexOf('font-size') > -1){
var size = container.classList[i].substr(-1, 1);
if(parseInt(size) < 9){
incrementedSize = parseInt(size) + 1;
} else return;
container.classList.remove(container.classList[i]);
container.classList.add('font-size' + incrementedSize);
return;
}
}
}

function fontSizeMinus(){
var container = document.getElementById('container');
var decrementedSize = 0;
for (var i = 0; i < container.classList.length; i++){
if(container.classList[i].indexOf('font-size') > -1){
var size = container.classList[i].substr(-1, 1);
if(parseInt(size) > 1){
incrementedSize = parseInt(size) - 1;
} else return;
container.classList.remove(container.classList[i]);
container.classList.add('font-size' + incrementedSize);
return;
}
}
var container = document.getElementById('container');
var decrementedSize = 0;
for (var i = 0; i < container.classList.length; i++){
if(container.classList[i].indexOf('font-size') > -1){
var size = container.classList[i].substr(-1, 1);
if(parseInt(size) > 1){
incrementedSize = parseInt(size) - 1;
} else return;
container.classList.remove(container.classList[i]);
container.classList.add('font-size' + incrementedSize);
return;
}
}
}
Loading

0 comments on commit 8174995

Please sign in to comment.