Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 8300afd606
Fetching contributors…

Cannot retrieve contributors at this time

288 lines (280 sloc) 9.441 kb
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="local.js"></script>
<script src="api_key.js"></script>
<script id="config" type="text/javascript" charset="utf-8">
var $parameters = {
urlname: "etsy-craft-party",
width: 300,
_height: 500,
_name: "Everywhere Comments",
_description: "Shows the 3 most recent comments for the specified container."
};
var $queries = {
containers: function() {
return mup_widget.api_call("/ew/containers", {urlname: $parameters.urlname, fields: "meetup_count,past_meetup_count,member_count,geo_ip"});
},
comments: function() {
return mup_widget.api_call("/ew/comments", {urlname: $parameters.urlname, page: '3'});
},
events: function() {
return mup_widget.api_call("/ew/events", {status: "upcoming", urlname: $parameters.urlname});
}
};
</script>
<link rel="stylesheet" type="text/css" href="http://static2.meetupstatic.com/style/widget.css">
<script type="text/javascript" charset="utf-8">
mup_widget.with_jquery(function($, ctx) {
var resultCount = 0,
months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
numberFormat = function(nStr){
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1))
x1 = x1.replace(rgx, '$1' + ',' + '$2');
return x1 + x2;
},
getFormattedTime = function( millis ) {
var time = new Date( millis ),
hours = time.getHours(),
min = time.getMinutes(),
ampm = (hours > 11) ? 'PM' : 'AM';
min = (min < 10) ? ('0' + min) : min;
hours = (hours == 0) ? 1 : hours;
hours = (hours > 12) ? hours-12 : hours;
return hours + ':' + min + ' ' + ampm;
},
addLeadingZero = function( num ) {
return (num < 10) ? ('0' + num) : num;
},
getTwoDigitYear = function( yr ) {
return yr.substring(2,4);
},
getFormattedDate = function( millis ) {
var date = new Date( millis );
return addLeadingZero( date.getDate() ) + ' ' + months[date.getMonth()] + ' ' + getTwoDigitYear( date.getFullYear().toString() );
},
getTimeAgo = function( millis ) {
var now = new Date();
var post = new Date( millis );
var diff = now.getTime() - post.getTime();
var oneHour = 3600000;
var daysAgo = Math.floor( diff / oneHour / 24 );
var hoursAgo = Math.floor( diff / oneHour );
var output = '';
if ( daysAgo >= 1 ) {
return getFormattedTime( millis ) + ' ' + getFormattedDate( millis );
} else {
// Hours ago
if ( hoursAgo < 1 ) {
return 'just a moment ago';
} else if ( hoursAgo == 1) {
return 'about ' + hoursAgo + ' hour ago';
} else {
return 'about ' + hoursAgo + ' hours ago';
}
}
},
addLink = function( content, link ) {
return '<a href="' + link + '">' + content + '</a>';
};
String.prototype.trunc =
function(n,useWordBoundary){
var tooLong = this.length>n,
s_ = tooLong ? this.substr(0,n-1) : this;
s_ = useWordBoundary && tooLong ? s_.substr(0,s_.lastIndexOf(' ')) : s_;
return tooLong ? s_ +'...' : s_;
};
$.getJSON($queries.containers(), function(data) {
if (data.results.length == 0) {
$('.mup-widget-5', ctx).append(
'<div class="mup-widget error" style="width:' + $parameters.width + '">\
<div class="errorMsg">Oops. No results for "' + $parameters.urlname + '"</div>\
</div>');
}
else {
var container = data.results[0];
var total_meetup_count = container.meetup_count + container.past_meetup_count;
$('.mup-widget-5', ctx).append(
'<div class="mup-widget" style="width:' + $parameters.width + '">\
<div class="mup-hd">\
<h3>' + addLink( numberFormat(total_meetup_count) + ' ' + container.name + ' Meetups', container.meetup_url )+ '</h3>\
<h4>' + addLink( numberFormat(container.member_count) + ' people', container.meetup_url ) + '</h4>\
</div>\
<div class="mup-bd"><ul class="mup-list"></ul></div>\
</div>'
);
$.getJSON($queries.comments(), function(data) {
if (data.status && data.status.match(/^200/) == null) {
alert(data.status + ": " + data.details);
} else {
resultCount = parseInt(data.meta.total_count);
var cache = {};
$.each(data.results, function(i, com) {
if ( i < resultCount ) {
// My code here.
cache[i] = {comment: com.comment, time: com.time, member: com.member.name};
$('.mup-list', ctx).append(
'<li class="mup-item">\
<div class="mup-what">\
<span class="mup-comment">' + com.comment.trunc(115,true) + '<a name="expander" href="#">more</a></span>\
</div>\
<div class="mup-when">\
<span class="mup-time">via ' + com.member.name + ' ' + getTimeAgo( com.time ) + '</span>\
<span class="mup-loc mup-loc' + i + '" rel="' + com.event_id + '"></span>\
</div>\
</li>' );
}
});
// Expand/Collapse Long Comment
$('a[name=expander]', ctx).click(function(e) {
e.preventDefault();
var location = '';
$(this).parent().parent().parent().parent().html(
'<li class="mup-item">\
<div class="mup-what">\
<span class="mup-comment">'+ cache[0].comment + '</span>\
</div>\
<div class="mup-when">\
<span class="mup-time">via ' + cache[0].member + ' ' + getTimeAgo( cache[0].time ) + '</span>\
<span class="mup-loc rel="' + location + '"></span>\
</div>\
</li>');
});
$('.mup-widget', ctx).append('<div class="mup-ft"><div class="mup-logo"><img src="http://img1.meetupstatic.com/84869143793177372874/img/birddog/everywhere_widget.png"></div><div class="mup-getwdgt">' + addLink( 'ADD THIS TO YOUR SITE', 'http://www.meetup.com/meeup_api/foundry/' ) + '</div>');
$.getJSON($queries.events(), function(data) {
$.each(data.results, function(i, ev) {
for (var j = 0; j < 3; j++) {
var sel = '.mup-loc' + j;
ev.id == $(sel).attr('rel') ? $(sel).html( '&middot; ' + ev.city + ', ' + (ev.state == null ? ev.country.toUpperCase() : ev.state.toUpperCase()) ) : '';
}
});
});
}
});
}
});
});
</script>
<style type="text/css" media="screen">
.mup-widget-5 {
font-family: "lucida grande", lucida, tahoma, helvetica, arial, sans-serif !important;
font-size: 12px;
}
.mup-widget-5 .mup-widget,
.mup-widget-5 .mup-widget .mup-hd a,
.mup-widget-5 .mup-widget h3,
.mup-widget-5 .mup-widget h4 {
background: #1A1A1A;
}
.mup-widget-5 .mup-widget {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.mup-widget-5 .mup-widget .mup-hd {
padding: 10px 8px;
overflow: hidden;
}
.mup-widget-5 .mup-widget h3 {
font-size: 18px;
font-weight: bold;
}
.mup-widget-5 .mup-widget h3 a {
color: #AAA;
}
.mup-widget-5 .mup-widget h4 {
font-size: 13px;
font-weight: normal;
color: #F2F2F2;
}
.mup-widget-5 .mup-widget .mup-bd,
.mup-widget-5 .mup-widget .mup-timeline,
.mup-widget-5 .mup-widget .mup-bd p {
color: #000;
}
.mup-widget-5 .mup-widget .mup-bd {
padding: 0 8px;
}
.mup-widget-5 .mup-widget a,
.mup-widget-5 .mup-widget a:active,
.mup-widget-5 .mup-widget a:visited,
.mup-widget-5 .mup-widget a:hover {
color: #f2f2f2;
text-decoration: none;
}
.mup-widget-5 .mup-widget .mup-list {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
padding:0;
}
.mup-widget-5 .mup-widget .mup-list .mup-item {
position: relative;
padding: 12px 8px;
border-top-color: #1A1A1A;
border-top-style: solid;
border-top-width: 1px;
background: #333;
overflow: hidden;
}
.mup-widget-5 .mup-widget .mup-list .mup-item:first-child {
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.mup-widget-5 .mup-widget .mup-list .mup-item:last-child {
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
.mup-widget-5 .mup-widget .mup-what {
color: #f2f2f2;
margin-bottom: 3px;
}
.mup-widget-5 .mup-widget .mup-time {
font-size: 9px;
line-height: 1.2em;
}
.mup-widget-5 .mup-widget .mup-loc {
font-size: 9px;
line-height: 1.2em;
}
.mup-widget-5 .mup-widget .mup-comment {
word-wrap: break-word;
line-height: 1.2em;
}
.mup-widget-5 .mup-widget .mup-author {
line-height: 1.2em;
}
.mup-widget-5 .mup-widget .mup-ft .mup-getwdgt {
padding: 3px 8px;
font-size: 8px;
text-align: center;
background: #0A0A0A;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
.mup-widget-5 .mup-widget .mup-ft .mup-logo {
padding: 6px 8px;
}
</style>
</head>
<body>
<div class="mup-widget-5"></div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.