It works! It took some poking around, so I’ll include how I got this to work on Wordpress:
The article @Moors7 included above has 3 ways of doing this, I went with using the Scripts n Styles plugin. Install the plugin, and then go to the page you want to add particle functionality to. Problem 1 you’ll run into - Scripts n Styles metabox doesn’t pop up until you click on “screen options” in the top right hand corner, and then select Scripts n Styles.
Now down below your main content box, you’ll have a Scripts n Styles box to add Javascript. To use Morrs7’s code, put the following html into the content box:
<html>
<head>
<title>Spark function buttons Example</title>
</head>
<body>
<input type="text" class="form-control" placeholder="Start Hour?" id="startHour">
<input type="text" class="form-control" placeholder="Start Minute?" id="startMinute">
<input type="text" class="form-control" placeholder="Stop Hour?" id="stopHour">
<input type="text" class="form-control" placeholder="Stop Minute?" id="stopMinute">
<br>
<button type="button" onclick="sendValues()">Send values</button>
<!--
<button type="button" onclick="functionCall('functionName', 'functionArgument')">function 1</button>
<button type="button" onclick="functionCall('functionName', 'functionArgument')">function 2</button>
<button type="button" onclick="functionCall('functionName', 'functionArgument')">function 3</button>
<button type="button" onclick="functionCall('functionName', 'functionArgument')">function 4</button>
-->
[hoops name="particle"]
</body>
</html>
Then down in the Scripts n Styles box, add the following to the body box:
//you can use your accesstoken, or your email/passsword to log in. Uncomment accordingly below.
var accessToken = "your token";
var deviceID = "your ID";
var startHour;
var startMinute;
var stopHour;
var stopMinute;
var combinedTime;
//console.log(startHour + startMinute + stopHour + stopMinute);
function sendValues(){
startHour = document.getElementById('startHour');
startMinute = document.getElementById('startMinute');
stopHour = document.getElementById('stopHour');
stopMinute = document.getElementById('stopMinute');
combinedTime = startHour.value + '~' + startMinute.value + '~' + stopHour.value + '~' + stopMinute.value;
console.log(combinedTime);
functionCall('parse', combinedTime);
startHour.value = '';
startMinute.value = '';
stopHour.value = '';
stopMinute.value = '';
}
spark.on('login', function(response) {
console.log(response);
});
// callback to be executed by each core
var callback = function(err, data) {
if (err) {
console.log('An error occurred while getting device attrs:', err);
} else {
console.log('Device attr retrieved successfully:', data);
}
};
function functionCall(functionName, functionArgument){
// The function needs to be defined in the firmware uploaded to the
// the Spark core and registered to the Spark cloud, same thing we do
// with variables. You pass along the name of the function and the params.
spark.callFunction(deviceID, functionName, functionArgument, callback);
}
// Uncomment a line below depending on your preferred log-in method.
//spark.login({ username: 'email@example.com', password: 'password' });
spark.login({ accessToken: accessToken });
Finally, you need to create a hoop, because the plugin preformats the script tag. Go to Tools -> Scripts n Styles > Hoops, put particle in the name field, and the following in the code field.
<script src="http://cdn.jsdelivr.net/sparkjs/1.0.0/spark.min.js"></script>