Last active
December 21, 2015 08:58
-
-
Save aykutyaman/6281389 to your computer and use it in GitHub Desktop.
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
Template.workspaceBroadcast.workspace = function() { | |
return Workspaces.findOne(Session.get("selectedWorkspaceId")); | |
}; | |
Template.workspaceBroadcast.rendered = function() { | |
console.log('rendered'); | |
}; | |
Template.messages.messages = function(){ | |
return Messages.find({workspaceId: Session.get("selectedWorkspaceId")}, { sort: { submitted: -1 }}); | |
}; | |
Template.entryfield.events({ | |
"keydown #message": function(event, template) { | |
if(event.which === 13){ | |
var message = document.getElementById('message'); | |
if(message.value !== ''){ | |
var messageData = { | |
message: message.value, | |
workspaceId: Session.get("selectedWorkspaceId") | |
}; | |
Meteor.call("message", messageData, function(error, messageId) { | |
if (error) throwError(error.reason); | |
else message.value = ''; | |
}); | |
} | |
} | |
} | |
}); | |
Template.broadcastSidebar.events({ | |
"click #clear-messages": function(event, template) { | |
event.preventDefault(); | |
//Messages.remove({workspaceId: Session.get("selectedWorkspaceId")}); | |
Meteor.call("clearMessages", Session.get("selectedWorkspaceId"), function(error) { | |
if (error) throwError(error.reason); | |
}); | |
} | |
}); |
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
<template name="workspaceBroadcast"> | |
{{#with workspace}} | |
{{title}} | |
<video> | |
<source type="video/flash" src="{{_id}}"/> | |
</video> | |
{{> broadcastSidebar}} | |
{{/with}} | |
</template> | |
<template name="broadcastSidebar"> | |
{{> entryfield}} | |
{{> messages}} | |
</template> | |
<template name="entryfield"> | |
<input type="text" id="message" placeholder="Your Message" /> | |
</template> | |
<template name="messages"> | |
<p> | |
{{#each messages}} | |
{{> message}} | |
{{/each}} | |
</p> | |
</template> | |
<template name="message"> | |
<strong>{{author}}</strong> - {{message}} <br /> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment