Simple External Actions
Here are some actions that can be sent to the script without a ping and pong process. All of these actions need to be sent some specific data in a specific format.
- Sending a message to main script with the data it needs. gScriptname = "pandacrazy";
- localStorage.setItem("JR_message_" + gScriptName, JSON.stringify(data));
- The data should be in this format with command being the actual action command string from the list below.
- {"time":(new Date().getTime()),"command":command,"data":objectData}
- The objectData that it's looking for is different for each action so that will be explained in the action commands below.
- The jobData that holds the hit info must be in this object data format but not all have to be assigned:
- {"requesterName":"","requesterId":"","groupId":"","pay":"","title":"","duration":"0","hitsAvailable":0,"timeLeft":"","totalSeconds":0,"hitId":"","continueURL":"","returnURL":"","durationParsed":null,"jobNumber":"","friendlyRName":"","friendlyTitle":"","assignedOn":"","description":"","qual":"","keywords":""};
Here are the simple actions:
- acceptedhit - Send info about a hit accepted outside of the script.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- returned - Send info about a hit that was returned.
- This needs the data to have this object: {"hitId":thisHitID}
- submitted - Send info about a hit that was submitted.
- This needs the data to have this object: {"hitId":thisHitID}
- queueData - Send updated queue info to the script. Only uses the number in queue at this time.
- This needs the data to have this object: {"queueLength":length}
- projectedEarnings - Send the projected earnings from the dashboard.
- This needs the data to have this object: {"projectedEarnings":earnings}
- addOnlyJob - Add info about a hit that needs to be added but don't collect.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- addOnceJob - Add info about a hit that needs to be added and collected now but only one time.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- addJob - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- addSearchJob - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- startcollect - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- stopcollect - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- startgroup - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- stopgroup - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- pause - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- unpause - Add info about a hit that needs to be added and collected now.
- This needs the jobData object defined above to be sent like this: {"jobData":jobData}
- So for example if I wanted to send the hitID of a hit that I accepted I would use this to send it to the main script:
- localStorage.setItem("JR_message_" + gScriptName, JSON.stringify(
{"time":(new Date().getTime()),"command":"acceptedhit","data":
{"hitId":thisHitID} }));
- localStorage.setItem("JR_message_" + gScriptName, JSON.stringify(
The time data isn't actually used by the script so that could be left out but in the future I might need it so I just send it anyway. In the advanced messaging in the next topic it uses a unique ID that it gets from the date but it doesn't use it from the received message.
No questions yet.