-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from curationexperts/add-assets
Add missing assets
- Loading branch information
Showing
7 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
export default class DisplayUploadedFile { | ||
constructor() { | ||
this.regexp = /[^a-zA-Z0-9\.\-\+_]/g | ||
} | ||
replaceWhitespace(input) { | ||
return input.replace(this.regexp, '_') | ||
} | ||
|
||
requiresEscape(input) { | ||
return this.regexp.test(input) | ||
} | ||
|
||
displayReplaceMessage(input) { | ||
if (this.requiresEscape(input)) { | ||
return `<b> Note: </b> Your file name contained spaces, which have been replaced by underscores. | ||
This will have no effect on your import.` | ||
} else { | ||
return '' | ||
} | ||
} | ||
|
||
display() { | ||
var fileInput = document.querySelector('#file-upload') | ||
var files = fileInput.files | ||
for (var i = 0; i < files.length; i++) { | ||
var file = files[i] | ||
document.querySelector('#file-upload-display').innerHTML = ` | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="well style=" | ||
background-color: #dff0d8; | ||
border-color: #d6e9c6; | ||
color: #3c763d;"> | ||
<p>You sucessfully uploaded this CSV: <b> ${this.replaceWhitespace(file.name)} </b> | ||
</p> | ||
${this.displayReplaceMessage(file.name)} | ||
<p> | ||
</div> | ||
</div> | ||
</div>` | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var Zizia = { | ||
displayUploadedFile: function() { | ||
var DisplayUploadedFile = require('./DisplayUploadedFile') | ||
new DisplayUploadedFile().display() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.file-upload { | ||
width: 0.1px; | ||
height: 0.1px; | ||
opacity: 0; | ||
overflow: hidden; | ||
position: absolute; | ||
z-index: -1; | ||
} | ||
|
||
.file-upload + label { | ||
margin-bottom: 1em; | ||
} | ||
|
||
.file-upload:focus + label { | ||
outline: 1px dotted #000; | ||
outline: -webkit-focus-ring-color auto 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@require 'file-upload'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<%= form.file_field :manifest, required: true, id: 'file-upload', class: "file-upload form-control", onchange: "Tenejo.displayUploadedFile()" %> | ||
<%= form.file_field :manifest, required: true, id: 'file-upload', class: "file-upload form-control", onchange: "Zizia.displayUploadedFile()" %> | ||
<label for="file-upload" class="btn btn-lg btn-primary"><span class="glyphicon glyphicon-upload"></span> Upload Your CSV</label> | ||
<div id="file-upload-display"></div> |