Skip to content

Commit

Permalink
improved passing of settings and styles to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
arty-name committed Feb 11, 2012
1 parent e4ebd15 commit 7bf7845
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 70 deletions.
57 changes: 28 additions & 29 deletions build/open-google-reader.js
Expand Up @@ -19,39 +19,38 @@

if (!document.location.href.match(/^https?:..www.google.com.reader.view.1?$/)) return;

defineSettings();
function getSettings() {

function defineSettings() {
var settings = {

settings = {
// only required to be loaded on 404 url, i.e. http://www.google.com/reader/view/1
userId: '',

// only required to be loaded on 404 url, i.e. http://www.google.com/reader/view/1
userId: '',

// lowercase words to filter entries out by title
titleFilters: [],

// words to filter entries out by body (html included)
bodyFilters: [],

// your device screen's horizontal resolution
mobileViewPort: '800x480',

// filters to manipulate on entry content
// NB: set data.altered = true if you want these changes to be shared when you click "share"
entryHtmlAlterations: [],
entryDomAlterations: []

};
// lowercase words to filter entries out by title
titleFilters: [],

// words to filter entries out by body (html included)
bodyFilters: [],

// your device screen's horizontal resolution
mobileViewPort: '800x480',

// filters to manipulate on entry content
// NB: set data.altered = true if you want these changes to be shared when you click "share"
entryHtmlAlterations: [],
entryDomAlterations: []

};

var parts = settings.mobileViewPort.split('x');
settings.mobileViewPort = {
max: Math.max(parts[0], parts[1]),
min: Math.min(parts[0], parts[1])
};


return settings;
}
settings.css =
function getStyles(){ return (
"html, body {" +
" margin: 0;" +
" padding: 0;" +
Expand Down Expand Up @@ -365,7 +364,7 @@ settings.css =
" width: 2em; height: 100%; line-height: 2em; top: 0.1em;" +
"}" +
"" +
"";
"");}
/*
OVERVIEW
Expand Down Expand Up @@ -402,7 +401,7 @@ settings.css =
in the same order, so you can read code from top to bottom.
*/

function ui() {
function ui(settings, css) {

// static user id
var userId = settings.userId || window._USER_ID || (window.localStorage && localStorage.userId) || '-';
Expand Down Expand Up @@ -574,7 +573,7 @@ function ui() {
// add own css styles
function addStyles() {
document.body.previousElementSibling.appendChild(
DOM('style', undefined, [document.createTextNode(settings.css)])
DOM('style', undefined, [document.createTextNode(css)])
);
}

Expand Down Expand Up @@ -1849,15 +1848,15 @@ function lib() {

function onload() {
lib();
ui();
ui(getSettings(), getStyles());
}

if (typeof GM_xmlhttpRequest != "undefined" && !navigator.userAgent.match(/Chrome/)) {
// GreaseMonkey, fuck you very much! I don't need your overprotection.
var script = document.createElement('script');
script.innerHTML =
defineSettings.toString() + lib.toString() + ui.toString() +
'defineSettings(); lib(); ui();';
getSettings.toString() + getStyles.toString() + lib.toString() + ui.toString() +
'lib(); ui(getSettings(), getStyles());';
document.body.appendChild(script);
setTimeout(function(){
var style = document.createElement('style');
Expand Down
57 changes: 28 additions & 29 deletions build/open-google-reader.user.js
Expand Up @@ -19,39 +19,38 @@

if (!document.location.href.match(/^https?:..www.google.com.reader.view.1?$/)) return;

defineSettings();
function getSettings() {

function defineSettings() {
var settings = {

settings = {
// only required to be loaded on 404 url, i.e. http://www.google.com/reader/view/1
userId: '',

// only required to be loaded on 404 url, i.e. http://www.google.com/reader/view/1
userId: '',

// lowercase words to filter entries out by title
titleFilters: [],

// words to filter entries out by body (html included)
bodyFilters: [],

// your device screen's horizontal resolution
mobileViewPort: '800x480',

// filters to manipulate on entry content
// NB: set data.altered = true if you want these changes to be shared when you click "share"
entryHtmlAlterations: [],
entryDomAlterations: []

};
// lowercase words to filter entries out by title
titleFilters: [],

// words to filter entries out by body (html included)
bodyFilters: [],

// your device screen's horizontal resolution
mobileViewPort: '800x480',

// filters to manipulate on entry content
// NB: set data.altered = true if you want these changes to be shared when you click "share"
entryHtmlAlterations: [],
entryDomAlterations: []

};

var parts = settings.mobileViewPort.split('x');
settings.mobileViewPort = {
max: Math.max(parts[0], parts[1]),
min: Math.min(parts[0], parts[1])
};


return settings;
}
settings.css =
function getStyles(){ return (
"html, body {" +
" margin: 0;" +
" padding: 0;" +
Expand Down Expand Up @@ -365,7 +364,7 @@ settings.css =
" width: 2em; height: 100%; line-height: 2em; top: 0.1em;" +
"}" +
"" +
"";
"");}
/*
OVERVIEW
Expand Down Expand Up @@ -402,7 +401,7 @@ settings.css =
in the same order, so you can read code from top to bottom.
*/

function ui() {
function ui(settings, css) {

// static user id
var userId = settings.userId || window._USER_ID || (window.localStorage && localStorage.userId) || '-';
Expand Down Expand Up @@ -574,7 +573,7 @@ function ui() {
// add own css styles
function addStyles() {
document.body.previousElementSibling.appendChild(
DOM('style', undefined, [document.createTextNode(settings.css)])
DOM('style', undefined, [document.createTextNode(css)])
);
}

Expand Down Expand Up @@ -1849,15 +1848,15 @@ function lib() {

function onload() {
lib();
ui();
ui(getSettings(), getStyles());
}

if (typeof GM_xmlhttpRequest != "undefined" && !navigator.userAgent.match(/Chrome/)) {
// GreaseMonkey, fuck you very much! I don't need your overprotection.
var script = document.createElement('script');
script.innerHTML =
defineSettings.toString() + lib.toString() + ui.toString() +
'defineSettings(); lib(); ui();';
getSettings.toString() + getStyles.toString() + lib.toString() + ui.toString() +
'lib(); ui(getSettings(), getStyles());';
document.body.appendChild(script);
setTimeout(function(){
var style = document.createElement('style');
Expand Down
4 changes: 2 additions & 2 deletions release.bash
@@ -1,9 +1,9 @@
#!/bin/bash

echo 'settings.css =' > 27styles
echo 'function getStyles(){ return (' > 27styles
sed 's/^/"/;s/$/" +/;' src/styles.css >> 27styles
sed 's/^/"/;s/$/" +/;' src/styles.custom.css >> 27styles
echo '"";' >> 27styles
echo '"");}' >> 27styles

cat \
src/10meta.js \
Expand Down
9 changes: 4 additions & 5 deletions src/25settings.js
@@ -1,8 +1,6 @@
defineSettings();
function getSettings() {

function defineSettings() {

settings = {
var settings = {

// only required to be loaded on 404 url, i.e. http://www.google.com/reader/view/1
userId: '',
Expand All @@ -28,5 +26,6 @@ function defineSettings() {
max: Math.max(parts[0], parts[1]),
min: Math.min(parts[0], parts[1])
};


return settings;
}
4 changes: 2 additions & 2 deletions src/30ui.js
Expand Up @@ -34,7 +34,7 @@
in the same order, so you can read code from top to bottom.
*/

function ui() {
function ui(settings, css) {

// static user id
var userId = settings.userId || window._USER_ID || (window.localStorage && localStorage.userId) || '-';
Expand Down Expand Up @@ -206,7 +206,7 @@ function ui() {
// add own css styles
function addStyles() {
document.body.previousElementSibling.appendChild(
DOM('style', undefined, [document.createTextNode(settings.css)])
DOM('style', undefined, [document.createTextNode(css)])
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/50onload.js
@@ -1,15 +1,15 @@

function onload() {
lib();
ui();
ui(getSettings(), getStyles());
}

if (typeof GM_xmlhttpRequest != "undefined" && !navigator.userAgent.match(/Chrome/)) {
// GreaseMonkey, fuck you very much! I don't need your overprotection.
var script = document.createElement('script');
script.innerHTML =
defineSettings.toString() + lib.toString() + ui.toString() +
'defineSettings(); lib(); ui();';
getSettings.toString() + getStyles.toString() + lib.toString() + ui.toString() +
'lib(); ui(getSettings(), getStyles());';
document.body.appendChild(script);
setTimeout(function(){
var style = document.createElement('style');
Expand Down

0 comments on commit 7bf7845

Please sign in to comment.