Skip to content

Commit

Permalink
Class'ify Fluid Twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbriones committed Mar 4, 2008
1 parent 7af0d9d commit 6303adb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -0,0 +1,3 @@
0.1.1
======
- Class'ify FluidTwitter
6 changes: 3 additions & 3 deletions README
Expand Up @@ -10,7 +10,7 @@ Installation
(Assuming you've already downloaded Fluid from Fluidapp.com)

1. Create a new Fluid SSB
-- URL: http://twitter.com/home (you could also use http://twitter.com/username, but home will redirect you to the login as neccesary)
-- URL: http://twitter.com/home (you could also use http://twitter.com/username, but home will redirect you to the login as necessary)
2. Run the Fluid SSB you just created
3. In the menu, navigate to Userscripts -> Open Userscripts Folder
4. Paste fluid_twitter.user.js into the SSB's Userscript folder
Expand All @@ -20,10 +20,10 @@ Installation

You Win!

Cavaets
Caveats
===============
* As of FluidInstance 0.8.2, SSB's will not persist the enablement of your Userscripts. Translation: you will have to enable Fluid Twitter every time you open your SSB

TODO
===============
* Have Fluid Twitter to a JSON request to see if your friends timeline has been updated before reloading the window.
* Have Fluid Twitter to a JSON request to see if your friends timeline has been updated before reloading the window. This will require a way to persist username (and possibly password).
52 changes: 34 additions & 18 deletions fluid_twitter.user.js
Expand Up @@ -8,25 +8,41 @@
// @homepage http://brionesandco.com/ryabriones
// ==/UserScript==

function refreshTwitter() {
if($$('.wrapper').first().cumulativeScrollOffset()[1] > 90) return setTimeout(refreshTwitter, 30000);
if($F('status') != '') return setTimeout(refreshTwitter, 30000);
var FluidTwitter = Class.create({
initialize: function() {
this.trimUI();

setTimeout(this.refreshTwitter.bind(this), 30000);
},

window.location.reload();
}
trimUI: function() {
// hide some unneccessary parts of the UI
$('side', 'footer', 'navigation').invoke('hide');
$$('.badge').first().hide();

// alter divs to stretch with the viewport
$('container', 'content').invoke('setStyle', {width: '100%'});
$('status').setStyle({width: '90%'});

(function() {
$('side').hide();
$('footer').hide();
$('navigation').hide();

$('container').setStyle({width: '100%'});
$('content').setStyle({width: '100%'});
$('header').down('img').setStyle({paddingLeft: '10px'});

$('status').setStyle({width: '90%'});
$$('.bar').first().down('h3').down('label').setStyle({padding: 0});
$$('.badge').first().hide();
// alter "What are you doing?" h3 to allow thin viewport
$$('.bar').first().down('h3').down('label').setStyle({padding: 0});

$('header').down('img').setStyle({paddingLeft: '10px'});
},

setTimeout(refreshTwitter, 30000);
refreshTwitter: function() {
// don't refresh if i'm scrolling
if($$('.wrapper').first().cumulativeScrollOffset()[1] > 90)
return setTimeout(this.refreshTwitter.bind(this), 30000);

// don't refresh if i'm typing either
if($F('status') != '')
return setTimeout(this.refreshTwitter.bind(this), 30000);

window.location.reload();
}
});

(function() {
document.fluid_twitter = new FluidTwitter();
})();

0 comments on commit 6303adb

Please sign in to comment.