Skip to content

Commit

Permalink
handling of files with spaces, breakout utils js file
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinrice committed Aug 29, 2018
1 parent 01fb3c6 commit ab259f8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ <h3 style="margin-left: 10px;">Filter Images</h3>

<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="main.js"></script>
<script src="./js/utils.js"></script>
<script src="./js/nav.js"></script>
<script src="./js/charts.js"></script>
<script src="./js/home.js"></script>
Expand Down
10 changes: 5 additions & 5 deletions js/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $("#add-image").submit(function(e) {

async.forEachOfSeries(paths_global, function(item, index, done) {
var filename = path.basename(paths_global[index]).split(".")[0];
database.add_image(filename, paths_global[index], _currentProj, alert_image_upload);
database.add_image(nospaces(filename), paths_global[index], _currentProj, alert_image_upload);
done();
}, function(err) {
if (err) {
Expand Down Expand Up @@ -380,7 +380,7 @@ function insertErrorTemplate(error, id) {
'<div class="col-md-8">',
'<div class="row">',
'<div class="col-md-9">',
'<h3 style="word-wrap:break-word;" style="display: inline;">{{name}}</h3>',
'<h3 style="word-wrap:break-word;" style="display: inline;">{{displayName}}</h3>',
'</div>',
'<div class="col-md-3">',
'<div style="display: inline;" class="dropdown">',
Expand Down Expand Up @@ -485,6 +485,7 @@ function loadHeader(project) {
let paths = electron.remote.dialog.showOpenDialog({properties: ['openFile', 'multiSelections']});
async.forEachOfSeries(paths, function(item, index, done) {
var filename = path.basename(paths[index]).split(".")[0];
filename = nospaces(filename)
database.add_image(filename, paths[index], project['name'], index, paths.length, alert_image_upload);
done();
}, function(err) {
Expand All @@ -500,9 +501,8 @@ function insertDetailTemplate(img_name, img_path, proj_name) {
}

function insertDetailTemplate__NEW(data, id, path, projname) {
data.displayName = withspaces(data.name)
insertIntoSlideMenu(data, id);
console.log('id', id)
console.log('path', path)
data.id = id;

if (data.error) {
Expand Down Expand Up @@ -559,7 +559,7 @@ function insertDetailTemplate__NEW(data, id, path, projname) {
var template = [
'<div class="col-md-4 col-xs-6">',
'<div class="row name-row">',
'<h3 class="image-name">{{name}}</h3>',
'<h3 class="image-name">{{displayName}}</h3>',
'<div class="dropdown" style="display:inline; float:right">',
'<button class="settings-button btn btn-outline-secondary float-right dropdown-toggle" style="background-color: #89cafd; margin-bottom: 2px; color: white" type="button" id="dropdown' + id + '" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">',
'<i class="material-icons icon" style="height:25px;width:15px;font-size:15px;">settings</i>',
Expand Down
2 changes: 1 addition & 1 deletion js/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function populate_project_with_images(bool, project_name, img_paths) {
/* Populate newly created project with provided images. */
for (var index in img_paths) {
var filename = path.basename(img_paths[index]).split(".")[0];
database.add_image(filename, img_paths[index], project_name, index, img_paths.length, alert_image_upload);
database.add_image(nospaces(filename), img_paths[index], project_name, index, img_paths.length, alert_image_upload);
}
}

Expand Down
7 changes: 7 additions & 0 deletions js/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function nospaces(str) {
return str.replace(/ /g, "…");
}

function withspaces(str) {
return str.replace(//g, " ");
}

0 comments on commit ab259f8

Please sign in to comment.