Created
February 4, 2021 12:42
-
-
Save karlosmid/ca75452ad69c758124e2c7b62af0517f 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
<!DOCTYPE html> | |
<!-- | |
! Excerpted from "Programming Elm", | |
! 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/jfelm for more book information. | |
--> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="x-ua-compatible" content="ie=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Picshare</title> | |
<link href="https://programming-elm.com/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"> | |
<link rel="stylesheet" href="main.css"> | |
</head> | |
<body> | |
<div id="main" class="main"></div> | |
<script src="picshare.js"></script> | |
<script> | |
(function() { | |
var app = Elm.Picshare.init({ | |
node: document.getElementById('main') | |
}); | |
// in the scope of init function --> | |
app.ports.listen.subscribe(listen); | |
function listen(url) { | |
var socket = new WebSocket(url); | |
socket.onmessage = function(event) { app.ports.receive.send(event.data); | |
}; | |
} | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment