javac -cp maryclient.jar MaryClientUser.java
+ *
+ * And run as:
+ * java -cp .:maryclient.jar MaryClientUser
+ *
+ * @author marc
+ *
+ */
+
+public class MaryClientUser {
+
+ public static void main(String[] args)
+ throws IOException, UnknownHostException, UnsupportedAudioFileException,
+ InterruptedException
+ {
+ String serverHost = System.getProperty("server.host", "cling.dfki.uni-sb.de");
+ int serverPort = Integer.getInteger("server.port", 59125).intValue();
+ MaryClient mary = MaryClient.getMaryClient(new Address(serverHost, serverPort));
+ String text = "Willkommen in der Welt der Sprachsynthese!";
+ // If the given locale is not supported by the server, it returns
+ // an ambigous exception: "Problem processing the data."
+ String locale = "de"; // or US English (en-US), Telugu (te), Turkish (tr), ...
+ String inputType = "TEXT";
+ String outputType = "AUDIO";
+ String audioType = "WAVE";
+ String defaultVoiceName = null;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ mary.process(text, inputType, outputType, locale, audioType, defaultVoiceName, baos);
+ // The byte array constitutes a full wave file, including the headers.
+ // And now, play the audio data:
+ AudioInputStream ais = AudioSystem.getAudioInputStream(
+ new ByteArrayInputStream(baos.toByteArray()));
+ LineListener lineListener = new LineListener() {
+ public void update(LineEvent event) {
+ if (event.getType() == LineEvent.Type.START) {
+ System.err.println("Audio started playing.");
+ } else if (event.getType() == LineEvent.Type.STOP) {
+ System.err.println("Audio stopped playing.");
+ } else if (event.getType() == LineEvent.Type.OPEN) {
+ System.err.println("Audio line opened.");
+ } else if (event.getType() == LineEvent.Type.CLOSE) {
+ System.err.println("Audio line closed.");
+ }
+ }
+ };
+
+ AudioPlayer ap = new AudioPlayer(ais, lineListener);
+ ap.start();
+ }
+}
diff --git a/external/marytts-5.1.2/doc/examples/client/c++/Makefile b/external/marytts-5.1.2/doc/examples/client/c++/Makefile
new file mode 100755
index 00000000..a609beda
--- /dev/null
+++ b/external/marytts-5.1.2/doc/examples/client/c++/Makefile
@@ -0,0 +1,45 @@
+##########################################################################
+# Copyright (C) 2000-2006 DFKI GmbH.
+# All rights reserved. Use is subject to license terms.
+#
+# Permission is hereby granted, free of charge, to use and distribute
+# this software and its documentation without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of this work, and to
+# permit persons to whom this work is furnished to do so, subject to
+# the following conditions:
+#
+# 1. The code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+# 2. Any modifications must be clearly marked as such.
+# 3. Original authors' names are not deleted.
+# 4. The authors' names are not used to endorse or promote products
+# derived from this software without specific prior written
+# permission.
+#
+# DFKI GMBH AND THE CONTRIBUTORS TO THIS WORK DISCLAIM ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DFKI GMBH NOR THE
+# CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+# THIS SOFTWARE.
+##########################################################################
+
+CC=g++
+CFLAGS=-Wall -w -O3 -g
+ICUDIR=/usr/local/icu
+ICULIBS=-Wl,-R,$(ICUDIR)/lib -L$(ICUDIR)/lib -licuuc -licui18n -ldl
+
+all: MaryDemo
+
+MaryDemo: MaryClient.o MaryDemo.o
+ $(CC) $(CFLAGS) *.o -o MaryDemo $(LIBS)
+
+%.o: %.cc
+ $(CC) $(CFLAGS) $(RFLAGS) -o $@ -c $<
+
+clean:
+ rm -rf *.o ./MaryDemo
+
diff --git a/external/marytts-5.1.2/doc/examples/client/c++/MaryClient.cc b/external/marytts-5.1.2/doc/examples/client/c++/MaryClient.cc
new file mode 100755
index 00000000..7e920d95
--- /dev/null
+++ b/external/marytts-5.1.2/doc/examples/client/c++/MaryClient.cc
@@ -0,0 +1,277 @@
+/**
+ * Copyright 2000-2006 DFKI GmbH.
+ * All Rights Reserved. Use is subject to license terms.
+ *
+ * Permission is hereby granted, free of charge, to use and distribute
+ * this software and its documentation without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of this work, and to
+ * permit persons to whom this work is furnished to do so, subject to
+ * the following conditions:
+ *
+ * 1. The code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ * 2. Any modifications must be clearly marked as such.
+ * 3. Original authors' names are not deleted.
+ * 4. The authors' names are not used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * DFKI GMBH AND THE CONTRIBUTORS TO THIS WORK DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DFKI GMBH NOR THE
+ * CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include | " + title + " | |
|---|---|
| " + name + " | "; - text += "" + value + " | "; - text += "
=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=T);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o 1?(h.on(t,n),e):h.on(t)}}}function Ao(){var t,n,e,r,i,o,a=ho(-30),u=1,s=1/0,l=.81;function c(r){var o,a=t.length,u=(1===n?Hi(t,xo):2===n?Ki(t,xo,bo):3===n?uo(t,xo,bo,wo):null).visitAfter(f);for(i=r,o=0;o1&&(t.y=a/c),n>2&&(t.z=u/c)}else{(e=t).x=e.data.x,n>1&&(e.y=e.data.y),n>2&&(e.z=e.data.z);do{l+=o[e.data.index]}while(e=e.next)}t.value=l}function d(t,a,c,h,f){if(!t.value)return!0;var d=[c,h,f][n-1],p=t.x-e.x,g=n>1?t.y-e.y:0,y=n>2?t.z-e.z:0,v=d-a,_=p*p+g*g+y*y;if(v*v/l<_)return _1&&0===g&&(_+=(g=fo(r))*g),n>2&&0===y&&(_+=(y=fo(r))*y),_1&&(e.vy+=g*t.value*i/_),n>2&&(e.vz+=y*t.value*i/_)),!0;if(!(t.length||_>=s)){(t.data!==e||t.next)&&(0===p&&(_+=(p=fo(r))*p),n>1&&0===g&&(_+=(g=fo(r))*g),n>2&&0===y&&(_+=(y=fo(r))*y),_1&&(e.vy+=g*v),n>2&&(e.vz+=y*v))}while(t=t.next)}}return c.initialize=function(e,...i){t=e,r=i.find((t=>"function"==typeof t))||Math.random,n=i.find((t=>[1,2,3].includes(t)))||2,h()},c.strength=function(t){return arguments.length?(a="function"==typeof t?t:ho(+t),h(),c):a},c.distanceMin=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(l=t*t,c):Math.sqrt(l)},c}const{abs:So,cos:Co,sin:Eo,acos:Oo,atan2:No,sqrt:Po,pow:jo}=Math;function To(t){return t<0?-jo(-t,1/3):jo(t,1/3)}const Ro=Math.PI,Do=2*Ro,Io=Ro/2,Uo=Number.MAX_SAFE_INTEGER||9007199254740991,Fo=Number.MIN_SAFE_INTEGER||-9007199254740991,Lo={x:0,y:0,z:0},qo={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,n){const e=n(t);let r=e.x*e.x+e.y*e.y;return void 0!==e.z&&(r+=e.z*e.z),Po(r)},compute:function(t,n,e){if(0===t)return n[0].t=0,n[0];const r=n.length-1;if(1===t)return n[r].t=1,n[r];const i=1-t;let o=n;if(0===r)return n[0].t=t,n[0];if(1===r){const n={x:i*o[0].x+t*o[1].x,y:i*o[0].y+t*o[1].y,t:t};return e&&(n.z=i*o[0].z+t*o[1].z),n}if(r<4){let n,a,u,s=i*i,l=t*t,c=0;2===r?(o=[o[0],o[1],o[2],Lo],n=s,a=i*t*2,u=l):3===r&&(n=s*i,a=s*t*3,u=i*l*3,c=t*l);const h={x:n*o[0].x+a*o[1].x+u*o[2].x+c*o[3].x,y:n*o[0].y+a*o[1].y+u*o[2].y+c*o[3].y,t:t};return e&&(h.z=n*o[0].z+a*o[1].z+u*o[2].z+c*o[3].z),h}const a=JSON.parse(JSON.stringify(n));for(;a.length>1;){for(let n=0;na&&(a=i[n]);return{min:o,mid:(o+a)/2,max:a,size:a-o}},align:function(t,n){const e=n.p1.x,r=n.p1.y,i=-No(n.p2.y-r,n.p2.x-e);return t.map((function(t){return{x:(t.x-e)*Co(i)-(t.y-r)*Eo(i),y:(t.x-e)*Eo(i)+(t.y-r)*Co(i)}}))},roots:function(t,n){n=n||{p1:{x:0,y:0},p2:{x:1,y:0}};const e=t.length-1,r=qo.align(t,n),i=function(t){return 0<=t&&t<=1};if(2===e){const t=r[0].y,n=r[1].y,e=r[2].y,o=t-2*n+e;if(0!==o){const r=-Po(n*n-t*e),a=-t+n;return[-(r+a)/o,-(-r+a)/o].filter(i)}return n!==e&&0===o?[(2*n-e)/(2*n-2*e)].filter(i):[]}const o=r[0].y,a=r[1].y,u=r[2].y;let s=3*a-o-3*u+r[3].y,l=3*o-6*a+3*u,c=-3*o+3*a,h=o;if(qo.approximately(s,0)){if(qo.approximately(l,0))return qo.approximately(c,0)?[]:[-h/c].filter(i);const t=Po(c*c-4*l*h),n=2*l;return[(t-c)/n,(-c-t)/n].filter(i)}l/=s,c/=s,h/=s;const f=(3*c-l*l)/3,d=f/3,p=(2*l*l*l-9*l*c+27*h)/27,g=p/2,y=g*g+d*d*d;let v,_,m,x,b;if(y<0){const t=-f/3,n=Po(t*t*t),e=-p/(2*n),r=Oo(e<-1?-1:e>1?1:e),o=2*To(n);return m=o*Co(r/3)-l/3,x=o*Co((r+Do)/3)-l/3,b=o*Co((r+2*Do)/3)-l/3,[m,x,b].filter(i)}if(0===y)return v=g<0?To(-g):-To(g),m=2*v-l/3,x=-v-l/3,[m,x].filter(i);{const t=Po(y);return v=To(-g+t),_=To(g+t),[v-_-l/3].filter(i)}},droots:function(t){if(3===t.length){const n=t[0],e=t[1],r=t[2],i=n-2*e+r;if(0!==i){const t=-Po(e*e-n*r),o=-n+e;return[-(t+o)/i,-(-t+o)/i]}return e!==r&&0===i?[(2*e-r)/(2*(e-r))]:[]}if(2===t.length){const n=t[0],e=t[1];return n!==e?[n/(n-e)]:[]}return[]},curvature:function(t,n,e,r,i){let o,a,u,s,l=0,c=0;const h=qo.compute(t,n),f=qo.compute(t,e),d=h.x*h.x+h.y*h.y;if(r?(o=Po(jo(h.y*f.z-f.y*h.z,2)+jo(h.z*f.x-f.z*h.x,2)+jo(h.x*f.y-f.x*h.y,2)),a=jo(d+h.z*h.z,1.5)):(o=h.x*f.y-h.y*f.x,a=jo(d,1.5)),0===o||0===a)return{k:0,r:0};if(l=o/a,c=a/o,!i){const i=qo.curvature(t-.001,n,e,r,!0).k,o=qo.curvature(t+.001,n,e,r,!0).k;s=(o-l+(l-i))/2,u=(So(o-l)+So(l-i))/2}return{k:l,r:c,dk:s,adk:u}},inflections:function(t){if(t.length<4)return[];const n=qo.align(t,{p1:t[0],p2:t.slice(-1)[0]}),e=n[2].x*n[1].y,r=n[3].x*n[1].y,i=n[1].x*n[2].y,o=18*(-3*e+2*r+3*i-n[3].x*n[2].y),a=18*(3*e-r-3*i),u=18*(i-e);if(qo.approximately(o,0)){if(!qo.approximately(a,0)){let t=-u/a;if(0<=t&&t<=1)return[t]}return[]}const s=2*o;if(qo.approximately(s,0))return[];const l=a*a-4*o*u;if(l<0)return[];const c=Math.sqrt(l);return[(c-a)/s,-(a+c)/s].filter((function(t){return 0<=t&&t<=1}))},bboxoverlap:function(t,n){const e=["x","y"],r=e.length;for(let i,o,a,u,s=0;s0||n.isPointerPressed)&&("touch"!==e.pointerType||void 0===e.movementX||[e.movementX,e.movementY].some((function(t){return Math.abs(t)>1})))&&(n.isPointerDragging=!0);var r,o,a,s=(r=i.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,a=window.pageYOffset||document.documentElement.scrollTop,{top:r.top+a,left:r.left+o});u.x=e.pageX-s.left,u.y=e.pageY-s.top,l.style.top="".concat(u.y,"px"),l.style.left="".concat(u.x,"px"),l.style.transform="translate(-".concat(u.x/n.width*100,"%, ").concat(n.height-u.y<100?"calc(-100% - 8px)":"21px",")")}),{passive:!0})})),i.addEventListener("pointerup",(function(t){if(n.isPointerPressed=!1,n.isPointerDragging)n.isPointerDragging=!1;else{var e=[t,n.pointerDownEvent];requestAnimationFrame((function(){if(0===t.button)if(n.hoverObj){var r=n["on".concat(n.hoverObj.type,"Click")];r&&r.apply(void 0,[n.hoverObj.d].concat(e))}else n.onBackgroundClick&&n.onBackgroundClick.apply(n,e);if(2===t.button)if(n.hoverObj){var i=n["on".concat(n.hoverObj.type,"RightClick")];i&&i.apply(void 0,[n.hoverObj.d].concat(e))}else n.onBackgroundRightClick&&n.onBackgroundRightClick.apply(n,e)}))}}),{passive:!0}),i.addEventListener("contextmenu",(function(t){return!(n.onBackgroundRightClick||n.onNodeRightClick||n.onLinkRightClick)||(t.preventDefault(),!1)})),n.forceGraph(o),n.shadowGraph(a);var c=function(t,n,e){var r=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return zr(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),Dr(t,n,{leading:r,maxWait:n,trailing:i})}((function(){ma(a,n.width,n.height),n.shadowGraph.linkWidth((function(t){return Kr(n.linkWidth)(t)+n.linkHoverPrecision}));var t=Ge(n.canvas);n.shadowGraph.globalScale(t.k).tickFrame()}),800);n.flushShadowCanvas=c.flush,(this._animationCycle=function t(){var e=!n.autoPauseRedraw||!!n.needsRedraw||n.forceGraph.isEngineRunning()||n.graphData.links.some((function(t){return t.__photons&&t.__photons.length}));if(n.needsRedraw=!1,n.enablePointerInteraction){var r=n.isPointerDragging?null:s();if(r!==n.hoverObj){var i=n.hoverObj,a=i?i.type:null,u=r?r.type:null;if(a&&a!==u){var h=n["on".concat(a,"Hover")];h&&h(null,i.d)}if(u){var f=n["on".concat(u,"Hover")];f&&f(r.d,a===u?i.d:null)}var d=r&&Kr(n["".concat(r.type.toLowerCase(),"Label")])(r.d)||"";l.style.visibility=d?"visible":"hidden",l.innerHTML=d,n.canvas.classList[r&&n["on".concat(u,"Click")]||!r&&n.onBackgroundClick?"add":"remove"]("clickable"),n.hoverObj=r}e&&c()}if(e){ma(o,n.width,n.height);var p=Ge(n.canvas).k;n.onRenderFramePre&&n.onRenderFramePre(o,p),n.forceGraph.globalScale(p).tickFrame(),n.onRenderFramePost&&n.onRenderFramePost(o,p)}Vr(),n.animationFrameRequestId=requestAnimationFrame(t)})()},update:function(t){}});return xa}));
diff --git a/hal-core/resources/web/js/lib/jquery.filer.js b/hal-core/resources/web/js/lib/jquery.filer.js
deleted file mode 100644
index c8a292ef..00000000
--- a/hal-core/resources/web/js/lib/jquery.filer.js
+++ /dev/null
@@ -1,991 +0,0 @@
-/*!
- * jQuery.filer
- * Copyright (c) 2015 CreativeDream
- * Website: https://github.com/CreativeDream/jquery.filer
- * Version: 1.0.5 (19-Nov-2015)
- * Requires: jQuery v1.7.1 or later
- */
-(function($) {
- "use strict";
- $.fn.filer = function(q) {
- return this.each(function(t, r) {
- var s = $(r),
- b = '.jFiler',
- p = $(),
- o = $(),
- l = $(),
- sl = [],
- n_f = $.isFunction(q) ? q(s, $.fn.filer.defaults) : q,
- n = n_f && $.isPlainObject(n_f) ? $.extend(true, {}, $.fn.filer.defaults, n_f) : $.fn.filer.defaults,
- f = {
- init: function() {
- s.wrap('');
- f._set('props');
- s.prop("jFiler").boxEl = p = s.closest(b);
- f._changeInput();
- },
- _bindInput: function() {
- if(n.changeInput && o.size() > 0) {
- o.bind("click", f._clickHandler);
- }
- s.on({
- "focus": function() {
- o.addClass('focused');
- },
- "blur": function() {
- o.removeClass('focused');
- },
- "change": function() {
- f._onChange();
- }
- });
- if(n.dragDrop) {
- (o.length > 0 ? o : s)
- .bind("drop", f._dragDrop.drop)
- .bind("dragover", f._dragDrop.dragEnter)
- .bind("dragleave", f._dragDrop.dragLeave);
- }
- if(n.uploadFile && n.clipBoardPaste) {
- $(window)
- .on("paste", f._clipboardPaste);
- }
- },
- _unbindInput: function() {
- if(n.changeInput && o.size() > 0) {
- o.unbind("click", f._clickHandler);
- }
- },
- _clickHandler: function() {
- s.click()
- },
- _applyAttrSettings: function() {
- var d = ["name", "limit", "maxSize", "extensions", "changeInput", "showThumbs", "appendTo", "theme", "addMore", "excludeName", "files", "uploadUrl", "uploadData", "options"];
- for(var k in d) {
- var j = "data-jfiler-" + d[k];
- if(f._assets.hasAttr(j)) {
- switch(d[k]) {
- case "changeInput":
- case "showThumbs":
- case "addMore":
- n[d[k]] = (["true", "false"].indexOf(s.attr(j)) > -1 ? s.attr(j) == "true" : s.attr(j));
- break;
- case "extensions":
- n[d[k]] = s.attr(j)
- .replace(/ /g, '')
- .split(",");
- break;
- case "uploadUrl":
- if(n.uploadFile) n.uploadFile.url = s.attr(j);
- break;
- case "uploadData":
- if(n.uploadFile) n.uploadFile.data = JSON.parse(s.attr(j));
- break;
- case "files":
- case "options":
- n[d[k]] = JSON.parse(s.attr(j));
- break;
- default:
- n[d[k]] = s.attr(j);
- }
- s.removeAttr(j);
- }
- }
- },
- _changeInput: function() {
- f._applyAttrSettings();
- n.beforeRender != null && typeof n.beforeRender == "function" ? n.beforeRender(p, s) : null;
- if(n.theme) {
- p.addClass('jFiler-theme-' + n.theme);
- }
- if(s.get(0)
- .tagName.toLowerCase() != "input" && s.get(0)
- .type != "file") {
- o = s;
- s = $("");
- s.css({
- position: "absolute",
- left: "-9999px",
- top: "-9999px",
- "z-index": "-9999"
- });
- p.prepend(s);
- f._isGn = s;
- } else {
- if(n.changeInput) {
- switch(typeof n.changeInput) {
- case "boolean":
- o = $('',
- m = html.find('.jFiler-item-thumb-image.fi-loading');
- $(g)
- .error(function() {
- g = f._thumbCreator.generateIcon(opts);
- html.addClass('jFiler-no-thumbnail');
- m.removeClass('fi-loading')
- .html(g);
- })
- .load(function() {
- m.removeClass('fi-loading')
- .html(g);
- });
- return true;
- }
- if(window.File && window.FileList && window.FileReader && opts.type == "image" && opts.size < 6e+6) {
- var y = new FileReader;
- y.onload = function(e) {
- var g = '
',
- m = html.find('.jFiler-item-thumb-image.fi-loading');
- $(g)
- .error(function() {
- g = f._thumbCreator.generateIcon(opts);
- html.addClass('jFiler-no-thumbnail');
- m.removeClass('fi-loading')
- .html(g);
- })
- .load(function() {
- m.removeClass('fi-loading')
- .html(g);
- });
- };
- y.readAsDataURL(file);
- } else {
- var g = f._thumbCreator.generateIcon(opts),
- m = html.find('.jFiler-item-thumb-image.fi-loading');
- html.addClass('jFiler-no-thumbnail');
- m.removeClass('fi-loading')
- .html(g);
- }
- },
- generateIcon: function(obj) {
- var m = new Array(3);
- if(obj && obj.type && obj.extension) {
- switch(obj.type) {
- case "image":
- m[0] = "f-image";
- m[1] = ""
- break;
- case "video":
- m[0] = "f-video";
- m[1] = ""
- break;
- case "audio":
- m[0] = "f-audio";
- m[1] = ""
- break;
- default:
- m[0] = "f-file f-file-ext-" + obj.extension;
- m[1] = (obj.extension.length > 0 ? "." + obj.extension : "");
- m[2] = 1
- }
- } else {
- m[0] = "f-file";
- m[1] = (obj.extension && obj.extension.length > 0 ? "." + obj.extension : "");
- m[2] = 1
- }
- var el = '';
- if(m[2] == 1) {
- var c = f._assets.text2Color(obj.extension);
- if(c) {
- var j = $(el)
- .appendTo("body"),
- h = j.css("box-shadow");
- h = c + h.substring(h.replace(/^.*(rgba?\([^)]+\)).*$/, '$1')
- .length, h.length);
- j.css({
- '-webkit-box-shadow': h,
- '-moz-box-shadow': h,
- 'box-shadow': h
- })
- .attr('style', '-webkit-box-shadow: ' + h + '; -moz-box-shadow: ' + h + '; box-shadow: ' + h + ';');
- el = j.prop('outerHTML');
- j.remove();
- }
- }
- return el;
- },
- _box: function(params) {
- if(n.beforeShow != null && typeof n.beforeShow == "function" ? !n.beforeShow(f.files, l, p, o, s) : false) {
- return false
- }
- if(l.length < 1) {
- if(n.appendTo) {
- var appendTo = $(n.appendTo);
- } else {
- var appendTo = p;
- }
- appendTo.find('.jFiler-items')
- .remove();
- l = $('');
- s.prop("jFiler").listEl = l;
- l.append(f._assets.textParse(n.templates.box))
- .appendTo(appendTo);
- l.on('click', n.templates._selectors.remove, function(e) {
- e.preventDefault();
- var cf = n.templates.removeConfirmation ? confirm(n.captions.removeConfirmation) : true;
- if(cf) {
- f._remove(params ? params.remove.event : e, params ? params.remove.el : $(this)
- .closest(n.templates._selectors.item));
- }
- });
- }
- for(var i = 0; i < f.files.length; i++) {
- if(!f.files[i]._appended) f.files[i]._choosed = true;
- f._addToMemory(i);
- f._thumbCreator.create(i);
- }
- }
- },
- _upload: function(i) {
- var el = f._itFc.html,
- formData = new FormData();
- formData.append(s.attr('name'), f._itFc.file, (f._itFc.file.name ? f._itFc.file.name : false));
- if(n.uploadFile.data != null && $.isPlainObject(n.uploadFile.data)) {
- for(var k in n.uploadFile.data) {
- formData.append(k, n.uploadFile.data[k])
- }
- }
- f._ajax.send(el, formData, f._itFc);
- },
- _ajax: {
- send: function(el, formData, c) {
- c.ajax = $.ajax({
- url: n.uploadFile.url,
- data: formData,
- type: n.uploadFile.type,
- enctype: n.uploadFile.enctype,
- xhr: function() {
- var myXhr = $.ajaxSettings.xhr();
- if(myXhr.upload) {
- myXhr.upload.addEventListener("progress", function(e) {
- f._ajax.progressHandling(e, el)
- }, false)
- }
- return myXhr
- },
- complete: function(jqXHR, textStatus) {
- c.ajax = false;
- f._ajFc++;
- if(f._ajFc >= f.files.length) {
- f._ajFc = 0;
- n.uploadFile.onComplete != null && typeof n.uploadFile.onComplete == "function" ? n.uploadFile.onComplete(l, p, o, s, jqXHR, textStatus) : null;
- }
- },
- beforeSend: function(jqXHR, settings) {
- return n.uploadFile.beforeSend != null && typeof n.uploadFile.beforeSend == "function" ? n.uploadFile.beforeSend(el, l, p, o, s, c.id, jqXHR, settings) : true;
- },
- success: function(data, textStatus, jqXHR) {
- c.uploaded = true;
- n.uploadFile.success != null && typeof n.uploadFile.success == "function" ? n.uploadFile.success(data, el, l, p, o, s, c.id, textStatus, jqXHR) : null
- },
- error: function(jqXHR, textStatus, errorThrown) {
- c.uploaded = false;
- n.uploadFile.error != null && typeof n.uploadFile.error == "function" ? n.uploadFile.error(el, l, p, o, s, c.id, jqXHR, textStatus, errorThrown) : null
- },
- statusCode: n.uploadFile.statusCode,
- cache: false,
- contentType: false,
- processData: false
- });
- return c.ajax;
- },
- progressHandling: function(e, el) {
- if(e.lengthComputable) {
- var t = Math.round(e.loaded * 100 / e.total)
- .toString();
- n.uploadFile.onProgress != null && typeof n.uploadFile.onProgress == "function" ? n.uploadFile.onProgress(t, el, l, p, o, s) : null;
- el.find('.jFiler-jProgressBar')
- .find(n.templates._selectors.progressBar)
- .css("width", t + "%")
- }
- }
- },
- _dragDrop: {
- dragEnter: function(e) {
- e.preventDefault();
- e.stopPropagation();
- p.addClass('dragged');
- f._set('feedback', n.captions.drop);
- n.dragDrop.dragEnter != null && typeof n.dragDrop.dragEnter == "function" ? n.dragDrop.dragEnter(e, o, s, p) : null;
- },
- dragLeave: function(e) {
- e.preventDefault();
- e.stopPropagation();
- if(!f._dragDrop._dragLeaveCheck(e)) {
- return false
- }
- p.removeClass('dragged');
- f._set('feedback', n.captions.feedback);
- n.dragDrop.dragLeave != null && typeof n.dragDrop.dragLeave == "function" ? n.dragDrop.dragLeave(e, o, s, p) : null;
- },
- drop: function(e) {
- e.preventDefault();
- p.removeClass('dragged');
- f._set('feedback', n.captions.feedback);
- if(e && e.originalEvent && e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files && e.originalEvent.dataTransfer.files.length > 0) {
- f._onChange(e, e.originalEvent.dataTransfer.files);
- }
- n.dragDrop.drop != null && typeof n.dragDrop.drop == "function" ? n.dragDrop.drop(e.originalEvent.dataTransfer.files, e, o, s, p) : null;
- },
- _dragLeaveCheck: function(e) {
- var related = e.relatedTarget,
- inside = false;
- if(related !== o) {
- if(related) {
- inside = $.contains(o, related);
- }
- if(inside) {
- return false;
- }
- }
- return true;
- }
- },
- _clipboardPaste: function(e, fromDrop) {
- if(!fromDrop && (!e.originalEvent.clipboardData && !e.originalEvent.clipboardData.items)) {
- return
- }
- if(fromDrop && (!e.originalEvent.dataTransfer && !e.originalEvent.dataTransfer.items)) {
- return
- }
- if(f._clPsePre) {
- return
- }
- var items = (fromDrop ? e.originalEvent.dataTransfer.items : e.originalEvent.clipboardData.items),
- b64toBlob = function(b64Data, contentType, sliceSize) {
- contentType = contentType || '';
- sliceSize = sliceSize || 512;
- var byteCharacters = atob(b64Data);
- var byteArrays = [];
- for(var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
- var slice = byteCharacters.slice(offset, offset + sliceSize);
- var byteNumbers = new Array(slice.length);
- for(var i = 0; i < slice.length; i++) {
- byteNumbers[i] = slice.charCodeAt(i);
- }
- var byteArray = new Uint8Array(byteNumbers);
- byteArrays.push(byteArray);
- }
- var blob = new Blob(byteArrays, {
- type: contentType
- });
- return blob;
- };
- if(items) {
- for(var i = 0; i < items.length; i++) {
- if(items[i].type.indexOf("image") !== -1 || items[i].type.indexOf("text/uri-list") !== -1) {
- if(fromDrop) {
- try {
- window.atob(e.originalEvent.dataTransfer.getData("text/uri-list")
- .toString()
- .split(',')[1]);
- } catch(e) {
- return;
- }
- }
- var blob = (fromDrop ? b64toBlob(e.originalEvent.dataTransfer.getData("text/uri-list")
- .toString()
- .split(',')[1], "image/png") : items[i].getAsFile());
- blob.name = Math.random()
- .toString(36)
- .substring(5);
- blob.name += blob.type.indexOf("/") != -1 ? "." + blob.type.split("/")[1].toString()
- .toLowerCase() : ".png";
- f._onChange(e, [blob]);
- f._clPsePre = setTimeout(function() {
- delete f._clPsePre
- }, 1000);
- }
- }
- }
- },
- _onSelect: function(i) {
- if(n.uploadFile && !$.isEmptyObject(n.uploadFile)) {
- f._upload(i)
- }
- n.onSelect != null && typeof n.onSelect == "function" ? n.onSelect(f.files[i], f._itFc.html, l, p, o, s) : null;
- if(i + 1 >= f.files.length) {
- n.afterShow != null && typeof n.afterShow == "function" ? n.afterShow(l, p, o, s) : null
- }
- },
- _onChange: function(e, d) {
- if(!d) {
- if(!s.get(0)
- .files || typeof s.get(0)
- .files == "undefined" || s.get(0)
- .files.length == 0) {
- if(!n.uploadFile && !n.addMore) {
- f._set('input', '');
- f._clear();
- }
- return false
- }
- f.files = s.get(0)
- .files;
- } else {
- if(!d || d.length == 0) {
- f._set('input', '');
- f._clear();
- return false
- }
- f.files = d;
- }
- if(!n.uploadFile && !n.addMore) {
- f._reset(true);
- }
- s.prop("jFiler")
- .files = f.files;
- if(!f._filesCheck() || (n.beforeSelect != null && typeof n.beforeSelect == "function" ? !n.beforeSelect(f.files, l, p, o, s) : false)) {
- f._set('input', '');
- f._clear();
- return false
- }
- f._set('feedback', f.files.length + f._itFl.length + ' ' + n.captions.feedback2);
- if(n.showThumbs) {
- f._thumbCreator._box();
- } else {
- for(var i = 0; i < f.files.length; i++) {
- f.files[i]._choosed = true;
- f._addToMemory(i);
- f._onSelect(i);
- }
- }
- if(!n.uploadFile && n.addMore) {
- var elem = $('');
- var attributes = s.prop("attributes");
- $.each(attributes, function() {
- elem.attr(this.name, this.value);
- });
- s.after(elem);
- f._unbindInput();
- sl.push(elem);
- s = elem;
- f._bindInput();
- f._set('props');
- }
- },
- _append: function(e, data) {
- var files = (!data ? false : data.files);
- if(!files || files.length <= 0) {
- return;
- }
- f.files = files;
- s.prop("jFiler")
- .files = f.files;
- if(n.showThumbs) {
- for(var i = 0; i < f.files.length; i++) {
- f.files[i]._appended = true;
- }
- f._thumbCreator._box();
- }
- },
- _getList: function(e, data) {
- var files = (!data ? false : data.files);
- if(!files || files.length <= 0) {
- return;
- }
- f.files = files;
- s.prop("jFiler")
- .files = f.files;
- if(n.showThumbs) {
- var returnData = [];
- for(var i = 0; i < f.files.length; i++) {
- f.files[i].forList = true;
- returnData.push(f._thumbCreator.create(i));
- }
- if(data.callback) {
- data.callback(returnData, l, p, o, s);
- }
- }
- },
- _retryUpload: function(e, data) {
- var id = parseInt(typeof data == "object" ? data.attr("data-jfiler-index") : data),
- obj = f._itFl.filter(function(value, key) {
- return value.id == id;
- });
- if(obj.length > 0) {
- if(n.uploadFile && !$.isEmptyObject(n.uploadFile) && !obj[0].uploaded) {
- f._itFc = obj[0];
- s.prop("jFiler")
- .current_file = f._itFc;
- f._upload(id);
- return true;
- }
- } else {
- return false;
- }
- },
- _remove: function(e, el) {
- if(el.binded) {
- if(typeof(el.data.id) != "undefined") {
- el = l.find(n.templates._selectors.item + "[data-jfiler-index='" + el.data.id + "']");
- if(el.size() == 0) {
- return false
- }
- }
- if(el.data.el) {
- el = el.data.el;
- }
- }
- var attrId = el.get(0)
- .jfiler_id || el.attr('data-jfiler-index'),
- id = null,
- excl_input = function(id) {
- var input = p.find("input[name^='jfiler-items-exclude-']:hidden")
- .first(),
- item = f._itFl[id],
- val = [];
- if(input.size() == 0) {
- input = $('');
- input.appendTo(p);
- }
- if(item.file._choosed || item.file._appended || item.uploaded) {
- f._prEr = true;
- f._itFr.push(item);
- if(n.addMore) {
- var current_input = item.input,
- count_same_input = 0;
- f._itFl.filter(function(val, index) {
- if(val.file._choosed && val.input.get(0) == current_input.get(0)) count_same_input++;
- });
- if(count_same_input == 1) {
- f._itFr = f._itFr.filter(function(val, index) {
- return val.file._choosed ? val.input.get(0) != current_input.get(0) : true;
- });
- current_input.val("");
- f._prEr = false;
- }
- }
- for(var i = 0; i < f._itFr.length; i++) {
- val.push(f._itFr[i].file.name);
- }
- val = JSON.stringify(val);
- input.val(val);
- }
- },
- callback = function(el, id) {
- excl_input(id);
- f._itFl.splice(id, 1);
- if(f._itFl.length < 1) {
- f._reset();
- f._clear();
- } else {
- f._set('feedback', f._itFl.length + ' ' + n.captions.feedback2);
- }
- el.fadeOut("fast", function() {
- $(this)
- .remove();
- });
- };
- for(var key in f._itFl) {
- if(key === 'length' || !f._itFl.hasOwnProperty(key)) continue;
- if(f._itFl[key].id == attrId) {
- id = key;
- }
- }
- if(!f._itFl.hasOwnProperty(id)) {
- return false
- }
- if(f._itFl[id].ajax) {
- f._itFl[id].ajax.abort();
- callback(el, id);
- return;
- }
- n.onRemove != null && typeof n.onRemove == "function" ? n.onRemove(el, f._itFl[id].file, id, l, p, o, s) : null;
- callback(el, id);
- },
- _addToMemory: function(i) {
- f._itFl.push({
- id: f._itFl.length,
- file: f.files[i],
- html: $(),
- ajax: false,
- uploaded: false,
- });
- if(n.addMore && !f.files[i]._appended) f._itFl[f._itFl.length - 1].input = s;
- f._itFc = f._itFl[f._itFl.length - 1];
- s.prop("jFiler")
- .files_list = f._itFl;
- s.prop("jFiler")
- .current_file = f._itFc;
- },
- _assets: {
- bytesToSize: function(bytes) {
- if(bytes == 0) return '0 Byte';
- var k = 1000;
- var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
- var i = Math.floor(Math.log(bytes) / Math.log(k));
- return(bytes / Math.pow(k, i))
- .toPrecision(3) + ' ' + sizes[i];
- },
- hasAttr: function(attr, el) {
- var el = (!el ? s : el),
- a = el.attr(attr);
- if(!a || typeof a == "undefined") {
- return false;
- } else {
- return true;
- }
- },
- getIcon: function(ext, type) {
- var types = ["audio", "image", "text", "video"];
- if($.inArray(type, types) > -1) {
- return '';
- }
- return '';
- },
- textParse: function(text, opts) {
- opts = $.extend({}, {
- limit: n.limit,
- maxSize: n.maxSize,
- extensions: n.extensions ? n.extensions.join(',') : null,
- }, (opts && $.isPlainObject(opts) ? opts : {}), n.options);
- switch(typeof(text)) {
- case "string":
- return text.replace(/\{\{fi-(.*?)\}\}/g, function(match, a) {
- a = a.replace(/ /g, '');
- if(a.match(/(.*?)\|limitTo\:(\d+)/)) {
- return a.replace(/(.*?)\|limitTo\:(\d+)/, function(match, a, b) {
- var a = (opts[a] ? opts[a] : ""),
- str = a.substring(0, b);
- str = (a.length > str.length ? str.substring(0, str.length - 3) + "..." : str);
- return str;
- });
- } else {
- return(opts[a] ? opts[a] : "");
- }
- });
- break;
- case "function":
- return text(opts);
- break;
- default:
- return text;
- }
- },
- text2Color: function(str) {
- if(!str || str.length == 0) {
- return false
- }
- for(var i = 0, hash = 0; i < str.length; hash = str.charCodeAt(i++) + ((hash << 5) - hash));
- for(var i = 0, colour = "#"; i < 3; colour += ("00" + ((hash >> i++ * 2) & 0xFF)
- .toString(16))
- .slice(-2));
- return colour;
- }
- },
- files: null,
- _itFl: [],
- _itFc: null,
- _itFr: [],
- _ajFc: 0,
- _prEr: false
- }
-
- s.on("filer.append", function(e, data) {
- f._append(e, data)
- }).on("filer.remove", function(e, data) {
- data.binded = true;
- f._remove(e, data);
- }).on("filer.reset", function(e) {
- f._reset();
- f._clear();
- return true;
- }).on("filer.generateList", function(e, data) {
- return f._getList(e, data)
- }).on("filer.retry", function(e, data) {
- return f._retryUpload(e, data)
- });
-
- f.init();
-
- return this;
- });
- };
- $.fn.filer.defaults = {
- limit: null,
- maxSize: null,
- extensions: null,
- changeInput: true,
- showThumbs: false,
- appendTo: null,
- theme: 'default',
- templates: {
- box: '
',
- item: '
',a=t.find(".jFiler-item-thumb-image.fi-loading");return e(l).error(function(){l=u._thumbCreator.generateIcon(n),t.addClass("jFiler-no-thumbnail"),a.removeClass("fi-loading").html(l)}).load(function(){a.removeClass("fi-loading").html(l)}),!0}if(window.File&&window.FileList&&window.FileReader&&"image"==n.type&&n.size<6e6){var r=new FileReader;r.onload=function(i){var l='
',a=t.find(".jFiler-item-thumb-image.fi-loading");e(l).error(function(){l=u._thumbCreator.generateIcon(n),t.addClass("jFiler-no-thumbnail"),a.removeClass("fi-loading").html(l)}).load(function(){a.removeClass("fi-loading").html(l)})},r.readAsDataURL(i)}else{var l=u._thumbCreator.generateIcon(n),a=t.find(".jFiler-item-thumb-image.fi-loading");t.addClass("jFiler-no-thumbnail"),a.removeClass("fi-loading").html(l)}},generateIcon:function(i){var t=new Array(3);if(i&&i.type&&i.extension)switch(i.type){case"image":t[0]="f-image",t[1]='';break;case"video":t[0]="f-video",t[1]='';break;case"audio":t[0]="f-audio",t[1]='';break;default:t[0]="f-file f-file-ext-"+i.extension,t[1]=i.extension.length>0?"."+i.extension:"",t[2]=1}else t[0]="f-file",t[1]=i.extension&&i.extension.length>0?"."+i.extension:"",t[2]=1;var n='";if(1==t[2]){var l=u._assets.text2Color(i.extension);if(l){var a=e(n).appendTo("body"),r=a.css("box-shadow");r=l+r.substring(r.replace(/^.*(rgba?\([^)]+\)).*$/,"$1").length,r.length),a.css({"-webkit-box-shadow":r,"-moz-box-shadow":r,"box-shadow":r}).attr("style","-webkit-box-shadow: "+r+"; -moz-box-shadow: "+r+"; box-shadow: "+r+";"),n=a.prop("outerHTML"),a.remove()}}return n},_box:function(i){if(null!=p.beforeShow&&"function"==typeof p.beforeShow?!p.beforeShow(u.files,s,r,o,l):!1)return!1;if(s.length<1){if(p.appendTo)var t=e(p.appendTo);else var t=r;t.find(".jFiler-items").remove(),s=e(''),l.prop("jFiler").listEl=s,s.append(u._assets.textParse(p.templates.box)).appendTo(t),s.on("click",p.templates._selectors.remove,function(t){t.preventDefault();var n=p.templates.removeConfirmation?confirm(p.captions.removeConfirmation):!0;n&&u._remove(i?i.remove.event:t,i?i.remove.el:e(this).closest(p.templates._selectors.item))})}for(var n=0;n
',item:'