This repository has been archived by the owner on Feb 15, 2019. It is now read-only.
Now even better #37
Closed
Closed
Now even better #37
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,141 @@ | |||
/* | |||
* timeago: a jQuery plugin, version: 0.9.2 (2010-09-14) | |||
* @requires jQuery v1.2.3 or later | |||
* | |||
* Timeago is a jQuery plugin that makes it easy to support automatically | |||
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). | |||
* | |||
* For usage and examples, visit: | |||
* http://timeago.yarp.com/ | |||
* | |||
* Licensed under the MIT: | |||
* http://www.opensource.org/licenses/mit-license.php | |||
* | |||
* Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org) | |||
*/ | |||
(function($) { | |||
$.timeago = function(timestamp) { | |||
if (timestamp instanceof Date) return inWords(timestamp); | |||
else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp)); | |||
else return inWords($.timeago.datetime(timestamp)); | |||
}; | |||
var $t = $.timeago; | |||
|
|||
$.extend($.timeago, { | |||
settings: { | |||
refreshMillis: 60000, | |||
allowFuture: false, | |||
strings: { | |||
prefixAgo: null, | |||
prefixFromNow: null, | |||
suffixAgo: "ago", | |||
suffixFromNow: "from now", | |||
seconds: "less than a minute", | |||
minute: "about a minute", | |||
minutes: "%d minutes", | |||
hour: "about an hour", | |||
hours: "about %d hours", | |||
day: "a day", | |||
days: "%d days", | |||
month: "about a month", | |||
months: "%d months", | |||
year: "about a year", | |||
years: "%d years", | |||
numbers: [] | |||
} | |||
}, | |||
inWords: function(distanceMillis) { | |||
var $l = this.settings.strings; | |||
var prefix = $l.prefixAgo; | |||
var suffix = $l.suffixAgo; | |||
if (this.settings.allowFuture) { | |||
if (distanceMillis < 0) { | |||
prefix = $l.prefixFromNow; | |||
suffix = $l.suffixFromNow; | |||
} | |||
distanceMillis = Math.abs(distanceMillis); | |||
} | |||
|
|||
var seconds = distanceMillis / 1000; | |||
var minutes = seconds / 60; | |||
var hours = minutes / 60; | |||
var days = hours / 24; | |||
var years = days / 365; | |||
|
|||
function substitute(stringOrFunction, number) { | |||
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction; | |||
var value = ($l.numbers && $l.numbers[number]) || number; | |||
return string.replace(/%d/i, value); | |||
} | |||
|
|||
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || | |||
seconds < 90 && substitute($l.minute, 1) || | |||
minutes < 45 && substitute($l.minutes, Math.round(minutes)) || | |||
minutes < 90 && substitute($l.hour, 1) || | |||
hours < 24 && substitute($l.hours, Math.round(hours)) || | |||
hours < 48 && substitute($l.day, 1) || | |||
days < 30 && substitute($l.days, Math.floor(days)) || | |||
days < 60 && substitute($l.month, 1) || | |||
days < 365 && substitute($l.months, Math.floor(days / 30)) || | |||
years < 2 && substitute($l.year, 1) || | |||
substitute($l.years, Math.floor(years)); | |||
|
|||
return $.trim([prefix, words, suffix].join(" ")); | |||
}, | |||
parse: function(iso8601) { | |||
var s = $.trim(iso8601); | |||
s = s.replace(/\.\d\d\d+/,""); // remove milliseconds | |||
s = s.replace(/-/,"/").replace(/-/,"/"); | |||
s = s.replace(/T/," ").replace(/Z/," UTC"); | |||
s = s.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400 | |||
return new Date(s); | |||
}, | |||
datetime: function(elem) { | |||
// jQuery's `is()` doesn't play well with HTML5 in IE | |||
var isTime = $(elem).get(0).tagName.toLowerCase() == "time"; // $(elem).is("time"); | |||
var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title"); | |||
return $t.parse(iso8601); | |||
} | |||
}); | |||
|
|||
$.fn.timeago = function() { | |||
var self = this; | |||
self.each(refresh); | |||
|
|||
var $s = $t.settings; | |||
if ($s.refreshMillis > 0) { | |||
setInterval(function() { self.each(refresh); }, $s.refreshMillis); | |||
} | |||
return self; | |||
}; | |||
|
|||
function refresh() { | |||
var data = prepareData(this); | |||
if (!isNaN(data.datetime)) { | |||
$(this).text(inWords(data.datetime)); | |||
} | |||
return this; | |||
} | |||
|
|||
function prepareData(element) { | |||
element = $(element); | |||
if (!element.data("timeago")) { | |||
element.data("timeago", { datetime: $t.datetime(element) }); | |||
var text = $.trim(element.text()); | |||
if (text.length > 0) element.attr("title", text); | |||
} | |||
return element.data("timeago"); | |||
} | |||
|
|||
function inWords(date) { | |||
return $t.inWords(distance(date)); | |||
} | |||
|
|||
function distance(date) { | |||
return (new Date().getTime() - date.getTime()); | |||
} | |||
|
|||
// fix for IE6 suckage | |||
document.createElement("abbr"); | |||
document.createElement("time"); | |||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -443,30 +443,36 @@ require.def("stream/streamplugins", | ||
settings.get('notifications', 'enableWebkitNotifications') && | settings.get('notifications', 'enableWebkitNotifications') && | ||
window.webkitNotifications && | window.webkitNotifications && | ||
window.webkitNotifications.checkPermission() == 0) { | window.webkitNotifications.checkPermission() == 0) { | ||
if(tweet.mentioned && !settings.get('notifications', 'mentions')) { | if(tweet.mentioned && !settings.get('notifications', 'mentions')) { | ||
return | return | ||
} | } | ||
if(tweet.direct_message && !settings.get('notifications', 'direct')) { | if(tweet.direct_message && !settings.get('notifications', 'direct')) { | ||
return | return | ||
} | } | ||
if(!tweet.mentioned && !tweet.direct_message && !settings.get('notifications', 'tweets')) { | if(!tweet.mentioned && !tweet.direct_message && !settings.get('notifications', 'tweets')) { | ||
return | return | ||
} | } | ||
try { | try { | ||
var notification = | var tweetHash = { | ||
window.webkitNotifications.createNotification(tweet.data.user.profile_image_url, | 'name':tweet.data.user.screen_name, | ||
tweet.data.user.name, | 'screen_name':tweet.data.user.screen_name, | ||
tweet.data.text); | 'avatar':tweet.data.user.profile_image_url, | ||
notification.show(); | 'text':tweet.textHTML, | ||
notification.onclose = function() { | 'created_at':tweet.data.created_at, | ||
--plugin.current; | 'source':tweet.data.source, | ||
} //onclose | }; | ||
++plugin.current; | if(tweet.data.retweeted_status) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please always use brackets |
|||
//hide after 5 seconds | tweetHash.RTby = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. above you use _ to separate, here MIXEDCase |
|||
setTimeout(function() { | 'screen_name': tweet.data.retweeted_status.user.screen_name, | ||
notification.cancel(); | 'name': tweet.data.retweeted_status.user.name | ||
}, 5000); | }; | ||
} catch(e) { | var notification = window.webkitNotifications.createHTMLNotification("notification\notification.html#"+JSON.stringify(tweetHash)); | ||
notification.show(); | |||
notification.onclose = function() { | |||
--plugin.current; | |||
} //onclose | |||
++plugin.current; | |||
} catch(e) { | |||
} | } | ||
} | } | ||
this(); | this(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,96 @@ | |||
<html> | |||
<head> | |||
<script type="text/javascript" src="http://www.google.com/jsapi"> | |||
</script> | |||
<script type="text/javascript"> | |||
google.load("jquery", "1.4.2"); | |||
</script> | |||
<script type="text/javascript" src="ext/jquery.timeago.js"></script> | |||
<script type="text/javascript" src="notification.js"></script> | |||
<style> | |||
body | |||
{ | |||
font: 84% Arial, sans-serif | |||
} | |||
#top | |||
{ | |||
width: 270px; | |||
} | |||
#avatar | |||
{ | |||
margin: 0px 5px 5px 0px; | |||
padding-bottom: 5px; | |||
float: left; | |||
height: 48px; | |||
width: 48px; | |||
} | |||
#img{ | |||
width: 48px; | |||
} | |||
a | |||
{ | |||
color: #2276BB; | |||
} | |||
a:link {text-decoration:none} | |||
a:visited {text-decoration:none} | |||
a:hover {text-decoration:underline} | |||
a:active {text-decoration:underline} | |||
a#user | |||
{ | |||
font-weight: bold; | |||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are not completly consistent with the CSS indenting. Please also put the opening { on the opening line |
|||
} | |||
a#user:link {color:#333} | |||
a#user:visited {color:#333} | |||
a#user:hover {color:#2276BB} | |||
a#user:active {color:#2276BB} | |||
span#rt | |||
{ | |||
color:#333; | |||
font-size: 11px; | |||
display: none; | |||
} | |||
#main | |||
{ | |||
width: 217px; | |||
float: right; | |||
padding-bottom: 5px; | |||
} | |||
#bottom | |||
{ | |||
color: #999 !important; | |||
font-size: 11px; | |||
padding-bottom: 5px; | |||
} | |||
#bottom a | |||
{ | |||
color: #999 !important; | |||
} | |||
.btext | |||
{ | |||
white-space:nowrap; | |||
} | |||
#tlogo | |||
{ | |||
float: right; | |||
padding-bottom: 5px; | |||
margin-right: 5px; | |||
} | |||
</style> | |||
</head> | |||
<body> | |||
<div id="container"> | |||
<div id="top"> | |||
<div id="img"> | |||
<a href="#"><img width="48" height="48" id="avatar"/></a> | |||
</div> | |||
<div id="main"> | |||
<a id="user" href="#"></a> <span id="rt">(Retweeted by <a id="rtby" href="#"></a>)</span> <span id="msg"></span><br/> | |||
</div> | |||
</div> | |||
<div id="bottom"> | |||
<span class="btext"><a id="timestamp"></a> <span id="via">via web</span></span> | |||
<a href="http://twitter.com/"><img id="tlogo" src="http://a0.twimg.com/a/1285890902/images/twitter_t_logo_outline.png" height="20" width="16"/></a> | |||
</div> | |||
</div> | |||
</body> | |||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the formatting is a little off. Two space indent and no quoting of keys please. 1 space after :.