Skip to content

Instantly share code, notes, and snippets.

@twinge
Created February 6, 2009 20:47
Show Gist options
  • Save twinge/59600 to your computer and use it in GitHub Desktop.
Save twinge/59600 to your computer and use it in GitHub Desktop.
system.script, communityCreator.js
function communityCreator_selectTemplate(tdObj) {
var input = tdObj.getElementsByTagName("input")[0];
if(!input.disabled)
input.checked = true;
}
function communityCreator_submit(form) {
var name = form.elements["display_name"].value.replace(/[^a-z0-9_~\-]/g, "_");
var url = "/report-raw/global/checkCommunityName?name="+escape(name);
importXML(url, "communityCreator_checkNameResults");
}
function communityCreator_checkNameResults(xmlObj) {
if(xmlObj) {
if(!checkReportXML(xmlObj)) return false;
xmlObj = xmlObj.responseXML;
var errorCode = xmlObj.getElementsByTagName("errorCode")[0];
var errorString = xmlObj.getElementsByTagName("errorString")[0];
var nameError = document.getElementById("communityCreator_nameError");
var titleError = document.getElementById("communityCreator_titleError");
var descError = document.getElementById("communityCreator_descError");
while(nameError.childNodes.length > 0) {
nameError.removeChild(nameError.firstChild);
}
while(titleError.childNodes.length > 0) {
titleError.removeChild(titleError.firstChild);
}
while(descError.childNodes.length > 0) {
descError.removeChild(descError.firstChild);
}
if(!errorCode) {
nameError.appendChild(document.createTextNode("Error Communicating with GCX"));
} else if(errorCode.firstChild.nodeValue == "ERROR") {
nameError.appendChild(document.createTextNode(errorString.firstChild.nodeValue));
} else if(errorCode.firstChild.nodeValue == "SUCCESS") {
var form = document.getElementById("communityCreator_form");
if(form.elements["title"].value.length < 3) {
titleError.appendChild(document.createTextNode("Title must be greater then 3 characters"));
return;
}
if(form.elements["description"].value.length <= 0) {
descError.appendChild(document.createTextNode("Community must have a description"));
return;
}
form.submit();
}
}
}
function communityCreator_preview(imgStr) {
var oWin = window.open(imgStr, "_templatePreview", "height=620,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
}
function communityCreator_cancel(form) {
window.location = "/screen/Public/home";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment