UNPKG

soocrate-core

Version:

this is the core of soocrate application

2 lines 28.2 kB
(window.webpackJsonpsession=window.webpackJsonpsession||[]).push([[0],{544:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),o=r(n(549)),s=r(n(548)),a=r(n(547));function r(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(t,n,i){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._options=t,this._editorsHolderID=i,this._editorContainerID="container-"+this._options.signalingOptions.room,this.createCRATE(),this._model=n,this._editor=new a.default(n,t.signalingOptions.room,this._editorContainerID),session.config.storageServer&&(this._storageServerState={},this.findremote(!0),this._timerStorageServer=setInterval(function(){return r.findremote()},5e3),this._editor.on("thereAreChanges",function(){2===r._storageServerState&&r.join()}));var d=this._options.signalingOptions.session,l=session.default.getCrateSession(d);l._previous&&(d=l._previous._options.signalingOptions.session),session.default.focusOnSession(d,this._options.signalingOptions.session,this._editor);var c=new o.default(jQuery("#"+this._editorContainerID+" #sharinglink")),m=jQuery("#"+this._editorContainerID+" #shareicon");this._statesHeader=new s.default(n,c,m,this._editorContainerID),jQuery("#"+this._editorContainerID+" #closeDocument").click(function(){var e=session.default.getCrateSession(r._options.signalingOptions.room);session.headSession!==e?(e._previous&&(e._previous._next=e._next),e._next?e._next._previous=e._previous:session.lastSession=e._previous,jQuery("#"+r._editorContainerID).remove(),e.moveToPrevious(),e.close()):console.log("You cannot remove the first document")})}return i(e,[{key:"createCRATE",value:function(){var e=this,t=' \n<div class="col-md-10 editorContainer" id="'+this._editorContainerID+'" >\n \x3c!-- Head --\x3e\n <div id="head">\n <div id="firstrow" class="row">\n <div id="connectionState">\n </div>\n <div id="title">\n '+this._options.name+'\n </div>\n <div id="features">\n <div id="shareicon">\n <i class="fa fa-link fa-2x ficon2"></i>\n </div>\n <div id="saveicon"><i class="fa fa-floppy-o fa-2x ficon2"></i></div>\n <div id="remotesave" style=" width: 20px;">\n <i class="fa fa-cloud fa-2x ficon2"></i>\n </div>\n <div id="closeDocument" style="\n float: right;\n position: relative;\n ">\n <i class="fa fa-window-close" aria-hidden="true" ></i>\n </div>\n </div>\n </div>\n <div id="sharinglink" class="row">\n </div>\n </div>\n \n \x3c!-- Content --\x3e\n <div id="content" class="content">\n <div id="users" class="row">\n <div id="state" style="margin-left: -50px;" ">\n <i class="fa fa-globe fa-3x ficon "></i>\n </div>\n </div>\n <div id="editorSection">\n <div id="editor" class="editor">\n </div>\n <div id="comments">\n </div>\n </div>\n </div>\n\n\n <div id="inputCommentModal" class="modal fade" role="dialog" style="display: none;">\n <div class="modal-dialog">\n \n \x3c!-- Modal content--\x3e\n <div class="modal-content">\n <div class="modal-body">\n <button type="button" class="close" data-dismiss="modal">×</button>\n <h4>Comment</h4>\n <p><textarea name="commentInput" id="commentInput" style="width: 100%;" rows="5"></textarea></p>\n </div>\n <div class="modal-footer">\n <button type="button" class="btn btn-default" id="saveComment"data-dismiss="modal">Save</button>\n </div>\n </div>\n \n </div>\n </div>\n ';jQuery("#"+this._editorsHolderID).append(t),jQuery("#"+this._editorContainerID+" #saveComment").click(function(){e.saveComment()}),jQuery("#"+this._editorContainerID+" #remotesave").click(function(){jQuery("#"+e._editorContainerID+" #remotesave").hasClass("PIN")?e.kill():e.join()})}},{key:"saveComment",value:function(){this._editor.saveComment()}},{key:"findremote",value:function(e){var t=this,n=this._options.signalingOptions.room,i=jQuery("#"+this._editorContainerID+" #remotesave");if(session.config.storageServer){var o=session.config.storageServer+"/exist/"+n;fetch(o).then(function(e){return e.json()}).then(function(n){t._storageServerState=n.results,0==n.results?t.unpin(i):1==n.results?t.pin(i,"active"):e?t.join():t.pin(i,"sleep")}).catch(function(e){console.log(e),clearInterval(t._timerStorageServer),t.unpin(i)})}}},{key:"pin",value:function(e,t){"active"===t?e.css("color","green"):e.css("color","gray"),e.removeClass("UNPIN"),e.addClass("PIN")}},{key:"unpin",value:function(e){e.css("color","red"),e.removeClass("PIN"),e.addClass("UNPIN")}},{key:"join",value:function(){var e=this,t=this._options.signalingOptions.room;$.ajax({type:"GET",url:session.config.storageServer+"/join/"+t,success:function(t,n){e.findremote()},error:function(){e.findremote()},async:!0})}},{key:"kill",value:function(){var e=this,t=this._options.signalingOptions.room;1==confirm("Do you want remove document from remote server!")&&$.ajax({type:"GET",url:session.config.storageServer+"/kill/"+t,success:function(n,i){e.findremote(t)},async:!1})}}],[{key:"addMoveShortcuts",value:function(){var e={37:"prev",39:"next"};document.addEventListener&&document.addEventListener("keydown",function(t){var n=e[t.keyCode];if((t.ctrlKey||t.metaKey)&&n){var i=document.createEvent("Event");i.initEvent(n,!0,!1),t.target.dispatchEvent(i),t.preventDefault()}},!1),$(document).on("next",function(){console.log("next"),session.default.actualSession.moveToNext()}),$(document).on("prev",function(){console.log("prev"),session.default.actualSession.moveToPrevious()})}}]),e}();t.default=d,d.addMoveShortcuts()},545:function(e,t,n){"use strict";var i,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(s){var a,r,d,l=(a=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|"[^"]*"|'[^']*'/g,r=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,d=/[^-+\dA-Z]/g,function(e,t,n,i){if(1!==arguments.length||"string"!==(null===(s=e)?"null":void 0===s?"undefined":"object"!==(void 0===s?"undefined":o(s))?void 0===s?"undefined":o(s):Array.isArray(s)?"array":{}.toString.call(s).slice(8,-1).toLowerCase())||/\d/.test(e)||(t=e,e=void 0),(e=e||new Date)instanceof Date||(e=new Date(e)),isNaN(e))throw TypeError("Invalid date");var s,m=(t=String(l.masks[t]||t||l.masks.default)).slice(0,4);"UTC:"!==m&&"GMT:"!==m||(t=t.slice(4),n=!0,"GMT:"===m&&(i=!0));var u=n?"getUTC":"get",h=e[u+"Date"](),f=e[u+"Day"](),v=e[u+"Month"](),p=e[u+"FullYear"](),y=e[u+"Hours"](),g=e[u+"Minutes"](),k=e[u+"Seconds"](),C=e[u+"Milliseconds"](),b=n?0:e.getTimezoneOffset(),_=function(e){var t=new Date(e.getFullYear(),e.getMonth(),e.getDate());t.setDate(t.getDate()-(t.getDay()+6)%7+3);var n=new Date(t.getFullYear(),0,4);n.setDate(n.getDate()-(n.getDay()+6)%7+3);var i=t.getTimezoneOffset()-n.getTimezoneOffset();t.setHours(t.getHours()-i);var o=(t-n)/6048e5;return 1+Math.floor(o)}(e),w=function(e){var t=e.getDay();return 0===t&&(t=7),t}(e),T={d:h,dd:c(h),ddd:l.i18n.dayNames[f],dddd:l.i18n.dayNames[f+7],m:v+1,mm:c(v+1),mmm:l.i18n.monthNames[v],mmmm:l.i18n.monthNames[v+12],yy:String(p).slice(2),yyyy:p,h:y%12||12,hh:c(y%12||12),H:y,HH:c(y),M:g,MM:c(g),s:k,ss:c(k),l:c(C,3),L:c(Math.round(C/10)),t:y<12?l.i18n.timeNames[0]:l.i18n.timeNames[1],tt:y<12?l.i18n.timeNames[2]:l.i18n.timeNames[3],T:y<12?l.i18n.timeNames[4]:l.i18n.timeNames[5],TT:y<12?l.i18n.timeNames[6]:l.i18n.timeNames[7],Z:i?"GMT":n?"UTC":(String(e).match(r)||[""]).pop().replace(d,""),o:(b>0?"-":"+")+c(100*Math.floor(Math.abs(b)/60)+Math.abs(b)%60,4),S:["th","st","nd","rd"][h%10>3?0:(h%100-h%10!=10)*h%10],W:_,N:w};return t.replace(a,function(e){return e in T?T[e]:e.slice(1,e.length-1)})});function c(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e}l.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},l.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],timeNames:["a","p","am","pm","A","P","AM","PM"]},void 0===(i=function(){return l}.call(t,n,t,e))||(e.exports=i)}()},546:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=n(545);(i=s)&&i.__esModule;var a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._editorContainerID=t,this._viewEditor={},this._inputCommentModel=$("#"+this._editorContainerID+" #inputCommentModal"),this._comments=$("#"+this._editorContainerID+" #comments"),this._ql_editor=$("#"+this._editorContainerID+" .ql-editor"),this._editor=$("#"+this._editorContainerID+" .editor"),this._commentInput=$("#"+this._editorContainerID+" #commentInput"),this._currentTimestamp={},this._commentCallback={},this.commentAddClick=this.commentAddClick.bind(this),this.commentsClick=this.commentsClick.bind(this)}return o(e,[{key:"commentAddClick",value:function(e,t){this._commentCallback=e.bind(t),this._inputCommentModel.modal("show")}},{key:"commentServerTimestamp",value:function(){var e=this;return new Promise(function(t,n){e._currentTimestamp=Math.round((new Date).getTime()/1e3),t(e._currentTimestamp)})}},{key:"commentsClick",value:function(){this._comments.is(":visible")?(this._ql_editor.hasClass("ql-comments")&&this._ql_editor.removeClass("ql-comments"),this._comments.hide(),this._comments.css("width","0%"),this._editor.css("width","100%")):(this._comments.addClass("comment"),this._editor.hasClass("ql-comments")||this._editor.addClass("ql-comments"),this._comments.css("width","30%"),this._editor.css("width","70%"),this._comments.show())}},{key:"addCommentToList",value:function(e,t,n,i,o,s){var a=this,r=s,d=new Date,l=dateFormat(d,"dddd, mmmm dS, yyyy, h:MM:ss TT"),c="ql-comment-"+t+"-"+r,m=$("<div class='comment-box "+c+" row' id='comment-box-"+c+"' tabindex=\"1\" title='"+l+"'>\n <div class='comment-head row'>\n <div id=\""+c+'"style="background-color:'+o+';width: 40px;" ><img class="imageuser" src="./icons/'+n+'.png" alt="'+i+"\"></div>\n \n <div class='comment-details'>\n <div class='comment-author'>"+i+"</div>\n </div>\n </div>\n <div class='comment-body row' >"+e+"</div>\n \n </div>");this._comments.append(m),$("#comment-box-"+c).focusin(function(){a.commentBoxFocus(c)}),$("#comment-box-"+c).focusout(function(){a.commentBoxFocus(c,"out")})}},{key:"saveComment",value:function(){var e=this._commentInput.val();this._commentCallback(e);var t=this._viewEditor.options.modules.comment.commentAddOn,n=this._viewEditor.options.modules.comment.commentAuthorId,i=this._viewEditor.options.modules.comment.color;this.addCommentToList(e,n,t,store.get("myId").pseudo,i,this._currentTimestamp)}},{key:"commentBoxFocus",value:function(e,t){"out"!==t?($(".ql-comments #"+e).addClass("commentFocus"),this._comments.find("."+e).css("border-color","red")):($(".ql-comments #"+e).removeClass("commentFocus"),this._comments.find(".comment-box").css("border-color","#F0F0F0"))}},{key:"viewEditor",get:function(){return this._viewEditor},set:function(e){this._viewEditor=e}}]),e}();t.default=a},547:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),o=r(n(189)),s=r(n(546)),a=n(12);function r(e){return e&&e.__esModule?e:{default:e}}var d=n(190)("crate:view:editor");Quill.register("modules/cursors",QuillCursors),Quill.register("modules/comment",QuillComment);var l=function(e){function t(e,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.model=e,o.markers={},o.startTimer={},o.viewEditor={},o._editorContainerID=i,o._comments=new s.default(o._editorContainerID),o._sessionID=n,o.loadDocument(n),o.startPing(5e3),jQuery("#"+o._editorContainerID+" #saveicon").click(function(){o.saveDocument()}),jQuery("#"+o._editorContainerID+" #title").focusout(function(){o.changeTitle(),o.emit("thereAreChanges")}),o.viewEditor.on("selection-change",function(e,t,n){e&&o.model.core.caretMoved(e)}),o.viewEditor.on("text-change",function(e,t,n){o.textChange(e,t,n),o.emit("thereAreChanges")}),o.model.core.on("remoteInsert",function(e,t){o.remoteInsert(e,t),o.emit("thereAreChanges")}),o.model.core.on("remoteRemove",function(e){o.remoteRemove(e),o.emit("thereAreChanges")}),o.model.core.on("remoteCaretMoved",function(e,t){o.remoteCaretMoved(e,t)}),o.model.core.on("remoteCaretMoved",function(e,t){o.remoteCaretMoved(e,t)}),o.model.on("changeTitle",function(e){jQuery("#"+o._editorContainerID+" #title").text(e),o.emit("thereAreChanges")}),o.model.core.on("ping",function(e,t){o.atPing(e,t)}),o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.EventEmitter),i(t,[{key:"loadDocument",value:function(e){var t=this;if(this.createViewDocument(),store.get("CRATE2-"+e)){var n=store.get("CRATE2-"+e);this.viewEditor.setContents(n.delta,"user"),jQuery("#"+this._editorContainerID+" #title").text(n.title),session.default.openIn()}jQuery("#"+this._editorContainerID+" #title").click(function(){jQuery("#"+t._editorContainerID+" #title").attr("contenteditable","true")}),this.markers={},this.model.markers=this.markers;var i=this.model.uid;this.markers[i]=new o.default(i,{lifeTime:5e3,range:{index:0,length:0},cursor:!1,isItME:!0},this),store.get("myId")?this.markers[i].setPseudo(store.get("myId").pseudo):store.set("myId",{id:i,pseudo:this.markers[i].pseudoName}),this.UpdateComments();var s=this.viewEditor.options.modules.comment;s.commentAddOn=this.markers[i].animal,s.commentAuthorId=this.model.uid,s.color=this.markers[i].colorRGB}},{key:"createViewDocument",value:function(){var e=new Quill("#"+this._editorContainerID+" #editor",{modules:{formula:!0,toolbar:{container:[[{header:[1,2,3,4,5,6,!1]}],[{font:[]}],["bold","italic","underline","strike"],[{align:[]}],[{list:"ordered"},{list:"bullet"}],[{color:[]},{background:[]}],["clean"],["formula","image","link"],["subdocument"],["comments-toggle"],["comments-add"]],handlers:{subdocument:function(e){this.quill.getSelection();var t=window.location.href.split("?")[0]+"?"+session.default.GUID();this.quill.theme.tooltip.edit("link",t)},undo:function(e){this.quill.history.undo()},redo:function(e){this.quill.history.redo()}}},cursors:{autoRegisterListener:!0,hideDelay:500,hideSpeed:0},history:{delay:500,maxStack:1e3},comment:{enabled:!0,commentAuthorId:123,commentAddOn:"Author Name",color:"yellow",commentAddClick:this._comments.commentAddClick,commentsClick:this._comments.commentsClick,commentTimestamp:this._comments.commentServerTimestamp,containerID:this._editorContainerID}},theme:"snow"});$(".ql-subdocument .ql-comments-toggle .ql-comments-add").attr("data-toggle","tooltip"),$(".ql-comments-toggle,.ql-comments-add").css({position:"relative",top:"-5px"}),$(".ql-subdocument").html("<strong>SUB</strong>"),$(".ql-subdocument").attr("title","Add subdocument"),$(".ql-comments-toggle").html('<i class="fa fa-comments"></i>'),$(".ql-comments-toggle").attr("title","Show/hide comments"),$(".ql-comments-add").html('<i class="fa fa-comment"></i>'),$(".ql-comments-add").attr("title","Add comment"),e.theme.tooltip.save2=e.theme.tooltip.save,e.theme.tooltip.save=function(){e.theme.tooltip.save2(),session.default.openIn()},this._comments.viewEditor=e,this.viewEditor=e}},{key:"saveDocument",value:function(){var e={date:(new Date).getTime(),title:jQuery("#"+this._editorContainerID+" #title").text(),delta:this.viewEditor.editor.delta,sequence:this.model.sequence,causality:this.model.causality,name:this.model.name,webRTCOptions:this.model.webRTCOptions,markers:{},signalingOptions:this.model.signalingOptions};store.set("CRATE2-"+this.model.signalingOptions.session,e),alert("Document is saved successfully")}},{key:"textChange",value:function(e,t,n){this.cleanQuill(),this.applyChanges(e,0)}},{key:"applyChanges",value:function(e,t){var n=this,i=t;JSON.parse(JSON.stringify(e,null,2)).ops.forEach(function(e){for(var t=Object.keys(e),o="",s="",a="",r=t.length-1;r>=0;r--){var d=e[t[r]];"attributes"===t[r]?s=d:(o=t[r],a=d)}i=n.sendIt("",s,0,a,o,i,!1)})}},{key:"sendIt",value:function(e,t,n,i,o,s,a){switch(o){case"retain":if(""!=t){this.sendIt("","",s,i,"delete",s,!0);var r=this.viewEditor.editor.delta.slice(s,s+i);this.applyChanges(r,s)}else s+=i;break;case"insert":if(e=i,void 0!=i.formula)t=this.viewEditor.getFormat(s,1),this.model.core.insert({type:"formula",text:i,att:t},s);else if(void 0!=i.video)t=this.viewEditor.getFormat(s,1),this.model.core.insert({type:"video",text:i,att:t},s);else if(void 0!=i.image)t=this.viewEditor.getFormat(s,1),this.model.core.insert({type:"image",text:i,att:t},s);else{for(var l=s;l<s+e.length;++l)t=this.viewEditor.getFormat(l,1),d("Local insert : ",e[l-s],l),this.model.core.insert({type:"char",text:e[l-s],att:t},l);s+=e.length}break;case"delete":var c=i;a||this.UpdateComments(),0==n&&(n=s);for(l=n;l<n+c;++l)this.model.core.remove(n)}return s}},{key:"remoteInsert",value:function(e,t){var n=t-1;if(d("Remote Insert : ",e,n),-1!==n){switch(e.type){case"formula":this.viewEditor.insertEmbed(n,"formula",e.text.formula,"silent");break;case"image":this.viewEditor.insertEmbed(n,"image",e.text.image,"silent");break;case"video":this.viewEditor.insertEmbed(n,"video",e.text.video,"silent");break;case"char":this.viewEditor.insertText(n,e.text,e.att,"silent"),"\n"!=e.text&&this.viewEditor.removeFormat(n,1,"silent")}e.att&&("\n"!=e.text&&(this.viewEditor.formatLine(n,e.att,"silent"),this.viewEditor.formatText(n,1,e.att,"silent")),e.att.commentAuthor&&this.UpdateComments(),e.att.link&&session.default.openIn())}session.default.openIn(),this.cleanQuill()}},{key:"remoteRemove",value:function(e){d("Remote remove : ",e);var t=e-1;-1!==t&&(this.viewEditor.deleteText(t,1,"silent"),this.UpdateComments()),this.cleanQuill()}},{key:"remoteCaretMoved",value:function(e,t){if(t)if(this.markers[t])this.markers[t].update(e,!0);else{var n={lifeTime:5e3,range:e,cursor:!1,isItME:!1};this.markers[t]=new o.default(t,n,this)}}},{key:"cleanQuill",value:function(){}},{key:"changeTitle",value:function(){jQuery("#"+this._editorContainerID+" #title").attr("contenteditable","false"),""==jQuery("#"+this._editorContainerID+" #title").text()&&jQuery("#"+this._editorContainerID+" #title").text("Untitled document"),this.model.name=jQuery("#"+this._editorContainerID+" #title").text(),this.model.core.sendChangeTitle(jQuery("#"+this._editorContainerID+" #title").text())}},{key:"startPing",value:function(e){var t=this;this.startTimer=setInterval(function(){var e="Anonymous";store.get("myId").pseudo&&(e=store.get("myId").pseudo),t.model.core.sendPing(e)},e)}},{key:"stopPing",value:function(){clearInterval(this.startTimer)}},{key:"atPing",value:function(e,t){if(this.markers[e])this.markers[e].update(null,!1),this.markers[e].setPseudo(t);else{this.markers[e]=new o.default(e,{lifeTime:5e3,range:{index:0,length:0},cursor:!1,isItME:!1},this),this.markers[e].setPseudo(t)}}},{key:"UpdateComments",value:function(){var e=this;jQuery("#"+this._editorContainerID+" #comments").empty(),this.viewEditor.editor.delta.ops.forEach(function(t){if(t.insert&&t.attributes&&t.attributes.commentAuthor){var n=t.attributes.commentAuthor,i={},s=(i=e.markers[n]?e.markers[n]:{animal:o.default.getPseudoname(n,null),pseudoName:o.default.getPseudoname(n),colorRGB:o.default.getColor(n,"rgb")}).animal,a=i.pseudoName,r=i.colorRGB;e._comments.addCommentToList(t.attributes.comment,n,s,a,r,t.attributes.commentTimestamp)}})}},{key:"saveComment",value:function(){this._comments.saveComment()}}]),t}();t.default=l},548:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();var o=function(){function e(t,n,i,o){var s=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.model=t,this.startSharingText='<i class="fa fa-link fa-2x ficon2"></i>',this.startSharingTooltip="start sharing",this.stopSharingText='<i class="fa fa-unlink fa-2x ficon2"></i>',this.stopSharingTooltip="stop sharing",this.red="#cd2626",this.yellow="#eead0e",this.green="#228b22",this.blue="#00BFFF",this._editorContainerID=o,this.networkState=jQuery("#"+this._editorContainerID+" #state"),this.setNetworkState("connected"),t.rps.on("statechange",function(e){switch(e){case"connected":s.setNetworkState("connected");break;case"partially connected":s.setNetworkState("partiallyConnected");break;case"disconnected":s.setNetworkState("disconnected")}}),i.click(function(){var e=window.location.href.split("?")[0];n.printLink(e+"?"+s.model.signalingOptions.session),jQuery("#"+s._editorContainerID+" #copyButton").click(function(){s.copyLink()})}),n.qrcode.click(function(){var e=window.location.href.split("?")[0];e=e+"?"+s.model.signalingOptions.session,n.qrcodeCanvas.html(""),n.qrcodeCanvas.qrcode({size:400,text:e})})}return i(e,[{key:"copyLink",value:function(){console.log("Copy => #"+this._editorContainerID+" #sessionUrl"),jQuery("#"+this._editorContainerID+" #sessionUrl").select(),document.execCommand("Copy")}},{key:"setNetworkState",value:function(e){switch(e){case"connected":this.networkState.css("color",this.green),this.networkState.attr("data-content","<span class='alert-success'>Congratulations!</span>\n You are connected to people, and people are \n connected to you. <span class='alert-info'>You can start editing \" \n together</span>.");break;case"partiallyConnected":this.networkState.css("color",this.green),this.networkState.attr("data-content","<span class='alert-warning'>Partially connected</span>: \n either you are connected to people, or people are connected to you. \n This is not great, but you <span class='alert-info'> still can edit.</span>");break;case"disconnected":this.networkState.css("color",this.red),this.networkState.attr("data-content","<span class='alert-danger'>Disconnected</span>:\n you are currently editing <span class='alert-info'>on\n your own</span>.")}}}]),e}();t.default=o},549:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();var o=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.linkContainer=jQuery("<div>").appendTo(t).css("position","relative").css("top","0px").css("width","45vw-25px").css("z-index","0").css("opacity","0.9").attr("id","linkContainer").hide();var i=jQuery("<div>").appendTo(t).attr("id","modalQRCode"+n).attr("tabindex","-1").attr("role","dialog").attr("aria-labelledby","modalQRCodeLabel").attr("aria-hidden","true").addClass("modal"),o=jQuery("<div>").appendTo(i).addClass("modal-dialog"),s=jQuery("<div>").appendTo(o).addClass("modal-content text-center");this.qrcodeCanvas=jQuery("<div>"),s.append(jQuery("<br>")).append(this.qrcodeCanvas).append(jQuery("<br>")),this.alert=jQuery("<div>").appendTo(this.linkContainer),this.dismiss=jQuery("<button>").appendTo(this.alert).attr("type","button").addClass("close").html('<span aria-hidden="true">&times;</span><span class="sr-only"> Close </span>');var a=jQuery("<div>").appendTo(this.alert).addClass("container"),r=jQuery("<div>").appendTo(a).addClass("input-group").attr("style","margin-left: -16px;");this.input=jQuery("<input>").appendTo(r).attr("type","text").attr("id","sessionUrl").attr("placeholder","Nothing to see here, move along.").addClass("form-control");var d=jQuery("<span>").appendTo(r).addClass("input-group-btn");this.qrcode=jQuery("<button>").appendTo(d).attr("aria-label","QR-code").attr("type","button").attr("data-target","#modalQRCode"+n).attr("data-toggle","modal").addClass("btn btn-default").html('<i class="fa fa-qrcode"></i>'),this.action=jQuery('<button id="copyButton">').appendTo(d).attr("aria-label","Go!").attr("type","button").addClass("btn btn-default").html("Go!").css("z-index","15");var l=this;this.dismiss.unbind("click").click(function(){l.linkContainer.hide()})}return i(e,[{key:"printLink",value:function(e){this.linkContainer.show(),this.action.html('<i class="fa fa-clipboard"></i>'),this.action.attr("aria-label","Copy to clipboard"),this.input.attr("readonly","readonly"),this.input.val(e),this.qrcode.show()}},{key:"printLaunchLink",value:function(e){return this.printLink(e),this.input.attr("placeholder","A link will appear in this field, give it to your friend!"),this.action.unbind("click"),this.qrcode.hide(),this.action}},{key:"printAnswerLink",value:function(e){return this.printLink(e),this.input.attr("placeholder","A link will appear in this field. Please give it back to your friend."),this.action.unbind("click"),this.qrcode.hide(),this.action}},{key:"askLink",value:function(){this.linkContainer.show(),this.alert.removeClass("alert-warning").addClass("alert-info"),this.action.html("Go!"),this.action.attr("aria-label","Stamp the ticket"),this.input.removeAttr("readonly"),this.input.val(""),this.action.unbind("click"),this.qrcode.hide()}},{key:"askLaunchLink",value:function(){return this.askLink(),this.input.attr("placeholder","Please, copy the ticket of your friend here to stamp it!"),this.qrcode.hide(),this.action}},{key:"askAnswerLink",value:function(){return this.askLink(),this.input.attr("placeholder","Copy the stamped ticket to confirm your arrival in the network"),this.qrcode.hide(),this.action}},{key:"hide",value:function(){this.linkContainer.hide()}}]),e}();t.default=o}}]); //# sourceMappingURL=0.jquery-crate.bundle.js.map