Home Reference Source Repository
public class | source

Utils

You can directly use instance of this class. utils

Utils class, holds all convenience methods for project.

Static Method Summary

Static Public Methods
public static
public static
public static
public static
public static
public static
public static

Clear the local cache for the current page

public static

setFileInCache(fileId: string, visibilityBool: boolean): *

public static

store the current time as the lastViewed in page local cache

public static

Toggle visibility and return the new visibility state of the element

public static

Static Public Methods

public static addToggleButtonForElement(element: HTMLElement): jQuery source

Params:

NameTypeAttributeDescription
element HTMLElement

File container from pull page.

Return:

jQuery

jQuery div containing the diff for the file.

public static getCachedCommitNumber(): number source

Return:

number

number of commits as cached, 0 if never viewed before

public static getCachedFiles(): Object<string, boolean> source

Return:

Object<string, boolean>

the ID of each diff and it's visibility bool.

public static getKeyIdFromEvent(clickEvent: MouseEvent): string source

Params:

NameTypeAttributeDescription
clickEvent MouseEvent

Click event from a file's action bar.

Return:

string

ID of the file from the file's Github page.

public static getLastViewed(): number source

Return:

number

Unix timestamp of the last time the page was viewed, -1 if no value is cached.

public static getPageCache(): Object source

Return:

Object

Namespaced cache from page specific storage

public static resetCacheForPage(): undefined source

Clear the local cache for the current page

Return:

undefined

public static setFileInCache(fileId: string, visibilityBool: boolean): * source

Params:

NameTypeAttributeDescription
fileId string

file id to be stored

visibilityBool boolean

true if the file should be visible on page load. false if the file should be hidden

Return:

*

public static setLastViewed() source

store the current time as the lastViewed in page local cache

public static toggleVisibility(fileContent: jQuery): boolean source

Toggle visibility and return the new visibility state of the element

Params:

NameTypeAttributeDescription
fileContent jQuery

jQuery div containing the diff for the file.

Return:

boolean

true if the file should be visible on page load. false if the file should be hidden.

public static updateLocalStorage(key: string, value: object): boolean source

Params:

NameTypeAttributeDescription
key string

key for cached pair

value object

value for the cached pair

Return:

boolean

true if the value was saved.