-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CodeApe
committed
Jul 23, 2024
0 parents
commit df85183
Showing
9 changed files
with
855,430 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
.vscode | ||
.idea |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//go:build js && wasm | ||
|
||
package wasmecdict | ||
|
||
import ( | ||
"syscall/js" | ||
) | ||
|
||
const version = "0.0.1" | ||
|
||
func lookUp(_ js.Value, args []js.Value) any { | ||
if len(args) > 0 { | ||
text := args[0].String() | ||
res := LookUp(text) | ||
if res != nil { | ||
return js.ValueOf(res.toMap()) | ||
} | ||
} | ||
return js.Undefined() | ||
} | ||
|
||
func info(_ js.Value, _ []js.Value) any { | ||
return map[string]interface{}{ | ||
"version": version, | ||
"words": len(dictMapSingleton), | ||
"lemmas": len(lemmaMapSingleton), | ||
"author": "[email protected]", | ||
"email": "[email protected]", | ||
"DictionaryData": "https://github.com/skywind3000/ECDICT", | ||
"License": "MIT", | ||
} | ||
} | ||
|
||
func main() { | ||
js.Global().Set("lookUp", js.FuncOf(lookUp)) //export window.lookUp to lookUp English word | ||
js.Global().Set("ecDictionary", js.FuncOf(info)) // export ecDictionary show info | ||
done := make(chan struct{}, 0) | ||
<-done | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.