-
Notifications
You must be signed in to change notification settings - Fork 70
71 Capturing User Input
These components are required for SplashBuddy to capture the user's input:
- SplashBuddy and it's required components
- Latest release supports User Input
-
form.html
inside thepresentation.bundle
under your localized language.
These components are optional for SplashBuddy to capture the user's input:
-
form.js
inside the same location as yourform.html
-
form.css
inside the same location as yourform.html
-
readSplashValues.sh
to read the values SplashBuddy records
Please review the component list located here
<html>
<head>
<!-- Insert External Resources here -->
</head>
<body>
<form>
<!-- Form Components Here -->
</form>
</body>
</html>
Javascript: <script type='text/javascript' src='script.js'></script>
Stylesheet (CSS): <link />
Inside the form there are many different options available, below breaks down each one, along with each function.
Tag Name | Use | Example |
---|---|---|
ID | Be able to link to your element using #ID where ID is the ID of your element. |
id='Name' |
Name | The name of your input, this will be the name of the text file the values are saved to. | name='firstname' |
sbReq | If set to true, SplashBuddy won't allow the form to be submitted until the value is provided | sbReq='true' |
These options are for use with the <input />
tag.
Option | Use | Example | Reference |
---|---|---|---|
Placeholder | Set a placeholder to provide a description for the field prior to user inserting values. | placeholder='Johhny Appleseed' |
Info |
Value | Set a value to the input prior to user's interaction | value='Johhny Appleseed' |
Info |
Disabled | This disables the element, you can enable it via. script, or keep is disabled. | disabled |
Info |
Type | This is the type of input values expected, current options are text , radio , or checkbox
|
type='text' |
Info |
Radio Example Below
Type specific options
Option | Use | Example | Reference |
---|---|---|---|
checked | For use in checkbox type only, use this to set the default value | <input type='checkbox' name='model' checked /> |
Info |
Select is another method of capturing user input, this is a drop down list the user can select from. Example:
<select id='Sites' name='site' sbReq='true'>
<option value='headquarters'>Headquarters</option>
<option value='remote'>Remote Office</option>
<option value='warehouse'>Warehouse</option>
</select>
All user's input is stored in plain text currently at ~/Library/Containers/io.fti.SplashBuddy/Data/
where ~
is the user's space where SplashBuddy is running. All files are stored in text files.
One way to read this is with the script below:
The below script writes to /Library/Logs/SplashBuddyValues.log
for logging, and saves the user's input values to /Library/Preferences/io.fti.SplashBuddyValues.plist
which can be read by executing defaults read /Library/Preferences/io.fti.SplashbuddyValues.plist
#!/bin/bash
###################################################
# SplashBuddy Read Values
# Reads the values dropped by SplashBuddy application from the user.
###################################################
#Define Logging
log_location="/Library/Logs/SplashBuddyValues.log"
ScriptLogging()
{
DATE=$(date +%Y-%m-%d\ %H:%M:%S)
LOG="$log_location"
echo "$DATE" " $1" >> $LOG
echo "$DATE" " $1"
}
ScriptLogging "————Read SplashBuddy Values—————-"
##Variables
assetString="asset-tag"; # The name used for the asset tag
writeToPlist="/Library/Preferences/io.fti.SplashBuddyValues.plist";
##Functions
# Execute - DO NOT EDIT BEYOND THIS LINE
loggedInUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
path="/Users/$loggedInUser/Library/Containers/io.fti.SplashBuddy/Data"
ScriptLogging "User discovered: $loggedInUser";
function getSplashBuddyResults() {
for file in $(ls "$path" | grep .txt); do
key=$(awk -F . '{print $1}' <<< $file);
value=$(cat $path/$file);
ScriptLogging "$key with value of $value";
if [[ $value == 'TRUE' || $value == 'on' ]]; then
ScriptLogging 'Writing True boolean value for $key';
sudo defaults write $writeToPlist $key -bool TRUE;
elif [[ $value == 'FALSE' ]]; then
ScriptLogging 'Writing False boolean value for $key';
sudo defaults write $writeToPlist $key -bool FALSE;
else
ScriptLogging "Writing $value for $key into plist";
/usr/bin/sudo /usr/bin/defaults write $writeToPlist "$key" -string "$value";
ScriptLogging "Value being read: $(/usr/bin/defaults read $writeToPlist \"$key\")";
fi
if [[ "$key" == "$assetString" ]]; then
ScriptLogging "Reading asset-tag value...";
currAssetTag = $(/usr/sbin/nvram asset-tag | /usr/bin/awk '{print $NF}' 2>/dev/null);
if [[ $currAssetTag == "" ]]; then
/usr/bin/sudo /usr/sbin/nvram asset-tag=$value;
fi
fi
done
}
while [[ $(ls $path | grep .txt | wc -l) -eq 0 ]]; do
ScriptLogging "$(ls $path | grep .txt | wc -l)";
ScriptLogging "Path: $path";
ScriptLogging "Contents: $(ls $path)";
sleep 5;
done
##Execute
getSplashBuddyResults;
ScriptLogging "——End——"
exit 0
-
Password type is not supported
- Possible solution is using Public Key Encryption to encrypt user's sensitive data before being saved.
- Only the type options of
radio
,checkbox
, andtext
are currently supported.
If you can, please contribute.
You can also freely edit the wiki, every little bit helps!
Thank you 🌈