ajaxController.bindActionToUrl( "content.delete" , "/app/default/faceless/fw.action/content.delete" ); ajaxController.bindActionToUrl( "content.publish" , "/app/default/faceless/fw.action/content.publish" ); ajaxController.bindActionToUrl( "search.page" , "/app/default/faceless/fw.action/search.page" ); highColor = "#D0BAB9"; function highRow( row ) { if ( row && row.getElementsByTagName ) { var cells = row.getElementsByTagName( "td" ); for ( var i = 0; i < cells.length; i++ ) { if ( cells[i].className != "noChange" ) { cells[i].formerBgCol = cells[i].style.backgroundColor ? cells[i].style.backgroundColor : "transparent"; cells[i].style.backgroundColor = highColor; } } } } function lowRow( row ) { if ( row && row.getElementsByTagName ) { var cells = row.getElementsByTagName( "td" ); for ( var i = 0; i < cells.length; i++ ) { if ( cells[i].formerBgCol ) { cells[i].style.backgroundColor = cells[i].formerBgCol; cells[i].formerBgCol = undefined; } } } } function getPage( query, entityName , offset , count, pageSize) { var action = new AjaxAction(); // set name with which the action is bound to an url action.setName( "search.page" ); // add parameters action.addParam( "offset" , offset ); action.addParam( "count" , count ); action.addParam( "max" , pageSize ? pageSize + "" : 10 + "" ); action.addParam( "ce_name" , entityName ); action.addParam( "q" , query ); $("feedback").innerHTML = "
Seite wird angefordert. (" + getTimestamp() + ")
"; // fire action //ajaxController.fireActionToTargetFunction( action , receivePage ); ajaxController.fireActionIntoElement( action , "searchTarget" ); } function receivePage(ajaxAction, ajaxResponse) { if ( ajaxResponse.isError() ) { $("feedback").innerHTML = "
" + response.getErrorMessage() + "
"; } else { $("search").innerHTML = ajaxResponse.getContentAsString(); } } function removeRow( entityName, entityId) { if ( confirm( "Eintrag wirklich löschen? Die Daten können nicht wiederhergestellt werden" ) ) { var action = new AjaxAction(); // set name with which the action is bound to an url action.setName( "content.delete" ); // add parameters action.addParam( "task" , "delete" ); action.addParam( "entityName" , entityName ); action.addParam( "entityId" , entityId ); $("feedback").innerHTML = "
Objekt wird entfernt. (" + getTimestamp() + ")
"; // fire action ajaxController.fireActionToTargetFunction( action , receiveRemove ); } } function receiveRemove(ajaxAction, ajaxResponse) { if ( ajaxResponse.isError() ) { $("feedback").innerHTML = "
" + response.getErrorMessage() + "
"; } else { var entityName = ajaxResponse.getParameter( "entityName" ); var entityId = ajaxResponse.getParameter( "entityId" ); var row = $( entityName + "_" + entityId ); if ( row ) { row.parentNode.removeChild( row ); } $("feedback").innerHTML = ajaxResponse.getContentAsString(); } } function publish( entityName, entityId) { managePublish( "publish", entityName, entityId ) ; } function unpublish( entityName, entityId) { managePublish( "unpublish", entityName, entityId ) ; } function managePublish( task, entityName, entityId ) { var action = new AjaxAction(); // set name with which the action is bound to an url action.setName( "content.publish" ); action.addParam( "task" , task ); action.addParam( "ce_name" , entityName ); action.addParam( "ce_id" , entityId ); $("feedback").innerHTML = "
Aktion gestartet. (" + getTimestamp() + ")
"; // fire action ajaxController.fireActionToTargetFunction( action , receivePublish ); } function receivePublish(ajaxAction, ajaxResponse) { if ( ajaxResponse.isError() ) { $("feedback").innerHTML = "
" + response.getErrorMessage() + "
"; } else { var task = ajaxResponse.getParameter( "task" ); var entityName = ajaxResponse.getParameter( "ce_name" ); var entityId = ajaxResponse.getParameter( "ce_id" ); var img = $( 'publish_' + entityName + "_" + entityId ); if ( task == 'publish' ) { img.onclick = function() { managePublish( 'unpublish', entityName, entityId ); }; img.src = '/app/default/images/lock.png'; img.parentNode.parentNode.style.backgroundColor = '#67B86A'; } else if ( task == 'unpublish' ) { img.onclick = function() { managePublish( 'publish', entityName, entityId ); }; img.src = '/app/default/images/unlock.png'; img.parentNode.parentNode.style.backgroundColor = '#FF7E7E'; } $("feedback").innerHTML = ajaxResponse.getContentAsString(); } } function getTimestamp() { // date for user feedback var now = new Date(); var buf = now.getHours() < 10 ? "0" : "" ; buf += now.getHours() + ":"; buf += now.getMinutes() < 10 ? "0" : "" ; buf += now.getMinutes() + ":" ; buf += now.getSeconds() < 10 ? "0" : "" ; buf += now.getSeconds(); return buf; }