Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addSnap(top, left, numberVal) {
- //Check if the data already contains a value for the pair.
- if (contains(sendingData, "[block-" + top + ":" + left + "]", "[/block]")) {
- //The sendingData already contains the current block.
- var getData = splitReduced(sendingData, "[block-" + top + ":" + left + "]", "[/block]");
- var getData_whole = "[block-" + top + ":" + left + "]" + getData + "[/block]";
- sendingData = sendingData.replace(getData_whole, "")
- }
- //Validate the positions
- var positionValidated = false;
- for (var i = 0; i < validPositions.length; i++) {
- if (validPositions[i][0] == top && validPositions[i][1] == left) positionValidated = true;
- }
- if (!positionValidated) {
- //The position is not valid, send a nasty error-message.
- return;
- }
- //Create a new block with the data.
- var blockData = '[block-' + top + ':' + left + ']' + numberVal + '[/block]';
- sendingData = sendingData + blockData;
- //DEBUG:
- console.log("Added " + top + ":" + left + " to data. Ready to ship.");
- }
Advertisement
Add Comment
Please, Sign In to add comment