this implements a full screen modal dialog that looks something like this:
---------------------------------
| <title> |
|---------------------------------|
| pie | |
| chart | <arbitrary content> |
| svg | |
---------------------------------
The intended use is as a splash screen dialog for starting a PWA app, though I suppose it could be used for many things.
- noiceCore.js (
noiceCoreUtility
) - noiceCoreUI.js (
noiceCoreUIElement
,noiceCoreUIOverlay
)
-
netStatus
string, default: 'network status:'
- whenthis.welcomeMode
is set tofalse
, this is a text element on screen that you can set the value of (see example) -
dbStatus
string, default: 'database status:'
- whenthis.welcomeMode
is set tofalse
, this is a text element on screen that you can set the value of (see example) -
netReadBytes
string, default: 0 bytes
- whenthis.welcomeMode
is set tofalse
, this is a text element on screen that you can set the value of (see example) -
dbStatusDetail
string, default: ''
- whenthis.welcomeMode
is set tofalse
, this is a text element on screen that you can set the value of (see example) -
showPieChart
bool, default: false
- whenthis.welcomeMode
is set tofalse
, you can set this value totrue
to display the built in pie chart (see diagram and example) -
showCancelBtn
bool, default: false
- if set to a value oftrue
, show the cancel button, otherwise don't -
title
string, default: 'startup'
- text for the<title>
element in the diagram above -
message
string, default: 'application startup'
- whenthis.welcomeMode
is set tofalse
, you can set this value totrue
to display the built in pie chart (see diagram and example) -
runAnimation
bool, default: false
- if set to a value oftrue
, will execute theanimationCallback
(if specified) in an infiniterequestAnimationFrame()
loop until the value is changed tofalse
-
welcomeMode
bool, default: false
- if a value oftrue
, show thewelcomeImage
,welcomeTitle
&welcomeMessage
attributes. If a value offalse
, remove those elements and displaynetStatus
,netReadBytes
,dbStatus
,dbStatusDetail
andmessage
elements, and allow theshowPieChart
(if settrue
) to toggle the SVG pie chart visibility (see example) -
welcomeTitle
string, default: 'Welcome'
- whenwelcomeMode
is set to atrue
value, this is a text element on screen that you can set the value of (see example) -
welcomeMessage
string, default; "To begin, touch 'start'"
- whenwelcomeMode
is set to atrue
value, this is a text element on screen that you can set the value of (see example) -
chartSize
integer (svg passthrough), default: 200
- this value determines the radius of the pie chart. The value is given in SVG units -
welcomeImage
string (image path), default: './gfx/hicox_flower.svg'
- display this image in thepie chart svg
area in the diagram above, whenwelcomeMode
is set to a value oftrue
-
startBtnText
string, default: 'start'
- textContent of the start button -
cancelBtnText
string, default: 'reload'
- textContent of the cancel button
-
addPieChart({args})
- each object can contain an arbitrary number of pie charts overlaid atop one another. This function allows you to add a pie chart and takes the following args:-
name
string
- this should be a distinct name (you will use this name to update the chart) -
fill
string (svg passthrough)
- this sets the color of the fill (hint: use CSSrgba(...)
to set opacity when multiple charts are in play at once) see documentation -
stroke
string (svg passthrough)
- this sets the color of the stroke see documentation -
strokeWidth
integer (svg passthrough)
- this sets the width of the stroke (default: 1) see documentation
-
-
updatePieChart(name, percent)
- set thepercent
value of the pie chart identified byname
(NOTE, this is thename
given viaaddPieChart()
or thepieCharts
attribute at instantiation);
let sd = new startupDialog({
title: 'Shabidoo v 4.20',
welcomeTitle: 'Welcome to Shabidoo',
showPieChart: false,
welcomeMode: true,
showCancelBtn: true,
cancelBtnText: 'cancel',
pieCharts: [
{ name:'db', fill:'rgba(6, 133, 135, .5)' },
{ name:'network', fill:'rgba(17, 47, 65, .2)' }
],
cancelButtonCallback: function(self, evt){
// just close it, this is a demo after all
self.remove();
},
startButtonCallback: function(self, evt){
// do jazzhands here
self.welcomeMode = false;
self.showPieChart = true;
self.runAnimation = true;
evt.target.disabled = true;
self.netStatus = 'demo status:';
self.netReadBytes = `running animation`;
self.dbStatus = 'dummy text!';
},
animationCallback: function(self){
if (self.hasOwnProperty('_animatePolygon')){
self._animatePolygon.phase = -(((self._animationFrame%2000)/2000) * Math.PI * 2);
self._animatePolygon.fillOpacity = (self._animatePolygon.baseFillOpacity + (.15 * ((Math.cos(2*Math.PI * (self._animationFrame%250)/250)) + .5)));
if (((self._animationFrame%100)/100) == 0){
self._animatePolygon.edges = 3 + Math.floor(Math.random() * 5);
}
}
},
animationStartCallback: function(self){
if (! self.hasOwnProperty('_animatePolygon')){
self._animatePolygon = new noiceRadialPolygonPath({
edges: 3,
radius: ((self.chartSize/2) * (6/8)),
baseFillOpacity:.25
}).append(self.svgDOMObject);
}
},
animationExitCallback: function(self){
if (self.hasOwnProperty('_animatePolygon')){
self._animatePolygon.remove();
delete self._animatePolygon
}
}
}).append(document.body);