<commit_before>package main

import (
	"github.com/MJKWoolnough/gopherjs/xdom"
	"github.com/MJKWoolnough/gopherjs/xform"
	"github.com/MJKWoolnough/gopherjs/xjs"
	"honnef.co/go/js/dom"
)

func settingsTab(c dom.Element) {
	s, err := RPC.Settings()
	if err != nil {
		xjs.Alert("Error reading settings: %s", err)
		return
	}
	c.AppendChild(xjs.SetInnerText(xdom.H2(), "Change Settings"))
	c.AppendChild(xform.Label("Server Name", "serverName"))
	sn := xform.InputText("serverName", s.ServerName)
	c.AppendChild(sn)
	c.AppendChild(xdom.Br())
	c.AppendChild(xform.Label("Listen Address", "listenAddr"))
	la := xform.InputText("listenAddr", s.ListenAddr)
	c.AppendChild(la)
	c.AppendChild(xdom.Br())
	c.AppendChild(xform.Label("Servers Path", "serversPath"))
	sp := xform.InputText("serversPath", s.DirServers)
	c.AppendChild(sp)
	c.AppendChild(xdom.Br())
	c.AppendChild(xform.Label("Maps Path", "mapsPath"))
	mp := xform.InputText("mapsPath", s.DirMaps)
	c.AppendChild(mp)
	c.AppendChild(xdom.Br())

	sb := xdom.Button()
	xjs.SetInnerText(sb, "Save")
	sb.AddEventListener("click", false, func(dom.Event) {
		go func() {
			s.ServerName = sn.Value
			s.ListenAddr = la.Value
			s.DirServers = sp.Value
			s.DirMaps = mp.Value
			if err := RPC.SetSettings(s); err != nil {
				xjs.Alert("Error saving settings: %s", err)
			} else {
				SetTitle(sn.Value)
			}
		}()
	})
	c.AppendChild(sb)
}<commit_msg>Rewrote settingsTab in new form style<commit_after>package main

import (
	"github.com/MJKWoolnough/gopherjs/xdom"
	"github.com/MJKWoolnough/gopherjs/xform"
	"github.com/MJKWoolnough/gopherjs/xjs"
	"honnef.co/go/js/dom"
)

func settingsTab(c dom.Element) {
	s, err := RPC.Settings()
	if err != nil {
		xjs.Alert("Error reading settings: %s", err)
		return
	}
	sn := xform.InputText("serverName", s.ServerName)
	sn.Required = true
	la := xform.InputText("listenAddr", s.ListenAddr)
	la.Required = true
	sp := xform.InputText("serversPath", s.DirServers)
	sp.Required = true
	mp := xform.InputText("mapsPath", s.DirMaps)
	mp.Required = true
	sb := xform.InputSubmit("Save")
	sb.AddEventListener("click", false, func(e dom.Event) {
		if sn.Value == "" || la.Value == "" || sp.Value == "" || mp.Value == "" {
			return
		}
		e.PreventDefault()
		sb.Disabled = true
		go func() {
			s.ServerName = sn.Value
			s.ListenAddr = la.Value
			s.DirServers = sp.Value
			s.DirMaps = mp.Value
			if err := RPC.SetSettings(s); err != nil {
				xjs.Alert("Error saving settings: %s", err)
				return
			}
			SetTitle(sn.Value)
			sb.Disabled = false
		}()
	})
	xjs.AppendChildren(c, xjs.AppendChildren(xdom.Form(), xjs.AppendChildren(xdom.Fieldset(),
		xjs.SetInnerText(xdom.Legend(), "Change Settings"),
		xform.Label("Server Name", "serverName"), sn, xdom.Br(),
		xform.Label("Listen Address", "listenAddr"), la, xdom.Br(),
		xform.Label("Servers Path", "serversPath"), sp, xdom.Br(),
		xform.Label("Maps Path", "mapsPath"), mp, xdom.Br(),
		sb,
	)))
}
{'fraction_non_alphanumeric': 0.17745231607629428, 'fraction_numerical': 0.0003405994550408719, 'mean_word_length': 4.263440860215054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3165166', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1157, 'n_words': 200}