Commit f44fc4ba authored by Siong-Ui Te's avatar Siong-Ui Te

add setting for tipitaka site

parent 66c889a8
......@@ -13,44 +13,16 @@ addons:
- make
- git
- gettext
# https://docs.travis-ci.com/user/build-matrix/
jobs:
include:
# for dictionary.online-dhamma.net
- env: TARGET_WEBSITE=dhamma
install:
- cd dictionary/
- make install
script:
- make make-dhamma
after_success:
- make custom_dhamma_deploy
# for dictionary.sutta.org
- env: TARGET_WEBSITE=sutta
install:
- cd dictionary/
- make install
script:
- make make-sutta
after_success:
- make custom_sutta_deploy
# dpl v2 (not working for lots of symlinks)
#deploy:
# - provider: pages:git
# repo: siongui/dictionary.sutta.org
# keep_history: false
# token: $GITHUB_TOKEN
# local_dir: website
# on:
# branch: master
# edge: true
# verbose: true
# dpl v1 (not working for lots of symlinks)
#deploy:
# - provider: pages
# repo: siongui/dictionary.sutta.org
# skip_cleanup: true
# github_token: $GITHUB_TOKEN
# local_dir: website
# on:
# branch: master
install:
- cd tipitaka/
- make install
script:
- make make-sutta
deploy:
- provider: pages
repo: siongui/tipitaka.sutta.org
skip_cleanup: true
github_token: $GITHUB_TOKEN
local_dir: tipitaka/website
on:
branch: master
......@@ -66,7 +66,6 @@ Set Up Development Environment
- Go_
- gopalilib_
- gtmpl_
- `go-online-pali-ime`_
- `gopherjs-input-suggest`_
- GopherJS_
......
{{define "navbar"}}
<style>
@media screen and (max-width: 1023px) {
/* show mavbar-menu on screen less than 1024px */
/* show navbar-menu on screen less than 1024px */
#menu-toggle:checked ~ #paliNavbarMenu { display: block; }
/* make navbar-burger become cross on screen less than 1024px */
......
......@@ -71,6 +71,7 @@ func main() {
// Call velthuis before SetupModalInput (order of keyevent handler matters)
velthuis.BindPaliInputMethodToInputTextElementById("modal-input")
SetupModalInput("#modal-input")
SetupPaliSetting()
HideIsLoadingWebsite()
}
package main
import (
. "github.com/siongui/godom"
"github.com/siongui/gopalilib/lib"
)
func SavePaliSetting(setting lib.PaliSetting) {
str, _ := lib.PaliSettingToJsonString(setting)
LocalStorage.Set("PaliSetting", str)
}
func LoadPaliSetting() lib.PaliSetting {
setting, _ := lib.JsonStringToPaliSetting(LocalStorage.GetItem("PaliSetting"))
return setting
}
func SetupPaliSetting() {
isPreview := Document.GetElementById("isShowWordPreview")
p2en := Document.GetElementById("p2en")
p2ja := Document.GetElementById("p2ja")
p2zh := Document.GetElementById("p2zh")
p2vi := Document.GetElementById("p2vi")
p2my := Document.GetElementById("p2my")
dicLangOrder := Document.GetElementById("dicLangOrder")
setting := lib.GetDefaultPaliSetting()
// check if there is saved setting in user browser
if s := LocalStorage.GetItem("PaliSetting"); s == "null" {
// no setting saved, use default setting
SavePaliSetting(setting)
} else {
// use saved setting
setting, _ = lib.JsonStringToPaliSetting(s)
}
// restore setting
isPreview.Set("checked", setting.IsShowWordPreview)
p2en.Set("checked", setting.P2en)
p2ja.Set("checked", setting.P2ja)
p2zh.Set("checked", setting.P2zh)
p2vi.Set("checked", setting.P2vi)
p2my.Set("checked", setting.P2my)
dicLangOrder.Set("value", setting.DicLangOrder)
// set up event handler for setting change
isPreview.AddEventListener("click", func(e Event) {
setting.IsShowWordPreview = isPreview.Get("checked").Bool()
SavePaliSetting(setting)
})
// https://stackoverflow.com/questions/4471401/getting-value-of-html-checkbox-from-onclick-onchange-events
p2en.AddEventListener("click", func(e Event) {
setting.P2en = p2en.Get("checked").Bool()
SavePaliSetting(setting)
})
p2ja.AddEventListener("click", func(e Event) {
setting.P2ja = p2ja.Get("checked").Bool()
SavePaliSetting(setting)
})
p2zh.AddEventListener("click", func(e Event) {
setting.P2zh = p2zh.Get("checked").Bool()
SavePaliSetting(setting)
})
p2vi.AddEventListener("click", func(e Event) {
setting.P2vi = p2vi.Get("checked").Bool()
SavePaliSetting(setting)
})
p2my.AddEventListener("click", func(e Event) {
setting.P2my = p2my.Get("checked").Bool()
SavePaliSetting(setting)
})
dicLangOrder.AddEventListener("change", func(e Event) {
setting.DicLangOrder = dicLangOrder.Get("options").Call("item",
dicLangOrder.Get("selectedIndex").Int()).Get("value").String()
SavePaliSetting(setting)
})
}
......@@ -47,10 +47,9 @@ func possibleWordClickHandler(word string) {
SetModalContent("Fail to Get " + word + ": " + err.Error())
return
}
setting := lib.GetDefaultPaliSetting()
html := `<div class="previewWordName is-size-4 mb-1">` + wordLinkHtml(word) + `</div>`
html += dicmgr.GetWordDefinitionHtml(wi, setting, Window.Navigator().Languages())
html += dicmgr.GetWordDefinitionHtml(wi, LoadPaliSetting(), Window.Navigator().Languages())
SetModalContent(html)
}()
}
......@@ -102,8 +101,7 @@ func showWordDefinitionInModal(word string) {
SetModalContent("Fail to Get " + word + ": " + err.Error())
return
}
setting := lib.GetDefaultPaliSetting()
SetModalContent(dicmgr.GetWordDefinitionHtml(wi, setting, Window.Navigator().Languages()))
SetModalContent(dicmgr.GetWordDefinitionHtml(wi, LoadPaliSetting(), Window.Navigator().Languages()))
}
func FindLongestPrefixWithNonZeroSuggestedWords(word string) string {
......
{{define "navbar"}}
<style>
@media screen and (max-width: 1023px) {
/* show mavbar-menu on screen less than 1024px */
/* show navbar-menu on screen less than 1024px */
#menu-toggle:checked ~ #paliNavbarMenu { display: block; }
/* make navbar-burger become cross on screen less than 1024px */
......@@ -12,15 +12,22 @@
/* #paliNavbarMenu { left:0; right:0; top:100%; position: absolute; } */
}
label[for="setting-toggle"]:hover {
cursor: pointer;
background-color: #fafafa;
color: #3273dc;
}
#setting-toggle:not(:checked) ~ article.setting-menu { display: none; }
#setting-toggle:not(:checked) + .navbar > .navbar-menu > .navbar-start > label span:nth-child(1) { display: none; }
#setting-toggle:checked + .navbar > .navbar-menu > .navbar-start > label span:nth-child(2) { display: none; }
</style>
<input type="checkbox" id="setting-toggle" class="is-hidden">
<nav class="navbar has-background-light-gold has-border-gold" role="navigation" aria-label="main navigation">
<input type="checkbox" id="menu-toggle" class="is-hidden">
<div class="navbar-brand">
<a class="navbar-item is-size-4 is-gold" href="{{.SiteUrl}}/">
<!--
<span data-default-string="Pāli Tipiṭaka">{{gettext "Pāli Tipiṭaka"}}</span>
-->
<span data-default-string="Pali Tipitaka">{{gettext "Pali Tipitaka"}}</span> (Pāli Tipiṭaka)
</a>
......@@ -37,6 +44,9 @@
<span data-default-string="Dictionary">{{gettext "Dictionary"}}</span>
</a>
<label class="navbar-item" for="setting-toggle">
<span>&#9660;</span><span>&#9658;</span><span data-default-string="Setting">{{gettext "Setting"}}</span>
</label>
</div>
<div class="navbar-end">
<div class="navbar-item has-dropdown is-hoverable">
......
{{define "setting"}}
<article class="message is-info setting-menu">
<div class="message-body">
<input type="checkbox" id="isShowWordPreview"/>
<span data-default-string="Input Word Explanation Preview">{{gettext "Input Word Explanation Preview"}}</span>
<br />
<br />
<div>
<span data-default-string="What Languages of Dictionaries to Show?">{{gettext "What Languages of Dictionaries to Show?"}}</span>
<br />
<input type="checkbox" checked="checked" id="p2en"/>
<span data-default-string='Pāli-English'>{{gettext "Pāli-English"}}</span>
<br />
<input type="checkbox" checked="checked" id="p2ja"/>
<span data-default-string='Pāli-Japanese'>{{gettext "Pāli-Japanese"}}</span>
<br />
<input type="checkbox" checked="checked" id="p2zh"/>
<span data-default-string='Pāli-Chinese'>{{gettext "Pāli-Chinese"}}</span>
<br />
<input type="checkbox" checked="checked" id="p2vi"/>
<span data-default-string='Pāli-Vietnamese'>{{gettext "Pāli-Vietnamese"}}</span>
<br />
<input type="checkbox" checked="checked" id="p2my"/>
<span data-default-string='Pāli-Burmese'>{{gettext "Pāli-Burmese"}}</span>
<br />
</div>
<br />
<span data-default-string='The Order of Languages of Dictionaries to Show?'>{{gettext "The Order of Languages of Dictionaries to Show?"}}</span>
<br />
<select id="dicLangOrder">
<option value="hdr" selected="selected" data-default-string='According to Language Settings in Browser'>{{gettext "According to Language Settings in Browser"}}</option>
<option value="en" data-default-string='English First'>{{gettext "English First"}}</option>
<option value="ja" data-default-string='Japanese First'>{{gettext "Japanese First"}}</option>
<option value="zh" data-default-string='Chinese First'>{{gettext "Chinese First"}}</option>
<option value="vi" data-default-string='Vietnamese First'>{{gettext "Vietnamese First"}}</option>
<option value="my" data-default-string='Burmese First'>{{gettext "Burmese First"}}</option>
</select>
</div>
</article>
{{end}}
......@@ -15,6 +15,7 @@
</head>
<body>
{{template "navbar" .}}
{{template "setting" .}}
{{template "tmpinfo" .}}
<div class="is-loading-xml is-hidden notification is-info is-light" style="position: sticky; top: 0; z-index: 5;">Loading XML ...</div>
......
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