how do I refactor this to use oop , with mvc pattern.
(function () {
var dataToImage = { 'a': 'a.gif', 'b': 'something.gif' };
var currentimage = dataToImage['a'];
function setCurrentImage(e){ currentImage = e.src; }
function getMousePosition(){ }
function drawToolbar {
for(i in dataToImage){
document.write('<img src="'+dataToImage[i]+'" onclick="setCurrentImage(this);">');
}
document.write('<div onclick="drawImage(this,getMousePosition())"></div>');
return;
}
function drawImage(div,xy) {
var img = document.createElement('div');
div.style["left"] = xy[0];
div.style["top"] = xy[1];
img.innerHTML='<img src="'+currentImage+'">');
div.appendChild(img);
return;
}
drawToolbar();
}());