Skip to content

Instantly share code, notes, and snippets.

Template.movie.events({
'click .seen': function (e, t) {
// User has set status to "seen", but not exited poster
Session.set('seen-movie', true);
},
'click .not-seen': function (e, t) {
// User has set status to "not seen", but not exited poster
Session.set('seen-movie', false);
}
'mouseout .poster': function (e, t) {
if (Meteor.isClient) {
function updateHTML(elmId, value) {
document.getElementById(elmId).innerHTML = value;
}
// This function is called when an error is thrown by the player
function onPlayerError(errorCode) {
alert("An error occured of type:" + errorCode);
}
@BenjaminRH
BenjaminRH / gist:5659769
Created May 28, 2013 00:30
Demonstrating displaying different CSS for anonymous/logged-in users in Meteor
<template name="css">
{{#if currentUser}}
<style type="text/css">
/* I'm for logged-in users */
</style>
{{else}}
<style type="text/css">
/* I'm for anonymous users */
</style>
{{/if}}
var defaultLocations = {
widgetA: 'location-21',
widgetB: 'location-4',
// ...
}
Template.List.widgets = function () {
var userLocations = Meter.user().profile.widgetLocations; // { widgetB: 'location-5' }
var widgetLocations = _.extend(defaultLocations, userLocations); // Override the defaults where the user has changed them
var something = [];
Template.myTemplate.foobar.events({
'click #whatever': function (e, t) {
this.toggle = true;
},
'mouseout #whatever': function (e, t) {
if (this.toggle === true) {
// The user toggled this
// Do some toggling stuff here.
}
}
// Server
Meteor.publish('views', function () {
return Views.find({ userId: this.userId });
});
Meteor.publish('movies', function () {
return Movies.find();
});
// Client
// Attempt to log in as a new user.
Accounts.createUser = function (options, callback) {
options = _.clone(options); // we'll be modifying options
if (!options.password)
throw new Error("Must set options.password");
var verifier = Meteor._srp.generateVerifier(options.password);
// strip old password, replacing with the verifier object
delete options.password;
options.srp = verifier;
Template.rightSidebar.events({
'change #search-input, paste #search-input, keyup #search-input': function (event, template) {
var q = template.find('#search-input').value;
var url ="http://gdata.youtube.com/feeds/api/videos?q="+q+"&start-index=6&max-results=5&v=2&alt=json";
Meteor.http.get(url, function (error, result) {
if (result.statusCode === 200) {
var youtube = result.data.feed.entry;
var vidId = [];
for (var i=0; i < youtube.length; i++) {
<template name="myTemplate">
{{#with profile}}
{{foobar}}
{{/with}}
</template>
Template.timelinePublic.helpers({
timelineItems: function() {
return timelineItems.find({ timeline: Session.get("currentTimeline") });
}
});