User:Yitzi/wikia.js

/* */ /* */ $('.DBQuery').each(function { var lines = $(this).text.split(($(this).text.indexOf('\r') != -1) ? '\r' : '\n'); var database = ; var formId = ; var resultId = ''; var properties = ["test", "test2"]; var entries = []; // Parse config for (var i in lines)  {  var temp = lines[i].split('=', 2);  if (temp.length != 2)     {    continue;    }  switch ($.trim(temp[0]))     {    case 'database':      database = ($.trim(temp[1]));      break;    case 'form':    formId = ($.trim(temp[1]));      break;    case 'result':      resultId = ($.trim(temp[1]));      break;    }  } //Now to construct the list of entries fulfilling a particular query: function query(queryentries,modes,allownones)  {  alert (properties);  } //Next, a constructor function to create a new table-containing div. function DBtablediv(name,tableentries)  {  this.testproperty="test";  } //And now to make the actual query form. var $queryTable=$(' ').addClass('wikitable jcTable'); for (var i in properties)  {  var $tr = $(' '); $tr.append(' '+properties[i]+' '); var querymode=document.createElement("select"); var temp=document.createElement("option"); temp.text='Allowed values:'; querymode.add(temp,null); var temp=document.createElement("option"); temp.text='Disallowed values:'; querymode.add(temp,null); querymode.selectedIndex=1; querymode.id=properties[i]+"queryMode"; var $td = $(' '); $td.append(querymode); $tr.append($td); var $td = $(' '); var queryValues=document.createElement("input"); queryValues.type="text"; queryValues.id=properties[i]+'queryValue'; $td.append(queryValues); $tr.append($td); var allowNone=document.createElement("input"); queryValues.id=properties[i]+'allowNone'; allowNone.type="checkbox"; allowNone.checked=true; var $td = $(' '); $td.append('Allow empty entries').append(allowNone); $tr.append($td); $queryTable.append($tr); } $form = $(' ').attr({'action': '#', 'id': 'jcForm' + formId}).submit(function {  queryentries=[];  modes=[];  allownones=[];  for (var i in properties)    {    temp=document.getElementById(properties[i]+'queryValue');    alert(temp.id);

} newEntries=query(queryentries,modes,allownones); new DBtablediv(queryName.value,newEntries); }); $form.append($queryTable); $form.append(' '); $form.append('Name for new table:'); var queryName=document.createElement("input"); queryName.type="text"; $form.append(queryName); $form.append($(' ').attr({type: 'submit', value: 'Get matching entries'})); $('#bodyContent #' + formId + ',#WikiaArticle #' + formId).empty.append($form); }); /* */ /* */