yss js functions - yOyOeK1/oiyshTerminal GitHub Wiki
- mApp. for fast touche GUI - jQuery Mobile in yss
- mDoCmd. for communication with tools and bash from any layer ( stdout / stdin )
- otdmDriverProto.py indepth explenation / documentation - coder edition
- otdmDriverWebCmdSubProcess.py indepth explenation / documentation - coder edition
- pager. for doing some magic.. with your yss
- for Three.js sites to help with animation taskers
- for Three.js sites give console renderer and other ingo use on screen ? key
- for Three.js sites puts text / OSD
- for Three.js sites invert / red black / postprocessor
- t4y. for Three.js sites with .obj .stl .gbl files
- example ( Make your site ) - yss site .svg base data from mqtt
mApp is a helper from oiyshTerminal family - Main class
This one is helping with holding mobile look of your site. Powerd by jQuery Mobile is nice for fingers gui. Fast Big Buttons is what I need when I'm writing. I don't wast to do back button! This class is doing all for you. In area of simple gui for mobile. use in: yss-otdm, yss-packitso, yss-multisvg
Kind: global class
-
mApp
-
.appFrame ⇒
string
-
.makeNiceList ⇒
string
-
.lvElement ⇒
string
-
.lvBuild ⇒
string
-
.appFrame ⇒
function returns Basic Frame of a page. if needed back or goTo button is there to use
Kind: instance namespace of mApp
Returns: string
- to put it for example as $('#htmlDyno').html( returnStr )
;
Param | Type | Description |
---|---|---|
args | json |
to set up thinks in frame. |
Properties
Name | Type | Description |
---|---|---|
args | json |
The default values for frame arguments |
args.goTo | string |
if set then past to pager.goToByHash(goTo) to move without reloading |
args.backButton | string |
if set then past to onclick="backButton"
|
args.title | string |
to put page header title |
args.content | string |
to put your content in frame |
Example
$("#htmlDyno").html( mApp2.appFrame({
"content":"Hello world",
"goTo": "pager.goToByHash('pageByName=test functions')"
}) );
will put in htmlDymo div html element App Frame with Hello world in it. bonus go to button to go to test functions page.
wraps data with rule key: <b>val</b></br>
fast !!
Kind: instance namespace of mApp
Returns: string
- ready to put in your div or other place
Param | Type | Description |
---|---|---|
data | dict |
expect dict of keys: vals |
Properties
Name | Type | Description |
---|---|---|
data | dict |
|
data['key' | string |
key is a name to use as description of a value |
data.key | string |
value to display strong |
to make your stuff in lightning speed wrap your data to nice stuff.
Kind: instance namespace of mApp
Returns: string
- to put it for example as $('#htmlDyno').html( returnStr )
;
Param | Type | Description |
---|---|---|
head | string |
set head of list view item |
content |
string | json
|
if {string} then put as content of item |
link | string |
[''=DefultValue] - not set link at all or if set put <a href="#" noclick="link"... over all item |
Properties
Name | Type | Description |
---|---|---|
content | object |
set more custome things like |
content.img | string |
url for image to put on left of item |
content.content |
string | dict
|
put it as content or if {dict} set do automaticly a list of parameters in item. it will make key: <strong>value</strong>
|
content.tip |
string | dict
|
set head tip cloud in right top corner of item |
content.class | string |
set extra class at <h2 class=".. try ui-body-b
|
content.content | object |
if is dict then do expect that is a {"key":1,"index":23} |
content.content | dict |
if dictionary then use rule key: <strong>val</strong><br>
|
content.tip | dict |
if dictionary then use rule key: <strong>val</strong><br>
|
Example
tr+= this.app.lvBuild({
"header": "files in directory:",
"headerTip": items.length,
"items": items
});
A fast way to get consistance look
Build in easy way list view customizable and fast touch freandly!
Kind: instance namespace of mApp
Returns: string
- to put it for example as $('#htmlDyno').html( returnStr )
;
Param | Type | Description |
---|---|---|
data |
string | json
|
if {string} directly element in frame of list view |
Properties
Name | Type | Description |
---|---|---|
data | object |
if {json} set up thinks in list view to build |
data.header | string |
sets header of list view |
data.headerTip | string |
sets header tip / noti info |
data.items |
string | array | json
|
array of Objects mApp.lvElement to list view |
data.searchOn | bool |
[true=DefaultValue] |
Class mDoCmd is a helper from oiyshTerminal family - Main class
Kind: global class
you can make a instace of it to use it to run cmd communication support. It can do command, update on stdout/in , callbacks,.... mqtt and otdm-nrf-yss are making a bridge from bash or otdmTool.py to mqtt. Then using function from this class you can interact with process or only make some bash work.
Check otdmTool.py site otdmDriverWebCmdSubProcess - documentation
To know if still running. true (running..)
Kind: instance property of mDoCmd
To identify current command communication topic
Kind: instance property of mDoCmd
To collect data stdout from cmd from shell
Kind: instance property of mDoCmd
Methode run to command from otdmTools and get result - call back on finish.
Kind: instance method of mDoCmd
Param | Type | Description |
---|---|---|
args | json |
json structure of arguments pass same way as you use otdmTools.py Argument is a key and value is value. |
callBack | object |
can be not set - then only dump to cl( ... ) will pass data , result as arguments |
Example
this.mDoCmd.otdmArgs({
"dfs": "/tmp/abc",
"act": "MKDIR"
},(data,res)=>{cl("ok");});
will console.log out "ok" on done. Example
this.mDoCmd.otdmArgs({
"dfs": "/tmp"
},(data,res)=>{cl(data);});
will console.log out list of files and directories
Methode to run command from bash layer and get live conection with stdin / stdout. It use pH
as a key in creating new mqtt topic to establish trafic. Running process. So you can intercact with thread.
Kind: instance method of mDoCmd
Param | Type | Description |
---|---|---|
cmd | array |
array example:["ls","/tmp"] structure of arguments pass same way as you use otdmTools.py Argument is a key and value is value. |
updateObj | string |
id of html element will update status of app stdout |
callBack | object |
can be not set - then only dump to cl( ... ). Will pass data, result arguments if callBack is set then pass (data ,result ) arguments |
Methode to run command from bash layer and get live conection with stdin / stdout. It use pH
as a key in creating new mqtt topic to establish trafic. Running process. So you can intercact with thread.
Kind: instance method of mDoCmd
Param | Type | Description |
---|---|---|
cmd | string |
example: "df -h |
updateObj | string |
id of html element will update status of app stdout |
cbFunc | object |
can be not set - then only dump to cl( ... ). Will pass data, result arguments if callBack is set then pass (data ,result ) arguments |
Methode to run command from bash layer and get live conection with stdin / stdout. It use pH
as a key in creating new mqtt topic to establish trafic. Running process. So you can intercact with thread. Plast it do exitCode check for you.
Kind: instance method of mDoCmd
Param | Type | Default | Description |
---|---|---|---|
cmd | string |
example: "df -h | |
updateObj | string |
id of html element will update status of app stdout | |
cbFuncOk | object |
calledback on OK exitCode:0 can be not set - then only dump to cl( ... ). Will pass data, result arguments if callBack is set then pass (data ,result ) arguments |
|
cbFuncErr | object |
calledback on Error exitCode:!0 can be not set - then only dump to cl( ... ). Will pass data, result arguments if callBack is set then pass (data ,result ) arguments |
|
rAsJson | bool |
true |
true:default if true return in json if false as it came |
Default callback methode for .otdmArgs
methode on DONE. Will only spit to console.log the result.
Kind: instance method of mDoCmd
Param | Type | Description |
---|---|---|
data | json/string |
json / string tipically if all is ok then get json. |
Methode to update worker live connection is it DONE. Put it in your site onMassageCallBack if you want to update status or run next one. If running not starting text.
Kind: instance method of mDoCmd
Param | Type | Description |
---|---|---|
r | json |
incomming msg from websocket server. it will look for owne topic with pH as key. if done will come sets end of cmdWork to false. |
Default callback methode for .doCmd
methode. Will only spit to console.log the result.
Kind: instance method of mDoCmd
-
toDegrees(rad) ⇒
number
-
function to radian to convert to degrees
-
toRad(angle) ⇒
number
-
function to degrees to convert to radians
-
degToHdg(deg) ⇒
String
-
function to get degrees to "001" 3 char str
-
mMapVal(val, minI, maxI, minO, maxO, inLimits) ⇒
number
-
function to making map in range
- storeIt(key, val, forMs, inLimits)
-
function to store data for later...
-
avgIt(key, forMs, toMs) ⇒
number
-
function to avg it - to avg key value in storage
function to radian to convert to degrees
Kind: global function
Returns: number
- - The degrees
Param | Type | Description |
---|---|---|
rad | number |
The radian to convert to degrees |
function to degrees to convert to radians
Kind: global function
Returns: number
- - The radian
Param | Type | Description |
---|---|---|
angle | number |
The degrees to convert to radian |
function to get degrees to "001" 3 char str
Kind: global function
Returns: String
- - The 3 char degrees "001"
Param | Type | Description |
---|---|---|
deg | number |
The degrees |
function to making map in range
Kind: global function
Returns: number
- - The value with map set ..
Param | Type | Default | Description |
---|---|---|---|
val | number |
The value to convert | |
minI | number |
The minimum on input | |
maxI | number |
The maximum on input | |
minO | number |
The minimum on output | |
maxO | number |
The maximum on output | |
inLimits | bool |
false |
= (def: false) - The maximum on output |
function to store data for later...
Kind: global function
Param | Type | Description |
---|---|---|
key | number |
The key to identyfy this value |
val | number |
The value to store |
forMs | number |
The store for how many ms. |
inLimits | bool |
= (def: false) - The maximum on output |
function to avg it - to avg key value in storage
Kind: global function
Returns: number
- - The avg of key value ..
Param | Type | Description |
---|---|---|
key | number |
The key to identyfy the value in storage |
forMs | number |
The ms of sample to avg |
toMs | number |
The ms o point |
- cl(msg)
-
function to console.log ing.... try to use this one to silence down interface
-
rotateSvgSetRC(objName, objNameRc, ang) ⇒
nothing
-
function to rotate object over center of other object in .svg object by name
-
rotateSvg(objName, haveRotateCenter, ang) ⇒
nothing
-
function to rotate object over center point in .svg object by name
-
moveOnPath(objToMove, objPath, posNormal) ⇒
nothing
-
function to move object over path in .svg object by name
-
putText(objName, text, align, chars) ⇒
nothing
-
function to put text in .svg object by name
function to console.log ing.... try to use this one to silence down interface
Kind: global function
Param | Type | Description |
---|---|---|
msg | string |
The msg to console.log |
function to rotate object over center of other object in .svg object by name
Kind: global function
Returns: nothing
- - Set rotation of object over obejct in .svg on screen
Param | Type | Description |
---|---|---|
objName | string |
The object name in .svg |
objNameRc | stirng |
The object2 name to rotate over it center |
ang | number |
The angle in deg |
function to rotate object over center point in .svg object by name
Kind: global function
Returns: nothing
- - Set rotation of object over obejct in .svg on screen
Param | Type | Description |
---|---|---|
objName | string |
The object name in .svg |
haveRotateCenter | bool |
if true then look for [object name]RC (rotation center) |
ang | number |
The angle in deg |
function to move object over path in .svg object by name
Kind: global function
Returns: nothing
- - Set position of object on the path in .svg on screen
Param | Type | Description |
---|---|---|
objToMove | string |
The object name in .svg to move |
objPath | string |
The object name in .svg to path over |
posNormal | number |
The position on the path 0...1 |
function to put text in .svg object by name
Kind: global function
Returns: nothing
- - Set text to .svg on screen
Param | Type | Description |
---|---|---|
objName | string |
The object name in .svg |
text | string |
The text to put in .svg |
align | string |
The aligment definition [c |
chars | number |
The to limit length |
class otdmDriverProto()
This is a programer documentation for otdmDriverProto. If you want to your owne Driver this is a place to be. It's python code explenation of what is in back of the idea and functions. This one is running in shell layer in python3. More about otdmTools info is comming....
To make tasks simple. Making work will be only by saing what to do but how to make it is Handle by selected corect DriverProto. It know if this work is on http API or file system or mysql database using some selections. Not important :) If you have driverProto for it it is in otdm-
- You can use your driverProto from yss / bash / otdm- instance
- one line tasks any ware
- will do for using in packitso .deb builder
By implementing your DriverProto you can extend options and join the family otdm-
$ otdmTools.py -dfs '/tmp' -oFile '--'
argument dfs if is same as your keyWord your driver will be execute to do the task. -oFile
store data to output file if -- to stdout.
$ otdmTools.py -dfs '/tmp/abc123' -act MKDIR -oFile '--'
-act
is not GET|POST|DELETE it will try your argument in try So you can put your own function handler and argument vector is pass from otdmTool.py
$ tm=`tempfile`;otdmTools.py -forceHost 192.168.43.220 -dnrfByUid "*" \
-oFile ${tm} >> /dev/null
cat ${tm} | jq '.[].id'
force different host then in .otdm/config.json / use Node-RED driver proto / GETAll () to tm
file then jq .id
from result
$ tm=`tempfile`
outTemp='{"name":.name,"path":.fullPath}'
otdmTools.py -dfs "/tmp" -oFile ${tm} >> /dev/null
cat ${tm} | jq '.[] | select( .isFile == false ) | '${outTemp}
Returns only directory from /tmp in array of dicts {"name":.name,"path":.fullPath}
.....
"path": "//tmp/jsdoc-api"
}
{
"name": "pyjsdoc",
"path": "//tmp/pyjsdoc"
}
.....
ver: 0.2.2
It's for inhereting and overriting some of it's function / method.
There is a name restriction for new files otdmDriver
YOURNAME.py
Adding otdmDriver
YOURNAMEProto.py
in name will make skip your file in
plugin init step.
All your driversProto should to extand by otdmDriverProto
nice cmd: python import pdb; pdb.set_trace()
keyWord: string - @overwriteIt important to invoce from arguments from console.
iKey: string - @overwriteIt if want to use driver in packitso
iUid: string - @overwriteIt if want to use driver int packitso
isPackitso: bool - @overwriteIt important to use in packitso only if ready
def __init__(args, conf, name, suffix)
Arguments
- args: dict - with argumens to parse and look for your inputs
- conf: dict - from otdmTools.py instance .otdm/config.json is comming
- name: string - to identyfy in .otdm/config.json
- suffix: string | dict - to pass some args in instance
def getHelp(implemented=0)
@overwriteIt - to set your own help as extra. After the default $ otdmTools.py -h '1'
def getHost()
@overwriteIt - use rest as curl instance for http api HOST:getPort/getSuffix/getApiPath Returns
[string] - host defined from config and iff set handles -forceHost (then call super)
def getPort()
@overwriteIt - use rest as curl instance for http api getHost:PORT/getSuffix/getApiPath Returns
[string] - port defined from config
def getSuffix()
@overwriteIt - use rest as curl instance for http api getHost:getPort/suffix/getApiPath Returns
[string] - suffix defined from self.suffix set on super()
def getApiPath()
@overwriteIt - use rest as curl instance for http api getHost:getPort/getSuffix/path Returns
[string] - suffix defined from config
def getHeaders()
@overwriteIt - if want to make http api with this header or overwriteit
def GETAll()
@overwriteIt - to hendle request of all something like all Returns
[list] - of data some form
def GET(d)
@overwriteIt - to hendle request of single work read Arguments
- d: object - to identyfy your work to get it Returns
[list] - data some form file storable json preffered
def POST(d)
@overwriteIt - to hendle request of single work write / make / execute / do taks Arguments
- d: object - to put in work as data input to work Returns
[json] - to raport status
def DELETE(d)
@overwriteIt - to hendle request of deleting / removing / dropping / eresing something like all Returns
[list] - to raport status
class otdmDriverWebCmdSubProcess(otdmSubProc, otdmDriverProto)
to access it use:
$ otdmTools.py -webCmdSubProcess ......
Web cmd sub precess driverProto brings bash and pips to a game of oiyshTerminal and otdm-tools. It's to run somethin externaly on different instance of otdm-tools or localy but event starting it can be a web page javascript funcion invoque. Or as a element in any of your dayly tasks.
Brings bash layer to web page or Node-red.
For me updating system repository
-stdout
[string] if set then result of command returns to stdout -> -oFile
of subrocess two not only mqtt
$ curl 'http://localhost:1880/yss/?otdmQ:\{"webCmdSubProcess":"\[ls,/tmp,|,grep,313\]","pH":"66","stdhttp":"yes"\}'
to get ls
with 313
words in it, from host localhost. Return [array] of elements. Last element is [int] = -1 (end of process)
$ otdmTools.py -pH "pH84946_91997" -oFile "/tmp/ee.json" -webCmdSubProcess \
'[cat,/data/data/com.termux/files/home/.otdm/config.json,|,jq,"keys in conf: "+keys[],-r]'
Return on mqtt subP/pH84946_91997/line
0:keys in conf: grafana
1:keys in conf: mqtt
2:keys in conf: mysql
3:keys in conf: node-red
4:keys in conf: otdm
This will can
file in bash pipe
it to jq
parse it in jq
add prefix. Result is send to mqtt at subP/pH84946_91997
$ otdmTools.py -webCmdSubProcess "[mplayer,/myMusic.mp3]" -pH "pH93419_" -oFile "--"
This will start mqtt topic
- subP/pH93419_/status - will public starting or done
- subP/pH93419_/line - will give line by line from command
- subP/pH93419_/in - it's a stdin of command so in this example sending p will pause :)
Check: helper on javascript site mDoCmd - documentation
or
# to file result not the subprocess status, cmd running in shell
$ otdmTools.py -pH "pH84" -oFile "/tmp/res11.json" -webCmdSubProcess '[sh,-c,echo "abc" | grep "ab333"; echo $?]' -stdout 1
keyWord webCmdSubProcess
Class sPager is a helper from oiyshTerminal family - Main class
But we should refer to instance pager
Nice!
This one is helping managing sites. Having menu shaders and work with Screens manager. This is only a documentation to help you how to use it to do somethin you want!
Kind: global class
-
sPager
- .setPage(pageNo)
-
.goToByHash(url) ⇒
string
Methode - not recomendet shortest way to set now a different site but not the best. Check .goToByHash()
Kind: instance method of sPager
Param | Type | Description |
---|---|---|
pageNo | integer |
will sec curent site from this.pages[pageNo] to set now |
Kind: instance method of sPager
Returns: string
- correct string to use in onclick="returnValue"
to sustain back in browser. Passing arguments and not reload ish
Param | Type | Description |
---|---|---|
url | string |
in zone of yss |
Example
// clean way to change a page and ads timestamp
// at end as updater to reduce chaching
pager.goToByHash('pageByName=pack it so');
Three.js for yss - animation helper and tasker is accessable by t4y global object. It's a instance of it to use.
methode to animate object in scene
Kind: instance method of T4y_ani
Param | Type | Description |
---|---|---|
itd | object |
The object t4y.otsce.getObjectByName("nameOfObjectInScane") |
whatToDo | json |
can make: { 'rotateY': mag } |
Three.js for yss - console.log infos by hitting "h" on Three.js site it will responce as terminal in console. is accessable by t4y global object. It's a instance of it to use.
Kind: global class
Three.js for yss - put text is accessable by t4y global object. It's a instance of it to use.
methode to put text on screen
Kind: instance method of T4y_putText
Param | Type | Description |
---|---|---|
msg | string |
The msg to put |
args | json |
The arguments example: { name :"HDGText", - name of object in scren color: 0xf0a32a, size: 5, replace: "HDGText", handle: 'cb', x:-20, y:2, z: -43, ry:-20, extrude: .5 } |
Three.js for yss - postprocessor actions. can invert / red black all things on scren and is compatible with yss shader. is accessable by t4y global object. It's a instance of it to use.
Kind: global class
Three.js for yss - Main class is accessable by t4y global object. It's a instance of it to use.
methode to init your scene frome file.
Kind: instance method of Three4Yss
Param | Type | Description |
---|---|---|
glbFileModel | string |
The path to .glb file |
extras | json |
extsas to pass: { //'camPos': [12.530088021598306, 62.72307047093599, 26.921712853935578], //'camRot': [-0.945604247598529, 0.16391450066952107, 0.22234511182624667], 'controls': false, 'lightPos': [0,80,-80], 'camDeb': false } |
It is init on start by pager. Example yss site with description how to do it your self. This class need to be in directory of your project.
This is minimum of overwriting to set up your page. or grab blank :)
Kind: global class
See: this code on - GitHub
overtire with your constructions...
Kind: instance property of s_basicSailPage
Returns: [string] - name of your site
overtire function and set your site title
Kind: instance property of s_basicSailPage
Returns: [string] - html hex color definition of your background
overtire function and set default background color of your site
Kind: instance property of s_basicSailPage
Returns: [string] - to put in htmlDyno
overtire function
need to return html of your site
Kind: instance property of s_basicSailPage
Returns: [xmlObject] - xml object
overtire functon and set
need to return xml object of .svg or nothing
overtire methode and set looper if you need one
Kind: instance method of s_basicSailPage
overtire methode and set will be called after .getHtml
Kind: instance method of s_basicSailPage
overtire methode and set invoke after .svgDyno()
Kind: instance method of s_basicSailPage
overtire function / methode call on every msg comming from webSocket /ws/yss it's a place to put your callbacks
Kind: instance method of s_basicSailPage
Param | Type | Description |
---|---|---|
r | json |
incomming msg to process. this is a place to put your callbacks. expocting incomming message to be r = { "topic": "abc/cd", "payload": "11.3" } |
Powered by: jsdoc2md