Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinrice committed Sep 30, 2018
1 parent 5420b5c commit 5c568eb
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 147 deletions.
Binary file removed archer_meta.png
Binary file not shown.
27 changes: 2 additions & 25 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,8 @@ <h3 style="margin-left: 10px;">Filter Images</h3>
script.src = map_src
document.getElementsByTagName('head')[0].appendChild(script);
</script>

<script>
const {Menu, MenuItem} = electron.remote
let rightClickPosition = null

const menu = new Menu()
const menuItem = new MenuItem({
label: 'Inspect Element',
click: () => {
remote.getCurrentWindow().inspectElement(rightClickPosition.x, rightClickPosition.y)
}
})
menu.append(menuItem)

window.addEventListener('contextmenu', (e) => {
e.preventDefault()
rightClickPosition = {x: e.x, y: e.y}
menu.popup(remote.getCurrentWindow())
}, false)
</script>



<link rel="stylesheet" href="./node_modules/choices.js/assets/styles/css/choices.min.css">
<script src="./node_modules/choices.js/assets/scripts/dist/choices.min.js"></script>
<link rel="stylesheet" href="./node_modules/choices.js/assets/styles/css/choices.min.css">
<script src="./node_modules/choices.js/assets/scripts/dist/choices.min.js"></script>
</body>

</html>
15 changes: 1 addition & 14 deletions js/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,14 @@ function addLineChart(id, xlabels, ylabel, values) {
pointHoverBorderColor: "#ff0099",
pointBorderWidth: 1,
data: values
}//, {
// label: "My Second dataset",
// backgroundColor: "rgba(3, 88, 106, 0.3)",
// borderColor: "rgba(3, 88, 106, 0.70)",
// pointBorderColor: "rgba(3, 88, 106, 0.70)",
// pointBackgroundColor: "rgba(3, 88, 106, 0.70)",
// pointHoverBackgroundColor: "#fff",
// pointHoverBorderColor: "rgba(151,187,205,1)",
// pointBorderWidth: 1,
// data: [82, 23, 66, 9, 99, 4, 2]
//}]
}
]},
options: {
responsive: true,
animation: {
animateScale: true
},
scales: {
// xAxes: [{
// display: false
// }],
yAxes: [{
ticks: {
beginAtZero: true,
Expand Down
57 changes: 0 additions & 57 deletions js/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ console.log(db_filename);
class Database {
constructor(opts) {
this.db = this.init_database();
// this.last_image_id = 0;
}

/* Uses callback(boolean) to return if Projects contains name. */
Expand Down Expand Up @@ -220,62 +219,6 @@ class Database {
});
}

/* Uses callback(img_path, proj_name, meta_dict, success) to add metadata in a dictionary. */
// add_image_meta(img_path, proj_name, meta_dict, callback) {
// var _this = this;
// var db = this.db;
// db.serialize(function() {
// var columns = [];
// db.each("PRAGMA table_info(Images)", function(err, col) {
// if (err) {
// console.error("FAILING: " + err);
// }
// columns.push(col.name);
// }, function() {
// console.log('add_project: columns', columns);
// for (var meta_key in meta_dict) {
// meta_key = meta_key.replace("-", "_");
// var col_exists = (columns.indexOf(meta_key) >= 0);
// var meta_value = meta_dict[meta_key];
// if (!col_exists) {
// var meta_type = typeof meta_value;
// db.run("ALTER TABLE Images ADD " + meta_key + " " + meta_type + ";");
// console.log('add_project: col added', meta_key, meta_type);
// } else {
// console.log('contains column', columns[meta_key])
// }
// }
//
// var success = false;
// _this.has_image(img_path, proj_name, function(bool) {
// if (bool) {
// var add_meta = "";
// var meta_length = Object.keys(meta_dict).length;
// var count = 0;
// var meta_values = [];
// for (var meta_key in meta_dict) {
// add_meta += meta_key + "=?";
// meta_values.push(meta_dict[meta_key]);
// if (count < meta_length - 1) {
// add_meta += ", ";
// }
// count++;
// }
// console.log(meta_values);
// var query = "UPDATE Images SET " + add_meta + " WHERE path=? AND proj_name=?";
// console.log(query, "query");
// var stmt = db.prepare(query);
// var params = meta_values + [img_path, proj_name];
// stmt.run(params);
// stmt.finalize();
// success = true;
// }
//
// callback(success);
// });
// });
// });
// }
add_image_meta(imgname, img_path, proj_name, meta_key, meta_value, callback) {
// set metadata for image
// if column doesn't exist, add column
Expand Down
25 changes: 1 addition & 24 deletions js/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ const path = require('path')
const fs = require('fs')
const remote = require('electron').remote
const Mustache = require('Mustache')
// const ExifImage = require('exif').ExifImage;
const { ExifTool } = require("exiftool-vendored");
const exiftool = new ExifTool();
const Chart = require('chart.js');
// const echarts = require('echarts');
// const select2 = require('select2');
const Choices = require('Choices.js')
const async = require("async");

Expand All @@ -35,13 +32,6 @@ $("#add-image").submit(function(e) {
loadDetail(_currentProj);
paths_global = null;
});
// for (var index in paths_global) {
// var filename = path.basename(paths_global[index]).split(".")[0];
// database.add_image(filename, paths_global[index], _currentProj, alert_image_upload);
// }

// loadDetail(_currentProj);
// paths_global = null;
});

function loadDetail(projectName, filter_params = {}) {
Expand All @@ -58,9 +48,6 @@ function loadDetail(projectName, filter_params = {}) {
document.getElementById('removefilter').onclick = removeFilterRow
document.getElementById('submitfilter').onclick = performFilter


// document.getElementById('checknonebtn').onclick = uncheckAll

redirect('detail');

/* Display project header. */
Expand Down Expand Up @@ -464,9 +451,7 @@ function loadHeader(project) {
if (typeof value != "string") {
value = JSON.stringify(value);
}
// value.replace(/,/g , "");
value = value.split(',').join(" ");
//value.replace("", "");
csvString += value + ", ";
});
csvString += "\n";
Expand Down Expand Up @@ -562,9 +547,7 @@ function insertDetailTemplate__NEW(data, id, path, projname) {
mediacontents = '<{{media}} class="img-responsive rounded" src="{{path}}" alt="' + data.sorry + '" controls>'
data.thumbcontents = '<{{media}} class="img-responsive rounded thumb" src="{{path}}" alt="{{displayName}}" controls>'
} else {
//mediacontents = '<object type="application/pdf" data="{{path}}"><p>' + data.sorry + '</p></object>'
var path_nospace = data.path.replace(/ /g, '%20')
console.log(path_nospace)
mediacontents = '<webview src="{{path}}" plugins></webview>'
data.thumbcontents = '<webview src="{{path}}" class="thumb" plugins></webview>'
}
Expand Down Expand Up @@ -731,12 +714,6 @@ function loadCharts(proj_name, filter_params) {
'</div>',
'</div>',
'</div>',
// '<div class=" col-md-4 col-xs-12">',
// '<div class="clearfix"></div>',
// '<div class="x_content">',
// '<canvas id="pie3"></canvas>',
// '</div>',
// '</div>',
'</div>',
].join("\n");

Expand Down Expand Up @@ -921,6 +898,7 @@ function setPhotoRemove(name) {
};
}

// TODO: a project for the future
// function setPhotoRename(name) {
// var projName = document.getElementById('project-name').innerHTML;
// document.getElementById("rename" + name).onclick = function() {
Expand Down Expand Up @@ -949,7 +927,6 @@ function clearDetailsHtml() {
document.getElementById("detail-charts").innerHTML = ""
document.getElementById("name-menu").innerHTML = ""
document.getElementById("thumb-menu").innerHTML = ""
// document.getElementById("file-label2").innerHTML = ""
}

module.exports = {
Expand Down
13 changes: 1 addition & 12 deletions js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@ function slideDrawer() {
var wid = menu.style.width
if (wid != '0px') {
menu.style.width = '0px'
//wrapper.style.marginLeft = '15px'
// wid = document.getElementById('side-nav').offsetWidth
// var newWidth = body.offsetWidth + wid
// body.style.width = newWidth.toString() + 'px'
} else {
menu.style.width = '170px' //"16.666%"
//wid = document.getElementById('side-nav').offsetWidth + 15
//wrapper.style.marginLeft = wid.toString() + 'px'
// body.style.width = "83.333%"
// body.style.marginLeft = wid.toString() + 'px'
//body.style.width = "66.666%"
// var newWidth = body.offsetWidth - wid
// body.style.width = newWidth.toString() + 'px'
menu.style.width = '170px'
}
}

Expand Down
5 changes: 0 additions & 5 deletions js/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ function insertSearchResults(error, results) {
"</div>",
"</div>",
].join("\n");
// data = {
// displayName: results.proj_name,
// name: results.proj_name,
// imgsrc: results.path,
// };
}

var filler = Mustache.render(template, results);
Expand Down
1 change: 0 additions & 1 deletion js/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function showNewProject() {
function populateProjectsScreen() {
document.getElementById("projects-body").innerHTML = "";
database.get_projects(function (projects_list) {
console.log(projects_list);

projects_list.sort(compareTimestamp);

Expand Down
1 change: 0 additions & 1 deletion js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function populate_settings_view(fields, favorite_fields, csv_fields) {

/* Update settings when a box is checked. */
$("#favcheck" + tag).click(function() {
console.log('triggering click fxn for ' + $(this).val() + ", " + $(this).is(":checked"))
database.update_favorites_field($(this).val(), "f", $(this).is(":checked"));
});

Expand Down
5 changes: 1 addition & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function createWindow () {
slashes: true
}))

// Open the DevTools.
// Open the DevTools (not for prod)
// mainWindow.webContents.openDevTools()

// Emitted when the window is closed.
Expand Down Expand Up @@ -80,6 +80,3 @@ if (app) {
}
})
}

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
2 changes: 0 additions & 2 deletions sections/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ <h2 class="section-heading">Contact us</h2>
We want to hear your thoughts! Drop us a line at <i>team@archerimpact.com</i>
or give us feedback on our metadata extractor in the feedback form below. Thanks!
<p>
<!-- <iframe src="https://docs.google.com/forms/d/e/1FAIpQLSdxK0pkRT43uXrkwQ20BKWAxj0bbchAu7AXAf8dxSoiTCLmZA/viewform?embedded=true" width="760" height="850" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe> -->
<!-- <webview id="annoying" src="https://docs.google.com/forms/d/e/1FAIpQLSdxK0pkRT43uXrkwQ20BKWAxj0bbchAu7AXAf8dxSoiTCLmZA/viewform?embedded=true" display:"inline-flex" width="760" height="850" frameborder="0" marginheight="0" marginwidth="0">Loading...</webview> -->
</p>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion sections/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ <h1 style="color: #3d3d3d; padding:0px; margin-top: 20px; margin-bottom: 20px;">
<button type="submit" style="background-color: #0d77e2; float:right;" class="btn btn-primary btn-lg">Create Project</button>
</form>
<script src="./js/new.js"></script>
<!-- Choose image: TODO: take image selection out and put in details.html -->
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion undefined.csv

This file was deleted.

0 comments on commit 5c568eb

Please sign in to comment.