The 6th generation of my works, project F (foxtrot).
See also Eday for the 5th generation of my works.
It's very simple
// app namespace website as https://github.com/force-website
const app=(new Force).app('website','https://9r3i.github.io/force-website');
app.init();
Force is defined as constant function
in global scope. Force must be called as class to use its methods and properties, just like this sample.
const force = new Force();
version
string of Force release version (readonly)host
string of ForceServer host to fetch APIpkey
string of privilage key, given by ForceServer as logged inloadedApp
object of loaded app, after app commitinit
plugin
object of Force app plugins set, See plugin object section
-
app
function of app initialization, See app method section -
get
promise function to fetch data without host, parameters:url
string of urlupl
function of upload progress callbackdnl
function of download progress callbackdta
object of data to be queried in url
-
fetch
function of xhr to fetch some data from initial host with ForceServer default method, parameters:mt
string of method of object class; *requireddt
object of data requestcf
object of other configs, as the following:method
string of request method; default:POST
host
string of host (overwrite this.host)headers
object of headersupload
function of upload callbackdownload
function of download callbackunderfour
function of underfour callback
-
post
function of xhr stream, parameters:mt
string of method of object class; *requiredcb
function of callbackdt
object of data requestcf
object of other configs, as the following:method
string of request method; default:POST
host
string of hostheaders
object of headersupload
function of upload callbackdownload
function of download callbackunderfour
function of underfour callback
-
alert
promise function of alert dialog. This is just likewindow.alert
but in DOM scope. *requiresdialogCSS
to initialize the style, parameters:text
string of text to print in alert dialog
-
confirm
promise function of confirm, seealert
, parameters:text
string of text to print in alert dialog
-
prompt
promise function of prompt, seealert
, parameters:text
string of text to print in alert dialogdef
string of default text value
-
dialogAlert
function of alert, this is non-promise version of thealert
method, parameters:text
string of text to print in alert dialogcb
function of callback
-
dialogConfirm
function of confirm, this is non-promise version of theconfirm
method, parameters:text
string of text to print in alert dialogcb
function of callback
-
dialogPrompt
function of prompt, this is non-promise version of theprompt
method, parameters:text
string of text to print in alert dialogcb
function of callbackdef
string of default text valuetype
string of input type; default:text
holder
string of input placeholder
-
virtualFileClearance
function of clearance. This method is an event-listener totouchmove
of 3 fingers. Then it's gonna ask toconfirm
the clearance of all virtual files. -
dialog
function of tiny dialog, parameters:text
string of text message; *requiredhold
bool of holding to show; default:false
title
string of dialog title; default: Alertoktext
string of ok text button; default: OKbgtap
bool of background tap to close; default:false
This
dialog
method will return the dialog element with special methods:-
close
function of close the dialog -
show
function of show the dialog, it wouldn't be necessary if parameterhold
set tofalse
-
addButton
function of adding a button, parameters:cb
function of callback when the button clickedbtext
string of button text; default: Submitclr
string of button color, available indialogCSS
; default: blue
-
addInput
function of adding input, parameters:cb
function of callback when the button clickeddef
string of default input texttype
string of input type; default: textholder
string of input placeholder
Note: This
addInput
method will automatically useaddButton
as submit, that's why the callback parameter is needed.
-
splash
function of splash message, this method requiresloaderCSS
, parameters:str
mixed of splash messaget
int of time message appears in second; default: 3limit
int of nestedparseJSON
limit; default: 1
-
parseJSON
function of json parse to string, parameters:obj
mixed of object to be parsed to the stringlimit
int of nested limit; default: 1space
int of space white-break; auto; default: 0pad
int of white-break padding per line; default: 2
-
stream
function of basic xhr stream, parameters:url
string of urlcb
function of success callback of response code 200er
function of error callbackdt
object of data formhd
object of headersul
function of upload progressdl
function of download progressmt
string of methodud4
function of under-four ready-state
-
onFunctionReady
function of ready callback, parameters:fn
string of function namecb
function of callbackcr
int of auto-generate progress
-
virtualFile
function of storing virtual file, parameters:f
string of filename, orfalse
to clear all virtual filesc
string of content, orfalse
to delete it
This
virtualFile
method is working different,- clear wipe all virtual files
this.virtualFile(false);
- get get a virtual file content
this.virtualFile('filename.txt');
- set set a virtual file with content
this.virtualFile('filename.txt','content');
- delete delete a virtual file
this.virtualFile('filename.txt',false);
-
isScriptLoaded
function of checking script that was loaded byloadScript
orloadScriptFile
, parameters:f
string of file ID
-
loadScriptFile
function of script loading, parameters:f
string of file, full with path
-
loadScript
function of script loading by string, parameters:s
string of script contenti
string of script ID
-
loadStyleFile
function of style loading, parameters:f
string of file, full with path
-
loadStyle
function of style loading by string, parameters:s
string of style contenti
string of style ID
-
loadModuleFile
function of module loading, parameters:f
string of file, full with path
-
loadModule
function of module loading by string, parameters:s
string of module contenti
string of module ID
-
clearElement
function of clearing element, parameters:el
object of DOM element
-
buildElement
function of element building, parameters:tag
string of tag nametext
string of text used byinnerText
attr
object of attribute used bysetAttribute
children
array of children elementshtml
string of html used byinnerHTML
content
string of content used bytextContent
-
buildQuery
function of url query builer, parameters:data
object of datakey
string of key; auto-generate
-
parseQuery
function of url query parser, parameters:t
string of url query
-
objectLength
function of object length counter, parameters:obj
object of data to be counted
-
loader
function of loader, this method requiresloaderCSS
, parameters:text
string of loader text, orfalse
to turn it offinfo
string of loader informationvalue
int of current value of progressmax
int of maximum value of progress
-
loaderCSS
function of loader and splash style builder -
dialogCSS
function of dialog style builder -
fontCSS
function of font style string output -
absorbEvent
function of absorbing event, parameters:event
object of event itself
-
temp
function of temporary callback, parameters:cb
function of the callback
This method is to initialize an app, parameters:
ns
string of app namespace (required)root
string of app root; default: apps (local)config
mixed of config for inner app (optional)
This app
method has an output as object, properties:
root
string of app rootnamespace
string of app namespaceconfig
string of app configForce
object of Force object
And methods:
init
async function of initialize of app objectcacheExpired
function of cache expiration checking
Some of app is very simple to call, like this sample:
const app=(new Force).app(<app_namespace>);
await app.init();
This property is special, object plugin to help loaded app fulfill its goal.
root
string of plugin root; default: plugins (local)plug
array of namespaces that has been registeredparam
object of registered plugin parameterhosts
object of registered plugin hostForce
object of Force objectconfig
object of Force config of cache
register
function of registering a plugin or more to be registered, return this self plugin object, parameters:ns
string of plugin namespace, or array of plugins setpr
mixed of plugin parametershost
string of plugin host
cacheExpired
function of cache expiration checkingprepare
async function of plugins preparation to prepare all registered plugins with process, return this self plugin object, parameters:root
string of plugin root or hostcb
function of progress callback
init
function of initialization to initialize all prepared plugins, return this self plugin object
That's all there is to it. Alhamdulillaah...