Skip to content

Instantly share code, notes, and snippets.

@karlosmid
Created February 4, 2021 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlosmid/ca75452ad69c758124e2c7b62af0517f to your computer and use it in GitHub Desktop.
Save karlosmid/ca75452ad69c758124e2c7b62af0517f to your computer and use it in GitHub Desktop.
<!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