Helper functions on the window.FW
object are used for a variety of different things. They are added to window.FW
in index.js and are defined in the helpers folder.
This page is not yet complete.
find #
FW.find
(String
: str, String
: attribute = 'slug') ⇒ Object
or undefined
Uses Array.prototype.find() to return the first page in FW.state.p.pages
whose attribute
has the value str
.
View Source
gen #
FW.gen
(Object
: state) ⇒ String
Given a FW.state
object, return the full HTML of the current Feather Wiki that is used to save a new file.
getChildList #
FW.getChildList
(Object
: page, Boolean
: collapse) ⇒ HTMLElement
Returns an li
HTMLElement that contains the provided page
's name
attribute and a nested unordered list (ul
) of its children if it has any.
If collapse == true
(as is the case with the Pages tab in the menu), then a details
tag is used instead of ul
, and Feather Wiki will store the id
s of pages that were expanded in FW.state.sbx
. If the current page is nested below other pages, then all of the parent pages leading down to the current child will be expanded by default.
View Source
getChildren #
FW.getChildren
(Object
: page) ⇒ Array<Object>
Uses Array.prototype.filter() to return an array of pages from FW.state.p.pages
whose parent
attribute matches the provided page
's id
attribute.
View Source
getPage #
FW.getPage
() ⇒ Object
or undefined
Gets the current page based on the current FW.state.query.page
value if there is one (i.e. the ?page=slug
portion of the URL) or the currently set home page if not set. If no home page is set or the slug in FW.state.query.page
is not found, undefined
is returned.
View Source
hash #
Object | FW.hash
provides functions for getting simple hashes of values.
hash.object #
FW.hash.object
(Object
: obj) ⇒ String
hash.string #
FW.hash.string
(String
: str) ⇒ String
img #
Object | FW.img
provides functions for manipulating image HTML within the wiki.
img.abbr #
FW.img.abbr
(String
: content) ⇒ String
Truncate image using its stored ID instead
img.fix #
FW.img.fix
(String
: content, Boolean
: not) ⇒ String
Restore image HTML after using it stored mangling (or mangle it if not
)
img.put #
FW.img.put
(Event
: e, Object
: i, Function
: ins = () => {}) ⇒ void
Given form event e
and stored image data i
, do ins()
img.resizeImage #
FW.img.resizeImage
()
Adapted from https://gist.github.com/ORESoftware/ba5d03f3e1826dc15d5ad2bcec37f7bf
img.upload #
FW.img.upload
(Object
: state, Function
: ins = () => {}) ⇒ void
Uploads and resizes an image and put it into FW.state.p.img
with the image hash as its key.
inject #
FW.inject
json #
FW.json
missing #
FW.missing
parseJs #
FW.parseJs
tidy #
FW.tidy
upload #
FW.upload
xtr #
FW.xtr