Handles focus for search forms and selection for url bar on first load, also removes binary from version control

This commit is contained in:
sloum 2021-05-29 14:06:04 -07:00
parent 7cd61129ec
commit 66cf96173f
21 changed files with 119 additions and 51 deletions

Binary file not shown.

View File

@ -1,46 +0,0 @@
package main
import (
"math/rand"
"github.com/wailsapp/wails"
)
// Counter is what we use for counting
type Counter struct {
r *wails.Runtime
store *wails.Store
}
// WailsInit is called when the component is being initialised
func (c *Counter) WailsInit(runtime *wails.Runtime) error {
c.r = runtime
c.store = runtime.Store.New("Counter", 0)
return nil
}
// RandomValue sets the counter to a random value
func (c *Counter) RandomValue() {
c.store.Set(rand.Intn(1000))
}
// Increment will increment the counter
func (c *Counter) Increment() {
increment := func(data int) int {
return data + 1
}
// Update the store using the increment function
c.store.Update(increment)
}
// Decrement will decrement the counter
func (c *Counter) Decrement() {
decrement := func(data int) int {
return data - 1
}
// Update the store using the decrement function
c.store.Update(decrement)
}

View File

@ -229,6 +229,48 @@ header input.loading {
max-height: 100%;
}
#content label {
display: block;
color: cyan;
font-size: 1.5em;
}
#content input#QueryResponse {
width: 100%;
padding-left: 10px;
background-color: rgb(50,50,50);
margin: 1.2em 0;
display: block;
color: silver;
border: 1px solid whitesmoke;
border-radius: 5px;
box-sizing: border-box;
font-size: 1.5em;
}
#content input#QueryResponse:focus {
border-color: goldenrod;
}
#content input[type=submit] {
display: inline-block;
float: right;
border-radius: 5px;
background-color: rgb(50,50,50);
color: silver;
border: 2px solid whitesmoke;
padding: 0.25em 2em;
font-size: 1.5em;
transition: 0.2s;
cursor: pointer;
}
#content input[type=submit]:hover, #content input[type="submit"]:focus {
background-color: goldenrod;
color: rgb(50,50,50);
text-decoration: underline;
}
#ui-url-display {
position: fixed;
bottom: 0;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
66eac47c1791d0f528229ab34094c1dc4efa376c {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"4e560ec1526b360e11a28a543ef8f1f7\"}","integrity":"sha512-XsKfK/ke7/D2I1WfyEOpDpDqRLF7YSeGf+udxbQHgItnaxIV6/XuG9yii2w0TGgeLRuDygZUfkoy1QopMYuP8Q==","time":1622322312510,"size":131216}

View File

@ -0,0 +1,2 @@
cb3b77c7492bf4f078d7acd94fb5e862da78367d {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"8798ce7bdbe346cc7a2f9be8e307c3b4\"}","integrity":"sha512-IIkeD/2edoq+/zQYivx7tIaHt4MFZ2OskinjZib82oos/1g9Xy0cDZQ77NO4518COkEYAIq3OFDIMWrsGRrNKw==","time":1622321463560,"size":298498}

View File

@ -0,0 +1,2 @@
a61d13aaf3d4175393cb3d75142f4f670e8f62bb {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"889f1e189940a03b95dec08c7a044fc0\"}","integrity":"sha512-fhxKHhId0qrgS/lje7mcxnDeIk2RTNDNQwuoHC78EkwkhRiYQvOvH2Y5ZwOYok38m4b+qLpWqX8eiI1ZJII/Fw==","time":1622321144050,"size":298450}

View File

@ -0,0 +1,2 @@
e23017872f3cfbe800fe1f3fca12ff76cf10101e {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"b89f0b9183f28229436644364baa4b9b\"}","integrity":"sha512-fhxKHhId0qrgS/lje7mcxnDeIk2RTNDNQwuoHC78EkwkhRiYQvOvH2Y5ZwOYok38m4b+qLpWqX8eiI1ZJII/Fw==","time":1622300036573,"size":298450}

View File

@ -0,0 +1,2 @@
62c95167583f4bf52d136028f41cc47a1b138109 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"d71c0086a93e23f3b638e8fa48ad9525\"}","integrity":"sha512-1HSkGIRu/9h75+ebf0jsS0k0ITxt36GL5iH/Xoq6keZ6P+sKWtM89cTgKUBxHLJY/QPbws0JNoX4oR+WAyZzoA==","time":1622321581848,"size":298498}

View File

@ -0,0 +1,2 @@
d939a3b9f1ef4b63d16f410dae728a7091f8f0a0 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"f760dd32e08bbdcc2baf71c7c6716039\"}","integrity":"sha512-3XUd7/CFypMW+YslWCt0f6dWYdI+l7w1bCVh1dahTzSUJzoZg4xJRfrYCkUoIi3Id3pWeY+uLeEGe+z7OTxGtA==","time":1622321272584,"size":298488}

View File

@ -0,0 +1,2 @@
b58ac59ad896befe0d8bee4d9b2fd307cc6d8134 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"53cbd4c47b369421ce6a713d4e3f3a65\"}","integrity":"sha512-1HSkGIRu/9h75+ebf0jsS0k0ITxt36GL5iH/Xoq6keZ6P+sKWtM89cTgKUBxHLJY/QPbws0JNoX4oR+WAyZzoA==","time":1622321530952,"size":298498}

View File

@ -0,0 +1,2 @@
9e7369686f63d882278cd63cfc204bc2fe5370a1 {"key":"{\"terser\":\"4.8.0\",\"node_version\":\"v16.2.0\",\"terser-webpack-plugin\":\"1.4.5\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.m?js(\\\\?.*)?$\", \"i\"),\"chunkFilter\":() => true,\"warningsFilter\":() => true,\"extractComments\":false,\"sourceMap\":false,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"output\":{\"comments\":new RegExp(\"^\\\\**!|@preserve|@license|@cc_on\", \"i\")}}},\"hash\":\"bec053d131226d623dcfddb862424a16\"}","integrity":"sha512-o95NZ3FJy4mInBC0ewONL1mEpbr4USIIhIQWSgofmW8ODP+kEdnAiW00iP6szYPMk/6tTdQaX/EDlPvzn1zfAw==","time":1622321373355,"size":298498}

View File

@ -229,6 +229,48 @@ header input.loading {
max-height: 100%;
}
#content label {
display: block;
color: cyan;
font-size: 1.5em;
}
#content input#QueryResponse {
width: 100%;
padding-left: 10px;
background-color: rgb(50,50,50);
margin: 1.2em 0;
display: block;
color: silver;
border: 1px solid whitesmoke;
border-radius: 5px;
box-sizing: border-box;
font-size: 1.5em;
}
#content input#QueryResponse:focus {
border-color: goldenrod;
}
#content input[type=submit] {
display: inline-block;
float: right;
border-radius: 5px;
background-color: rgb(50,50,50);
color: silver;
border: 2px solid whitesmoke;
padding: 0.25em 2em;
font-size: 1.5em;
transition: 0.2s;
cursor: pointer;
}
#content input[type=submit]:hover, #content input[type="submit"]:focus {
background-color: goldenrod;
color: rgb(50,50,50);
text-decoration: underline;
}
#ui-url-display {
position: fixed;
bottom: 0;

View File

@ -110,6 +110,9 @@ function parseURL(u, queryString) {
return out;
}
// TODO:
// - Autofocus form input on search form pages
// Main entry point
function start() {
// Ensure the default app div is 100% wide/high
@ -151,6 +154,7 @@ function start() {
});
url.focus({preventScroll: true});
url.setSelectionRange(0, url.value.length);
var showUrlTip = (e) => {
urlDisplay.innerText = event.target.href;
@ -174,7 +178,6 @@ function start() {
url.value = urlObj.string();
content.innerHTML = val;
addAnchorListeners();
addSearchFormListeners();
url.classList.remove('loading');
if (addToHistory) {
backend.History.Add(url.value)
@ -182,6 +185,7 @@ function start() {
}
main.focus({preventScroll: true});
main.scroll({top: 0});
addSearchFormListeners();
}, (err) => {
spinner.classList.remove('loading');
url.value = previousURL;
@ -209,13 +213,14 @@ function start() {
var addSearchFormListeners = () => {
document.querySelectorAll('form#search').forEach(form => {
var input = document.getElementById('QueryResponse');
form.addEventListener('submit', (e) => {
e.preventDefault();
var input = document.getElementById('QueryResponse');
let target = parseURL(form.action, input.value);
makeRequest(target.string(), true);
})
})
});
input.focus()
});
}
// Window Event Handlers

View File

@ -15,6 +15,7 @@ var (
strikeReg = regexp.MustCompile(`\~\~(.*?)\~\~`)
underscoreReg = regexp.MustCompile(`__(.*?)__`)
anchorReg = regexp.MustCompile(`\[(.*?)\]\((.*?)\)[^\)]`)
imgReg = regexp.MustCompile(`\!\[(.*?)\]\((.*?)\)[^\)]`)
escapeReg = regexp.MustCompile(`^\>(\s|)`)
blockquoteReg = regexp.MustCompile(`\&gt\;(.*?)$`)
backtipReg = regexp.MustCompile("`(.*?)`")
@ -47,6 +48,8 @@ func NewMarkdown(input io.Reader) string {
line = strikeReg.ReplaceAll(line, []byte(`<s>$1</s>`))
// wrap underscored text in "<u>" tags
line = underscoreReg.ReplaceAll(line, []byte(`<u>$1</u>`))
// convert images to image tags
line = imgReg.ReplaceAll(line, []byte(`<img src="$2" alt="$1">`))
// convert links to anchor tags
line = anchorReg.ReplaceAll(line, []byte(`<a href="$2">$1</a>`))
// escape and wrap blockquotes in "<blockquote>" tags