Пример #1
0
func Keypress(model Model, event dom.Event) Model {
	if t, ok := event.Target().(*dom.HTMLInputElement); ok {
		// TODO: save/restore focus and cursor position
		return Model(t.Value)
	}
	return model
}
Пример #2
0
// CreateTodo is an event listener which creates a new todo and adds it to the
// todo list.
func (v *App) CreateTodo(ev dom.Event) {
	input, ok := ev.Target().(*dom.HTMLInputElement)
	if !ok {
		panic("Could not convert event target to dom.HTMLInputElement")
	}
	v.Todos.AddTodo(input.Value)
	document.QuerySelector(".new-todo").(dom.HTMLElement).Focus()
}
Пример #3
0
// ToggleAll toggles all the todos in the list.
func (v *App) ToggleAll(ev dom.Event) {
	input := ev.Target().(*dom.HTMLInputElement)
	if !input.Checked {
		v.Todos.UncheckAll()
	} else {
		v.Todos.CheckAll()
	}
}
Пример #4
0
func paliIME(event dom.Event) {
	elm := event.Target().(*dom.HTMLInputElement)

	if lastInput != "" && elm.Value != "" {
		v := elm.Value
		if len(v) == (len(lastInput) + 1) {
			result := checkLastTwoCharacter(lastInput[len(lastInput)-1:], v[len(v)-1:])
			if result != "" {
				elm.Value = v[:len(v)-2] + result
			}
		}
	}
	lastInput = elm.Value
}
Пример #5
0
func inputKeyUp(event dom.Event) {
	input := event.Target().(*dom.HTMLInputElement)

	span := dom.GetWindow().Document().GetElementByID("foo2")
	span.SetInnerHTML(input.Value)
}