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();versionstring of Force release version (readonly)hoststring of ForceServer host to fetch APIpkeystring of privilage key, given by ForceServer as logged inloadedAppobject of loaded app, after app commitinitpluginobject of Force app plugins set, See plugin object section
-
appfunction of app initialization, See app method section -
getpromise function to fetch data without host, parameters:urlstring of urluplfunction of upload progress callbackdnlfunction of download progress callbackdtaobject of data to be queried in url
-
fetchfunction of xhr to fetch some data from initial host with ForceServer default method, parameters:mtstring of method of object class; *requireddtobject of data requestcfobject of other configs, as the following:methodstring of request method; default:POSThoststring of host (overwrite this.host)headersobject of headersuploadfunction of upload callbackdownloadfunction of download callbackunderfourfunction of underfour callback
-
postfunction of xhr stream, parameters:mtstring of method of object class; *requiredcbfunction of callbackdtobject of data requestcfobject of other configs, as the following:methodstring of request method; default:POSThoststring of hostheadersobject of headersuploadfunction of upload callbackdownloadfunction of download callbackunderfourfunction of underfour callback
-
alertpromise function of alert dialog. This is just likewindow.alertbut in DOM scope. *requiresdialogCSSto initialize the style, parameters:textstring of text to print in alert dialog
-
confirmpromise function of confirm, seealert, parameters:textstring of text to print in alert dialog
-
promptpromise function of prompt, seealert, parameters:textstring of text to print in alert dialogdefstring of default text value
-
dialogAlertfunction of alert, this is non-promise version of thealertmethod, parameters:textstring of text to print in alert dialogcbfunction of callback
-
dialogConfirmfunction of confirm, this is non-promise version of theconfirmmethod, parameters:textstring of text to print in alert dialogcbfunction of callback
-
dialogPromptfunction of prompt, this is non-promise version of thepromptmethod, parameters:textstring of text to print in alert dialogcbfunction of callbackdefstring of default text valuetypestring of input type; default:textholderstring of input placeholder
-
virtualFileClearancefunction of clearance. This method is an event-listener totouchmoveof 3 fingers. Then it's gonna ask toconfirmthe clearance of all virtual files. -
dialogfunction of tiny dialog, parameters:textstring of text message; *requiredholdbool of holding to show; default:falsetitlestring of dialog title; default: Alertoktextstring of ok text button; default: OKbgtapbool of background tap to close; default:false
This
dialogmethod will return the dialog element with special methods:-
closefunction of close the dialog -
showfunction of show the dialog, it wouldn't be necessary if parameterholdset tofalse -
addButtonfunction of adding a button, parameters:cbfunction of callback when the button clickedbtextstring of button text; default: Submitclrstring of button color, available indialogCSS; default: blue
-
addInputfunction of adding input, parameters:cbfunction of callback when the button clickeddefstring of default input texttypestring of input type; default: textholderstring of input placeholder
Note: This
addInputmethod will automatically useaddButtonas submit, that's why the callback parameter is needed.
-
splashfunction of splash message, this method requiresloaderCSS, parameters:strmixed of splash messagetint of time message appears in second; default: 3limitint of nestedparseJSONlimit; default: 1
-
parseJSONfunction of json parse to string, parameters:objmixed of object to be parsed to the stringlimitint of nested limit; default: 1spaceint of space white-break; auto; default: 0padint of white-break padding per line; default: 2
-
streamfunction of basic xhr stream, parameters:urlstring of urlcbfunction of success callback of response code 200erfunction of error callbackdtobject of data formhdobject of headersulfunction of upload progressdlfunction of download progressmtstring of methodud4function of under-four ready-state
-
onFunctionReadyfunction of ready callback, parameters:fnstring of function namecbfunction of callbackcrint of auto-generate progress
-
virtualFilefunction of storing virtual file, parameters:fstring of filename, orfalseto clear all virtual filescstring of content, orfalseto delete it
This
virtualFilemethod 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);
-
isScriptLoadedfunction of checking script that was loaded byloadScriptorloadScriptFile, parameters:fstring of file ID
-
loadScriptFilefunction of script loading, parameters:fstring of file, full with path
-
loadScriptfunction of script loading by string, parameters:sstring of script contentistring of script ID
-
loadStyleFilefunction of style loading, parameters:fstring of file, full with path
-
loadStylefunction of style loading by string, parameters:sstring of style contentistring of style ID
-
loadModuleFilefunction of module loading, parameters:fstring of file, full with path
-
loadModulefunction of module loading by string, parameters:sstring of module contentistring of module ID
-
clearElementfunction of clearing element, parameters:elobject of DOM element
-
buildElementfunction of element building, parameters:tagstring of tag nametextstring of text used byinnerTextattrobject of attribute used bysetAttributechildrenarray of children elementshtmlstring of html used byinnerHTMLcontentstring of content used bytextContent
-
buildQueryfunction of url query builer, parameters:dataobject of datakeystring of key; auto-generate
-
parseQueryfunction of url query parser, parameters:tstring of url query
-
objectLengthfunction of object length counter, parameters:objobject of data to be counted
-
loaderfunction of loader, this method requiresloaderCSS, parameters:textstring of loader text, orfalseto turn it offinfostring of loader informationvalueint of current value of progressmaxint of maximum value of progress
-
loaderCSSfunction of loader and splash style builder -
dialogCSSfunction of dialog style builder -
fontCSSfunction of font style string output -
absorbEventfunction of absorbing event, parameters:eventobject of event itself
-
tempfunction of temporary callback, parameters:cbfunction of the callback
This method is to initialize an app, parameters:
nsstring of app namespace (required)rootstring of app root; default: apps (local)configmixed of config for inner app (optional)
This app method has an output as object, properties:
rootstring of app rootnamespacestring of app namespaceconfigstring of app configForceobject of Force object
And methods:
initasync function of initialize of app objectcacheExpiredfunction 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.
rootstring of plugin root; default: plugins (local)plugarray of namespaces that has been registeredparamobject of registered plugin parameterhostsobject of registered plugin hostForceobject of Force objectconfigobject of Force config of cache
registerfunction of registering a plugin or more to be registered, return this self plugin object, parameters:nsstring of plugin namespace, or array of plugins setprmixed of plugin parametershoststring of plugin host
cacheExpiredfunction of cache expiration checkingprepareasync function of plugins preparation to prepare all registered plugins with process, return this self plugin object, parameters:rootstring of plugin root or hostcbfunction of progress callback
initfunction of initialization to initialize all prepared plugins, return this self plugin object
That's all there is to it. Alhamdulillaah...