var counterIdCells = 80000;
var counterIdRows = 80000;
function createSpanCell()
{
var text = " ";
return "" + text + "";
}
function createSpanCellDelete()
{
return "";
}
function createSpanCellDeleteColumn()
{
return "";
}
function createErasableDroppable(id)
{
Droppables.add(id, {accept: 'draggable',
hoverclass: 'hover',
onDrop: function(drag,drop,ev)
{
var clone = drag.cloneNode(true);
clone.style.removeProperty('cursor');
clone.style.removeProperty('position');
clone.style.removeProperty('top');
clone.style.removeProperty('left');
clone.style.removeProperty('opacity');
// check if cell already have images - then simply
// add new image to that list
var imgList = drop.getElementsByTagName('img');
// if we already have images - then don't clear
// inner HTML - we can accumulate images in the cell
if(imgList.length==0)
{
drop.innerHTML='';
}
clone.ondblclick = function()
{
// if this image is last in the cell - then create new
var imgListIn = this.parentNode.getElementsByTagName('img');
if(imgListIn.length==1)
this.parentNode.innerHTML=createSpanCell();
else
// else - delete only this element
this.parentNode.removeChild(this);
};
drop.appendChild(clone);
}});
// make all images in this cell deletable
var cell = document.getElementById(id);
var images = cell.getElementsByTagName('img');
for(var i=0;i
var imgListIn = this.parentNode.parentNode.getElementsByTagName('img');
if(imgListIn.length==1)
this.parentNode.parentNode.innerHTML=createSpanCell();
else
// else - delete only this element
this.parentNode.removeChild(this);
};
}
}
function createNewRow(id) {
// take table
this.table = document.getElementById(id);
// find rows in the table
var tableBody = table.getElementsByTagName('tbody');
// find header of table
var header = table.getElementsByTagName('thead');
var headerRow = header[0].getElementsByTagName('th');
var tableRowLen = headerRow.length;
var newRow = document.createElement('tr');
newRow.id = 'row' + counterIdRows;
// append row to the body
tableBody[0].appendChild(newRow);
// next we need to loop throught all table rows and append cell to the end
for(var no=0;no0)
row.insertBefore(cell,cells[cells.length-1]);
else
row.appendChild(cell);
}
function createNewColumn(id) {
// take table
var table = document.getElementById(id);
// create new element 'column header' and insert it to the end of 'thead'
var columnHead = document.createElement('th');
columnHead.className = 'fancy';
deleteEl = createSpanCellDeleteColumn();
wholeEl = createSpanCell();
columnHead.innerHTML= wholeEl + deleteEl;
// find header of table
var header = table.getElementsByTagName('thead');
var headerRow = header[0].getElementsByTagName('tr');
// append column header to the header of table
insertBeforeLast(headerRow[0],columnHead,'th');
// find rows in the table
var tableBody = table.getElementsByTagName('tbody');
var tableRows = tableBody[0].getElementsByTagName('tr');
// next we need to loop throught all table rows and append cell to the end
for(var no=0;no