Commit 827dda96 authored by Siong-Ui Te's avatar Siong-Ui Te

move independent xslt code to common library

parent 36123b26
......@@ -104,6 +104,7 @@ lib_pali:
go get -u github.com/siongui/gopalilib/libfrontend
go get -u github.com/siongui/gopalilib/libfrontend/everyword
go get -u github.com/siongui/gopalilib/libfrontend/treeview
go get -u github.com/siongui/gopalilib/libfrontend/xslt
lib_gtmpl:
@echo "\033[92mInstalling Go html/template with gettext support ...\033[0m"
......
......@@ -9,6 +9,7 @@ import (
"github.com/siongui/gopalilib/libfrontend"
"github.com/siongui/gopalilib/libfrontend/everyword"
"github.com/siongui/gopalilib/libfrontend/treeview"
"github.com/siongui/gopalilib/libfrontend/xslt"
)
func getFinalShowLocale() string {
......@@ -35,7 +36,7 @@ func xmlAction(t lib.Tree) {
myXMLHTTPRequest.Send()
xmlDoc := myXMLHTTPRequest.ResponseXML()
fragment := GetXSLTProcessor().TransformToFragment(xmlDoc, Document)
fragment := xslt.GetXSLTProcessor().TransformToFragment(xmlDoc, Document)
mainview.QuerySelector("div.content").RemoveAllChildNodes()
mainview.QuerySelector("div.content").AppendChild(fragment)
......@@ -63,7 +64,7 @@ func main() {
json.Unmarshal(b, &tree)
treeview.NewTreeview("treeview", tree, xmlAction)
SetupXSLTProcessor(libfrontend.GetXslUrl())
xslt.SetupXSLTProcessor(libfrontend.GetXslUrl())
SetupModal()
SetupMobileTreeviewToggle()
SetupModalInput("#modal-input")
......
package main
import (
. "github.com/siongui/godom"
)
var xsltProcessor *XSLTProcessor
func GetXSLTProcessor() *XSLTProcessor {
return xsltProcessor
}
func SetupXSLTProcessor(xslUrl string) {
xsltProcessor = NewXSLTProcessor()
// Load the xsl file using synchronous (third param is set to false) XMLHttpRequest
myXMLHTTPRequest := NewXMLHttpRequest()
myXMLHTTPRequest.Open("GET", xslUrl, false)
myXMLHTTPRequest.Send()
xslStylesheet := myXMLHTTPRequest.ResponseXML()
// Finally import the .xsl
xsltProcessor.ImportStylesheet(xslStylesheet)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment