window.addEventListener('load', function() {
var workspace = document.getElementById('workspace');
var status = {
activeElement: false, //the element that was last clicked
elemBeingDragged: false, //the element that is being dragged
mouseDown: false, //current status of the mouse
resetVariables: function() { //reset the object's elements
this.activeElement = false;
this.elemBeingDragged = false;
},
cursorPosition: {
x: 0,
y: 0
},
resetCursorPosition: function(x, y) {
this.cursorPosition.x = x;
this.cursorPosition.y = y;
},
cursorClickPosition: {
x: 0,
y: 0
}
};
//the sources of the elements
var dragSources = {
elementSources: {
squareSource: document.getElementById('squareSource'),
circleSource: document.getElementById('circleSource')
},
ifDragSource: function(elem) {
var i;
var found = false;
for (i in this.elementSources) {
if (elem === this.elementSources[i]) {
found = true;
}
}
return found;
},
getElementSourceType: function(elem) {
if (elem.hasAttribute('data-shape')) {
return elem.getAttribute('data-shape');
} else {
return 'undefined shape';
}
},
setSourceElementPos: function() {
alert('test');
}
};
var workspaceMethods = {
hideWorkspaceElements: function() {
var workspaceElements = document.querySelectorAll("[data-workspace-shape]");
for (var i = 0; i < workspaceElements.length; i++) {
workspaceElements[i].style.display = 'none';
}
},
showWorkspaceElements: function() {
var workspaceElements = document.querySelectorAll('[data-workspace-shape]');
for (var i = 0; i < workspaceElements.length; i++) {
workspaceElements[i].style.display = 'block';
}
},
getWorkspaceShapes:function(){
return...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.