Last active
December 25, 2016 06:50
-
-
Save owulveryck/3256d582ad2241eeeaf118d5bf9c1cd0 to your computer and use it in GitHub Desktop.
GopherJS
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
package main | |
//go:generate gopherjs build main.go -o js/app.js -m | |
// +build ignore | |
import ( | |
"github.com/gopherjs/gopherjs/js" | |
"log" | |
) | |
// Router is the main reference to the director.js' Router object | |
type Router struct { | |
*js.Object | |
} | |
// NewRouter is the contructor, it locates the Router object in the window global object | |
// and returns its go representation | |
func NewRouter() *Router { | |
return &Router{js.Global.Get("Router").New()} | |
} | |
// On is the binding for the javascript router's on method | |
// it is used for ad-hoc routing | |
func (r *Router) On(path string, handler func()) { | |
r.Call("on", path, handler) | |
} | |
// Init is the binding for the javascript router's init function | |
// path value will be used if '/#/' is not found in the URL. | |
// (e.g., init('/') will resolve to '/#/', init('foo') will resolve to '/#foo'). | |
func (r *Router) Init(path string) { | |
r.Call("init", path) | |
} | |
func main() { | |
router := NewRouter() | |
router.On("/about", notImplementedYet) | |
router.On("/contact", notImplementedYet) | |
router.On("/", notImplementedYet) | |
router.Init("/") | |
} | |
var notImplementedYet = func() { | |
log.Println("Hello") | |
} |
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> | |
<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"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<title>Starter Template for Bootstrap</title> | |
<!-- Bootstrap core CSS --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4V | |
a+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
<!-- Custom styles for this template --> | |
<style> | |
body { | |
padding-top: 50px; | |
} | |
.starter-template { | |
padding: 40px 15px; | |
text-align: center; | |
} | |
</style> | |
</head> | |
<body> | |
<nav class="navbar navbar-inverse navbar-fixed-top"> | |
<div class="container"> | |
<div class="navbar-header"> | |
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
<a class="navbar-brand" href="#">Project name</a> | |
</div> | |
<div id="navbar" class="collapse navbar-collapse"> | |
<ul class="nav navbar-nav"> | |
<li class="active"><a href="#">Home</a></li> | |
<li><a href="#about">About</a></li> | |
<li><a href="#contact">Contact</a></li> | |
</ul> | |
</div><!--/.nav-collapse --> | |
</div> | |
</nav> | |
<div class="container"> | |
<div class="starter-template"> | |
<h1>Bootstrap starter template</h1> | |
<p id="main" class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p> | |
</div> | |
</div><!-- /.container --> | |
<!-- Bootstrap core JavaScript | |
================================================== --> | |
<!-- Placed at the end of the document so the pages load faster --> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> | |
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script> | |
<!-- Latest compiled and minified JavaScript --> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7T | |
xa" crossorigin="anonymous"></script> | |
<script src="js/director.min.js"></script> | |
<script src="js/app.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment