First of all, we need to write some JavaScript code that can simulate the events that we need to trigger to perform the drag-and-drop action. To do this, we are going to create three JavaScript functions (note that these three functions are not Java code). The first function is going to create a JavaScript event:
function createEvent(typeOfEvent) { var event = document.createEvent("CustomEvent"); event.initCustomEvent(typeOfEvent, true, true, null); event.dataTransfer = { data: {}, setData: function (key, value) { this.data[key] = value; }, getData: function (key) { return this.data[key]; } }; return event; }
We then need to write a function that will fire event instances ...