1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Added paste from clipboard support to uploads page.

This commit is contained in:
Uncled1023 2019-01-21 15:27:24 -08:00
parent 1d5d85b661
commit d3ac671618
4 changed files with 88 additions and 26 deletions

View File

@ -40,12 +40,12 @@
</div>
<div class="row">
<div class="col-sm-12">
<h2>Or just click here</h2>
<h2>Or paste them</h2>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h3>Your Choice</h3>
<h3>Or click</h3>
</div>
</div>
</div>

View File

@ -26,6 +26,19 @@ $(document).ready(function () {
linkExpireSelect($('#uploadSettings').find("#expireunit"));
});
document.onpaste = function (event) {
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
for (index in items) {
var item = items[index];
if (item.kind === 'file') {
// Convert file to blob
var file = item.getAsFile();
// Upload the file
upload(file);
}
}
}
});
function linkExpireSelect(element) {
@ -182,32 +195,36 @@ var dropZone = new Dropzone(document.body, {
clickable: "#uploadButton",
previewTemplate: function () { },
addedfile: function (file) {
// Convert file to blob
var blob = file.slice(0, file.size);
// Create a token for this upload
var token = {
callback: null,
cancel: function() {
this.callback();
},
isCancelable: function() {
return this.callback !== null;
}
};
// Create the Upload
var fileID = createUpload(file.name, token);
// Process the file
processFile(blob, file.name, file.type, file.size, fileID, token);
// Upload the file to the server
upload(file);
// Remove this file from the dropzone set
this.removeFile(file);
}
});
function upload(file) {
// Convert file to blob
var blob = file.slice(0, file.size);
// Create a token for this upload
var token = {
callback: null,
cancel: function () {
this.callback();
},
isCancelable: function () {
return this.callback !== null;
}
};
// Create the Upload
var fileID = createUpload(file.name, token);
// Process the file
processFile(blob, file.name, file.type, file.size, fileID, token);
}
var fileCount = 0;
function createUpload(fileName, token) {

View File

@ -305,6 +305,55 @@ function parseErrorMessage(errorObj) {
}
return errorMsg;
}
var re_weburl = new RegExp(
"^" +
// protocol identifier (optional)
// short syntax // still required
"(?:(?:(?:https?|ftp):)?\\/\\/)" +
// user:pass BasicAuth (optional)
"(?:\\S+(?::\\S*)?@)?" +
"(?:" +
// IP address exclusion
// private & local networks
"(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
"(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
"(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
// IP address dotted notation octets
// excludes loopback network 0.0.0.0
// excludes reserved space >= 224.0.0.0
// excludes network & broacast addresses
// (first & last IP address of each class)
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
"|" +
// host & domain names, may end with dot
// can be replaced by a shortest alternative
// (?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+
"(?:" +
"(?:" +
"[a-z0-9\\u00a1-\\uffff]" +
"[a-z0-9\\u00a1-\\uffff_-]{0,62}" +
")?" +
"[a-z0-9\\u00a1-\\uffff]\\." +
")+" +
// TLD identifier name, may end with dot
"(?:[a-z\\u00a1-\\uffff]{2,}\\.?)" +
")" +
// port number (optional)
"(?::\\d{2,5})?" +
// resource path (optional)
"(?:[/?#]\\S*)?" +
"$", "i"
);
function isValidURL(str) {
if (!re_weburl.test(str)) {
return false;
} else {
return true;
}
}
/***************************** TIMER Page Load *******************************/
var loopTime;

View File

@ -88,10 +88,6 @@
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="App_Data\ConnectionStrings.config">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="App_Data\MachineKey.config">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>