Skip to content

Instantly share code, notes, and snippets.

@thomasofdenmark
Created August 26, 2015 06:51
Show Gist options
  • Save thomasofdenmark/74080416bd9f5eb7fdd4 to your computer and use it in GitHub Desktop.
Save thomasofdenmark/74080416bd9f5eb7fdd4 to your computer and use it in GitHub Desktop.
<firebase-collection id="firebaseCollection"
data="{{videos}}"
location="https://deejay.firebaseio.com/playqueues/hansenbar"
order-by-child="score"
on-firebase-value="firebaseValue"
log="true">
</firebase-collection>
<template is="dom-repeat" items="[[videos]]">
<song-card playing="[[item.playing]]">
<span>[[item.score]]</span>
<span>[[item.title]]</span>
<iron-icon icon="thumb-down" on-tap="voteDown"></iron-icon>
<span>[[item.votedown]]</span>
<iron-icon icon="thumb-up" on-tap="voteUp"></iron-icon>
<span>[[item.voteup]]</span>
</song-card>
</template>
voteUp: function(e){
ref = this.$.firebaseCollection.query.ref();
var target = ref.child(e.model.item.__firebaseKey__);
target.update({"voteup": (e.model.item.voteup || 0) + 1, "score": (e.model.item.score || 0) + 1});
},
voteDown: function(e){
ref = this.$.firebaseCollection.query.ref();
var target = ref.child(e.model.item.__firebaseKey__);
target.update({"votedown": (e.model.item.votedown || 0) + 1, "score": (e.model.item.score || 0) - 1});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment