Added a global progress bar for all custom plugins which upload files. Also added a progress bar for the drag and drop box for attachment upload.

This commit is contained in:
Dario Milicic 2014-08-19 15:07:22 +02:00
parent 74a2bb2705
commit 53bed4e1f9
13 changed files with 150 additions and 72 deletions

View File

@ -165,12 +165,12 @@ install: $(EXECS)
@$(INSTALL) -v -m 0644 man/elogd.8 $(MANDIR)/man8/
@$(INSTALL) -v -m 0644 scripts/*.js $(ELOGDIR)/scripts/
@echo "Installing FCKeditor to $(ELOGDIR)/scripts/fckeditor"
@unzip -q -o scripts/fckeditor.zip -d $(ELOGDIR)/scripts/
@$(INSTALL) -v -m 0644 scripts/fckeditor/fckelog.js $(ELOGDIR)/scripts/fckeditor/fckelog.js
@mkdir -p -m 0755 $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog
@$(INSTALL) -v -m 0644 scripts/fckeditor/editor/plugins/elog/fckplugin.js $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog/fckplugin.js
@$(INSTALL) -v -m 0644 scripts/fckeditor/editor/plugins/elog/inserttime.gif $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog/inserttime.gif
# @echo "Installing CKeditor to $(ELOGDIR)/scripts/ckeditor"
# @unzip -q -o scripts/fckeditor.zip -d $(ELOGDIR)/scripts/
# @$(INSTALL) -v -m 0644 scripts/fckeditor/fckelog.js $(ELOGDIR)/scripts/fckeditor/fckelog.js
# @mkdir -p -m 0755 $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog
# @$(INSTALL) -v -m 0644 scripts/fckeditor/editor/plugins/elog/fckplugin.js $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog/fckplugin.js
# @$(INSTALL) -v -m 0644 scripts/fckeditor/editor/plugins/elog/inserttime.gif $(ELOGDIR)/scripts/fckeditor/editor/plugins/elog/inserttime.gif
@echo "Installing resources to $(ELOGDIR)/resources"
@$(INSTALL) -m 0644 resources/* $(ELOGDIR)/resources/

71
elogd.init Normal file
View File

@ -0,0 +1,71 @@
#!/bin/sh
# chkconfig: 3 90 10
# description: ELOG is a weblog with integrated database
# processname: elogd
# config: /usr/local/elog/elogd.cfg
# pidfile: /var/run/elogd.pid
# Source function library.
# . /etc/rc.d/init.d/functions
# Check for the config file
if [ ! -f /usr/local/elog/elogd.cfg ]; then
exit 0
fi
# See how we were called.
case "$1" in
start)
if [ -f /var/run/elogd.pid ] ; then
pid=`cat /var/run/elogd.pid`
if [ -d /proc/$pid ] ; then
echo "elogd already running"
# echo_failure
exit 1
fi
fi
if [ -f /var/run/elogd.pid ] ; then
rm -f /var/lock/subsys/elogd
rm -f /var/run/elogd.pid
fi
echo -n "Starting elogd: "
/usr/local/sbin/elogd -D -c /usr/local/elog/elogd.cfg > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
touch /var/lock/subsys/elogd
fi
echo
;;
stop)
echo ""
if [ -f /var/run/elogd.pid ] ; then
echo -n "Stoping elogd: "
/bin/kill `cat /var/run/elogd.pid`
rm -f /var/lock/subsys/elogd
rm -f /var/run/elogd.pid
echo_success
echo
else
echo -n "No elogd running?"
echo
fi
;;
status)
status -p /var/run/elogd.pid /usr/local/sbin/elogd
RETVAL=$?
;;
restart|reload)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0

View File

@ -7,7 +7,7 @@
# pidfile: /var/run/elogd.pid
# Source function library.
. /etc/rc.d/init.d/functions
# . /etc/rc.d/init.d/functions
# Check for the config file
if [ ! -f @PREFIX@/elog/elogd.cfg ]; then
@ -22,7 +22,7 @@ case "$1" in
pid=`cat /var/run/elogd.pid`
if [ -d /proc/$pid ] ; then
echo "elogd already running"
echo_failure
# echo_failure
exit 1
fi
fi
@ -35,9 +35,6 @@ case "$1" in
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
touch /var/lock/subsys/elogd
echo_success
else
echo_failure
fi
echo
;;
@ -52,7 +49,6 @@ case "$1" in
echo
else
echo -n "No elogd running?"
echo_failure
echo
fi

@ -1 +1 @@
Subproject commit 41551357b1c8e24cc2640d8558f683a94a1df3e4
Subproject commit 83f4ac1be652ca0db0ecb02e6a7bfa7daceec3f6

View File

@ -73,12 +73,16 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) {
{
var xhr = new window.XMLHttpRequest();
// Start the progress bar
progressJs().start();
//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);
//Update the progress bar
progressJs().set(percentComplete);
}
}, false);
@ -90,6 +94,10 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) {
url: URL,
data: formData,
success: function(data) {
// End the progress bar
progressJs().end();
if(data.attachments[0]) { // check if we have the correct response
dialog.getContentElement( 'Upload', 'src' ).setValue( data.attachments[0].fullName );
} else {
@ -97,6 +105,8 @@ CKEDITOR.dialog.add( 'fileuploadDialog', function( editor ) {
}
},
fail: function() {
// End the progress bar
progressJs().end();
console.log("error");
}
});

View File

@ -568,12 +568,15 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
{
var xhr = new window.XMLHttpRequest();
// Start the progress bar
progressJs().start();
//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);
//Update the progress bar
progressJs().set(percentComplete);
}
}, false);
@ -585,6 +588,10 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
url: URL,
data: formData,
success: function(data) {
// End the progress bar
progressJs().end();
if(data.attachments) { // check if we have the correct response
dialog.getContentElement( 'info', 'src' ).setValue( data.attachments[0].fullName );
} else {
@ -592,6 +599,8 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
}
},
fail: function() {
// End the progress bar
progressJs().end();
console.log("error");
}
});

View File

@ -1,4 +1,5 @@
$(document).ready(function() {
$('textarea').addClass("ckeditor");
// Need to wait for the ckeditor instance to finish initialization
@ -78,10 +79,10 @@ $(document).ready(function() {
}, 1);
});
// self.on('drop', function(event) {
// collection = $();
// self.trigger('dndHoverEnd');
// });
self.on('drop', function(event) {
collection = $();
self.trigger('dndHoverEnd');
});
});
};
@ -148,24 +149,18 @@ $(document).ready(function() {
{
var xhr = new window.XMLHttpRequest();
// Start the progress bar
progressJs().start();
//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);
//Update the progress bar
progressJs().set(percentComplete);
}
}, false);
//Download progress
// xhr.addEventListener("progress", function(evt){
// if (evt.lengthComputable) {
// var percentComplete = evt.loaded / evt.total;
// //Do something with download progress
// console.log(percentComplete);
// }
// }, false);
return xhr;
},
contentType: false,
@ -174,21 +169,21 @@ $(document).ready(function() {
url: URL,
data: formData,
success: function(data) {
console.log(data);
// End the progress bar
progressJs().end();
var attch = $(".attachment", $(data));
var attch_upload = $("#attachment_upload", $(data));
// attch.each(function(idx, element) {
// $("#attachment_upload").before(element);
// console.log(element);
// });
// add the new attachments to the current page
$("#attachment_upload").before(attch.slice(-files.length));
// replace the attachment upload section
$("#attachment_upload").replaceWith(attch_upload);
// console.log(attch.last());
},
fail: function() {
// End the progress bar
progressJs().end();
console.log("Error uploading files...");
}
});

11
scripts/progress/progress.min.js vendored Normal file
View File

@ -0,0 +1,11 @@
(function(l,e){"object"===typeof exports?e(exports):"function"===typeof define&&define.amd?define(["exports"],e):e(l)})(this,function(l){function e(a){this._targetElement="undefined"!=typeof a.length?a:[a];"undefined"===typeof window._progressjsId&&(window._progressjsId=1);"undefined"===typeof window._progressjsIntervals&&(window._progressjsIntervals={});this._options={theme:"blue",overlayMode:!1,considerTransition:!0}}function m(a,c){var d=this;100<=c&&(c=100);a.hasAttribute("data-progressjs")&&
setTimeout(function(){"undefined"!=typeof d._onProgressCallback&&d._onProgressCallback.call(d,a,c);var b=h(a);b.style.width=parseInt(c)+"%";var b=b.querySelector(".progressjs-percent"),g=parseInt(b.innerHTML.replace("%","")),e=parseInt(c),j=function(a,b,c){var d=Math.abs(b-c);3>d?k=30:20>d?k=20:intervanIn=1;0!=b-c&&(a.innerHTML=(f?++b:--b)+"%",setTimeout(function(){j(a,b,c)},k))},f=!0;g>e&&(f=!1);var k=10;j(b,g,e)},50)}function h(a){a=parseInt(a.getAttribute("data-progressjs"));return document.querySelector('.progressjs-container > .progressjs-progress[data-progressjs="'+
a+'"] > .progressjs-inner')}function p(a){for(var c=0,d=this._targetElement.length;c<d;c++){var b=this._targetElement[c];if(b.hasAttribute("data-progressjs")){var g=h(b);(g=parseInt(g.style.width.replace("%","")))&&m.call(this,b,g+(a||1))}}}function q(){var a,c=document.createElement("fakeelement"),d={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(a in d)if(void 0!==c.style[a])return d[a]}var n=function(a){if("object"===
typeof a)return new e(a);if("string"===typeof a){if(a=document.querySelectorAll(a))return new e(a);throw Error("There is no element with given selector.");}return new e(document.body)};n.version="0.1.0";n.fn=e.prototype={clone:function(){return new e(this)},setOption:function(a,c){this._options[a]=c;return this},setOptions:function(a){var c=this._options,d={},b;for(b in c)d[b]=c[b];for(b in a)d[b]=a[b];this._options=d;return this},start:function(){"undefined"!=typeof this._onBeforeStartCallback&&
this._onBeforeStartCallback.call(this);if(!document.querySelector(".progressjs-container")){var a=document.createElement("div");a.className="progressjs-container";document.body.appendChild(a)}for(var a=0,c=this._targetElement.length;a<c;a++){var d=this._targetElement[a];if(!d.hasAttribute("data-progressjs")){var b=d,g,e,j;"body"===b.tagName.toLowerCase()?(g=b.clientWidth,e=b.clientHeight):(g=b.offsetWidth,e=b.offsetHeight);for(var f=j=0;b&&!isNaN(b.offsetLeft)&&!isNaN(b.offsetTop);)j+=b.offsetLeft,
f+=b.offsetTop,b=b.offsetParent;b=f;d.setAttribute("data-progressjs",window._progressjsId);f=document.createElement("div");f.className="progressjs-progress progressjs-theme-"+this._options.theme;f.style.position="body"===d.tagName.toLowerCase()?"fixed":"absolute";f.setAttribute("data-progressjs",window._progressjsId);var k=document.createElement("div");k.className="progressjs-inner";var h=document.createElement("div");h.className="progressjs-percent";h.innerHTML="1%";k.appendChild(h);this._options.overlayMode&&
"body"===d.tagName.toLowerCase()?(f.style.left=0,f.style.right=0,f.style.top=0,f.style.bottom=0):(f.style.left=j+"px",f.style.top=b+"px",f.style.width=g+"px",this._options.overlayMode&&(f.style.height=e+"px"));f.appendChild(k);document.querySelector(".progressjs-container").appendChild(f);m(d,1);++window._progressjsId}}return this},set:function(a){for(var c=0,d=this._targetElement.length;c<d;c++)m.call(this,this._targetElement[c],a);return this},increase:function(a){p.call(this,a);return this},autoIncrease:function(a,
c){var d=this,b=parseInt(this._targetElement[0].getAttribute("data-progressjs"));"undefined"!=typeof window._progressjsIntervals[b]&&clearInterval(window._progressjsIntervals[b]);window._progressjsIntervals[b]=setInterval(function(){p.call(d,a)},c);return this},end:function(){a:{"undefined"!=typeof this._onBeforeEndCallback&&(!0===this._options.considerTransition?h(this._targetElement[0]).addEventListener(q(),this._onBeforeEndCallback,!1):this._onBeforeEndCallback.call(this));for(var a=parseInt(this._targetElement[0].getAttribute("data-progressjs")),
c=0,d=this._targetElement.length;c<d;c++){var b=this._targetElement[c],e=h(b);if(!e)break a;var l=1;100>parseInt(e.style.width.replace("%",""))&&(m.call(this,b,100),l=500);(function(a,b){setTimeout(function(){a.parentNode.className+=" progressjs-end";setTimeout(function(){a.parentNode.parentNode.removeChild(a.parentNode);b.removeAttribute("data-progressjs")},1E3)},l)})(e,b)}if(window._progressjsIntervals[a])try{clearInterval(window._progressjsIntervals[a]),window._progressjsIntervals[a]=null,delete window._progressjsIntervals[a]}catch(j){}}return this},
onbeforeend:function(a){if("function"===typeof a)this._onBeforeEndCallback=a;else throw Error("Provided callback for onbeforeend was not a function");return this},onbeforestart:function(a){if("function"===typeof a)this._onBeforeStartCallback=a;else throw Error("Provided callback for onbeforestart was not a function");return this},onprogress:function(a){if("function"===typeof a)this._onProgressCallback=a;else throw Error("Provided callback for onprogress was not a function");return this}};return l.progressJs=
n});

1
scripts/progress/progressjs.min.css vendored Normal file
View File

@ -0,0 +1 @@
.progressjs-inner{width:0}.progressjs-progress{z-index:9999999}.progressjs-theme-blue .progressjs-inner{height:2px;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;background-color:#3498db}.progressjs-theme-blue.progressjs-end{-webkit-transition:opacity .2s ease-out;-moz-transition:opacity .2s ease-out;-o-transition:opacity .2s ease-out;transition:opacity .2s ease-out;opacity:0}.progressjs-theme-blue .progressjs-percent{display:none}.progressjs-theme-blueOverlay{background-color:white;-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;-o-transition:all .2s ease-out;transition:all .2s ease-out}.progressjs-theme-blueOverlay .progressjs-inner{height:100%;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;background-color:#3498db}.progressjs-theme-blueOverlay.progressjs-end{opacity:0!important}.progressjs-theme-blueOverlay .progressjs-percent{display:none}.progressjs-theme-blueOverlay{background-color:white;-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;-o-transition:all .2s ease-out;transition:all .2s ease-out}.progressjs-theme-blueOverlay .progressjs-inner{height:100%;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;background-color:#3498db}.progressjs-theme-blueOverlay.progressjs-end{opacity:0!important}.progressjs-theme-blueOverlay .progressjs-percent{display:none}.progressjs-theme-blueOverlayRadius{background-color:white;-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;-o-transition:all .2s ease-out;transition:all .2s ease-out;border-radius:5px}.progressjs-theme-blueOverlayRadius .progressjs-inner{height:100%;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;background-color:#3498db;border-radius:5px}.progressjs-theme-blueOverlayRadius.progressjs-end{opacity:0!important}.progressjs-theme-blueOverlayRadius .progressjs-percent{display:none}.progressjs-theme-blueOverlayRadiusHalfOpacity{background-color:white;opacity:.5;-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;-o-transition:all .2s ease-out;transition:all .2s ease-out;border-radius:5px}.progressjs-theme-blueOverlayRadiusHalfOpacity .progressjs-inner{height:100%;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;background-color:#3498db;border-radius:5px}.progressjs-theme-blueOverlayRadiusHalfOpacity.progressjs-end{opacity:0!important}.progressjs-theme-blueOverlayRadiusHalfOpacity .progressjs-percent{display:none}.progressjs-theme-blueOverlayRadiusWithPercentBar{background-color:white;-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;-o-transition:all .2s ease-out;transition:all .2s ease-out;border-radius:5px}.progressjs-theme-blueOverlayRadiusWithPercentBar .progressjs-inner{height:100%;-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;background-color:#3498db;border-radius:5px}.progressjs-theme-blueOverlayRadiusWithPercentBar.progressjs-end{opacity:0!important}.progressjs-theme-blueOverlayRadiusWithPercentBar .progressjs-percent{width:70px;text-align:center;height:40px;position:absolute;right:50%;margin-right:-35px;top:50%;margin-top:-20px;font-size:30px;opacity:.5}.progressjs-theme-blackRadiusInputs{height:10px;border-radius:10px;overflow:hidden}.progressjs-theme-blackRadiusInputs .progressjs-inner{height:2px;-webkit-transition:all 1s ease-out;-moz-transition:all 1s ease-out;-o-transition:all 1s ease-out;transition:all 1s ease-out;background-color:#34495e}.progressjs-theme-blackRadiusInputs.progressjs-end{-webkit-transition:opacity .2s ease-out;-moz-transition:opacity .2s ease-out;-o-transition:opacity .2s ease-out;transition:opacity .2s ease-out;opacity:0}.progressjs-theme-blackRadiusInputs .progressjs-percent{display:none}

View File

@ -9915,7 +9915,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
if (enc_selected == 2 && fckedit_exist && show_text && !fixed_text) {
rsprintf("<script type=\"text/javascript\" src=\"../ckeditor/ckeditor.js\"></script>\n");
rsprintf("<script type=\"text/javascript\" src=\"../jquery-1.11.1.min.js\"></script>\n");
// rsprintf("<script type=\"text/javascript\" src=\"../fckeditor/fckeditor.js\"></script>\n");
rsprintf("<script type=\"text/javascript\" src=\"../progress/progress.min.js\"></script>\n");
rsprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"../progress/progressjs.min.css\">\n");
}
/* external script if requested */

View File

@ -1 +1 @@
#define GIT_REVISION "Mon Aug 11 11:19:47 2014 +0200 - 228262b"
#define GIT_REVISION "Thu Aug 14 13:59:07 2014 +0200 - 74a2bb2"

View File

@ -19,38 +19,6 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../src/elogd.c"
timestampString = "429458497.630275"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "26963"
endingLineNumber = "26963"
landmarkName = "load_password_file()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../src/elogd.c"
timestampString = "429458522.650716"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "26274"
endingLineNumber = "26274"
landmarkName = "load_password_file()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
@ -67,5 +35,21 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../src/elogd.c"
timestampString = "430066989.771518"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "27540"
endingLineNumber = "27540"
landmarkName = "load_password_file()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>