Skip to content

Latest commit

 

History

History
494 lines (356 loc) · 21.4 KB

JavaScript.md

File metadata and controls

494 lines (356 loc) · 21.4 KB

Members

LangHandlerJS : File

Namespace of functions for easy access to Language actions.

PluginHandlerJS : File

The JavaScript file to assist installed Plugins

PluginLoadJS : File

The JavaScript file that handles loading Plugin Scripts on page load.

SettingsJS : File

The JavaScript file loaded with the Settings Page

UniversalJS : File

JavaScript file loaded with every single page for Universal Functions

UniverseJS : File

Namespace of functions for easy access to repeatable actions. Aimed at reducing complexity, and duplicity.

UploadImageJS : File

The JavaScript file loaded with the Upload Image Page.

LangHandlerJS : File

Namespace of functions for easy access to Language actions.

Kind: global variable

LangHandlerJS.langHandler

The namepsace to access all internal functions.

Kind: static property of LangHandlerJS
Namepspace:

langHandler.UnicornComposite(arg0, argN)

Implementation of Composite Formatting from C# This is at its core based on the Stack Overflow Implementation found and reworked by Gabriel Nahmias. Which was agiain reworked by myself to work as a standalone method. https://stackoverflow.com/a/18234317/12707685 This will accept a composite formatted string for ease of translations.

Kind: static method of langHandler
Summary: Implementation of Composite Formatting from C#.

Param Type Description
arg0 string The String to preform the method on.
argN string All other arguments afterwards can be keys, with as many as needed to fill the string. Not enough or to many causing zero errors.

Example

langHandler.UnicornComposite("How is this for a {0}, I hope it {1}", "Test", "Works");
// Outputs: "How is this for a Test, I hope it Works."

PluginHandlerJS : File

The JavaScript file to assist installed Plugins

Kind: global variable

PluginHandlerJS.pluginAPI : object

The namespace to access all PluginHandler internal functions

Kind: static namespace of PluginHandlerJS

pluginAPI.ReturnItems(pluginName) ⇒ Array.HTMLCollection

Returns a live HTMLCollection that use the specified plugin.

Kind: static method of pluginAPI
Returns: Array.HTMLCollection - Live array of the DOM Element using the plugin.

Param Type Description
pluginName string is the name of the Plugin to search for.

pluginAPI.ParseConfig(rawConfig) ⇒ Object

Parses saved configuration data for plugins.

Kind: static method of pluginAPI
Returns: Object - A Parsed JSON Object of the configuration data.

Param Type Description
rawConfig string takes the raw string confiuration data.

PluginLoadJS : File

The JavaScript file that handles loading Plugin Scripts on page load.

Kind: global variable

SettingsJS : File

The JavaScript file loaded with the Settings Page

Kind: global variable

SettingsJS.onclickHandlers()

Registers onclick handlers wherever relavent within the page.

Kind: static method of SettingsJS
Implements: universe.SnackbarCommon(), langHandler.UnicornComposite(), removeHeaderPlugin(), changeOptionsAPI()

SettingsJS.removeHeaderPlugin(side)

Simplifies removing a Header Plugin from User Settings using GoPage APIs

Kind: static method of SettingsJS
Implements: universe.CreateJSONPOSTHeaders(), universe.SnackbarCommon(), langHandler.UnicornComposite(), universe.SnackbarError()

Param Type Description
side string Indicates the which Side the Header Plugin is being removed from. Valid Values: "right", "left"

SettingsJS.changeOptionsAPI(item, value)

Simplified method of making API Calls to GoPage API to change user settings.

Kind: static method of SettingsJS
Implements: doesJSONParse(), universe.SnackbarError(), universe.SnackbarCommon(), langHandler.UnicornComposite()

Param Type Description
item string The Identifier of the Item being changed.
value string The Value said Identifier is being changed to.

SettingsJS.doesJSONParse(data) ⇒ boolean

Method of checking if passed data will parse into JSON without any errors.

Kind: static method of SettingsJS
Returns: boolean - True if successfully parsed, false if it fails to parse.

Param Type Description
data string The data to test against.

UniversalJS : File

JavaScript file loaded with every single page for Universal Functions

Kind: global variable

UniversalJS.loadTimeStamp()

Loads the TimeStamp and modifies the HTML to reflect the current time.

Kind: static method of UniversalJS

UniversalJS.updaterTimeStamp()

Uses setInterval to call loadTimeStamp() every 1000 milliseconds (1 Second)

Kind: static method of UniversalJS
Implements: loadTimeStamp()

UniversalJS.checkCustomBackgroundImage()

Queries GoPage APIs to determine and set a background image if needed, injecting it into the DOM.

Kind: static method of UniversalJS

UniverseJS : File

Namespace of functions for easy access to repeatable actions. Aimed at reducing complexity, and duplicity.

Kind: global variable

UniverseJS.universe : object

The namespace to access all internal functions.

Kind: static namespace of UniverseJS

universe.SnackbarCommon(id, textToShow, [callback], [extraClass], [img], [alt], [additionalDetails])

Common method for creating Snackbars onscreen, usually not directly accessed, instead accessed through a higher level function.

Kind: static method of universe
Implements: ShowTemplateModal()

Param Type Description
id string Div ID of the Snackbar to target.
textToShow string The Text that will appear within the Snackbar.
[callback] function Optional function to execute after the Snackbar has disappeared.
[extraClass] string Optional className to provide. Not needed to be set when accessing from a higher function.
[img] string Optional Relative path to an Image Icon to display alongside the text.
[alt] string Optional ALT tag for the Image thats being displayed.
[additionalDetails] string Optional details that will show in a modal if the Snackbar image is clicked. Setting additional details also makes the Snackbar Image clickable.

Example

universe.SnackbarCommon("homePageSnackbar", "Success", universe.ReloadCallback());

Example (A More Complex Example)

universe.SnackbarCommon(
  "snackbar",
  langHandler.UnicornComposite(string, i18n_returnValueLinkItem),
  universe.HotReload("linkItemList", "/", homePageInit, "reload")
  );

universe.SnackbarError(id, textToShow, [callback], [details])

Simple way to create an Error Snackbar, defaulting many values passed to SnackbarCommon.

Kind: static method of universe
Implements: SnackbarCommon()

Param Type Description
id string Div ID of Snackbar to target.
textToShow string The Text that will appear within the Snackbar.
[callback] function Optional function to execute after the Snackbar has disappeared.
[details] string Optional details that will show in a modal if the Snackbar Image is clicked.

universe.ReloadCallback() ⇒ function

Provides a simple way to reload the page within callbacks. Since the standard location.reload() losses scope inside a callback.

Kind: static method of universe
Returns: function - Globally Scoped function to reload page: window.location.reload.bind(window.location)

universe.CreateJSONPOSTHeaders(data) ⇒ Object

Provides a simple way to retreive POST JSON Headers for use with Fetch requests.

Kind: static method of universe
Returns: Object - Fetch Request Options with provided data.

Param Type Description
data string JSON Object to set as the body of the Fetch details.

universe.ShowModal(id)

Sets a Modal's Display to "block" to show it on the page.

Kind: static method of universe

Param Type Description
id string Is the DOM ID of the Modal to Display.

universe.CloseModal(id)

Sets a Modal's Display to "none" to remove it from the page.

Kind: static method of universe

Param Type Description
id string Is the DOM ID of the Modal to Remove.

universe.ShowTemplateModal(text)

Will show an onscreen modal assuming the Template Modal Page is used. And will handle the closing of said modal.

Kind: static method of universe
Implements: CloseModal(), ShowModal()

Param Type Description
text string Is the Text to show within the Modal.

universe.WriteUserSettings(requestOptions, successCallback, errorCallback)

Uses GoPage APIs to set new UserSettings to the Server.

Kind: static method of universe

Param Type Description
requestOptions string Will be the Request Options passed to Fetch for the request
successCallback function The function to execute if the query is successful.
errorCallback function The function to execute if the query fails. The error callback is REQUIRED to accept a JSON Object of the error.

universe.GenericErrorHandler(snackbar, msg)

Intended to be a simple way to create an Error Snackbar that has now been superseded by SnackbarError.

Kind: static method of universe
Implements: SnackbarError()
Todo

  • Determine if this is still needed or in use.
Param Type Description
snackbar string DOM ID of the Snackbar to Target.
msg string The Message to display in the text of the Snackbar and to output to the console.

universe.FindReturnsString(action, status) ⇒ string

Can be used to help determine the right translated message. This does require that returnGlobalJS template is in use on the page. This will use the Global Strings to attempt to return the right action that has been preformed.

Kind: static method of universe
Returns: string - The translated string needed, Remember this will likely be a Composite String and shouldn't be displayed as is.

Param Type Description
action string Is the action that has occured. Valid values: "delete", "install", "update"
status string Is the status of said action. Valid Values: "pass", "fail"

universe.HotReload(elementID, url, callback, callbackArg)

Adds an easy way to Hot-Reload pages that are capable of doing so server side.

Kind: static method of universe

Param Type Description
elementID string The DOM ID of the element to replace in the Hot-Reload Action.
url string The URL to query for Hot-Reloading page data.
callback function Function to execute after the Hot-Reload is finished. Useful for calling any functions needed to add Event Handlers or process data on the page.
callbackArg string Arguments to pass to the callback function, useful if the callback needs to identify that its a callback.

Example

universe.HotReload("linkItemList", "/", homePageInit, "reload");

universe.Loader(shouldShow)

Simple method of injecting a Loading animation onto the center of the page.

Kind: static method of universe

Param Type Description
shouldShow boolean indicates if the loader is being turned off or on. True being on, and False being off.

universe.ChangeLangAPI(chosenLang)

Allowing easy universal access to the ChangeLangAPI, by just submitting the chosenLang

Kind: static method of universe

Param Type Description
chosenLang string The two digit language code that the server should save

UploadImageJS : File

The JavaScript file loaded with the Upload Image Page.

Kind: global variable

UploadImageJS.loadAvailableImages()

Builds the main content of the UploadImage Page. By using GoPage API's to check saved images, and display them.

Kind: static method of UploadImageJS
Todo

  • Inline with the Neutuer JavaScript Initiative, this should be done in Golang, and injected into the template.

UploadImageJS.insertImg(imageLoc) ⇒ string

Helps loadAvailableImages to build the page, by returned an HTML string

Kind: static method of UploadImageJS
Returns: string - HTML typed string, containing an IMG DOM Element

Param Type Description
imageLoc string is the URL to access the image.

UploadImageJS.setImage(name)

Will attempt to save the specified image as the Users background image.

Kind: static method of UploadImageJS

Param Type Description
name string is the name of the image you want to set as the background image.

UploadImageJS.unsetImage()

Will query GoPage API's to remove whatever is currently set as the User Image

Kind: static method of UploadImageJS

UploadImageJS.writeUserSettings()

Will allow an easy way of writing to user settings and setting up an error callback

Kind: static method of UploadImageJS