Google Calendar Display Current Time Line

By yooskeh Last update Mar 15, 2008 — Installed 29,386 times.

Post doesn't exist

Archived Comments (locked)

in
Subscribe to Archived Comments 35 posts, 17 voices



thouis User

Excellent script. This is called the "Marcus Bains Line" in other calendars:
http://people.csail.mit.edu/rahimi/marcus-bains...

 
mod_wastrel User

Very nice script. I wonder now though, do you use Google Reader, too? Some of the feed items I receive run for several pages of mostly plain text, and it's not always immediately obvious where the line is now that I was at the end of before I hit page-down (or page-up)--it tends to vary a little from feed to feed (?). If you wanted to fool around with the concept, having some "thin red line" show up where the page bottom (or top) used to be before hitting page-down (or page-up) would be very useful (why, it might even save me several minutes every day! :D). Thanks. (If you have any hints on a how-to as opposed to writing something yourself, they'd be appreciated.)

 
yooskeh Script's Author

Hello, Deodrus.

I think that it only has to change updataTimeLine function into this code for that.

Here is the code:

  function updataTimeLine() {
    if (currentDayBox) {
      var now = new Date;
      var h = now.getHours();
      var m = now.getMinutes();
      var s = now.getSeconds();
      var jh = h + 13;
      if (jh > 23) {
        jh -= 24;
      }
      var dstyle = currentDayBox.style;
      var cstyle = currentTimeLine.style;
      var jstyle = japanTimeLine.style;
      cstyle.top = (h * 6 + m / 10 + s / 600) + "ex";
      cstyle.left = dstyle.left;
      cstyle.width = dstyle.width;
      jstyle.top = (jh * 6 + m / 10 + s / 600) + "ex";
      jstyle.width = dstyle.width;
      if (h + 13 < 24) {
        jstyle.left = dstyle.left;
      } else {
        var left = dstyle.left.match(/([\d.]+)/)[1] - 0;
        var width = dstyle.width.match(/([\d.]+)/)[1] - 0;
        jstyle.left = (left + width) + "%";
      }
    }
  }

 
deodrus Scriptwright

Hi Margin!

This works wonders for me! I modified it a bit to fit my situation! You see, my girlfriend lives in Japan, and we keep updated with GoogleCalendar.
So what I did was to create a Japan Timeline (in green) that is 13 hours ahead of my current timeline (and the version that I sent her has 13 hours subtracted from her time to display mine).
The only problem is that I cannot figure out how to SHIFT that green line to the NEXT day (or PREVIOUS day, in her case) if it goes past midnight.

=> I believe the decowner attribute handles that??
Please let me know how I can fix this.

Here is the code:

(I'm terribly sorry about the long comment!!!)
======================================
// ==/UserScript==

GM_addStyle(<>

/* You can freely change line style. */
#currentTimeLine {
background: red;
height: 3px;
border: 1px solid black;
opacity: 0.5;
margin: -2px 0 0 1px;
position: absolute;
z-index: 2;
}

#japanTimeLine {
background: green;
height: 3px;
border: 1px solid black;
opacity: 0.5;
margin: -2px 0 0 1px;
position: absolute;
z-index: 2;</>);

window.addEventListener("load", function() {
var currentTimeLine = document.createElement("div");
currentTimeLine.id = "currentTimeLine";
var currentDayBox;
var japanTimeLine = document.createElement("div");
japanTimeLine.id = "japanTimeLine";
var japanDayBox;

function entryTimeLine() {
var U = unsafeWindow.U;
if (U.type == 0 || U.type == 1 || (U.type == 4 && U.extent <= 7)) {
var decowner = document.getElementById("decowner");
if (decowner) {
currentDayBox = decowner.getElementsByTagName("div")[0];
document.getElementById("grid").appendChild(currentTimeLine);
japanDayBox = decowner.getElementsByTagName("div")[0];
document.getElementById("grid").appendChild(japanTimeLine);
updataTimeLine();
} else {
currentDayBox = false;
japanDayBox = false;
}
}
}

function updataTimeLine() {
if (currentDayBox) {
var now = new Date;
var h = now.getHours();
var m = now.getMinutes();
var s = now.getSeconds();
var jh = h + 13;
var jm = m;
var js = s;
if (jh > 23)
{
jh -= 24;
}
var style = currentTimeLine.style;
var japstyle = japanTimeLine.style;
style.top = (h * 6 + m / 10 + s / 600) + "ex";
style.left = currentDayBox.style.left;
style.width = currentDayBox.style.width;
japstyle.top = (jh * 6 + jm / 10 + js / 600) + "ex";
japstyle.left = currentDayBox.style.left;
japstyle.width = currentDayBox.style.width;

}
}
}

var refresh = unsafeWindow._RefreshCalendar;
var refreshFuncName = refresh.toString().match(/^function ([\w_\$]+)\(/)[1];
unsafeWindow[refreshFuncName] = function() {
refresh.apply(this, arguments);
entryTimeLine();
};

entryTimeLine();
setInterval(updataTimeLine, 30000);
}, false);

 
yooskeh Script's Author

Oops! I mistook style in below comment. Please forget that style :P

Correct style is this:

#currentTimeLine {
background: red;
height: 3px;
border: 1px solid black;
opacity: 0.5;
margin: -2px 0 0 1px;
position: absolute;
z-index: 2;
}

 
yooskeh Script's Author

samdana: Sorry I respond late. Please look at Joe.Lotz's comment.

Joe.Lotz: Thanks! It's nice style. New version can easily edit CSS style. If you want to set the line's center on the current time, try style below.

#currentTimeLine {
background: red;
height: 1px;
border-style: solid;
border-width: 2px 1px;
border-color: black;
-moz-border-top-colors: black red;
-moz-border-bottom-colors: black red;
opacity: 0.5;
margin-left: 1px;
position: absolute;
z-index: 2;
}

 
Joe.Lotz User

samdana: You need to have greasemonkey installed
https://addons.mozilla.org/en-US/firefox/addon/748

margin: Very useful script, thanks! I've been some slight CSS changes for my personal preference. Anyone else can do the same to fit their tastes.

timeLine.style.cssText =
"background:red;height:3px;margin-left:1px;"+
"opacity:0.5;position:absolute;z-index:2;"+
"border:solid 1px #000000";

 
samdana User

how do i install the script?

 
yooskeh Script's Author

Thanks Emma. New version is now available.

 
emme User

Your script is very useful thanks.
It would be nice if the line only crossed the current day 'though, but I could not find an easy way to do it.
Thanks again,

Emme

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel