Commit 15e82055 authored by Sanjit Singh Chouhan's avatar Sanjit Singh Chouhan

initial commit

parent 311fde6e
date,name,start,end
2/6/18,a,12:00,13:00
2/6/18,b,13:00,13:30
2/6/18,c,14:00,15:00
3/6/18,d,12:00,13:00
3/6/18,e,13:00,13:30
3/6/18,f,14:00,15:00
\ No newline at end of file
This diff is collapsed.
logo.png

794 Bytes

{
"manifest_version": 2,
"name": "Summer of Data",
"version": "1.0",
"icons": {
"48": "logo.png"
},
"permissions": [
"activeTab"
],
"content_scripts": [
{
"matches": ["*://*.swecha.io/*"],
"js": ["summerofdata.js"]
}
]
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Summer of Data</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<h1 align="center">Summer of Data</h1>
<h2 align="center">Schedule for <span id="date_placeholder"></span></h2>
<table border="1" align="center">
<thead>
<tr>
<th width="10%">S.No</th>
<th width="50%">Name</th>
<th width="30%">Timing</th>
</tr>
</thead>
<tbody id="schedule_table_body">
</tbody>
</table>
<script src="schedule.js"></script>
</body>
</html>
\ No newline at end of file
var today = new Date();
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var date_text = today.getDate() + ' ' + monthNames[today.getMonth()] + ' ' + today.getFullYear();
document.getElementById("date_placeholder").appendChild(document.createTextNode(date_text));
$(document).ready(function() {
$.ajax({
type: "GET",
url: "data.csv",
dataType: "text",
success: function(data) {processData(data);}
});
});
var table = document.getElementById('schedule_table_body');
function processData(allText) {
var allTextLines = allText.split(/\r\n|\n/);
var headers = allTextLines[0].split(',');
var s_no = 1;
for (var i=1; i<allTextLines.length; i++) {
var data = allTextLines[i].split(',');
if (data.length == headers.length) {
var tarr = {};
for (var j=0; j<headers.length; j++) {
tarr[headers[j]]=data[j];
}
var record_date = new Date(tarr.date.replace( /(\d)\/(\d)\/(\d)/, "$2/$1/$3"));
console.log(record_date);
console.log(today);
if (record_date.getDate() == today.getDate() && record_date.getMonth() == today.getMonth() && record_date.getFullYear() == today.getFullYear()) {
var row = document.createElement("tr");
var sno = document.createElement("td");
sno.appendChild(document.createTextNode(s_no));
row.appendChild(sno);
var name = document.createElement("td");
name.appendChild(document.createTextNode(tarr.name));
row.appendChild(name);
var timing = document.createElement("td");
timing.appendChild(document.createTextNode(tarr.start + ' - ' + tarr.end));
row.appendChild(timing);
table.appendChild(row);
s_no++;
}
}
}
}
\ No newline at end of file
var banner = document.createElement("div");
var message = document.createTextNode("Welcome to Summer of Data");
banner.appendChild(message);
var schedule_btn = document.createElement("button");
schedule_btn.id = 'schedule_btn';
schedule_btn.appendChild(document.createTextNode("View Today's Schedule"));
schedule_btn.style.cssFloat = 'right';
schedule_btn.style.fontSize = '0.5em';
schedule_btn.style.height = '30px';
schedule_btn.style.lineHeight = '0';
schedule_btn.style.backgroundColor = '#e1ecf4';
banner.appendChild(schedule_btn);
banner.style.background = 'white';
banner.style.height = '50px';
banner.style.color = 'black';
banner.style.fontSize = '2em';
banner.style.padding = '5px';
banner.className = 'summer-of-data';
var schedule = document.createElement("div");
schedule.className = 'summer-of-data';
schedule.style.display = 'none';
var url = browser.extension.getURL('schedule.html');
console.log(url);
document.body.insertBefore(schedule, document.body.firstChild);
document.body.insertBefore(banner, document.body.firstChild);
schedule_btn.addEventListener("click", evt => {
var children = document.getElementById('top').children;
for (var i = 0; i < children.length; i++) {
children[i].style.display = 'none';
}
document.getElementsByClassName('summer-of-data').item(0).style.display = 'block';
document.getElementsByClassName('summer-of-data').item(1).style.display = 'block';
schedule.innerHTML = '\
\
<!DOCTYPE html>\n' +
'<html lang="en">\n' +
' <script src="jquery-3.3.1.min.js"></script>\n' +
'<body>\n' +
'<h1 align="center">Summer of Data</h1>\n' +
'<h2 align="center">Schedule for <span id="date_placeholder"></span></h2>\n' +
'\n' +
'<table border="1" align="center">\n' +
' <thead>\n' +
' <tr>\n' +
' <th width="10%">S.No</th>\n' +
' <th width="50%">Name</th>\n' +
' <th width="30%">Timing</th>\n' +
' </tr>\n' +
' </thead>\n' +
' <tbody id="schedule_table_body">\n' +
' </tbody>\n' +
'</table>\n' +
'\n' +
'<script src="schedule.js"></script>\n' +
'</body>\n' +
'</html>';
var today = new Date();
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var date_text = today.getDate() + ' ' + monthNames[today.getMonth()] + ' ' + today.getFullYear();
document.getElementById("date_placeholder").appendChild(document.createTextNode(date_text));
$(document).ready(function() {
$.ajax({
type: "GET",
url: "data.csv",
dataType: "text",
success: function(data) {processData(data);}
});
});
var table = document.getElementById('schedule_table_body');
function processData(allText) {
var allTextLines = allText.split(/\r\n|\n/);
var headers = allTextLines[0].split(',');
var s_no = 1;
for (var i=1; i<allTextLines.length; i++) {
var data = allTextLines[i].split(',');
if (data.length == headers.length) {
var tarr = {};
for (var j=0; j<headers.length; j++) {
tarr[headers[j]]=data[j];
}
var record_date = new Date(tarr.date.replace( /(\d)\/(\d)\/(\d)/, "$2/$1/$3"));
console.log(record_date);
console.log(today);
if (record_date.getDate() == today.getDate() && record_date.getMonth() == today.getMonth() && record_date.getFullYear() == today.getFullYear()) {
var row = document.createElement("tr");
var sno = document.createElement("td");
sno.appendChild(document.createTextNode(s_no));
row.appendChild(sno);
var name = document.createElement("td");
name.appendChild(document.createTextNode(tarr.name));
row.appendChild(name);
var timing = document.createElement("td");
timing.appendChild(document.createTextNode(tarr.start + ' - ' + tarr.end));
row.appendChild(timing);
table.appendChild(row);
s_no++;
}
}
}
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment