742 lines
26 KiB
JavaScript
Raw Normal View History

2018-01-20 21:35:29 -05:00
var navSelect = "home";
2018-04-15 23:47:12 -04:00
var dataMode;
2018-01-21 21:05:48 -05:00
var serverURL = window.location.origin;
2018-01-20 22:34:39 -05:00
var data;
2018-02-03 23:33:19 -05:00
var languageChart;
2018-02-23 19:08:53 -05:00
var dataOpen = false;
2018-04-15 18:48:21 -04:00
var submittable = true;
2018-01-24 18:59:56 -05:00
// var trelloInfo = {};
2018-01-20 21:35:29 -05:00
2018-01-21 15:03:26 -05:00
2018-01-20 21:35:29 -05:00
var navi = [ // Array containing navigation items in form [Font-Awesome class name, Display Text, Onclick function].
2018-01-20 22:34:39 -05:00
["home", "Home", "home"],
2018-04-15 18:48:21 -04:00
["bar-chart", "Data Values", "dataValues1"],
2018-01-20 22:34:39 -05:00
["database", "Database and Files", "files"],
2018-01-21 21:29:32 -05:00
["info", "About", "about"]
2018-01-20 19:37:14 -05:00
];
2018-01-21 21:05:48 -05:00
var members = [
2018-04-15 23:47:12 -04:00
"Kenneth Jao", "Yaman Qalieh", "Enrico Colon"
2018-01-21 21:05:48 -05:00
];
2018-01-21 15:03:26 -05:00
var dropOp = {
2018-04-15 23:47:12 -04:00
//Insert correct
2018-01-21 15:03:26 -05:00
};
2018-01-20 19:37:14 -05:00
2018-01-21 15:03:26 -05:00
var dropOpStore = {};
2018-01-31 17:12:54 -05:00
// Left This so that the post function can be reused
// function temporary(data) {
// for(var i = 0; i < data.length; i++) {
// $.ajax({
// url: serverURL + '/server',
// type: 'POST',
// data: JSON.stringify(data[i]),
// dataType: "json",
// contentType: 'application/json;charset=UTF-8'
// })
// .then(
// function success(data) {
// console.log(data);
// },
// function error(e) {
// console.log(e);
// }
// );
// }
// }
2018-01-21 17:15:39 -05:00
function createNav() {
2018-01-21 15:03:26 -05:00
for (var i = 0; i < navi.length; i++) { // Create navigation tabs.
var side = document.getElementById("sidebar");
var div = document.createElement("div");
div.className = "navi transition";
div.setAttribute("option", navi[i][2]);
div.onclick = function() {
var op = this.getAttribute("option");
if (navSelect === op) return;
updateMain(op);
};
var ic = document.createElement("i");
ic.className = "fa fa-" + navi[i][0];
ic["aria-hidden"] = true;
var p = document.createElement("p");
p.appendChild(document.createTextNode(navi[i][1]));
div.appendChild(ic);
div.appendChild(p);
side.appendChild(div);
2018-01-21 17:15:39 -05:00
}
2018-01-21 15:03:26 -05:00
}
2018-01-20 21:35:29 -05:00
function updateMain(op) { // Updates the actual page.
2018-01-20 22:34:39 -05:00
updateNav(op);
document.getElementById(navSelect).style.opacity = "0";
setTimeout(function() {
console.log(op);
2018-01-20 22:34:39 -05:00
document.getElementById(navSelect).style.display = "none";
2018-04-15 23:47:12 -04:00
document.getElementById(op).style.display = "block";
2018-01-20 22:34:39 -05:00
setTimeout(function() {
document.getElementById(op).style.opacity = "1";
}, 30);
navSelect = op;
}, 300);
2018-01-20 21:35:29 -05:00
}
function updateNav(op) { // Updates the sidebar navigation.
2018-01-20 22:34:39 -05:00
var oldNav = document.querySelectorAll("[option=" + navSelect + "]")[0];
var newNav = document.querySelectorAll("[option=" + op + "]")[0];
oldNav.style.backgroundColor = "rgba(0,0,0,0)";
oldNav.style.color = "white";
newNav.style.backgroundColor = "#F8F3F0";
newNav.style.color = "#F47922";
}
function getData(updatePage) {
2018-01-20 22:34:39 -05:00
$.ajax({
2018-01-21 21:05:48 -05:00
url: serverURL + '/server',
2018-01-20 22:34:39 -05:00
type: 'GET'
})
.then(
function success(incoming) {
data = incoming;
2018-01-21 15:05:20 -05:00
generateDropOp();
createDrop();
if(updatePage) dropOpUpdate("langSelect");
2018-01-20 22:34:39 -05:00
},
function error(e) {
console.log(e);
}
);
}
function language(language) {
2018-01-20 23:01:47 -05:00
return data.values.filter(function(element) {
2018-01-20 22:34:39 -05:00
return element.name === language;
2018-01-21 15:46:38 -05:00
})[0];
2018-01-20 21:35:29 -05:00
}
2018-01-21 15:03:26 -05:00
2018-01-21 17:15:39 -05:00
function phoneme(p) {
return data.values.map(function(language) {
obj = {};
if (language.phonemes[p] !== undefined) {
obj[language.name] = language.phonemes[p];
return obj;
}
return undefined;
}).filter(function(a) {
2018-01-21 21:05:48 -05:00
return (a !== undefined);
2018-01-21 17:15:39 -05:00
});
}
2018-04-15 18:48:21 -04:00
document.getElementById("flipMode").onclick = function() {
dropOpStore["flipMode"] = (dropOpStore["flipMode"] === "language") ? "phoneme" : "language";
}
2018-01-21 15:46:38 -05:00
function generateDropOp() { // For options that change based on data.
dropOp["langSelect"] = [function() { // Function that occurs when change language.
2018-01-21 21:05:48 -05:00
// Generate info box material.
2018-01-21 15:46:38 -05:00
var langInfo = language(dropOpStore["langSelect"]);
2018-01-21 21:05:48 -05:00
var info = document.getElementById("langInfoCont");
var dataBox = document.getElementById("dataTableCont");
2018-02-03 23:33:19 -05:00
var graph = document.querySelectorAll("#langGraph > canvas")[0];
2018-01-21 21:05:48 -05:00
info.style.opacity = "0";
dataBox.style.opacity = "0";
2018-02-03 23:33:19 -05:00
graph.style.opacity = "0";
2018-01-21 21:05:48 -05:00
setTimeout(function() {
while (info.firstChild) {
info.removeChild(info.firstChild);
}
var p = document.createElement("p");
var p2 = document.createElement("p");
var a = document.createElement("a");
p.appendChild(document.createTextNode("Type: " + (langInfo.type || "N/A")));
p2.appendChild(document.createTextNode("Source: "));
2018-02-24 23:00:18 -05:00
if(langInfo.source === null) {
p2.appendChild(document.createTextNode("N/A"));
} else if(langInfo.source.length > 0) {
2018-01-21 21:05:48 -05:00
a.href = langInfo.source;
srcText = (langInfo.source.length > 60) ? langInfo.source.substring(0, 57) + "..." : langInfo.source;
2018-01-21 21:05:48 -05:00
a.appendChild(document.createTextNode(srcText));
2018-04-15 23:47:12 -04:00
p2.appendChild(a);
2018-01-21 21:05:48 -05:00
}
info.appendChild(p);
info.appendChild(p2);
2018-04-15 23:47:12 -04:00
// Generate data box material.
2018-04-15 23:47:12 -04:00
var phonemes = Object.keys(langInfo.phonemes);
2018-04-15 23:47:12 -04:00
2018-01-21 21:05:48 -05:00
while (dataBox.firstChild) {
dataBox.removeChild(dataBox.firstChild);
}
dataBox.style.gridTemplateColumns = "repeat("+Math.ceil(phonemes.length/6).toString() + ", 1fr)";
for(var i = 0; i < 9; i++) dataBox.appendChild(document.createElement("div")); // Extra divs will be filled if necessary.
for(i = 0; i < phonemes.length; i++) {
var tableNum = Math.floor(i/6);
var row = i+2-tableNum*7;
var p1 = document.createElement("p");
var p2 = document.createElement("p");
p1.style.textAlign = "right";
p2.style.textAlign = "left";
p1.style.borderRight = "1px solid #D5D5D5";
if(i%6 === 0) {
var pT1 = document.createElement("p");
var pT2 = document.createElement("p");
pT1.style.textAlign = "right";
pT2.style.textAlign = "left";
pT1.style.borderRight = "1px solid #D5D5D5";
pT1.style.borderBottom = "1px solid #D5D5D5";
pT2.style.borderBottom = "1px solid #D5D5D5";
pT1.appendChild(document.createTextNode("Phoneme"));
pT2.appendChild(document.createTextNode("Percent"));
dataBox.children[tableNum].appendChild(pT1);
dataBox.children[tableNum].appendChild(pT2);
2018-04-15 23:47:12 -04:00
}
2018-01-21 21:05:48 -05:00
p1.appendChild(document.createTextNode(phonemes[i]));
2018-02-23 19:08:53 -05:00
p2.appendChild(document.createTextNode(langInfo.phonemes[phonemes[i]]));
2018-01-21 21:05:48 -05:00
dataBox.children[tableNum].appendChild(p1);
dataBox.children[tableNum].appendChild(p2);
}
2018-02-03 23:00:40 -05:00
var graphData = Object.entries(langInfo.phonemes).sort(function(a,b) {
2018-02-24 23:00:18 -05:00
return b[1] - a[1];
2018-02-03 23:00:40 -05:00
});
graphData = [graphData.map(function(a,b) {
return a[0];
}), graphData.map(function(a,b) {
return a[1];
})];
// Generate graphs.
2018-02-03 23:33:19 -05:00
var ctx = graph.getContext("2d");
2018-04-15 23:47:12 -04:00
try {
2018-02-03 23:33:19 -05:00
languageChart.destroy();
} catch(err) {}
2018-04-15 18:48:21 -04:00
languageChart = new Chart(ctx, chartOptions(graphData));
info.style.opacity = "1";
dataBox.style.opacity = "1";
graph.style.opacity = "1";
}, 300);
2018-04-15 23:47:12 -04:00
}].concat(["Select language..."].concat(data.languages));
2018-01-21 15:03:26 -05:00
}
2018-02-23 19:08:53 -05:00
function closeEditInput() {
2018-02-24 23:00:18 -05:00
try {
var input = document.getElementById("dataOpen");
var p = input.parentNode;
var patchData = {
action: 'phoneme_add',
2018-02-23 19:08:53 -05:00
data: {
2018-02-24 23:00:18 -05:00
language_id: language(dropOpStore["langSelect"]).id,
phoneme: p.previousSibling.innerText,
value: input.value
2018-02-23 19:08:53 -05:00
}
2018-02-24 23:00:18 -05:00
};
$.ajax({
url: serverURL + '/server',
type: 'PATCH',
dataType: "json",
contentType: 'application/json;charset=UTF-8',
data: JSON.stringify(patchData)
2018-02-23 19:08:53 -05:00
})
.then(
function success(incoming) {
2018-02-24 23:00:18 -05:00
p.appendChild(document.createTextNode(input.value));
p.removeChild(input);
2018-02-23 19:08:53 -05:00
},
function error(e) {
console.log(e);
}
2018-02-24 23:00:18 -05:00
);
dataOpen = false;
} catch(err) {}
2018-02-23 19:08:53 -05:00
}
2018-01-21 15:03:26 -05:00
function createDrop() {
var dropButtons = document.getElementsByClassName("dropdown");
2018-04-15 18:48:21 -04:00
for(var i = 0; i < dropButtons.length; i++) {
while(dropButtons[i].firstChild) dropButtons[i].removeChild(dropButtons[i].firstChild);
}
for (i = 0; i < dropButtons.length; i++) {
2018-01-21 15:03:26 -05:00
var div = document.createElement("div");
div.className = "button";
var p = document.createElement("p");
var op = dropButtons[i].getAttribute("option");
2018-01-21 15:46:38 -05:00
p.appendChild(document.createTextNode(dropOp[op][1]));
2018-01-21 15:03:26 -05:00
var ic = document.createElement("i");
ic.className = "fa fa-angle-down";
ic["aria-hidden"] = true;
div.appendChild(p);
div.appendChild(ic);
var div2 = document.createElement("div");
div2.className = "opCont transition";
var p3 = document.createElement("p");
p3.className = "transition";
p3.onclick = function() { // Open add language.
document.getElementById("newLanguage").style.display = "block";
setTimeout(function() {
document.getElementById("newLanguage").style.opacity = "1";
}, 10);
2018-04-15 23:47:12 -04:00
};
p3.appendChild(document.createTextNode("Add language..."));
div2.appendChild(p3);
2018-01-21 17:15:39 -05:00
for (var j = 2; j < dropOp[op].length; j++) {
2018-01-21 15:03:26 -05:00
var p2 = document.createElement("p");
p2.className = "transition";
p2.onclick = function(e) {
e.stopPropagation();
dropOpStore[op] = this.textContent;
dropOpUpdate(op);
let opCont = this.parentNode;
opCont.style.opacity = "0";
setTimeout(function() {
opCont.style.display = "none";
}, 300);
};
p2.appendChild(document.createTextNode(dropOp[op][j]));
div2.appendChild(p2);
}
2018-01-21 15:03:26 -05:00
div.onclick = function(e) {
e.stopPropagation();
let opCont = this.nextElementSibling;
2018-01-21 17:15:39 -05:00
if (opCont.style.display === "block") {
2018-01-21 15:03:26 -05:00
opCont.style.opacity = "0";
setTimeout(function() {
opCont.style.display = "none";
}, 300);
} else {
opCont.style.display = "block";
setTimeout(function() {
opCont.style.opacity = "1";
}, 30);
}
};
dropButtons[i].appendChild(div);
dropButtons[i].appendChild(div2);
}
}
function dropOpUpdate(op) {
2018-01-21 17:15:39 -05:00
var dropdown = document.querySelectorAll(".dropdown[option=" + op + "] .button p")[0];
2018-01-21 15:03:26 -05:00
dropdown.textContent = dropOpStore[op];
2018-01-21 15:46:38 -05:00
(dropOp[op][0])();
2018-01-21 15:03:26 -05:00
}
document.onclick = function(event) {
2018-01-21 17:15:39 -05:00
for (var i = 0; i < document.getElementsByClassName("dropdown").length; i++) {
2018-01-21 15:03:26 -05:00
var opCont = document.querySelectorAll(".dropdown .opCont")[i];
opCont.style.opacity = "0";
setTimeout(function() {
opCont.style.display = "none";
}, 300);
}
2018-04-15 23:47:12 -04:00
};
2018-01-21 15:03:26 -05:00
function homeCards() {
// GET posts from server
var week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var examplePost = [
{
author: "Kenneth Jao",
title: "Test Post!",
content: "This is test post! <a target='_blank' href='https://google.com'>Link</a> This link should work.<br> Newlines work.",
date: new Date(2018, 0, 26, 4, 51)
}
];
var home = document.getElementById("home");
for(var i = 0; i < examplePost.length; i++) {
var div = document.createElement("div");
div.className = "card";
var h2 = document.createElement("h2");
h2.textContent = examplePost[i].title;
div.appendChild(h2);
var h3 = document.createElement("h3");
var dt = examplePost[i].date;
var smallDate = (function() {
var m = (dt.getMonth()+1).toString();
var d = (dt.getDay()+1).toString();
m = (m.length === 1) ? "0" + m : m;
d = (d.length === 1) ? "0" + d : d;
return m+"/"+d+"/"+dt.getFullYear().toString();
})();
2018-04-15 23:47:12 -04:00
var fullDate = week[dt.getDay()] + ", " + month[dt.getMonth()] + " " + dt.getDate().toString() + ", " + dt.getFullYear().toString();
h3.textContent = smallDate + " | " + fullDate;
div.appendChild(h3);
var p = document.createElement("p");
p.innerHTML = examplePost[i].content;
div.appendChild(p);
home.appendChild(div);
}
}
2018-04-15 18:48:21 -04:00
function chartOptions(graphData) {
return {
type: 'bar',
data: {
labels: graphData[0],
datasets: [{
label: "Phoneme Prevalence",
data: graphData[1],
backgroundColor: 'rgba(244, 121, 34, 0.7)',
borderColor: 'rgba(246, 112, 18, 1)',
borderWidth: 2
}]
},
options: {
legend: {
labels: {
fontFamily: "'Open Sans Condensed', sans-serif",
fontSize: 20
}
},
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: "Phoneme (%)",
fontFamily: "'Open Sans Condensed', sans-serif",
fontSize: 20,
padding: 4
},
ticks: {
fontFamily: "'Open Sans Condensed', sans-serif",
fontSize: 20,
callback: function(value) {
return value + "%";
}
}
}],
xAxes: [{
scaleLabel: {
display: true,
labelString: "Percent Prevalence",
fontFamily: "'Open Sans Condensed', sans-serif",
fontSize: 20,
padding: 4
},
ticks: {
fontFamily: "'Open Sans Condensed', sans-serif",
fontSize: 20
}
}]
}
}
};
}
document.getElementById("newLanguage").onclick = function(event) { // Close add language.
document.getElementById("newLanguage").style.opacity = "0";
setTimeout(function() {
2018-04-15 23:47:12 -04:00
document.getElementById("newLanguage").style.display = "none";
2018-04-15 18:48:21 -04:00
}, 300);
document.getElementById("editLanguage").style.opacity = "0";
setTimeout(function() {
2018-04-15 23:47:12 -04:00
document.getElementById("editLanguage").style.display = "none";
}, 300);
2018-04-15 23:47:12 -04:00
};
2018-04-15 18:48:21 -04:00
document.querySelectorAll("#newLanguage > div")[0].onclick = function(event) {
event.stopPropagation();
2018-04-15 23:47:12 -04:00
};
2018-04-15 18:48:21 -04:00
document.getElementById("editData").onclick = function() { // Open edit language.
var langInfo = language(dropOpStore["langSelect"]);
document.querySelectorAll("#editLanguageName input")[0].value = langInfo.name;
var k = Object.keys(langInfo.phonemes);
var v = Object.values(langInfo.phonemes);
var str = "";
for(var i = 0; i < k.length; i++) {
str += k[i] + " " + v[i] + ((i === k.length-1) ? "" : "\n");
}
document.querySelectorAll("#editLanguagePhonemes textarea")[0].value = str;
document.getElementById("editLanguage").style.display = "block";
setTimeout(function() {
document.getElementById("editLanguage").style.opacity = "1";
}, 10);
2018-04-15 23:47:12 -04:00
};
2018-04-15 18:48:21 -04:00
document.querySelectorAll("#newLanguageSubmit p")[0].onclick = function() {
if(!submittable) return;
submittable = false;
var name = document.querySelectorAll("#newLanguageName input")[0].value;
if(name === "") {
alert("Please enter in the name for language!");
submittable = true;
2018-04-15 18:48:21 -04:00
return;
}
var info = document.querySelectorAll("#newLanguagePhonemes textarea")[0].value;
if(info === "") {
alert("Please enter in the values for phonemes!");
submittable = true;
2018-04-15 18:48:21 -04:00
return;
}
info = info.split("\n");
var phonemes = {};
for(var i = 0; i < info.length; i++) {
info[i] = info[i].split(/[ ,]+/);
var num = parseFloat(info[i][1]);
if(isNaN(num)) {
alert("Value for " + info[i][0] + " is not a number or does not exist!");
submittable = true;
2018-04-15 18:48:21 -04:00
return;
}
phonemes[info[i][0]] = num;
}
var newLanguage = {
name: name,
source: null,
phonemes: phonemes
};
2018-04-15 18:48:21 -04:00
this.innerText = "Processing...";
this.style.backgroundColor = "rgba(0,0,0,0.2)";
var p = this;
$.ajax({
url: serverURL + '/server',
type: 'POST',
dataType: "json",
contentType: 'application/json;charset=UTF-8',
data: JSON.stringify(newLanguage)
})
.then(
function success(incoming) {
document.getElementById("newLanguage").style.opacity = "0";
setTimeout(function() {
document.getElementById("newLanguage").style.display = "none";
submittable = true;
p.innerText = "Submit!";
p.style.backgroundColor = "#FEFEFE";
document.querySelectorAll("#newLanguageName input")[0].value = "";
document.querySelectorAll("#newLanguagePhonemes textarea")[0].value = "";
2018-04-15 18:48:21 -04:00
}, 300);
getData(true);
2018-04-15 18:48:21 -04:00
},
function error(e) {
alert("There was an error adding a language.");
2018-04-15 18:48:21 -04:00
console.log(e);
}
);
2018-04-15 23:47:12 -04:00
};
document.querySelectorAll("#editLanguageSubmit p")[0].onclick = function() {
if(!submittable) return;
var langInfo = language(dropOpStore["langSelect"]);
submittable = false;
var name = document.querySelectorAll("#editLanguageName input")[0].value;
if(name === "") {
alert("Please enter in the name for language!");
submittable = true;
return;
}
var info = document.querySelectorAll("#editLanguagePhonemes textarea")[0].value;
if(info === "") {
alert("Please enter in the values for phonemes!");
submittable = true;
return;
}
info = info.split("\n");
var newPhonemes = {};
for(var i = 0; i < info.length; i++) {
info[i] = info[i].split(/[ ,]+/);
var num = parseFloat(info[i][1]);
if(isNaN(num)) {
alert("Value for " + info[i][0] + " is not a number or does not exist!");
submittable = true;
return;
}
newPhonemes[info[i][0]] = num;
}
this.innerText = "Processing...";
this.style.backgroundColor = "rgba(0,0,0,0.2)";
var p = this;
var diffChange = [];
var diffRemove = [];
var phoKeys = Object.keys(langInfo.phonemes);
for(var i = 0; i < phoKeys.length; i++) {
if(newPhonemes[phoKeys[i]] === undefined) {
diffRemove.push(phoKeys[i]);
} else if(langInfo.phonemes[phoKeys[i]] !== newPhonemes[phoKeys[i]]) {
2018-04-15 23:47:12 -04:00
diffChange.push(phoKeys[i]);
} else {
continue;
}
}
var todo = {
name: newLanguage.name !== langInfo.name,
add: diffChange.length > 0,
remove: diffRemove.length > 0
2018-04-15 23:47:12 -04:00
};
var error = false;
if(todo.name) { // Ajax requests for changing name.
$.ajax({
url: serverURL + '/server',
type: 'PATCH',
dataType: "json",
contentType: 'application/json;charset=UTF-8',
data: JSON.stringify({
action: "language_name_edit",
data: {
language_id: langInfo.id,
language_name: name
}
})
})
.then(
function success(incoming) {
if(todo.name && !todo.add && !todo.remove) {
document.getElementById("editLanguage").style.opacity = "0";
setTimeout(function() {
document.getElementById("editLanguage").style.display = "none";
submittable = true;
p.innerText = "Submit!";
p.style.backgroundColor = "#FEFEFE";
document.querySelectorAll("#editLanguageName input")[0].value = "";
document.querySelectorAll("#editLanguagePhonemes textarea")[0].value = "";
}, 300);
getData(true);
}
},
function error(e) {
error = true;
alert("There was an error change the language name.");
console.log(e);
}
);
}
if(error) return;
for(var i = 0; i < diffChange.length; i++) { // Ajax requests for adding or editing phonemes.
$.ajax({
url: serverURL + '/server',
type: 'PATCH',
dataType: "json",
contentType: 'application/json;charset=UTF-8',
context: {counter: i},
data: JSON.stringify({
action: "phoneme_add",
data: {
language_id: langInfo.id,
phoneme: diffChange[i],
value: newPhonemes[diffChange[i]]
}
})
})
.then(
function success(incoming) {
if(todo.add && !todo.remove && this.counter === diffChange.length-1) {
document.getElementById("editLanguage").style.opacity = "0";
setTimeout(function() {
document.getElementById("editLanguage").style.display = "none";
submittable = true;
p.innerText = "Submit!";
p.style.backgroundColor = "#FEFEFE";
document.querySelectorAll("#editLanguageName input")[0].value = "";
document.querySelectorAll("#editLanguagePhonemes textarea")[0].value = "";
}, 300);
getData(true);
}
2018-04-15 23:47:12 -04:00
},
function error(e) {
error = true;
alert("There was an error change the phoneme values.");
console.log(e);
}
);
}
if(error) return;
console.log({
action: "phoneme_remove",
data: {
language_id: langInfo.id,
phoneme_id: diffRemove[i]
}
2018-04-15 23:47:12 -04:00
});
for(var i = 0; i < diffRemove.length; i++) { // Ajax requests for removing phoneme values.
$.ajax({
url: serverURL + '/server',
type: 'PATCH',
dataType: "json",
contentType: 'application/json;charset=UTF-8',
context: {counter: i},
data: JSON.stringify({
action: "phoneme_remove",
data: {
language_id: langInfo.id,
2018-04-15 22:03:14 -04:00
phoneme: diffRemove[i]
}
})
})
.then(
function success(incoming) {
if(this.counter === diffRemove.length-1) {
document.getElementById("editLanguage").style.opacity = "0";
setTimeout(function() {
document.getElementById("editLanguage").style.display = "none";
submittable = true;
p.innerText = "Submit!";
p.style.backgroundColor = "#FEFEFE";
document.querySelectorAll("#editLanguageName input")[0].value = "";
document.querySelectorAll("#editLanguagePhonemes textarea")[0].value = "";
}, 300);
getData(true);
}
2018-04-15 23:47:12 -04:00
},
function error(e) {
error = true;
alert("There was an error removing phoneme values.");
console.log(e);
}
);
}
2018-04-15 23:47:12 -04:00
};
2018-01-24 18:59:56 -05:00
/*function getTrelloCards() {
2018-01-21 21:05:48 -05:00
Trello.authorize();
var cardArr, listArr, lists;
var cards = window.Trello.rest(
2018-04-15 23:47:12 -04:00
"GET", "boards/vm2c2IZd/cards",
2018-01-21 21:05:48 -05:00
function success() {
cardArr = JSON.parse(cards.responseText);
lists = window.Trello.rest(
"GET", "boards/vm2c2IZd/lists",
function success() {
listArr = JSON.parse(lists.responseText);
for(var i = 0; i < listArr.length; i++) {
var arr = cardArr.filter(function(obj) {
return obj.idList === listArr[i].id;
}).map(a => a.name);
trelloInfo[listArr[i].name] = arr;
}
},
function error(e) {
console.log(e);
});
},
function error(e) {
console.log(e);
});
2018-01-24 18:59:56 -05:00
}*/
2018-01-21 21:05:48 -05:00
2018-01-21 15:03:26 -05:00
getData();
homeCards();
2018-01-21 15:03:26 -05:00
createNav();
updateNav(navSelect);
2018-04-15 18:48:21 -04:00