videoTax/main.html

408 lines
14 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset- "UTF-8" />
<meta name="description" content="Visualization of video lecture taxonomy">
<meta name="keywords" content="video, taxonomy, quality, properties, instruction, visualization">
<meta name="author" content="Martin Putzlocher">
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' href='./css/w3.css'>
<link rel='stylesheet' href='./css/w3-colors-signal.css'>
<title>Video Taxonomy Visualization</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.1.1/chart.min.js"></script>
<script>
2023-02-02 07:41:10 +00:00
/*
function processForm(e) {
if (e.preventDefault) e.preventDefault();
// do what you want with the form
// You must return false to prevent the default form behavior
return false;
}
var form = document.getElementById('newEntryForm');
if (form.attachEvent) {
form.attachEvent("submit", processForm);
} else {
form.addEventListener("submit", processForm);
}
*/
Chart.defaults.font.size = 12;
2023-04-03 10:26:10 +00:00
function createChart(data, videotitle) {
var ctx = document.getElementById("chartId").getContext("2d");
// const customText = {
// id: 'customText',
// afterDraw: (chart, args, options) => {
// const {
// ctx,
// canvas
// } = chart;
// textObjects = options.text;
//
// if (textObjects.length === 0) {
// return;
// }
/*
textObjects.forEach((textObj) => {
ctx.save();
ctx.textAlign = textObj.textAlign || 'center';
ctx.font = `${textObj.size || '20px'} ${textObj.font || 'Arial'}`;
ctx.fillStyle = textObj.color || 'black'
ctx.fillText(textObj.text, textObj.x, textObj.y)
ctx.restore();
})
}
}*/
var chartId = new Chart(ctx, {
type: 'polarArea',
2023-04-03 10:26:10 +00:00
data: {
labels: Array.from(data.keys()),
datasets: [{
label: videotitle,
data: Array.from(data.values()),
// backgroundColor: "rgba(128,128,128,0.5)",
backgroundColor: [
"#f8cc1b90",
"#fa7a4890",
"#31195590",
"#84a2cd90",
"#bed05790",
"#4777cd90",
"#ffa5c890"],
pointBackgroundColor: [
"#f8cc1b90",
"#fa7a4890",
"#31195590",
"#84a2cd90",
"#bed05790",
"#4777cd90",
"#ffa5c890"],
2023-04-03 10:26:10 +00:00
borderColor: ['black'],
borderWidth: 1,
pointRadius: 6,
}],
},
options: {
scales: {
r: {
angleLines: {
display: true
},
min: 0,
max: 4,
ticks: {
// forces step size to be 50 units
stepSize: 1,
font: {
size: 20
}
}
}
},
responsive: false,
elements: {
arc: {
2023-04-03 10:26:10 +00:00
borderWidth: 3
}
},
plugins: {
title: {
display: true,
text: 'Custom Chart Title',
padding: {
top: 10,
bottom: 30
},
font: {
size: 20
}
}
// ,
// customText: {
// text: [{
// text: 'Lorem ipsum',
// x: 0,
// y: 0,
// textAlign: 'center',
// size: '30px',
// color: 'black',
// font: 'Arial black'
// }
// ]
// }
2023-04-03 10:26:10 +00:00
}
},
plugins: {
legend: {
labels: {
// This more specific font property overrides the global property
fontSize: 10
2023-04-03 10:26:10 +00:00
}
}
// , customText: [customText]
2023-04-03 10:26:10 +00:00
}
});
2023-02-02 07:41:10 +00:00
2023-04-03 10:26:10 +00:00
return chartId;
};
2023-02-02 07:41:10 +00:00
let data = new Map();
data.set("instructional principle", 4); // instructional principle
data.set("visibility", 2); // visibility / audio
data.set("segmentation", 3); // segmentation
data.set("activity", 4); // activity
2023-04-03 10:26:10 +00:00
data.set("interactivity", 4); // interactivity
data.set("dynamic drawing", 3); // dynamic drawing
data.set("translatability", 2); // translatability
2023-04-03 13:37:29 +00:00
function loadNewRadarChart(chartId, data, videotitle, score) {
2023-04-03 10:26:10 +00:00
// let removalIndex = chartId.data.datasets.indexOf(ds1); //Locate index of ds1
let removalIndex = 0;
if(removalIndex >= 0) { //make sure this element exists in the array
chartId.data.datasets.splice(removalIndex, 1);
}
2023-04-03 13:37:29 +00:00
let taxLevel = "G";
let colorArray = [
"#f8cc1b90",
"#fa7a4890",
"#31195590",
"#84a2cd90",
"#bed05790",
"#4777cd90",
2023-04-03 13:37:29 +00:00
"#ffa5c890"];
let firstValueZero = 10;
function changeColorsGrey(item, index, arr){
if (index >= firstValueZero) {
arr[index] = "#AAAAAA33";
}
console.log(arr);
}
if (data.get("instructional principle") == 0) {
firstValueZero = 0;
colorArray.forEach(changeColorsGrey);
taxLevel = "0";
}
else if (data.get("visibility") == 0) {
firstValueZero = 1;
colorArray.forEach(changeColorsGrey);
taxLevel = "A";
}
else if (data.get("segmentation") == 0) {
firstValueZero = 2;
colorArray.forEach(changeColorsGrey);
taxLevel = "B";
}
else if (data.get("activity") == 0) {
firstValueZero = 3;
colorArray.forEach(changeColorsGrey);
taxLevel = "C";
}
else if (data.get("interactivity") == 0) {
firstValueZero = 4;
colorArray.forEach(changeColorsGrey);
taxLevel = "D";
}
else if (data.get("dynamic drawing") == 0) {
firstValueZero = 5;
colorArray.forEach(changeColorsGrey);
taxLevel = "E";
}
else if (data.get("translatability") == 0) {
firstValueZero = 6;
colorArray.forEach(changeColorsGrey);
taxLevel = "F";
}
else {
firstValueZero = 10;
colorArray.forEach(changeColorsGrey);
taxLevel = "G";
}
// chartId.data.labels.push(Array.from(data.keys()));
chartId.data.datasets =[{
label: videotitle,
data: Array.from(data.values()),
backgroundColor: colorArray,
pointBackgroundColor: colorArray,
2023-04-03 10:26:10 +00:00
borderColor: ['black'],
borderWidth: 1,
pointRadius: 6,
}];
2023-04-03 13:37:29 +00:00
chartId.options.plugins.title.text = videotitle + ", Taxonomy Level: " + taxLevel
+ ", Score: " + score;
chartId.update();
2023-04-03 10:26:10 +00:00
};
function setNewValues() {
console.log("Hi!");
2023-04-03 13:37:29 +00:00
let nameValue = document.getElementById("videoname").value;
console.log(nameValue);
2023-04-03 10:26:10 +00:00
data_ins = parseInt(document.getElementById("ins_sel").value);
data.set("instructional principle", data_ins);
data_vis = parseInt(document.getElementById("vis_sel").value);
data.set("visibility", data_vis);
data_seg = parseInt(document.getElementById("seg_sel").value);
data.set("segmentation", data_seg);
data_act = parseInt(document.getElementById("act_sel").value);
data.set("activity", data_act);
data_int = parseInt(document.getElementById("int_sel").value);
data.set("interactivity", data_int);
data_dyn = parseInt(document.getElementById("dyn_sel").value);
data.set("dynamic drawing", data_dyn);
data_tra = parseInt(document.getElementById("tra_sel").value);
data.set("translatability", data_tra);
2023-04-03 13:37:29 +00:00
let score = 0;
score = data_ins + data_vis + data_seg + data_act + data_int + data_int + data_dyn + data_tra;
2023-04-03 10:26:10 +00:00
console.log(data);
2023-04-03 13:37:29 +00:00
loadNewRadarChart(chartHandleId, data, nameValue, score);
}
</script>
</head>
<body>
<h1 class="w3-container w3-green">Video lectures taxonomy</h1>
<h2 class="w3-container w3-gray">Video information</h2>
<div class="w3-light-gray">
<p>Please fill in information on your video</p>
<form name="newEntryForm" class="w3-container w3-white w3-border w3-border-green" action="javascript:setNewValues();">
<label class="w3-text-green" for="videoname"><b>Name of Video</b></label>
<input class="w3-input w3-border w3-light-grey" type="text" id="videoname" name="videoname" value="name of video">
2023-02-02 07:41:10 +00:00
<div class="w3-row-padding">
2023-02-02 07:04:11 +00:00
<div class="w3-half">
<label class="w3-text-green" for="ins_sel"><b>A Instructional principle</b></label>
2023-02-02 07:04:11 +00:00
<select class="w3-select w3-border w3-white" name="ins_sel" id="ins_sel">
<option value="0" selected>not acceptable</option>
<option value="1">minimal requirements</option>
<option value="2">medium quality</option>
<option value="3">high quality</option>
<option value="4">excellent quality</option>
<!-- further options -->
</select>
</div>
<div class="w3-half">
<label class="w3-text-green" for="vis_sel"><b>B Visibility / Audio</b></label>
2023-02-02 07:04:11 +00:00
<select class="w3-select w3-border w3-white" name="vis_sel" id="vis_sel">
<option value="0" selected>not acceptable</option>
<option value="1">minimal requirements</option>
<option value="2">medium quality</option>
<option value="3">high quality</option>
<option value="4">excellent quality</option>
<!-- further options -->
</select>
</div>
</div>
2023-02-02 07:41:10 +00:00
<div class="w3-row-padding">
<div class="w3-half">
<label class="w3-text-green" for="seg_sel"><b>C Segmentation</b></label>
2023-02-02 07:41:10 +00:00
<select class="w3-select w3-border w3-white" name="seg_sel" id="seg_sel">
<option value="0" selected>not acceptable</option>
<option value="1">minimal requirements</option>
<option value="2">medium quality</option>
<option value="3">high quality</option>
<option value="4">excellent quality</option>
<!-- further options -->
</select>
</div>
<div class="w3-half">
<label class="w3-text-green" for="act_sel"><b>D Activity</b></label>
2023-02-02 07:41:10 +00:00
<select class="w3-select w3-border w3-white" name="act_sel" id="act_sel">
<option value="0" selected>not acceptable</option>
<option value="1">minimal requirements</option>
<option value="2">medium quality</option>
<option value="3">high quality</option>
<option value="4">excellent quality</option>
<!-- further options -->
</select>
</div>
</div>
<div class="w3-row-padding">
<div class="w3-half">
<label class="w3-text-green" for="int_sel"><b>E Interactivity</b></label>
2023-02-02 07:41:10 +00:00
<select class="w3-select w3-border w3-white" name="int_sel" id="int_sel">
<option value="0" selected>not acceptable</option>
<option value="1">minimal requirements</option>
<option value="2">medium quality</option>
<option value="3">high quality</option>
<option value="4">excellent quality</option>
<!-- further options -->
</select>
</div>
<div class="w3-half">
<label class="w3-text-green" for="dyn_sel"><b>F Principle of Dynamic Drawing</b></label>
2023-02-02 07:41:10 +00:00
<select class="w3-select w3-border w3-white" name="dyn_sel" id="dyn_sel">
<option value="0" selected>not acceptable</option>
<option value="1">minimal requirements</option>
<option value="2">medium quality</option>
<option value="3">high quality</option>
<option value="4">excellent quality</option>
<!-- further options -->
</select>
</div>
</div>
<div class="w3-row-padding">
<div class="w3-half">
<label class="w3-text-green" for="tra_sel"><b>G Translatability</b></label>
2023-02-02 07:41:10 +00:00
<select class="w3-select w3-border w3-white" name="tra_sel" id="tra_sel">
<option value="0" selected>not acceptable</option>
<option value="1">minimal requirements</option>
<option value="2">medium quality</option>
<option value="3">high quality</option>
<option value="4">excellent quality</option>
<!-- further options -->
</select>
</div>
<div class="w3-half">
</div>
</div>
<div class="w3-container w3-margin">
<input class="w3-btn w3-green" type="submit" name="do_entry" value="OK" onlick="javascript:setNewValues();">
<input class="w3-btn w3-grey" type="reset" name="reset" value="Reset">
</div>
</form>
</div>
<hr/>
<canvas id="chartId" aria-label="chart" height="500" width="700"></canvas>
<script>
2023-04-03 10:26:10 +00:00
let chartHandleId = createChart(data, "title");
</script>
</body>
</html>