diff --git a/cps/helper.py b/cps/helper.py index eb898b48..d90e15dc 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -89,11 +89,10 @@ def make_mobi(book_id, calibrepath): try: p = subprocess.Popen((kindlegen + " \"" + file_path + u".epub\"").encode(sys.getfilesystemencoding()), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - except: + except Exception: error_message = _(u"kindlegen failed, no excecution permissions") - app.logger.error("make_mobi: "+error_message) + app.logger.error("make_mobi: " + error_message) return error_message, RET_FAIL - # Poll process for new output until finished while True: nextline = p.stdout.readline() @@ -122,11 +121,13 @@ def make_mobi(book_id, calibrepath): db.session.commit() return file_path + ".mobi", RET_SUCCESS else: - app.logger.error("make_mobi: kindlegen failed with error while converting book") - return None, RET_FAIL + app.logger.info("make_mobi: kindlegen failed with error while converting book") + if not error_message: + error_message='kindlegen failed, no excecution permissions' + return error_message, RET_FAIL else: - app.logger.error("make_mobi: epub not found: %s.epub" % file_path) - return None, RET_FAIL + error_message = "make_mobi: epub not found: %s.epub" % file_path + return error_message, RET_FAIL class StderrLogger(object): @@ -176,7 +177,7 @@ def send_raw_email(kindle_mail, msg): if settings["mail_password"]: mailserver.login(settings["mail_login"], settings["mail_password"]) - mailserver.sendmail(settings["mail_login"], kindle_mail, msg) + mailserver.sendmail(settings["mail_from"], kindle_mail, msg) mailserver.quit() smtplib.stderr = org_stderr @@ -229,6 +230,7 @@ def send_mail(book_id, kindle_mail, calibrepath): if resultCode == RET_SUCCESS: msg.attach(get_attachment(data)) else: + app.logger.error = (data) return data #_("Could not convert epub to mobi") elif 'pdf' in formats: msg.attach(get_attachment(formats['pdf'])) @@ -305,7 +307,7 @@ def delete_book_gdrive(book): def update_dir_stucture(book_id, calibrepath): db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort) book = db.session.query(db.Books).filter(db.Books.id == book_id).first() - path = os.path.join(calibrepath, book.path)#.replace('/',os.path.sep)).replace('\\',os.path.sep) + path = os.path.join(calibrepath, book.path) authordir = book.path.split('/')[0] new_authordir = get_valid_filename(book.authors[0].name) @@ -333,14 +335,14 @@ def update_dir_structure_gdrive(book_id): new_authordir = get_valid_filename(book.authors[0].name) titledir = book.path.split('/')[1] new_titledir = get_valid_filename(book.title) + " (" + str(book_id) + ")" - + if titledir != new_titledir: print (titledir) gFile=gd.getFileFromEbooksFolder(web.Gdrive.Instance().drive,os.path.dirname(book.path),titledir) gFile['title']= new_titledir gFile.Upload() book.path = book.path.split('/')[0] + '/' + new_titledir - + if authordir != new_authordir: gFile=gd.getFileFromEbooksFolder(web.Gdrive.Instance().drive,None,authordir) gFile['title'] = new_authordir @@ -400,8 +402,8 @@ class Updater(threading.Thread): for file in delete_files: parts = file.split(os.sep) sub = '' - for i in range(len(parts)): - sub = os.path.join(sub, parts[i]) + for part in parts: + sub = os.path.join(sub, part) if sub == '': sub = os.sep count = 0 @@ -432,7 +434,7 @@ class Updater(threading.Thread): logging.getLogger('cps.web').debug('Update on OS-System : ' + sys.platform) new_permissions = os.stat(root_dst_dir) # print new_permissions - for src_dir, dirs, files in os.walk(root_src_dir): + for src_dir, __, files in os.walk(root_src_dir): dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1) if not os.path.exists(dst_dir): os.makedirs(dst_dir) @@ -455,11 +457,13 @@ class Updater(threading.Thread): logging.getLogger('cps.web').debug('Move File '+src_file+' to '+dst_dir) if change_permissions: try: - os.chown(dst_file, permission.st_uid, permission.st_uid) - # print('Permissions: User '+str(new_permissions.st_uid)+' Group '+str(new_permissions.st_uid)) + os.chown(dst_file, permission.st_uid, permission.st_gid) except Exception as e: e = sys.exc_info() - logging.getLogger('cps.web').debug('Fail '+str(dst_file)+' error: '+str(e)) + old_permissions = os.stat(dst_file) + logging.getLogger('cps.web').debug('Fail change permissions of ' + str(dst_file) + '. Before: ' + + str(old_permissions.st_uid) + ':' + str(old_permissions.st_gid) + ' After: ' + + str(permission.st_uid) + ':' + str(permission.st_gid) + ' error: '+str(e)) return def update_source(self, source, destination): diff --git a/cps/redirect.py b/cps/redirect.py new file mode 100644 index 00000000..b521bc28 --- /dev/null +++ b/cps/redirect.py @@ -0,0 +1,28 @@ +# http://flask.pocoo.org/snippets/62/ + +try: + from urllib.parse import urlparse, urljoin +except ImportError: + from urlparse import urlparse, urljoin +from flask import request, url_for, redirect + + +def is_safe_url(target): + ref_url = urlparse(request.host_url) + test_url = urlparse(urljoin(request.host_url, target)) + return test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc + + +def get_redirect_target(): + for target in request.values.get('next'), request.referrer: + if not target: + continue + if is_safe_url(target): + return target + + +def redirect_back(endpoint, **values): + target = request.form['next'] + if not target or not is_safe_url(target): + target = url_for(endpoint, **values) + return redirect(target) diff --git a/cps/static/css/main.css b/cps/static/css/main.css index 4e3ac86f..4afb28f7 100644 --- a/cps/static/css/main.css +++ b/cps/static/css/main.css @@ -104,7 +104,7 @@ body { height: 80%; /* margin-left: 10%; */ margin: 0 auto; - max-width: 1250px; + /* max-width: 1250px; */ z-index: 2; position: relative; overflow: hidden; @@ -652,10 +652,10 @@ input:-ms-placeholder { padding: 4px; } -@media only screen and (max-width: 1040px) { +@media only screen and (max-width: 1040px) and (orientation: portrait) { #viewer{ - width: 50%; - margin-left: 25%; + width: 80%; + margin-left: 10%; } #divider, @@ -745,15 +745,63 @@ input:-ms-placeholder { height: 740px; } } - /*For iPad landscape layouts only */ + /*For iPad landscape layouts only *//* @media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation: landscape) { #viewer iframe { width: 460px; height: 415px; } +}*/ + +@media only screen +and (min-device-width : 768px) +and (max-device-width : 1024px) +and (orientation : landscape) +/*and (-webkit-min-device-pixel-ratio: 2)*/ { + #viewer{ + width: 80%; + margin-left: 10%; + } + #divider, + #divider.show { + display: none; + } } + + /*For iPad landscape layouts only */ +@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation: landscape) { + #viewer iframe { + width: 960px; + height: 515px; + } +} + +/* For iPhone 6\6s portrait layouts only */ +@media only screen and (min-device-width : 375px) and (max-device-width : 667px) and (orientation: portrait) { + #viewer { + width: 300px; + height: 480px; + } + #viewer iframe { + width: 300px; + height: 480px; + } +} + +/* For iPhone 6\6s landscape layouts only */ +@media only screen and (min-device-width : 375px) and (max-device-width : 667px) and (orientation: landscape) { + #viewer { + width: 450px; + height: 300px; + } + #viewer iframe { + width: 450px; + height: 300px; + } +} + /* For iPhone portrait layouts only */ -@media only screen and (max-device-width: 480px) and (orientation: portrait) { +@media only screen and (max-device-width: 374px) and (orientation: portrait) { #viewer { width: 256px; height: 432px; @@ -763,8 +811,9 @@ input:-ms-placeholder { height: 432px; } } + /* For iPhone landscape layouts only */ -@media only screen and (max-device-width: 480px) and (orientation: landscape) { +@media only screen and (max-device-width: 374px) and (orientation: landscape) { #viewer iframe { width: 256px; height: 124px; diff --git a/cps/static/css/style.css b/cps/static/css/style.css index e136fedf..87f7b4c5 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -43,8 +43,8 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te .btn-file {position: relative; overflow: hidden;} .btn-file input[type=file] {position: absolute; top: 0; right: 0; min-width: 100%; min-height: 100%; font-size: 100px; text-align: right; filter: alpha(opacity=0); opacity: 0; outline: none; background: white; cursor: inherit; display: block;} -.btn-toolbar .btn { margin-bottom: 5px; } - +.btn-toolbar .btn,.discover .btn { margin-bottom: 5px; } +.button-link {color:#fff;} .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open .dropdown-toggle.btn-primary{ background-color: #1C5484; } .btn-primary.disabled, .btn-primary[disabled], fieldset[disabled] .btn-primary, .btn-primary.disabled:hover, .btn-primary[disabled]:hover, fieldset[disabled] .btn-primary:hover, .btn-primary.disabled:focus, .btn-primary[disabled]:focus, fieldset[disabled] .btn-primary:focus, .btn-primary.disabled:active, .btn-primary[disabled]:active, fieldset[disabled] .btn-primary:active, .btn-primary.disabled.active, .btn-primary[disabled].active, fieldset[disabled] .btn-primary.active { background-color: #89B9E2; } .btn-toolbar>.btn+.btn, .btn-toolbar>.btn-group+.btn, .btn-toolbar>.btn+.btn-group, .btn-toolbar>.btn-group+.btn-group { margin-left:0px; } @@ -52,3 +52,13 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te .spinner {margin:0 41%;} .spinner2 {margin:0 41%;} +.block-label {display: block;} +.fake-input {position: absolute; pointer-events: none; top: 0;} + +.author-bio img {margin: 0 1em 1em 0;} +.author-link img {display: inline-block;max-width: 100px;} + +#remove-from-shelves .btn, +#shelf-action-errors { + margin-left: 5px; +} diff --git a/cps/static/img/goodreads.svg b/cps/static/img/goodreads.svg new file mode 100644 index 00000000..f89130e9 --- /dev/null +++ b/cps/static/img/goodreads.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/cps/static/js/details.js b/cps/static/js/details.js new file mode 100644 index 00000000..74dbb08e --- /dev/null +++ b/cps/static/js/details.js @@ -0,0 +1,39 @@ +$( document ).ready(function() { + $("#have_read_form").ajaxForm(); +}); + +$("#have_read_cb").on("change", function() { + $(this).closest("form").submit(); +}); + +$("#shelf-actions").on("click", "[data-shelf-action]", function (e) { + e.preventDefault(); + + $.get(this.href) + .done(() => { + const $this = $(this); + switch ($this.data("shelf-action")) { + case "add": + $("#remove-from-shelves").append(` ${this.textContent}`); + break; + case "remove": + $("#add-to-shelves").append(`
\xa0
').append(m),a.setStartAfter(d[0].firstChild.firstChild),a.setEndAfter(m)):(d.empty().append("\xa0").append(m).append("\xa0"),a.setStart(d[0].firstChild,1),a.setEnd(d[0].lastChild,0)),d.css({top:p.getPos(c,g.getBody()).y}),d[0].focus(),e=g.selection.getSel(),e.removeAllRanges(),e.addRange(a),g.$("*[data-mce-selected]").removeAttr("data-mce-selected"),c.setAttribute("data-mce-selected",1),J=c,I(),a)):null)}function G(){J&&(J.removeAttribute("data-mce-selected"),g.$("#"+M).remove(),J=null)}function H(){L.destroy(),J=null}function I(){L.hide()}var J,K=g.getBody(),L=new e(g.getBody(),u),M="sel-"+g.dom.uniqueId();return k.ceFalse&&(B(),C()),{showCaret:y,showBlockCaretContainer:A,hideFakeCaret:I,destroy:H}}var p=g.isContentEditableTrue,q=g.isContentEditableFalse,r=c.isAfterContentEditableFalse,s=c.isBeforeContentEditableFalse;return o}),g("74",["e"],function(a){function b(b,c,d){for(var e=[];c&&c!=b;c=c.parentNode)e.push(a.nodeIndex(c,d));return e}function c(a,b){var c,d,e;for(d=a,c=b.length-1;c>=0;c--){if(e=d.childNodes,b[c]>e.length-1)return null;d=e[b[c]]}return d}return{create:b,resolve:c}}),g("6i",["p","h","c","74","i","d","6","9","5","1k","1p","4m"],function(a,b,c,d,e,f,g,h,i,j,k,l){return function(c){function d(a,b){try{c.getDoc().execCommand(a,!1,b)}catch(a){}}function m(){var a=c.getDoc().documentMode;return a?a:6}function n(a){return a.isDefaultPrevented()}function o(a){var b,d;a.dataTransfer&&(c.selection.isCollapsed()&&"IMG"==a.target.tagName&&_.select(a.target),b=c.selection.getContent(),b.length>0&&(d=ga+escape(c.id)+","+escape(b),a.dataTransfer.setData(ha,d)))}function p(a){var b;return a.dataTransfer&&(b=a.dataTransfer.getData(ha),b&&b.indexOf(ga)>=0)?(b=b.substr(ga.length).split(","),{id:unescape(b[0]),html:unescape(b[1])}):null}function q(a,b){c.queryCommandSupported("mceInsertClipboardContent")?c.execCommand("mceInsertClipboardContent",!1,{content:a,internal:b}):c.execCommand("mceInsertContent",!1,a)}function r(){function a(a){var b=$.create("body"),c=a.cloneContents();return b.appendChild(c),_.serializer.serialize(b,{format:"html"})}function d(d){if(!d.setStart){if(d.item)return!1;var e=d.duplicate();return e.moveToElementText(c.getBody()),b.compareRanges(d,e)}var f=a(d),g=$.createRng();g.selectNode(c.getBody());var h=a(g);return f===h}c.on("keydown",function(a){var b,e,f=a.keyCode;if(!n(a)&&(f==Z||f==Y)){if(b=c.selection.isCollapsed(),e=c.getBody(),b&&!$.isEmpty(e))return;if(!b&&!d(c.selection.getRng()))return;a.preventDefault(),c.setContent(""),e.firstChild&&$.isBlock(e.firstChild)?c.selection.setCursorLocation(e.firstChild,0):c.selection.setCursorLocation(e,0),c.nodeChanged()}})}function s(){c.shortcuts.add("meta+a",null,"SelectAll")}function t(){c.settings.content_editable||$.bind(c.getDoc(),"mousedown mouseup",function(a){var b;if(a.target==c.getDoc().documentElement)if(b=_.getRng(),c.getBody().focus(),"mousedown"==a.type){if(j.isCaretContainer(b.startContainer))return;_.placeCaretAt(a.clientX,a.clientY)}else _.setRng(b)})}function u(){c.on("keydown",function(a){if(!n(a)&&a.keyCode===Y){if(!c.getBody().getElementsByTagName("hr").length)return;if(_.isCollapsed()&&0===_.getRng(!0).startOffset){var b=_.getNode(),d=b.previousSibling;if("HR"==b.nodeName)return $.remove(b),void a.preventDefault();d&&d.nodeName&&"hr"===d.nodeName.toLowerCase()&&($.remove(d),a.preventDefault())}}})}function v(){window.Range.prototype.getClientRects||c.on("mousedown",function(a){if(!n(a)&&"HTML"===a.target.nodeName){var b=c.getBody();b.blur(),i.setEditorTimeout(c,function(){b.focus()})}})}function w(){c.on("click",function(a){var b=a.target;/^(IMG|HR)$/.test(b.nodeName)&&"false"!==$.getContentEditableParent(b)&&(a.preventDefault(),c.selection.select(b),c.nodeChanged()),"A"==b.nodeName&&$.hasClass(b,"mce-item-anchor")&&(a.preventDefault(),_.select(b))})}function x(){function a(){var a=$.getAttribs(_.getStart().cloneNode(!1));return function(){var b=_.getStart();b!==c.getBody()&&($.setAttrib(b,"style",null),X(a,function(a){b.setAttributeNode(a.cloneNode(!0))}))}}function b(){return!_.isCollapsed()&&$.getParent(_.getStart(),$.isBlock)!=$.getParent(_.getEnd(),$.isBlock)}c.on("keypress",function(d){var e;if(!n(d)&&(8==d.keyCode||46==d.keyCode)&&b())return e=a(),c.getDoc().execCommand("delete",!1,null),e(),d.preventDefault(),!1}),$.bind(c.getDoc(),"cut",function(d){var e;!n(d)&&b()&&(e=a(),i.setEditorTimeout(c,function(){e()}))})}function y(){document.body.setAttribute("role","application")}function z(){c.on("keydown",function(a){if(!n(a)&&a.keyCode===Y&&_.isCollapsed()&&0===_.getRng(!0).startOffset){var b=_.getNode().previousSibling;if(b&&b.nodeName&&"table"===b.nodeName.toLowerCase())return a.preventDefault(),!1}})}function A(){m()>7||(d("RespectVisibilityInDesign",!0),c.contentStyles.push(".mceHideBrInPre pre br {display: none}"),$.addClass(c.getBody(),"mceHideBrInPre"),ba.addNodeFilter("pre",function(a){for(var b,c,d,f,g=a.length;g--;)for(b=a[g].getAll("br"),c=b.length;c--;)d=b[c],f=d.prev,f&&3===f.type&&"\n"!=f.value.charAt(f.value-1)?f.value+="\n":d.parent.insert(new e("#text",3),d,!0).value="\n"}),ca.addNodeFilter("pre",function(a){for(var b,c,d,e,f=a.length;f--;)for(b=a[f].getAll("br"),c=b.length;c--;)d=b[c],e=d.prev,e&&3==e.type&&(e.value=e.value.replace(/\r?\n$/,""))}))}function B(){$.bind(c.getBody(),"mouseup",function(){var a,b=_.getNode();"IMG"==b.nodeName&&((a=$.getStyle(b,"width"))&&($.setAttrib(b,"width",a.replace(/[^0-9%]+/g,"")),$.setStyle(b,"width","")),(a=$.getStyle(b,"height"))&&($.setAttrib(b,"height",a.replace(/[^0-9%]+/g,"")),$.setStyle(b,"height","")))})}function C(){c.on("keydown",function(b){var d,e,f,g,h;if(!n(b)&&b.keyCode==a.BACKSPACE&&(d=_.getRng(),e=d.startContainer,f=d.startOffset,g=$.getRoot(),h=e,d.collapsed&&0===f)){for(;h&&h.parentNode&&h.parentNode.firstChild==h&&h.parentNode!=g;)h=h.parentNode;"BLOCKQUOTE"===h.tagName&&(c.formatter.toggle("blockquote",null,h),d=$.createRng(),d.setStart(e,0),d.setEnd(e,0),_.setRng(d))}})}function D(){function a(){U(),d("StyleWithCSS",!1),d("enableInlineTableEditing",!1),aa.object_resizing||d("enableObjectResizing",!1)}aa.readonly||c.on("BeforeExecCommand MouseDown",a)}function E(){function a(){X($.select("a"),function(a){var b=a.parentNode,c=$.getRoot();if(b.lastChild===a){for(;b&&!$.isBlock(b);){if(b.parentNode.lastChild!==b||b===c)return;b=b.parentNode}$.add(b,"br",{"data-mce-bogus":1})}})}c.on("SetContent ExecCommand",function(b){"setcontent"!=b.type&&"mceInsertLink"!==b.command||a()})}function F(){aa.forced_root_block&&c.on("init",function(){d("DefaultParagraphSeparator",aa.forced_root_block)})}function G(){c.on("keydown",function(a){var b;n(a)||a.keyCode!=Y||(b=c.getDoc().selection.createRange(),b&&b.item&&(a.preventDefault(),c.undoManager.beforeChange(),$.remove(b.item(0)),c.undoManager.add()))})}function H(){var a;m()>=10&&(a="",X("p div h1 h2 h3 h4 h5 h6".split(" "),function(b,c){a+=(c>0?",":"")+b+":empty"}),c.contentStyles.push(a+"{padding-right: 1px !important}"))}function I(){m()<9&&(ba.addNodeFilter("noscript",function(a){for(var b,c,d=a.length;d--;)b=a[d],c=b.firstChild,c&&b.attr("data-mce-innertext",c.value)}),ca.addNodeFilter("noscript",function(a){for(var b,c,d,g=a.length;g--;)b=a[g],c=a[g].firstChild,c?c.value=f.decode(c.value):(d=b.attributes.map["data-mce-innertext"],d&&(b.attr("data-mce-innertext",null),c=new e("#text",3),c.value=d,c.raw=!0,b.append(c)))}))}function J(){function a(a,b){var c=h.createTextRange();try{c.moveToPoint(a,b)}catch(a){c=null}return c}function b(b){var d;b.button?(d=a(b.x,b.y),d&&(d.compareEndPoints("StartToStart",e)>0?d.setEndPoint("StartToStart",e):d.setEndPoint("EndToEnd",e),d.select())):c()}function c(){var a=g.selection.createRange();e&&!a.item&&0===a.compareEndPoints("StartToEnd",a)&&e.select(),$.unbind(g,"mouseup",c),$.unbind(g,"mousemove",b),e=d=0}var d,e,f,g=$.doc,h=g.body;g.documentElement.unselectable=!0,$.bind(g,"mousedown contextmenu",function(h){if("HTML"===h.target.nodeName){if(d&&c(),f=g.documentElement,f.scrollHeight>f.clientHeight)return;d=1,e=a(h.x,h.y),e&&($.bind(g,"mouseup",c),$.bind(g,"mousemove",b),$.getRoot().focus(),e.select())}})}function K(){c.on("keyup focusin mouseup",function(b){65==b.keyCode&&a.metaKeyPressed(b)||_.normalize()},!0)}function L(){c.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function M(){c.inline||c.on("keydown",function(){document.activeElement==document.body&&c.getWin().focus()})}function N(){c.inline||(c.contentStyles.push("body {min-height: 150px}"),c.on("click",function(a){var b;if("HTML"==a.target.nodeName){if(g.ie>11)return void c.getBody().focus();b=c.selection.getRng(),c.getBody().focus(),c.selection.setRng(b),c.selection.normalize(),c.nodeChanged()}}))}function O(){g.mac&&c.on("keydown",function(b){!a.metaKeyPressed(b)||b.shiftKey||37!=b.keyCode&&39!=b.keyCode||(b.preventDefault(),c.selection.getSel().modify("move",37==b.keyCode?"backward":"forward","lineboundary"))})}function P(){d("AutoUrlDetect",!1)}function Q(){c.on("click",function(a){var b=a.target;do if("A"===b.tagName)return void a.preventDefault();while(b=b.parentNode)}),c.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function R(){c.on("init",function(){c.dom.bind(c.getBody(),"submit",function(a){a.preventDefault()})})}function S(){ba.addNodeFilter("br",function(a){for(var b=a.length;b--;)"Apple-interchange-newline"==a[b].attr("class")&&a[b].remove()})}function T(){c.on("dragstart",function(a){o(a)}),c.on("drop",function(a){if(!n(a)){var d=p(a);if(d&&d.id!=c.id){a.preventDefault();var e=b.getCaretRangeFromPoint(a.x,a.y,c.getDoc());_.setRng(e),q(d.html,!0)}}})}function U(){}function V(){var a;return!da||c.removed?0:(a=c.selection.getSel(),!a||!a.rangeCount||0===a.rangeCount)}function W(){function b(a){var b=new l(a.getBody()),c=a.selection.getRng(),d=k.fromRangeStart(c),e=k.fromRangeEnd(c),f=b.prev(d),g=b.next(e);return!a.selection.isCollapsed()&&(!f||f.isAtStart()&&d.isEqual(f))&&(!g||g.isAtEnd()&&d.isEqual(g))}c.on("keypress",function(d){!n(d)&&!_.isCollapsed()&&d.charCode>31&&!a.metaKeyPressed(d)&&b(c)&&(d.preventDefault(),c.setContent(String.fromCharCode(d.charCode)),c.selection.select(c.getBody(),!0),c.selection.collapse(!1),c.nodeChanged())}),c.on("keydown",function(a){var d=a.keyCode;n(a)||d!=Z&&d!=Y||b(c)&&(a.preventDefault(),c.setContent(""),c.nodeChanged())})}var X=h.each,Y=a.BACKSPACE,Z=a.DELETE,$=c.dom,_=c.selection,aa=c.settings,ba=c.parser,ca=c.serializer,da=g.gecko,ea=g.ie,fa=g.webkit,ga="data:text/mce-internal,",ha=ea?"Text":"URL";return C(),r(),g.windowsPhone||K(),fa&&(W(),t(),w(),F(),R(),z(),S(),g.iOS?(M(),N(),Q()):s()),ea&&g.ie<11&&(u(),y(),A(),B(),G(),H(),I(),J()),g.ie>=11&&(N(),z()),g.ie&&(s(),P(),T()),da&&(W(),u(),v(),x(),D(),E(),L(),O(),z()),{refreshContentEditable:U,isHidden:V}}}),g("5r",["22","4t","6c","e","s","o","6d","2b","6e","t","l","i","j","6f","6g","6h","u","5","6i","9"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u=d.DOM,v=function(a){var b=new k(a.settings,a.schema);return b.addAttributeFilter("src,href,style,tabindex",function(b,c){for(var d,e,f,g=b.length,h=a.dom;g--;)if(d=b[g],e=d.attr(c),f="data-mce-"+c,!d.attributes.map[f]){if(0===e.indexOf("data:")||0===e.indexOf("blob:"))continue;"style"===c?(e=h.serializeStyle(h.parseStyle(e),d.name),e.length||(e=null),d.attr(f,e),d.attr(c,e)):"tabindex"===c?(d.attr(f,e),d.attr(c,null)):d.attr(f,a.convertURL(e,c,d.name))}}),b.addNodeFilter("script",function(a){for(var b,c,d=a.length;d--;)b=a[d],c=b.attr("type")||"no/type",0!==c.indexOf("mce-")&&b.attr("type","mce-"+c)}),b.addNodeFilter("#cdata",function(a){for(var b,c=a.length;c--;)b=a[c],b.type=8,b.name="#comment",b.value="[CDATA["+b.value+"]]"}),b.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(b){for(var c,d=b.length,e=a.schema.getNonEmptyElements();d--;)c=b[d],c.isEmpty(e)&&0===c.getAll("br").length&&(c.append(new l("br",1)).shortEnded=!0)}),b},w=function(a){a.settings.auto_focus&&r.setEditorTimeout(a,function(){var b;b=a.settings.auto_focus===!0?a:a.editorManager.get(a.settings.auto_focus),b.destroyed||b.focus()},100)},x=function(a){a.bindPendingEventDelegates(),a.initialized=!0,a.fire("init"),a.focus(!0),a.nodeChanged({initial:!0}),a.execCallback("init_instance_callback",a),w(a)},y=function(a){return a.inline?u.styleSheetLoader:a.dom.styleSheetLoader},z=function(k,l){var r,w,z=k.settings,A=k.getElement(),B=k.getDoc();z.inline||(k.getElement().style.visibility=k.orgVisibility),l||z.content_editable||(B.open(),B.write(k.iframeHTML),B.close()),z.content_editable&&(k.on("remove",function(){var a=this.getBody();u.removeClass(a,"mce-content-body"),u.removeClass(a,"mce-edit-focus"),u.setAttrib(a,"contentEditable",null)}),u.addClass(A,"mce-content-body"),k.contentDocument=B=z.content_document||a,k.contentWindow=z.content_window||b,k.bodyElement=A,z.content_document=z.content_window=null,z.root_name=A.nodeName.toLowerCase()),r=k.getBody(),r.disabled=!0,k.readonly=z.readonly,k.readonly||(k.inline&&"static"===u.getStyle(r,"position",!0)&&(r.style.position="relative"),r.contentEditable=k.getParam("content_editable_state",!0)),r.disabled=!1,k.editorUpload=new g(k),k.schema=new m(z),k.dom=new d(B,{keep_values:!0,url_converter:k.convertURL,url_converter_scope:k,hex_colors:z.force_hex_style_colors,class_filter:z.class_filter,update_styles:!0,root_element:k.inline?k.getBody():null,collect:z.content_editable,schema:k.schema,onSetAttrib:function(a){k.fire("SetAttrib",a)}}),k.parser=v(k),k.serializer=new f(z,k),k.selection=new e(k.dom,k.getWin(),k.serializer,k),k.formatter=new j(k),k.undoManager=new q(k),k._nodeChangeDispatcher=new o(k),k._selectionOverrides=new p(k),c.setup(k),n.setup(k),i.setup(k),k.fire("PreInit"),z.browser_spellcheck||z.gecko_spellcheck||(B.body.spellcheck=!1,u.setAttrib(r,"spellcheck","false")),k.quirks=new s(k),k.fire("PostRender"),z.directionality&&(r.dir=z.directionality),z.nowrap&&(r.style.whiteSpace="nowrap"),z.protect&&k.on("BeforeSetContent",function(a){t.each(z.protect,function(b){a.content=a.content.replace(b,function(a){return""})})}),k.on("SetContent",function(){k.addVisual(k.getBody())}),z.padd_empty_editor&&k.on("PostProcess",function(a){a.content=a.content.replace(/^(]*>( | |\s|\u00a0|
|)<\/p>[\r\n]*|
[\r\n]*)$/,"")}),k.load({initial:!0,format:"html"}),k.startContent=k.getContent({format:"raw"}),k.on("compositionstart compositionend",function(a){k.composing="compositionstart"===a.type}),k.contentStyles.length>0&&(w="",t.each(k.contentStyles,function(a){w+=a+"\r\n"}),k.dom.addStyle(w)),y(k).loadAll(k.contentCSS,function(a){x(k)},function(a){x(k),h.contentCssError(k,a)})};return{initContentBody:z}}),g("4v",["g"],function(a){return a.PluginManager}),g("4w",["g"],function(a){return a.ThemeManager}),g("4u",["22","4t","e","6","5r","4v","4w","9","2a"],function(a,b,c,d,e,f,g,h,i){var j=c.DOM,k=function(a,b,c){var d,e,g=f.get(c);if(d=f.urls[c]||a.documentBaseUrl.replace(/\/$/,""),c=h.trim(c),g&&h.inArray(b,c)===-1){if(h.each(f.dependencies(c),function(c){k(a,b,c)}),a.plugins[c])return;e=new g(a,d,a.$),a.plugins[c]=e,e.init&&(e.init(a,d),b.push(c))}},l=function(a){var b=[];h.each(a.settings.plugins.replace(/\-/g,"").split(/[ ,]/),function(c){k(a,b,c)})},m=function(a){var b,c=a.settings;c.theme&&("function"!=typeof c.theme?(c.theme=c.theme.replace(/-/,""),b=g.get(c.theme),a.theme=new b(a,g.urls[c.theme]),a.theme.init&&a.theme.init(a,g.urls[c.theme]||a.documentBaseUrl.replace(/\/$/,""),a.$)):a.theme=c.theme)},n=function(a){var b,c,d,e,f,g=a.settings,h=a.getElement();return g.render_ui&&a.theme&&(a.orgDisplay=h.style.display,"function"!=typeof g.theme?(b=g.width||j.getStyle(h,"width")||"100%",c=g.height||j.getStyle(h,"height")||h.offsetHeight,d=g.min_height||100,e=/^[0-9\.]+(|px)$/i,e.test(""+b)&&(b=Math.max(parseInt(b,10),100)),e.test(""+c)&&(c=Math.max(parseInt(c,10),d)),f=a.theme.renderUI({targetNode:h,width:b,height:c,deltaWidth:g.delta_width,deltaHeight:g.delta_height}),g.content_editable||(c=(f.iframeHeight||c)+("number"==typeof c?f.deltaHeight||0:""),c