Skip to content

Latest commit

 

History

History
1130 lines (734 loc) · 35.1 KB

fire.user.md

File metadata and controls

1130 lines (734 loc) · 35.1 KB

fire

FIRE's global object.


fire.metaData

The userscript's metadata

Kind: static property of fire
Access: public


fire.api

The userscript's api urls and keys

Kind: static property of fire
Access: public


fire.clickHandlers

Click handlers for the settings window.

Kind: static constant of fire
Access: private


clickHandlers.requestToken()

Open the "Request authorization" MetaSmoke page.

Kind: static method of clickHandlers
Access: private


clickHandlers.saveToken(input, callback)

Request a token from the MetaSmoke code.

Kind: static method of clickHandlers
Access: private

Param Type Description
input object The input DOM node that contains the code.
callback function The callback that receives the MetaSmoke code.

clickHandlers.disableReadonly()

Close all popup windows and open the "Request write token" popup.

Kind: static method of clickHandlers
Access: private


fire.requestStackExchangeToken()

requestStackExchangeToken - Request a Stack Exchange Write token for this app.

Kind: static method of fire
Access: private


fire.checkHashForWriteToken()

checkHashForWriteToken - Check the url hash to see if a write token has been obtained. If so, parse it.

Kind: static method of fire
Access: private


fire.checkWriteTokenSuccess()

checkWriteTokenSuccess - Check if the write token was successfully obtained.

Kind: static method of fire
Access: private


fire.getDataForUrl(reportedUrl, callback)

getDataForUrl - Loads MetaSmoke data for a specified post url.

Kind: static method of fire
Access: private

Param Type Description
reportedUrl string The url that's been reported.
callback singleReportCallback An action to perform after the report is loaded.

fire.listHasCurrentUser(flags)boolean

listHasCurrentUser - Checks if the list of users on this flag report contains the current user.

Kind: static method of fire
Returns: boolean - true if the current user is found in the flag list.
Access: private

Param Type Description
flags object A report's (auto-)flags, where it's users array has to be checked.

fire.loadDataForReport(openAfterLoad)

loadDataForReport - Loads a report's data when you hover over the FIRE button.

Kind: static method of fire
Access: private

Param Type Description
openAfterLoad boolean Open the report popup after load?

fire.updateReportCache()

updateReportCache - Loads all MS data on the page.

Kind: static method of fire
Access: private


fire.parseDataForReport(data, openAfterLoad, $this, skipLoadPost)

parseDataForReport - Parse a report's loaded data.

Kind: static method of fire
Access: private

Param Type Description
data object A MetaSmoke report
openAfterLoad boolean Open the report popup after load?
$this object The clicked FIRE report button
skipLoadPost boolean skip loading additional data fot the post?

fire.parseSiteUrl(url)string

parseSiteUrl - Parse a site url into a api parameter.

Kind: static method of fire
Returns: string - The Stack Exchange API name for the report's site.
Access: private

Param Type Description
url string A report's Stack Exchange link

fire.loadStackExchangeSites()

loadStackExchangeSites - Loads a list of all Stack Exchange Sites.

Kind: static method of fire
Access: private


fire.loadPost(report)

loadPost - Loads additional information for a post, from the Stack exchange API.

Kind: static method of fire
Access: private

Param Type Description
report object The MetaSmoke report.

fire.loadPostRevisions(report)

loadPostRevisions - Loads a post's revision history from the Stack Exchange API.

Kind: static method of fire
Access: private

Param Type Description
report object The MetaSmoke report.

fire.showEditedIcon()

showEditedIcon - Render a "Edited" icon on a opened report popup.

Kind: static method of fire
Access: private


fire.showReputation(reputation)

showReputation - Shows a user's reputation in the report.

Kind: static method of fire
Access: private

Param Type Description
reputation number The user's reputation.

fire.loadPostFlagStatus(report)

loadPostFlagStatus - Loads a post's flagging status from the Stack Exchange API.

Kind: static method of fire
Access: private

Param Type Description
report object The MetaSmoke report.

fire.loadCurrentSEUser([page])

loadPostFlagStatus - Loads the current Stack Exchange user and what sites they're registered at from the Stack Exchange API.

Kind: static method of fire
Access: private

Param Type Default Description
[page] number 1 the page to load.

fire.parseUserResponse(response, page)

parseUserResponse - Parse the user response.

Kind: static method of fire
Access: private

Param Type Description
response object the Stack Exchange user response.
page number The page that's been loaed.

fire.getSE(method, parameters, success, error, always)

getSE - GET call on the Stack Exchange API.

Kind: static method of fire
Access: private

Param Type Description
method string The Stack Exchange api method.
parameters object The parameters to be passed to the Stack Exchange api.
success function The success callback.
error function The error callback.
always function The always callback.

fire.stackExchangeAjaxCall(method, parameters, config)jqXHR

stackExchangeAjaxCall - Perform an AJAX call on the Stack Exchange API.

Kind: static method of fire
Returns: jqXHR - The jqXHR Promise.
Access: private

Param Type Description
method string The Stack Exchange api method.
parameters object The parameters to be passed to the Stack Exchange api.
config object The AJAX call configuration object, containing:
config.call function The jquery AJAX call to use.
config.success function The success callback.
config.error function The error callback.
config.always function The always callback.

fire.getWriteToken([callback])

getWriteToken - Gets a MetaSmoke write token.

Kind: static method of fire
Access: private

Param Type Description
[callback] function A optional function to run after the write token was obtained.

fire.chatListener(message)

chatListener - Chat message event listener. If SmokeDetector reports another post, decorate the message.

Kind: static method of fire
Access: private

Param Type Description
message object The received message, containing:
message.event_type number The message type
message.user_id number The message's userID
message.message_id number The message ID

fire.decorateMessage(message)

decorateMessage - Adds the "FIRE" button to the passed message.

Kind: static method of fire
Access: public

Param Type Description
message object The message DOM node the button should be added to.

fire.filterOnContents($object, text)object

filterOnContents - Filter a jQuery list on the element text.

Kind: static method of fire
Returns: object - The filtered list
Access: private

Param Type Description
$object object A jQuery list of DOM elements
text string The text the element should contain.

fire.toastrPositionChangeHandler()

toastrPositionChangeHandler - Set the toastr position class.

Kind: static method of fire
Access: private


fire.toastrDurationHandler()

toastrDurationHandler - Update the toastr popup duration.

Kind: static method of fire
Access: private


fire.blurOptionClickHandler()

blurOptionClickHandler - Set the "Blur" option for the popup modal.

Kind: static method of fire
Access: private


fire.flagOptionClickHandler()

flagOptionClickHandler - Set the "Flag" option for "tpu-" feedback.

Kind: static method of fire
Access: private


fire.debugOptionClickHandler()

debugOptionClickHandler - Set the "Debug" option to show logs in the dev console.

Kind: static method of fire
Access: private


fire.imageOptionClickHandler()

imageOptionClickHandler - Set the "HideImages" option to hide or show images in reports.

Kind: static method of fire
Access: private


fire.boolOptionClickHandler(element, message, key, [callback])

boolOptionClickHandler - Set a boolean option after a setting checkbox was clicked.

Kind: static method of fire
Access: private

Param Type Description
element object The `input[type=checkbox]`` DOM node that was clicked.
message string The message to show.
key string The setting key to save.
[callback] function A optional callback.

fire.keyboardShortcuts(e)

keyboardShortcuts - Handle keypress events for the popup.

Kind: static method of fire
Access: private

Param Type Description
e object the jQuery keyboard event

fire.openReportPopupForMessage(message)

openReportPopupForMessage - Opens a report popup for a specific message.

Kind: static method of fire
Access: public

Param Type Description
message object The message DOM node the report should be opened for.

fire.writeTokenPopup(callback)

writeTokenPopup - Open a popup to enter the write token.

Kind: static method of fire
Access: private

Param Type Description
callback function The action to perform after getting a write token / chosing read-only mode.

fire.openReportPopup()

openReportPopup - Build a report popup and show it.

Kind: static method of fire
Access: private


fire.openSettingsPopup()

openSettingsPopup - Opens a popup to change fire's settings.

Kind: static method of fire
Access: private


fire.closePopup()object

closePopup - Close the popup.

Kind: static method of fire
Returns: object - The previously closed popup's button (if any) so it can be re-opened.
Access: private


fire.getPopupLeft()number

getPopupLeft - Gets the left position for the popup.

Kind: static method of fire
Returns: number - The left position for the popup.
Access: private


fire.postMetaSmokeFeedback(data, verdict, button)

postMetaSmokeFeedback - Submit MetaSmoke feedback.

Kind: static method of fire
Access: private

Param Type Description
data object The report data.
verdict string The chosen verdict.
button object The clicked button.

fire.postMetaSmokeSpamFlag(data, api, token, feedbackSuccess)undefined

postMetaSmokeSpamFlag - Flag the post as spam.

Kind: static method of fire
Returns: undefined - returns undefined to break out of the function.
Access: private

Param Type Description
data object The report data.
api object API configuration object, containing:
api.url string The API url.
api.key string The API key.
token string The MetaSmoke write token.
feedbackSuccess object A jQuery DOM node containing the feedback success message.

fire.keyCodesToArray(keyCodes)array.number

keyCodesToArray - Structure the keyCodes Array.

Kind: static method of fire
Returns: array.number - An array of keyCodes mapped from the input chars / keyCodes.
Access: private

Param Type Description
keyCodes number | string | array An number, string, or array of numbers or strings containing keys or keycodes.

fire.createFeedbackButton(data, keyCodes, text, verdict, tooltip)object

createFeedbackButton - Create a feedback button for the top of the popup.

Kind: static method of fire
Returns: object - The constructed feedback button.
Access: private

Param Type Description
data object the report data.
keyCodes number | string | array The keyCodes to use for this button.
text string The text to display for this button.
verdict string This button's MetaSmoke verdict
tooltip string The tooltip to display for this button.

fire.createCloseButton(clickHandler)object

createCloseButton - Create a button to close a popup.

Kind: static method of fire
Returns: object - The constructed "close" button.
Access: private

Param Type Description
clickHandler function The button's click handler.

fire.createSettingsCheckBox(id, value, handler, labelText, headerText)object

createSettingsCheckBox - Creates a input[type=checkbox] for the settings.

Kind: static method of fire
Returns: object - The constructed settings checkbox.
Access: private

Param Type Description
id string The option's name.
value boolean The option's current value.
handler function The option's click handler.
labelText string The text to show next to the checkbox.
headerText string The header to show above the checkbox.

fire._(tagName, [cssClass], [options])object

_ - Wrapper to create a new element with a specified class.

Kind: static method of fire
Returns: object - A jQuery DOM node.
Access: private

Param Type Description
tagName string The tag to create.
[cssClass] string The tag's css class. Optional. If this is an object, this is assumed to be options.
[options] object The options to use for the created element.

fire.br()object

br - Create a linebreak.

Kind: static method of fire
Returns: object - A jQuery <br /> DOM node.
Access: private


fire.span(contents)object

span - Create a <span> with the specified contents.

Kind: static method of fire
Returns: object - A jQuery <span> DOM node with the specified contents.
Access: private

Param Type Description
contents object A jQuery DOM node to use insert into the span.

fire.button(text, clickHandler)object

button - Create a button.

Kind: static method of fire
Returns: object - A jQuery <button> DOM node.
Access: private

Param Type Description
text string The button's text
clickHandler function The button's click handler.

fire.hasEmojiSupport()

hasEmojiSupport - Detect Emoji support in this browser.

Kind: static method of fire
Access: private


fire.emojiOrImage(emoji, [large])object

emojiOrImage - Returns the emoji if it's supported. Otherwise, return a fallback image.

Kind: static method of fire
Returns: object - A jQuery <span> DOM node with the specified emoji as string or image.
Access: private

Param Type Default Description
emoji string The emoji to render
[large] boolean false Make it large?

fire.injectExternalScripts()

injectExternalScripts - Inject FIRE stylesheet and Toastr library.

Kind: static method of fire
Access: private


fire.injectCSS(path)

injectCSS - Inject the specified stylesheet.

Kind: static method of fire
Access: private

Param Type Description
path string The path to the CSS file.

fire.injectScript(name, path, [callback], [always])

injectScript - Inject the specified script.

Kind: static method of fire
Access: private

Param Type Description
name string The global name to check against before injecting the script. Exapme: (typeof myInjectedGlobal)
path string The script's path.
[callback] function An optional "success" callback.
[always] function An optional "always" callback.

fire.loadToastrCss()

loadToastrCss - Load toastr css.

Kind: static method of fire
Access: private


fire.initializeToastr()

initializeToastr - Set toastr options.

Kind: static method of fire
Access: private


fire.registerOpenLastReportKey()

registerOpenLastReportKey - Open the last report on [Ctrl]+[Space].

Kind: static method of fire
Access: private


fire.registerAnchorHover()

registerAnchorHover - Register the "tooltip" hover for anchor elements.

Kind: static method of fire
Access: private


fire.registerWebSocket()

registerWebSocket - Register a websocket listener.

Kind: static method of fire
Access: private


fire.registerForLocalStorage(object, key, localStorageKey)

registerForLocalStorage - Adds a property on fire that's stored in localStorage.

Kind: static method of fire
Access: private

Param Type Description
object object The object to register the property on.
key string The key to use on the object.
localStorageKey string The key to use in localStorage.

fire.registerLoggingFunctions()

registerLoggingFunctions - Registers logging functions on fire.

Kind: static method of fire
Access: private


fire.showFireOnExistingMessages()

showFireOnExistingMessages - Adds the "FIRE" button to all existing messages and registers an event listener to do so after "load older messages" is clicked.

Kind: static method of fire
Access: private


fire.decorateExistingMessages(timeout)

decorateExistingMessages - Decorate messages that exist on page load.

Kind: static method of fire
Access: private

Param Type Description
timeout number The time to wait before trying to decorate the messages.

fire.getLogger(fn)function

getLogger - Gets a log wrapper for the specified console function.

Kind: static method of fire
Returns: function - A fire-wrapped console function.
Access: private

Param Type Description
fn function the console function to wrap in a debug condition.

fire.socketOnMessage(message)

socketOnMessage - Handle socket messages.

Kind: static method of fire
Access: private

Param Type Description
message object The socket message.

fire.expandLinksOnHover()

expandLinksOnHover - Expands anchor elements in the report's body on hover, to show the href.

Kind: static method of fire
Access: private


fire.initLocalStorage(hOP, defaultStorage)

initLocalStorage - Initializes localStorage.

Kind: static method of fire
Access: private

Param Type Description
hOP function Object.hasOwnProperty bound securely.
defaultStorage objects localStorage's default settings.

fire.setValue(key, value)

setValue - Sets a value on fire.userData, stored in localStorage.

Kind: static method of fire
Access: private

Param Type Description
key string the localStorage key.
value object the value to set.

fire.clearValue(key)

clearValue - Removes a value from fire.userData, stored in localStorage

Kind: static method of fire
Access: private

Param Type Description
key string the localStorage key.

fire.getCurrentChatUser()

getCurrentChatUser - Gets the currently logged-in user.

Kind: static method of fire
Access: private


fire.getFireConstants()object

getFireConstants - Gets constants to be used in fire.

Kind: static method of fire
Returns: object - FIRE's constants
Access: private


fire~singleReportCallback : function

This is a callback that is passed a single report's data.

Kind: inner typedef of fire

Param Type Description
reportData object The data for the loaded report.