View sample7.go
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 | |
import ( | |
"bytes" | |
"encoding/json" | |
"syscall/js" | |
) | |
func editionMode(this js.Value, args []js.Value) interface{} { | |
if len(args) != 1 { |
View index.html
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
<div id="main" class="center"> | |
<h1>Webassembly tutorial<h1> | |
<h2 id="description">JSON Beautifier Online service</h2> | |
<div> | |
<label for="input">Raw JSON</label> | |
<textarea rows="10" cols="100" id="input" name="input" onfocus="editionMode(this)" onblur="prettify(this)"></textarea> | |
</div> | |
<div> | |
<label for="output">Pretty JSON</label> | |
<textarea rows="10" cols="100" id="output" name="output" readonly="true"></textarea> |
View sample6.go
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 | |
import ( | |
"strings" | |
"syscall/js" | |
) | |
func main() { | |
document := js.Global().Get("document") | |
input := document.Call("getElementById", "description"). |
View index.html
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
<div id="main" class="center"> | |
<h1>Webassembly tutorial<h1> | |
<h2 id="description">Sample 6 | Reading the HTML content from Go</h2> | |
<h2 id="descriptionUppercase"></h2> | |
</div> |
View sample5.go
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 | |
import ( | |
"syscall/js" | |
"time" | |
) | |
func main() { | |
document := js.Global().Get("document") | |
message := document.Call("getElementById", "description") |
View smaple4.go
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 | |
import ( | |
"syscall/js" | |
"time" | |
) | |
func addGreenClass(classes js.Value) { | |
if classes.Call("contains", "pink").Bool() { | |
classes.Call("remove", "pink") |
View index.html
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
<div id="main" class="center"> | |
<h1>Webassembly tutorial<h1> | |
<h2 id="description">Sample 4 | Modifying the classes of an HTML element</h2> | |
<h3 id="simpleText" class="green">Hello my friend!</h3> | |
</div> |
View sample3.go
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 | |
import ( | |
"syscall/js" | |
) | |
func main() { | |
document := js.Global().Get("document") | |
h2 := document.Call("createElement", "h2") |
View index.html
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
<div id="main" class="center"> | |
<h1>Webassembly tutorial<h1> | |
</div> |
View sample2.go
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 | |
import ( | |
"fmt" | |
"syscall/js" | |
"time" | |
) | |
func main() { | |
currentTime := time.Now().Format("2006-01-02 15:04:05") |
NewerOlder