mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-12 19:33:03 +00:00
Modified the toolbar image upload button so it correctly uploads images to ELOG. Changed the response content type to application/json so the client won't have to parse the response to JSON.
This commit is contained in:
parent
d05e6016b7
commit
25ed9017de
@ -8,5 +8,4 @@ CKEDITOR.editorConfig = function( config ) {
|
|||||||
// config.language = 'fr';
|
// config.language = 'fr';
|
||||||
// config.uiColor = '#AADC6E';
|
// config.uiColor = '#AADC6E';
|
||||||
config.extraPlugins = 'abbr,timestamp,dndfiles,eqneditor';
|
config.extraPlugins = 'abbr,timestamp,dndfiles,eqneditor';
|
||||||
config.filebrowserUploadUrl = "./"
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit bc15610a6c29370d2ca1b4ddfd15a3692dabbabc
|
Subproject commit e339fdcd88b87ae2f742d68a48ad3b3197418dd3
|
||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
CKEDITOR.dialog.add( 'image2', function( editor ) {
|
CKEDITOR.dialog.add( 'image2', function( editor ) {
|
||||||
|
|
||||||
// RegExp: 123, 123px, empty string ""
|
// RegExp: 123, 123px, empty string ""
|
||||||
@ -526,7 +527,6 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'Upload',
|
id: 'Upload',
|
||||||
hidden: true,
|
|
||||||
filebrowser: 'uploadButton',
|
filebrowser: 'uploadButton',
|
||||||
label: lang.uploadTab,
|
label: lang.uploadTab,
|
||||||
elements: [
|
elements: [
|
||||||
@ -539,8 +539,57 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
|
|||||||
{
|
{
|
||||||
type: 'fileButton',
|
type: 'fileButton',
|
||||||
id: 'uploadButton',
|
id: 'uploadButton',
|
||||||
filebrowser: 'info:src',
|
onLoad: function( a ) {
|
||||||
label: "uploadaj ovde",
|
CKEDITOR.document.getById( this.domId ).on( 'click', function() {
|
||||||
|
|
||||||
|
// grab the file(s) from the file input tag and upload it using AJAX
|
||||||
|
var dialog = this.getDialog();
|
||||||
|
var files = dialog.getContentElement("Upload", "upload").getInputElement().$.files;
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('drop-count', files.length); // number of files being uploaded
|
||||||
|
for (var i = 0; i < files.length; i++) {
|
||||||
|
formData.append('next_attachment', parent.next_attachment);
|
||||||
|
formData.append('encoding', "HTML");
|
||||||
|
formData.append('attfile', files[i]);
|
||||||
|
formData.append('acmd', "Upload"); // Command for the server to recognize this as an ajax upload
|
||||||
|
}
|
||||||
|
|
||||||
|
var URL = '/' + parent.logbook + '/upload.html?next_attachment=' + parent.next_attachment;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
xhr: function()
|
||||||
|
{
|
||||||
|
var xhr = new window.XMLHttpRequest();
|
||||||
|
|
||||||
|
//Upload progress
|
||||||
|
xhr.upload.addEventListener("progress", function(evt){
|
||||||
|
if (evt.lengthComputable) {
|
||||||
|
var percentComplete = evt.loaded / evt.total;
|
||||||
|
//Do something with upload progress
|
||||||
|
// console.log(percentComplete);
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
return xhr;
|
||||||
|
},
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
type: 'POST',
|
||||||
|
url: URL,
|
||||||
|
data: formData,
|
||||||
|
success: function(data) {
|
||||||
|
dialog.getContentElement( 'info', 'src' ).setValue( data.attachments[0].fullName );
|
||||||
|
},
|
||||||
|
fail: function() {
|
||||||
|
console.log("error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Do not call the built-in click command
|
||||||
|
return false;
|
||||||
|
}, this );
|
||||||
|
},
|
||||||
|
label: lang.btnUpload,
|
||||||
'for': [ 'Upload', 'upload' ]
|
'for': [ 'Upload', 'upload' ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -22,5 +22,26 @@ $(document).ready(function() {
|
|||||||
ev.editor.commands.save.exec = overridecmd.exec;
|
ev.editor.commands.save.exec = overridecmd.exec;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// There is a default listener on the submit button that we
|
||||||
|
// need to get rid off in order to get custom upload working
|
||||||
|
CKEDITOR.on('dialogDefinition', function (ev) {
|
||||||
|
// Take the dialog name and its definition from the event data.
|
||||||
|
var dialogName = ev.data.name;
|
||||||
|
var dialogDefinition = ev.data.definition;
|
||||||
|
|
||||||
|
// Check if the definition is from the dialog we're
|
||||||
|
// interested in (the 'image2' dialog).
|
||||||
|
if ( dialogName == 'image2' ) {
|
||||||
|
|
||||||
|
var dialogObj = dialogDefinition.dialog;
|
||||||
|
dialogObj.on("show", function() {
|
||||||
|
// replace the submit function with something useless
|
||||||
|
dialogObj.getContentElement( 'Upload', 'upload' ).submit = function() {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
CKEDITOR.replace('Text');
|
CKEDITOR.replace('Text');
|
||||||
});
|
});
|
||||||
@ -26349,7 +26349,7 @@ void show_uploader_json(LOGBOOK *lbs)
|
|||||||
}
|
}
|
||||||
if (!getcfg("global", "charset", charset, sizeof(charset)))
|
if (!getcfg("global", "charset", charset, sizeof(charset)))
|
||||||
strcpy(charset, DEFAULT_HTTP_CHARSET);
|
strcpy(charset, DEFAULT_HTTP_CHARSET);
|
||||||
rsprintf("Content-Type: text/plain;charset=%s\r\n\r\n", charset);
|
rsprintf("Content-Type: application/json;charset=%s\r\n\r\n", charset);
|
||||||
|
|
||||||
long attch_count = strtol(getparam("drop-count"), NULL, 10);
|
long attch_count = strtol(getparam("drop-count"), NULL, 10);
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
#define GIT_REVISION "Thu Jul 31 17:01:04 2014 +0200 - a883408"
|
#define GIT_REVISION "Wed Aug 6 15:19:55 2014 +0200 - d05e601"
|
||||||
|
|||||||
Binary file not shown.
@ -19,5 +19,21 @@
|
|||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "Yes"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "../src/elogd.c"
|
||||||
|
timestampString = "429029143.140329"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "26437"
|
||||||
|
endingLineNumber = "26437"
|
||||||
|
landmarkName = "load_password_file()"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
</Breakpoints>
|
</Breakpoints>
|
||||||
</Bucket>
|
</Bucket>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user