Skip to content

Instantly share code, notes, and snippets.

@harfangk
Created November 26, 2016 12:11
Show Gist options
  • Save harfangk/51e750f737b0d7e9c8cacab9d9883aef to your computer and use it in GitHub Desktop.
Save harfangk/51e750f737b0d7e9c8cacab9d9883aef to your computer and use it in GitHub Desktop.
web/static/js/video.js
=========================================================================================================
/***
* Excerpted from "Programming Phoenix",
* published by The Pragmatic Bookshelf.
* Copyrights apply to this code. It may not be used to create training material,
* courses, books, articles, and the like. Contact us if you are in doubt.
* We make no guarantees that this code is fit for any purpose.
* Visit http://www.pragmaticprogrammer.com/titles/phoenix for more book information.
***/
let Video = {
init(socket, element){ if(!element){ return }
let playerId = element.getAttribute("data-player-id")
let videoId = element.getAttribute("data-id")
socket.connect()
Player.init(element.id, playerId, () => {
this.onReady(videoId, socket)
})
}
}
export default Video
web/static/js/app.js
=========================================================================================================
// Brunch automatically concatenates all files in your
// watched paths. Those paths can be configured at
// config.paths.watched in "brunch-config.js".
//
// However, those files will only be executed if
// explicitly imported. The only exception are files
// in vendor, which are never wrapped in imports and
// therefore are always executed.
// Import dependencies
//
// If you no longer want to use a dependency, remember
// to also remove its path from "config.paths.watched".
import "phoenix_html"
// Import local files
//
// Local files can be imported directly using relative
// paths "./socket" or full ones "web/static/js/socket".
import Video from "./video"
Video.init(socket, document.getElementById("video"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment