var langIdStart = false; var curLang = ''; var editorActive = false; var editorOldContent = ""; var editorOldClass = ""; var curEditId = ''; var editorElements = new Array(); var editorPlaceholder = document.createElement('tr'); var editorTop = '
\nEnglish\n
\n
\n'; //French\nGerman\n
\n
\n'; var editorTopEN = '
'; var editorTopFR = '
'; var editorTopDE = '
'; var editorBottomEN = '
'; var editorBottomFR = '
'; var editorBottomDE = '
'; var editorHomeTeam = '
'; var editorHomeScore = '
'; var editorAwayTeam = '
'; var editorAwayScore = '
'; var editorTitle_EN = '
'; var editorTitle_FR = '
'; var editorTitle_DE = '
'; var editorJersey = '
'; var editorPosition_EN = '
'; var editorEmail = '
'; var editorFName = '
'; var editorLName = '
'; var editorHandle = '
'; var editorHandleEditable = '
'; var editorPassword = '
'; var editorPassword_Retype = '
'; var editorName = '
'; var editorName_EN = '
'; var editorName_FR = '
'; var editorName_DE = '
'; var editorContent_EN = '
'; var editorContent_FR = '
'; var editorContent_DE = '
'; var editorDesc_EN = '
'; var editorDesc_FR = '
'; var editorDesc_DE = '
'; var editorVersion = '
'; var editorMeta = '
'; var editorDateTime = '
'; var editorMonthYear = '
'; var editorDate = '
'; var editorTime = '
'; var editorIconList = '
'; var editorGalleryThumb = '
'; var editorURL = '
'; var editorPostStatus = '
'; var editorArchived = '
'; var editorCommentStatus = '
'; var editorCategory = '

[Add]
'; var editorCancel = ''; var editorUpdate = ''; var editorAdd = ''; var editorFiles = '
' + '
'; var editorCoachPicture = '
'; var editorSupportStaffPicture = '
'; var editorBottom = '
'; function getTrEditorOutput(module,action,langId, tid) { var editorCancelSmall = '\n'; var editorUpdateSmall = '\n'; var editorAddSmall = '\n'; output = ''; var temp = document.getElementById(tid); editorPlaceholder = document.createElement('tr'); // alert(temp.childNodes.length); while (temp.childNodes.length > 0) { var elem = temp.childNodes[0]; temp.removeChild(elem); // alert(temp.childNodes.length); editorPlaceholder.appendChild(elem); } switch (module) { case 'users': if (action == 'update') { var elem = document.createElement('td'); elem.id = 'editSection'; elem.innerHTML = editorCancelSmall + editorUpdateSmall + '' + '' + '' + '' + '' + '' + ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); } break; case 'scores': if (action == 'update') { var elem = document.createElement('td'); elem.id = 'editSection'; elem.innerHTML = editorCancelSmall + editorUpdateSmall + '' + '' + '' + '' + '' + '' + ''; temp.appendChild(elem); elem = document.createElement('td'); var cal = document.createElement('calendar'); cal.id = 'contentdate'; cal.setAttribute('type','datePickerSmall'); elem.appendChild(cal); // elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); } break; case 'roster': if (action == 'update') { var elem = document.createElement('td'); elem.id = 'editSection'; elem.innerHTML = editorCancelSmall + editorUpdateSmall + '' + '' + '' + '' + '' + '' + ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); } break; case 'teamstats': if (action == 'update') { var elem = document.createElement('td'); elem.id = 'editSection'; elem.innerHTML = editorCancelSmall + editorUpdateSmall + '' + '' + '' + '' + '' + '' + ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); } break; case 'calendar': if (action == 'update') { var elem = document.createElement('td'); elem.id = 'editSection'; elem.innerHTML = editorCancelSmall + editorUpdateSmall + '' + '' + '' + '' + '' + '' + ''; temp.appendChild(elem); elem = document.createElement('td'); var cal = document.createElement('calendar'); cal.id = 'contentdate'; cal.setAttribute('type','datePickerSmall'); elem.appendChild(cal); // elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); elem = document.createElement('td'); elem.innerHTML = ''; temp.appendChild(elem); } break; } } function getEditorOutput(module, action, langId) { editorCancel = '\n'; editorUpdate = '\n'; editorAdd = '\n'; var editorCancelSmall = '\n'; var editorUpdateSmall = '\n'; var editorAddSmall = '\n'; output = ''; switch (module) { case 'users': if (action == 'update') { output += ''; output += editorCancelSmall + editorUpdateSmall; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; } else { output += editorTop; output += editorTopEN + editorBottomEN; //output += editorTopFR + editorTitle_FR + editorContent_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorContent_DE + editorBottomDE; output += editorHandleEditable; output += editorPassword; output += editorPassword_Retype; output += editorEmail; output += editorFName; output += editorLName; output += '
'; output += '
'; output += editorBottom; output += editorCancel + editorAdd; } break; case 'news': output += editorTop; output += editorTopEN + editorTitle_EN + editorContent_EN + editorBottomEN; //output += editorTopFR + editorTitle_FR + editorContent_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorContent_DE + editorBottomDE; output += editorMeta; output += editorArchived; output += editorFiles; output += editorBottom; if (action == 'update') output += editorCancel + editorUpdate; else if (action == 'add') output += editorCancel + editorAdd; break; case 'registration': case 'recruitment': // case 'ensembles': // case 'recordings': // case 'teaching': // case 'bio': output += editorTop; output += editorTopEN + editorContent_EN + editorBottomEN; output += editorFiles; //output += editorTopFR + editorContent_FR + editorBottomFR; //output += editorTopDE + editorContent_DE + editorBottomDE; output += editorBottom; if (action == 'update') output += editorCancel + editorUpdate; else if (action == 'add') { output += editorCancel + editorAdd; } break; case 'pictures': output += editorTop; output += editorTopEN + editorBottomEN; //output += editorTopFR + editorBottomFR; //output += editorTopDE + editorBottomDE; output += editorName + editorBottom; if (action == 'update') output += editorCancel + editorUpdate; else if (action == 'add') output += editorCancel + editorAdd; break; case 'gallery': output += editorTop; output += editorTopEN + editorTitle_EN + editorBottomEN; //output += editorTopFR + editorTitle_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorBottomDE; if (action == 'update') { output += editorGalleryThumb + editorBottom; output += editorCancel + editorUpdate; } else if (action == 'add') { output += editorBottom; output += editorCancel + editorAdd; } break; case 'links': output += editorTop; output += editorTopEN + editorTitle_EN + editorDesc_EN + editorURL + editorBottomEN; //output += editorTopFR + editorTitle_FR + editorDesc_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorDesc_DE + editorBottomDE; output += editorIconList; output += editorFiles; output += editorBottom; if (action == 'update') output += editorCancel + editorUpdate; else if (action == 'add') output += editorCancel + editorAdd; break; case 'coaches': case 'fieldstaff': output += editorTop; output += editorTopEN + editorName_EN + editorDesc_EN + editorBottomEN; //output += editorTopFR + editorTitle_FR + editorContent_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorContent_DE + editorBottomDE; if (module == 'coaches') output += editorCoachPicture; else output += editorSupportStaffPicture; output += editorBottom; if (action == 'update') output += editorCancel + editorUpdate; else if (action == 'add') output += editorCancel + editorAdd; break; case 'scores': if (action == 'update') { output += ''; output += editorCancelSmall + editorUpdateSmall; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; } else if (action == 'add') { output += editorTop; output += editorTopEN + editorBottomEN; //output += editorHomeTeam; output += editorHomeTeam + editorHomeScore + editorAwayTeam + editorAwayScore + editorDesc_EN + editorDate; //output += editorTopFR + editorTitle_FR + editorDesc_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorDesc_DE + editorBottomDE; output += editorBottom; output += editorCancel + editorAdd; } break; case 'roster': if (action == 'update') { output += ''; output += editorCancelSmall + editorUpdateSmall; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; } else if (action == 'add') { output += editorTop; output += editorTopEN + editorJersey + editorName_EN + editorPosition_EN + editorBottomEN; //output += editorTopFR + editorTitle_FR + editorDesc_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorDesc_DE + editorBottomDE; output += editorBottom; output += editorCancel + editorAdd; } break; case 'teamstats': if (action == 'update') { output += ''; output += editorCancelSmall + editorUpdateSmall; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; } else if (action == 'add') { } break; case 'calendar': if (action == 'update') { output += ''; output += editorCancelSmall + editorUpdateSmall; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; output += ''; } else if (action == 'add') { output += editorTop; output += editorTopEN + editorTitle_EN + editorDesc_EN + editorBottomEN; //output += editorTopFR + editorTitle_FR + editorDesc_FR + editorBottomFR; //output += editorTopDE + editorTitle_DE + editorDesc_DE + editorBottomDE; output += editorDate + editorBottom; output += editorCancel + editorAdd; } break; } return output; } /** *************************** AJAX *************************** **/ function ajaxCon(incString, methodOnFinish) { var catString = ''; var ajaxCat = new sack(); catString = ajaxCat.encVar('cookie', document.cookie) +'&'+ incString; ajaxCat.requestFile = '/ajax_server.php'; ajaxCat.method = 'POST'; ajaxCat.onLoading = function () { }; ajaxCat.onLoaded = function () {}; ajaxCat.onInteractive = function () {}; ajaxCat.onCompletion = methodOnFinish; ajaxCat.runAJAX(catString); } /** *************************** ADD RECEIVED *************************** **/ function addReceived(xmlDoc) { // alert(xmlDoc); var contentItem = xmlDoc.getElementsByTagName('contentList')[0]; var itemId = xmlDoc.getElementsByTagName('action')[0].getAttribute('targetId'); document.location.reload(); } /** *************************** UPDATE RECEIVED*************************** **/ function updateReceived(xmlDoc) { // alert('update received'); // alert(xmlDoc); var itemId = xmlDoc.getElementsByTagName('action')[0].getAttribute('targetId'); var module = xmlDoc.getElementsByTagName('action')[0].getAttribute('module'); if (document.getElementById(module+'Item_'+itemId).nodeName == 'TR') { document.location.reload(); } else { document.getElementById(module+'Item_'+itemId).innerHTML = xmlDoc.getElementsByTagName('content')[0].getAttribute('value'); } editorActive = false; } /** *************************** EDIT RECEIVED *************************** **/ function editReceived(xmlDoc) { var contentList = xmlDoc.getElementsByTagName('contentList')[0].childNodes; var relatedTables = xmlDoc.getElementsByTagName('relatedTable'); var module = xmlDoc.getElementsByTagName('action')[0].getAttribute('module'); var objId = xmlDoc.getElementsByTagName('action')[0].getAttribute('targetId'); var editor = document.createElement('div'); var curDiv = document.getElementById(module+'Item_'+ objId); var langId = xmlDoc.getElementsByTagName('action')[0].getAttribute('lang'); var editorOutput = getEditorOutput(module,'update', langId); if (curDiv.nodeName == 'TR') { getTrEditorOutput(module,'update',langId, module+'Item_'+ objId); // curDiv.innerHTML = editorOutput; } else { editor.className = 'editSection'; editor.id = 'editSection'; curDiv.innerHTML = ""; editor.innerHTML = editorOutput; curDiv.appendChild(editor); } if (document.getElementById('contentdate')) { cal.addCalendar('contentdate'); } if (document.getElementById('contentLangEN')) { switchLang(langId); } if (document.getElementById('contentfiles')) { ajaxCon('module=files&action=list',listReceived); } if (module == 'coaches' || module == 'fieldstaff') { document.getElementById('contentpicture_iframe').src = '/file.php?module='+module+'&action=addPicture&parentId='+module+'&contentId=' + objId; } for (x = 0; x=0; cnt--) { if (!contentList[x]) continue; var itemId = contentList[x].attributes[cnt].name; var itemValue = contentList[x].attributes[cnt].value; switch (contentList[x].attributes[cnt].name) { // case 'comment_status': // case 'post_status': case 'archived': editorElements[editorElements.length] = itemId; var obj = document.getElementById('content'+itemId); var innerCnt = 0; for (innerCnt; innerCnt < obj.options.length; innerCnt++) { if (obj.options[innerCnt].value == itemValue) { obj.selectedIndex = innerCnt; break; } } break; case 'category_id': editorElements[editorElements.length] = itemId; var obj; var objCnt = 0; for (objCnt = 0; objCnt < relatedTables.length; objCnt++) { obj = relatedTables[objCnt]; if (obj.getAttribute('id') == 'categories') { var childCnt; var child; for (childCnt = 0; childCnt < obj.childNodes.length; childCnt++) { child = obj.childNodes[childCnt]; var childObj = document.createElement('option'); childObj.value = child.getAttribute('category_id'); childObj.appendChild(document.createTextNode(child.getAttribute('name'))); if (childObj.value == itemValue) childObj.selected = "selected"; document.getElementById('content'+itemId).appendChild(childObj); } break; } } break; case 'group_id': editorElements[editorElements.length] = itemId; var obj; var objCnt = 0; for (objCnt = 0; objCnt < relatedTables.length; objCnt++) { obj = relatedTables[objCnt]; if (obj.getAttribute('id') == 'groups') { var childCnt; var child; for (childCnt = 0; childCnt < obj.childNodes.length; childCnt++) { child = obj.childNodes[childCnt]; var childObj = document.createElement('option'); childObj.value = child.getAttribute('group_id'); childObj.appendChild(document.createTextNode(child.getAttribute('group_name'))); if (childObj.value == itemValue) childObj.selected = "selected"; document.getElementById('content'+itemId).appendChild(childObj); } break; } } break; /* case 'name': case 'name_EN': case 'name_FR': case 'name_DE': case 'title': case 'title_EN': case 'title_FR': case 'title_DE': case 'description': case 'description_EN': case 'description_FR': case 'description_DE': case 'meta': case 'version': if (document.getElementById('content'+itemId)) document.getElementById('content'+itemId).value = itemValue; else { var newElem = document.createElement('input'); newElem.type = 'hidden'; newElem.id = 'content'+itemId; newElem.value = itemValue; document.getElementById('editSectionContent').appendChild(newElem); } editorElements[editorElements.length] = itemId; break; */ case 'content': case 'content_EN': case 'content_FR': case 'content_DE': if (document.getElementById('content'+itemId)) { document.getElementById('content'+itemId).value = itemValue; tinyMCE.execCommand('mceAddControl', false, 'content'+itemId); } else { var newElem = document.createElement('input'); newElem.type = 'hidden'; newElem.id = 'content'+itemId; newElem.value = itemValue; document.getElementById('editSectionContent').appendChild(newElem); } editorElements[editorElements.length] = itemId; break; case 'date': editorElements[editorElements.length] = itemId; if (document.getElementById('content'+itemId)) { var d = new Date(itemValue * 1000.0); calObjs['content'+itemId].setFullDate(d.getFullYear(),d.getMonth(),d.getDate()); } else { var newElem = document.createElement('input'); newElem.type = 'hidden'; newElem.id = 'content'+itemId; newElem.value = itemValue; document.getElementById('editSectionContent').appendChild(newElem); } break; case 'picture_id': editorElements[editorElements.length] = 'picture_id'; if (document.getElementById('content'+ itemId)) { ilist.addIconList('content'+ itemId, 'pictures&gallery_id='+objId+'&THUMB_SMALL', itemId); document.getElementById('content'+ itemId).value = itemValue; } else { var newElem = document.createElement('input'); newElem.type = 'hidden'; newElem.id = 'content'+itemId; newElem.value = itemValue; document.getElementById('editSectionContent').appendChild(newElem); } break; case 'icon_id': editorElements[editorElements.length] = itemId; if (document.getElementById('content'+ itemId)) { ilist.addIconList('content'+itemId, 'icons', itemId); document.getElementById('content'+itemId).value = itemValue; } else { var newElem = document.createElement('input'); newElem.type = 'hidden'; newElem.id = 'content'+itemId; newElem.value = itemValue; document.getElementById('editSectionContent').appendChild(newElem); } break; default: editorElements[editorElements.length] = itemId; if (document.getElementById('content'+ itemId)) { document.getElementById('content'+itemId).value = itemValue; } else { var newElem = document.createElement('input'); newElem.type = 'hidden'; newElem.id = 'content'+itemId; newElem.value = itemValue; document.getElementById('editSectionContent').appendChild(newElem); } } } } editorActive = true; switchLang(langId); } /** *************************** CANCEL *************************** **/ function editCancel () { if (editorActive) { // tinyMCE.execCommand('mceRemoveControl',false,'contentBody'); if (document.getElementById('contentcontent_EN')) { if (document.getElementById('contentcontent_EN')) tinyMCE.execCommand('mceRemoveControl', false, 'contentcontent_EN'); if (document.getElementById('contentcontent_FR')) tinyMCE.execCommand('mceRemoveControl', false, 'contentcontent_FR'); if (document.getElementById('contentcontent_DE')) tinyMCE.execCommand('mceRemoveControl', false, 'contentcontent_DE'); } if (document.getElementById('editSection').parentNode.nodeName == 'TR') { var temp = document.getElementById('editSection').parentNode; temp.className = editorOldClass; while (temp.childNodes.length > 0) temp.removeChild(temp.childNodes[0]); while (editorPlaceholder.childNodes.length > 0) { var elem = editorPlaceholder.childNodes[0]; editorPlaceholder.removeChild(elem); temp.appendChild(elem); } } else { document.getElementById('editSection').parentNode.innerHTML = editorOldContent; } editorActive = false; curEditId = ''; } } /** *************************** LIST *************************** **/ function listReceived (xmlDoc) { var contentList = xmlDoc.getElementsByTagName('contentList')[0].childNodes; var module = xmlDoc.getElementsByTagName('action')[0].getAttribute('module'); var x; //iterate new items for (x = 0; x[Delete]'; row.appendChild(cell); cell = document.createElement('td'); cell.innerHTML = fullname; row.appendChild(cell); row.id = 'filesItem_' + fname; // var cell = document.createElement('td'); // cell.appendChild(document.createTextNode('