<commit_before>package browserspeak

// Creates an anonymous function
func fn(source string) string {
	return "function() { " + source + " }"
}

func quote(src string) string {
	return "\"" + src + "\""
}

// Creates an event
func event(tagname, event, source string) string {
	return "$(" + quote(tagname) + ")." + event + "(" + fn(source) + ");"
}

// Call a method on a tag
func method(tagname, methodname, value string) string {
	return "$(" + quote(tagname) + ")." + methodname + "(" + value + ");"
}

// Call a method on a tag that takes a string as a parameter
func methodString(tagname, methodname, value string) string {
	return method(tagname, methodname, quote(value))
}

// Run code when the document is ready
func OnDocumentReady(source string) string {
	return "$(document).ready(" + fn(source) + ");"
}

// Display an intruding message
func Alert(msg string) string {
	return "alert(" + quote(msg) + ");"
}

// When a tag is clicked at
func OnClick(tagname, source string) string {
	return event(tagname, "click", source)
}

func SetText(tagname, text string) string {
	return methodString(tagname, "text", text)
}

func SetHTML(tagname, html string) string {
	return method(tagname, "html", html)
}

func SetValue(tagname, val string) string {
	return methodString(tagname, "val", val)
}

func SetRawValue(tagname, val string) string {
	return method(tagname, "val", val)
}

func Hide(tagname string) string {
	return "$(" + quote(tagname) + ").hide();"
}

func HideAnimated(tagname string) string {
	return "$(" + quote(tagname) + ").hide('normal');" // 'fast', 'normal', 'slow' or milliseconds
}

func Show(tagname string) string {
	return "$(" + quote(tagname) + ").show();"
}

func ShowAnimated(tagname string) string {
	return "$(" + quote(tagname) + ").show('normal');" // 'fast', 'normal', 'slow' or milliseconds
}

// Same as Show, but set display to inline instead of block
func ShowInline(tagname string) string {
	return "$(" + quote(tagname) + ").css('display', 'inline');"
}

// Same as Show, but set display to inline instead of block
func ShowInlineAnimated(tagname string) string {
	return ShowInline(tagname) + Hide(tagname) + ShowAnimated(tagname)
}

func Load(tagname, url string) string {
	return methodString(tagname, "load", url)
}

// Hide a tag if booleanURL doesn't return "1" (true)
func HideIfNot(booleanURL, tagname string) string {
	return "$.get(" + quote(booleanURL) + ", function(data) { if (data != \"1\") {" + Hide(tagname) + "}; });"
}

// Show a tag if booleanURL returns "1" (true)
func ShowAnimatedIf(booleanURL, tagname string) string {
	return "$.get(" + quote(booleanURL) + ", function(data) { if (data == \"1\") {" + ShowAnimated(tagname) + "}; });"
}

// Optimized function for login, logout and register
func HideIfNotLoginLogoutRegister(threeBooleanURL, logintag, logouttag, registertag string) string {
	src := "$.get(" + quote(threeBooleanURL) + ", function(data) {"
	// TODO: See what happens if data < 3 length
	src += "if (data[0] != \"1\") {" + Hide(logintag) + "};"
	src += "if (data[1] != \"1\") {" + Hide(logouttag) + "};"
	src += "if (data[2] != \"1\") {" + Hide(registertag) + "};"
	src += "});"
	return src
}

// Optimized function for login, logout and register
func ShowIfLoginLogoutRegister(threeBooleanURL, logintag, logouttag, registertag string) string {
	src := "$.get(" + quote(threeBooleanURL) + ", function(data) {"
	// TODO: See what happens if data < 3 length
	src += "if (data[0] == \"1\") {" + ShowInline(logintag) + "};"
	src += "if (data[1] == \"1\") {" + ShowInline(logouttag) + "};"
	src += "if (data[2] == \"1\") {" + ShowInline(registertag) + "};"
	src += "});"
	return src
}

// Returns html to run javascript once the document is ready
// Returns an empty string if there is no javascript to run.
func BodyJS(source string) string {
	if source != "" {
		return "<script type=\"text/javascript\">" + OnDocumentReady(source) + "</script>"
	}
	return ""
}

func Redirect(url string) string {
	return "window.location.href = \"" + url + "\";"
}
<commit_msg>Added a function for showing display:inline animated depending on the result from an url<commit_after>package browserspeak

// Creates an anonymous function
func fn(source string) string {
	return "function() { " + source + " }"
}

func quote(src string) string {
	return "\"" + src + "\""
}

// Creates an event
func event(tagname, event, source string) string {
	return "$(" + quote(tagname) + ")." + event + "(" + fn(source) + ");"
}

// Call a method on a tag
func method(tagname, methodname, value string) string {
	return "$(" + quote(tagname) + ")." + methodname + "(" + value + ");"
}

// Call a method on a tag that takes a string as a parameter
func methodString(tagname, methodname, value string) string {
	return method(tagname, methodname, quote(value))
}

// Run code when the document is ready
func OnDocumentReady(source string) string {
	return "$(document).ready(" + fn(source) + ");"
}

// Display an intruding message
func Alert(msg string) string {
	return "alert(" + quote(msg) + ");"
}

// When a tag is clicked at
func OnClick(tagname, source string) string {
	return event(tagname, "click", source)
}

func SetText(tagname, text string) string {
	return methodString(tagname, "text", text)
}

func SetHTML(tagname, html string) string {
	return method(tagname, "html", html)
}

func SetValue(tagname, val string) string {
	return methodString(tagname, "val", val)
}

func SetRawValue(tagname, val string) string {
	return method(tagname, "val", val)
}

func Hide(tagname string) string {
	return "$(" + quote(tagname) + ").hide();"
}

func HideAnimated(tagname string) string {
	return "$(" + quote(tagname) + ").hide('normal');" // 'fast', 'normal', 'slow' or milliseconds
}

func Show(tagname string) string {
	return "$(" + quote(tagname) + ").show();"
}

func ShowAnimated(tagname string) string {
	return "$(" + quote(tagname) + ").show('normal');" // 'fast', 'normal', 'slow' or milliseconds
}

// Same as Show, but set display to inline instead of block
func ShowInline(tagname string) string {
	return "$(" + quote(tagname) + ").css('display', 'inline');"
}

// Same as Show, but set display to inline instead of block
func ShowInlineAnimated(tagname string) string {
	return ShowInline(tagname) + Hide(tagname) + ShowAnimated(tagname)
}

// Same as ShowAnimatedIf, but set display to inline instead of block
func ShowInlineAnimatedIf(tagname string) string {
	return "$.get(" + quote(booleanURL) + ", function(data) { if (data == \"1\") {" + ShowInlineAnimated(tagname) + "}; });"
}

func Load(tagname, url string) string {
	return methodString(tagname, "load", url)
}

// Hide a tag if booleanURL doesn't return "1" (true)
func HideIfNot(booleanURL, tagname string) string {
	return "$.get(" + quote(booleanURL) + ", function(data) { if (data != \"1\") {" + Hide(tagname) + "}; });"
}

// Show a tag if booleanURL returns "1" (true)
func ShowAnimatedIf(booleanURL, tagname string) string {
	return "$.get(" + quote(booleanURL) + ", function(data) { if (data == \"1\") {" + ShowAnimated(tagname) + "}; });"
}

// Optimized function for login, logout and register
func HideIfNotLoginLogoutRegister(threeBooleanURL, logintag, logouttag, registertag string) string {
	src := "$.get(" + quote(threeBooleanURL) + ", function(data) {"
	// TODO: See what happens if data < 3 length
	src += "if (data[0] != \"1\") {" + Hide(logintag) + "};"
	src += "if (data[1] != \"1\") {" + Hide(logouttag) + "};"
	src += "if (data[2] != \"1\") {" + Hide(registertag) + "};"
	src += "});"
	return src
}

// Optimized function for login, logout and register
func ShowIfLoginLogoutRegister(threeBooleanURL, logintag, logouttag, registertag string) string {
	src := "$.get(" + quote(threeBooleanURL) + ", function(data) {"
	// TODO: See what happens if data < 3 length
	src += "if (data[0] == \"1\") {" + ShowInline(logintag) + "};"
	src += "if (data[1] == \"1\") {" + ShowInline(logouttag) + "};"
	src += "if (data[2] == \"1\") {" + ShowInline(registertag) + "};"
	src += "});"
	return src
}

// Returns html to run javascript once the document is ready
// Returns an empty string if there is no javascript to run.
func BodyJS(source string) string {
	if source != "" {
		return "<script type=\"text/javascript\">" + OnDocumentReady(source) + "</script>"
	}
	return ""
}

func Redirect(url string) string {
	return "window.location.href = \"" + url + "\";"
}

{'fraction_non_alphanumeric': 0.17619104193893312, 'fraction_numerical': 0.0043958655102768205, 'mean_word_length': 4.392696989109545, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '2159658', 'n_tokens_mistral': 2811, 'n_tokens_neox': 2842, 'n_words': 842}