|
|
|
|
/*!
|
|
|
|
|
* https://github.com/paulmillr/es6-shim
|
|
|
|
|
* @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com)
|
|
|
|
|
* and contributors, MIT License
|
|
|
|
|
* es6-shim: v0.35.4
|
|
|
|
|
* see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE
|
|
|
|
|
* Details and documentation:
|
|
|
|
|
* https://github.com/paulmillr/es6-shim/
|
|
|
|
|
*/
|
|
|
|
|
(function(e,t){if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){"use strict";var e=Function.call.bind(Function.apply);var t=Function.call.bind(Function.call);var r=Array.isArray;var n=Object.keys;var o=function notThunker(t){return function notThunk(){return!e(t,this,arguments)}};var i=function(e){try{e();return false}catch(t){return true}};var a=function valueOrFalseIfThrows(e){try{return e()}catch(t){return false}};var u=o(i);var f=function(){return!i(function(){return Object.defineProperty({},"x",{get:function(){}})})};var s=!!Object.defineProperty&&f();var c=function foo(){}.name==="foo";var l=Function.call.bind(Array.prototype.forEach);var p=Function.call.bind(Array.prototype.reduce);var v=Function.call.bind(Array.prototype.filter);var y=Function.call.bind(Array.prototype.some);var h=function(e,t,r,n){if(!n&&t in e){return}if(s){Object.defineProperty(e,t,{configurable:true,enumerable:false,writable:true,value:r})}else{e[t]=r}};var b=function(e,t,r){l(n(t),function(n){var o=t[n];h(e,n,o,!!r)})};var g=Function.call.bind(Object.prototype.toString);var d=typeof/abc/==="function"?function IsCallableSlow(e){return typeof e==="function"&&g(e)==="[object Function]"}:function IsCallableFast(e){return typeof e==="function"};var m={getter:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}Object.defineProperty(e,t,{configurable:true,enumerable:false,get:r})},proxy:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,{configurable:n.configurable,enumerable:n.enumerable,get:function getKey(){return e[t]},set:function setKey(r){e[t]=r}})},redefine:function(e,t,r){if(s){var n=Object.getOwnPropertyDescriptor(e,t);n.value=r;Object.defineProperty(e,t,n)}else{e[t]=r}},defineByDescriptor:function(e,t,r){if(s){Object.defineProperty(e,t,r)}else if("value"in r){e[t]=r.value}},preserveToString:function(e,t){if(t&&d(t.toString)){h(e,"toString",t.toString.bind(t),true)}}};var O=Object.create||function(e,t){var r=function Prototype(){};r.prototype=e;var o=new r;if(typeof t!=="undefined"){n(t).forEach(function(e){m.defineByDescriptor(o,e,t[e])})}return o};var w=function(e,t){if(!Object.setPrototypeOf){return false}return a(function(){var r=function Subclass(t){var r=new e(t);Object.setPrototypeOf(r,Subclass.prototype);return r};Object.setPrototypeOf(r,e);r.prototype=O(e.prototype,{constructor:{value:r}});return t(r)})};var j=function(){if(typeof self!=="undefined"){return self}if(typeof window!=="undefined"){return window}if(typeof global!=="undefined"){return global}throw new Error("unable to locate global object")};var S=j();var T=S.isFinite;var I=Function.call.bind(String.prototype.indexOf);var E=Function.apply.bind(Array.prototype.indexOf);var P=Function.call.bind(Array.prototype.concat);var C=Function.call.bind(String.prototype.slice);var M=Function.call.bind(Array.prototype.push);var x=Function.apply.bind(Array.prototype.push);var N=Function.call.bind(Array.prototype.shift);var A=Math.max;var R=Math.min;var _=Math.floor;var k=Math.abs;var L=Math.exp;var F=Math.log;var D=Math.sqrt;var z=Function.call.bind(Object.prototype.hasOwnProperty);var q;var W=function(){};var G=S.Map;var H=G&&G.prototype["delete"];var V=G&&G.prototype.get;var B=G&&G.prototype.has;var U=G&&G.prototype.set;var $=S.Symbol||{};var J=$.species||"@@species";var X=Number.isNaN||function isNaN(e){return e!==e};var K=Number.isFinite||function isFinite(e){return typeof e==="number"&&T(e)};var Z=d(Math.sign)?Math.sign:function sign(e){var t=Number(e);if(t===0){return t}if(X(t)){return t}return t<0?-1:1};var Y=function log1p(e){var t=Number(e);if(t<-1||X(t)){return NaN}if(t===0||t===Infinity){return t}if(t===-1){return-Infinity}return 1+t-1===0?t:t*(F(1+t)/(1+t-1))};var Q=function isArguments(e){return g(e)==="[object Arguments]"};var ee=function isArguments(e){return e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&g(e)!=="[object
|
|
|
|
|
h(Math,"acosh",Cr.acosh,Math.acosh(Number.MAX_VALUE)===Infinity);h(Math,"acosh",Cr.acosh,!Mr(Math.acosh(1+Number.EPSILON),Math.sqrt(2*Number.EPSILON)));h(Math,"cbrt",Cr.cbrt,!Mr(Math.cbrt(1e-300),1e-100));h(Math,"sinh",Cr.sinh,Math.sinh(-2e-17)!==-2e-17);var xr=Math.expm1(10);h(Math,"expm1",Cr.expm1,xr>22025.465794806718||xr<22025.465794806718);var Nr=Math.round;var Ar=Math.round(.5-Number.EPSILON/4)===0&&Math.round(-.5+Number.EPSILON/3.99)===1;var Rr=mr+1;var _r=2*mr-1;var kr=[Rr,_r].every(function(e){return Math.round(e)===e});h(Math,"round",function round(e){var t=_(e);var r=t===-1?-0:t+1;return e-t<.5?t:r},!Ar||!kr);m.preserveToString(Math.round,Nr);var Lr=Math.imul;if(Math.imul(4294967295,5)!==-5){Math.imul=Cr.imul;m.preserveToString(Math.imul,Lr)}if(Math.imul.length!==2){ne(Math,"imul",function imul(e,t){return ce.Call(Lr,Math,arguments)})}var Fr=function(){var e=S.setTimeout;if(typeof e!=="function"&&typeof e!=="object"){return}ce.IsPromise=function(e){if(!ce.TypeIsObject(e)){return false}if(typeof e._promise==="undefined"){return false}return true};var r=function(e){if(!ce.IsConstructor(e)){throw new TypeError("Bad promise constructor")}var t=this;var r=function(e,r){if(t.resolve!==void 0||t.reject!==void 0){throw new TypeError("Bad Promise implementation!")}t.resolve=e;t.reject=r};t.resolve=void 0;t.reject=void 0;t.promise=new e(r);if(!(ce.IsCallable(t.resolve)&&ce.IsCallable(t.reject))){throw new TypeError("Bad promise constructor")}};var n;if(typeof window!=="undefined"&&ce.IsCallable(window.postMessage)){n=function(){var e=[];var t="zero-timeout-message";var r=function(r){M(e,r);window.postMessage(t,"*")};var n=function(r){if(r.source===window&&r.data===t){r.stopPropagation();if(e.length===0){return}var n=N(e);n()}};window.addEventListener("message",n,true);return r}}var o=function(){var e=S.Promise;var t=e&&e.resolve&&e.resolve();return t&&function(e){return t.then(e)}};var i=ce.IsCallable(S.setImmediate)?S.setImmediate:typeof process==="object"&&process.nextTick?process.nextTick:o()||(ce.IsCallable(n)?n():function(t){e(t,0)});var a=function(e){return e};var u=function(e){throw e};var f=0;var s=1;var c=2;var l=0;var p=1;var v=2;var y={};var h=function(e,t,r){i(function(){g(e,t,r)})};var g=function(e,t,r){var n,o;if(t===y){return e(r)}try{n=e(r);o=t.resolve}catch(i){n=i;o=t.reject}o(n)};var d=function(e,t){var r=e._promise;var n=r.reactionLength;if(n>0){h(r.fulfillReactionHandler0,r.reactionCapability0,t);r.fulfillReactionHandler0=void 0;r.rejectReactions0=void 0;r.reactionCapability0=void 0;if(n>1){for(var o=1,i=0;o<n;o++,i+=3){h(r[i+l],r[i+v],t);e[i+l]=void 0;e[i+p]=void 0;e[i+v]=void 0}}}r.result=t;r.state=s;r.reactionLength=0};var m=function(e,t){var r=e._promise;var n=r.reactionLength;if(n>0){h(r.rejectReactionHandler0,r.reactionCapability0,t);r.fulfillReactionHandler0=void 0;r.rejectReactions0=void 0;r.reactionCapability0=void 0;if(n>1){for(var o=1,i=0;o<n;o++,i+=3){h(r[i+p],r[i+v],t);e[i+l]=void 0;e[i+p]=void 0;e[i+v]=void 0}}}r.result=t;r.state=c;r.reactionLength=0};var O=function(e){var t=false;var r=function(r){var n;if(t){return}t=true;if(r===e){return m(e,new TypeError("Self resolution"))}if(!ce.TypeIsObject(r)){return d(e,r)}try{n=r.then}catch(o){return m(e,o)}if(!ce.IsCallable(n)){return d(e,r)}i(function(){j(e,r,n)})};var n=function(r){if(t){return}t=true;return m(e,r)};return{resolve:r,reject:n}};var w=function(e,r,n,o){if(e===I){t(e,r,n,o,y)}else{t(e,r,n,o)}};var j=function(e,t,r){var n=O(e);var o=n.resolve;var i=n.reject;try{w(r,t,o,i)}catch(a){i(a)}};var T,I;var E=function(){var e=function Promise(t){if(!(this instanceof e)){throw new TypeError('Constructor Promise requires "new"')}if(this&&this._promise){throw new TypeError("Bad construction")}if(!ce.IsCallable(t)){throw new TypeError("not a valid resolver")}var r=Ae(this,e,T,{_promise:{result:void 0,state:f,reactionLength:0,fulfillReactionHandler0:void 0,rejectReactionHandler0:void 0,reactionCapability0:void 0}});var n=O(r);var o=n.reject;try{t(n.resolve,o)}catch(i){o(i)}return r};return e}();T=E.prototype;var P=function(e,t,r,n){var o=f
|
|
|
|
|
//# sourceMappingURL=es6-shim.map
|
|
|
|
|
|
|
|
|
|
/*! jQuery v1.8.3 jquery.com | jquery.org/license */
|
|
|
|
|
(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r<i;r++)v.event.add(t,n,u[n][r])}o.data&&(o.data=v.extend({},o.data))}function Ot(e,t){var n;if(t.nodeType!==1)return;t.clearAttributes&&t.clearAttributes(),t.mergeAttributes&&t.mergeAttributes(e),n=t.nodeName.toLowerCase(),n==="object"?(t.parentNode&&(t.outerHTML=e.outerHTML),v.support.html5Clone&&e.innerHTML&&!v.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):n==="input"&&Et.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):n==="option"?t.selected=e.defaultSelected:n==="input"||n==="textarea"?t.defaultValue=e.defaultValue:n==="script"&&t.text!==e.text&&(t.text=e.text),t.removeAttribute(v.expando)}function Mt(e){return typeof e.getElementsByTagName!="undefined"?e.getElementsByTagName("*"):typeof e.querySelectorAll!="undefined"?e.querySelectorAll("*"):[]}function _t(e){Et.test(e.type)&&(e.defaultChecked=e.checked)}function Qt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Jt.length;while(i--){t=Jt[i]+n;if(t in e)return t}return r}function Gt(e,t){return e=t||e,v.css(e,"display")==="none"||!v.contains(e.ownerDocument,e)}function Yt(e,t){var n,r,i=[],s=0,o=e.length;for(;s<o;s++){n=e[s];if(!n.style)continue;i[s]=v._data(n,"olddisplay"),t?(!i[s]&&n.style.display==="none"&&(n.style.display=""),n.style.display===""&&Gt(n)&&(i[s]=v._data(n,"olddisplay",nn(n.nodeName)))):(r=Dt(n,"display"),!i[s]&&r!=="none"&&v._data(n,"olddisplay",r))}for(s=0;s<o;s++){n=e[s];if(!n.style)continue;if(!t||n.style.display==="none"||n.style.display==="")n.style.display=t?i[s]||"":"none"}return e}function Zt(e,t,n){var r=Rt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function en(e,t,n,r){var i=n===(r?"border":"content")?4:t==="width"?1:0,s=0;for(;i<4;i+=2)n==="margin"&&(s+=v.css(e,n+$t[i],!0)),r?(n==="content"&&(s-=parseFloat(Dt(e,"padding"+$t[i]))||0),n!=="margin"&&(s-=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0)):(s+=parseFloat(Dt(e,"padding"+$t[i]))||0,n!=="padding"&&(s+=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0));return s}function tn(e,t,n){var r=t==="width"?e.offsetWidth:e.offsetHeight,i=!0,s=v.support.boxSizing&&v.css(e,"boxSizing")==="border-box";if(r<=0||r==null){r=Dt(e,t);if(r<0||r==null)r=e.style[t];if(Ut.test(r))return r;i=s&&(v.support.boxSizingReliable||r===e.style[t]),r=parseFloat(r)||0}return r+en(e,t,n||(s?"border":"content"),i)+"px"}function nn(e){if(Wt[e])return Wt[e];var t=v("<"+e+">").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write("<!doctype html><html><body>"),Ht
|
|
|
|
|
// Underscore.js 1.8.2
|
|
|
|
|
// http://underscorejs.org
|
|
|
|
|
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
|
|
|
// Underscore may be freely distributed under the MIT license.
|
|
|
|
|
(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=d(e,i,4);var o=!w(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=b(r,e);for(var u=null!=t&&t.length,i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t){var r=S.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||o,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=S[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var e=this,u=e._,i=Array.prototype,o=Object.prototype,a=Function.prototype,c=i.push,l=i.slice,f=o.toString,s=o.hasOwnProperty,p=Array.isArray,h=Object.keys,v=a.bind,g=Object.create,y=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):e._=m,m.VERSION="1.8.2";var d=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},b=function(n,t,r){return null==n?m.identity:m.isFunction(n)?d(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return b(n,t,1/0)};var x=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var l=o[c];t&&r[l]!==void 0||(r[l]=i[l])}return r}},_=function(n){if(!m.isObject(n))return{};if(g)return g(n);y.prototype=n;var t=new y;return y.prototype=null,t},j=Math.pow(2,53)-1,w=function(n){var t=n&&n.length;return"number"==typeof t&&t>=0&&j>=t};m.each=m.forEach=function(n,t,r){t=d(t,r);var e,u;if(w(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=b(t,r);for(var e=!w(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=w(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=b(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(b(t)),r)},m.every=m.all=function(n,t,r){t=b(t,r);for(var e=!w(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=b(t,r);for(var e=!w(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r){return w(n)||(n=m.values(n)),m.indexOf(n,t,"number"==typeof r&&r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=w(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=b(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=w(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=b(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=w(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(w(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=b(t,r),m.pluck(m.map(n,function(
|
|
|
|
|
/**
|
|
|
|
|
* marked v0.3.3 - a markdown parser
|
|
|
|
|
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
|
|
|
|
|
* https://github.com/chjj/marked
|
|
|
|
|
升级到v0.4.0 从/educoder/public/editormd/lib/marked.min.js复制
|
|
|
|
|
*/
|
|
|
|
|
!function(e){"use strict";var t={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:d,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6})*([^\n]+?) *(?:#+ *)?(?:\n+|$)/,nptable:d,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:d,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,text:/^[^\n]+/};function n(e){this.tokens=[],this.tokens.links={},this.options=e||m.defaults,this.rules=t.normal,this.options.pedantic?this.rules=t.pedantic:this.options.gfm&&(this.options.tables?this.rules=t.tables:this.rules=t.gfm)}t._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,t._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,t.def=p(t.def).replace("label",t._label).replace("title",t._title).getRegex(),t.bullet=/(?:[*+-]|\d+\.)/,t.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,t.item=p(t.item,"gm").replace(/bull/g,t.bullet).getRegex(),t.list=p(t.list).replace(/bull/g,t.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+t.def.source+")").getRegex(),t._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",t._comment=/<!--(?!-?>)[\s\S]*?-->/,t.html=p(t.html,"i").replace("comment",t._comment).replace("tag",t._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),t.paragraph=p(t.paragraph).replace("hr",t.hr).replace("heading",t.heading).replace("lheading",t.lheading).replace("tag",t._tag).getRegex(),t.blockquote=p(t.blockquote).replace("paragraph",t.paragraph).getRegex(),t.normal=f({},t),t.gfm=f({},t.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6})+([^\n]+?) *#* *(?:\n+|$)/}),t.gfm.paragraph=p(t.paragraph).replace("(?!","(?!"+t.gfm.fences.source.replace("\\1","\\2")+"|"+t.list.source.replace("\\1","\\3")+"|").getRegex(),t.tables=f({},t.gfm,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.pedantic=f({},t.normal,{html:p("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",t._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/}),n.rules=t,n.lex=function(e,t){return new n(t).lex(e)},n.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},n.prototype.token=function(e,n){var r,s,i,l,o,a,h,p,u,c,g,d,f;for(e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0
|
|
|
|
|
// Copyright (C) 2006 Google Inc.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
var IN_GLOBAL_SCOPE=true;window["PR_SHOULD_USE_CONTINUATION"]=true;var prettyPrintOne;var prettyPrint;(function(){var P=window;var i=["break,continue,do,else,for,if,return,while"];var u=[i,"auto,case,char,const,default,"+"double,enum,extern,float,goto,inline,int,long,register,short,signed,"+"sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,"+"new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,"+"concept,concept_map,const_cast,constexpr,decltype,delegate,"+"dynamic_cast,explicit,export,friend,generic,late_check,"+"mutable,namespace,nullptr,property,reinterpret_cast,static_assert,"+"static_cast,template,typeid,typename,using,virtual,where"];var y=[p,"abstract,assert,boolean,byte,extends,final,finally,implements,import,"+"instanceof,interface,null,native,package,strictfp,super,synchronized,"+"throws,transient"];var U=[y,"as,base,by,checked,decimal,delegate,descending,dynamic,event,"+"fixed,foreach,from,group,implicit,in,internal,into,is,let,"+"lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,"+"sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,"+"var,virtual,where"];var r="all,and,by,catch,class,else,extends,false,finally,"+"for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,"+"throw,true,try,unless,until,when,while,yes";var x=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,"+"Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,"+"goto,if,import,last,local,my,next,no,our,print,package,redo,require,"+"sub,undef,unless,until,use,wantarray,while,BEGIN,END";var K=[i,"and,as,assert,class,def,del,"+"elif,except,exec,finally,from,global,import,in,is,lambda,"+"nonlocal,not,or,pass,print,raise,try,with,yield,"+"False,True,None"];var g=[i,"alias,and,begin,case,class,"+"def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,"+"rescue,retry,self,super,then,true,undef,unless,until,when,yield,"+"BEGIN,END"];var z=[i,"as,assert,const,copy,drop,"+"enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,"+"pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"];var J=[i,"case,done,elif,esac,eval,fi,"+"function,in,local,set,then,until"];var C=[l,U,x,s,K,g,J];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;var E="str";var B="kwd";var j="com";var R="typ";var I="lit";var N="pun";var H="pln";var m="tag";var G="dec";var L="src";var S="atn";var n="atv";var Q="nocode";var O="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(ac){var ag=0;var V=false;var af=false;for(var Y=0,X=ac.length;Y<X;++Y){var ah=ac[Y];if(ah.ignoreCase){af=true}else{if(/[a-z]/i.test(ah.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){V=true;af=false;break}}}var ab={"b":8,"t":9,"n":10,"v":11,"f":12,"r":13};function ae(ak){var aj=ak.charCodeAt(0);if(aj!==92){return aj}var ai=ak.charAt(1);aj=ab[ai];if(aj){return aj}else{if("0"<=ai&&ai<="7"){return parseInt(ak.substring(1),8)}else{if(ai==="u"||ai==="x"){return parseInt(ak.substring(2),16)}else{return ak.charCodeAt(1)}}}}function W(ai){if(ai<32){return(ai<16?"\\x0":"\\x")+ai.toString(16)}var aj=String.fromCharCode(ai);return(aj==="\\"||aj==="-"||aj==="]"||aj==="^")?"\\"+aj:aj}function aa(ao){var at=ao.substring(1,ao.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}"+"|\\\\x[0-9A-Fa-f]{2}"+"|\\\\[0-3][0-7]{0,2}"+"|\\\\[0-7]{1,2}"+"|\\\\[\\s\\S]"+"|-"+"|[^-\\\\]","g"));var ai=[];var aq=at[0]==="^";var ap=["["];if(aq){ap.push("^")}for(var au=aq?1:0,am=at.length;au<am;++au){var ak=at[au];if(/\\[bdsw]/i.test(ak)){ap.push(ak)}else{var aj=ae(ak);var an;if(au+2<am&&"-"===at[au+1]){an=ae(at[au+2]);au+=2}else{an=aj}ai.push([aj,an]);if(!(an<65||aj>122)){if(!(an<65||aj>90)){ai.push([Math.max(65,aj)|32,Math.min(an,90)|32])}if(!(an<97||aj>122)){ai.push([Math.
|
|
|
|
|
// ┌────────────────────────────────────────────────────────────────────┐ \\
|
|
|
|
|
// │ Raphaël 2.1.3 - JavaScript Vector Library │ \\
|
|
|
|
|
// ├────────────────────────────────────────────────────────────────────┤ \\
|
|
|
|
|
// │ Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com) │ \\
|
|
|
|
|
// │ Copyright © 2008-2012 Sencha Labs (http://sencha.com) │ \\
|
|
|
|
|
// ├────────────────────────────────────────────────────────────────────┤ \\
|
|
|
|
|
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license.│ \\
|
|
|
|
|
// └────────────────────────────────────────────────────────────────────┘ \\
|
|
|
|
|
|
|
|
|
|
// Element= -> __Element=
|
|
|
|
|
!function(a){var b,c,d="0.4.2",e="hasOwnProperty",f=/[\.\/]/,g="*",h=function(){},i=function(a,b){return a-b},j={n:{}},k=function(a,d){a=String(a);var e,f=c,g=Array.prototype.slice.call(arguments,2),h=k.listeners(a),j=0,l=[],m={},n=[],o=b;b=a,c=0;for(var p=0,q=h.length;q>p;p++)"zIndex"in h[p]&&(l.push(h[p].zIndex),h[p].zIndex<0&&(m[h[p].zIndex]=h[p]));for(l.sort(i);l[j]<0;)if(e=m[l[j++]],n.push(e.apply(d,g)),c)return c=f,n;for(p=0;q>p;p++)if(e=h[p],"zIndex"in e)if(e.zIndex==l[j]){if(n.push(e.apply(d,g)),c)break;do if(j++,e=m[l[j]],e&&n.push(e.apply(d,g)),c)break;while(e)}else m[e.zIndex]=e;else if(n.push(e.apply(d,g)),c)break;return c=f,b=o,n.length?n:null};k._events=j,k.listeners=function(a){var b,c,d,e,h,i,k,l,m=a.split(f),n=j,o=[n],p=[];for(e=0,h=m.length;h>e;e++){for(l=[],i=0,k=o.length;k>i;i++)for(n=o[i].n,c=[n[m[e]],n[g]],d=2;d--;)b=c[d],b&&(l.push(b),p=p.concat(b.f||[]));o=l}return p},k.on=function(a,b){if(a=String(a),"function"!=typeof b)return function(){};for(var c=a.split(f),d=j,e=0,g=c.length;g>e;e++)d=d.n,d=d.hasOwnProperty(c[e])&&d[c[e]]||(d[c[e]]={n:{}});for(d.f=d.f||[],e=0,g=d.f.length;g>e;e++)if(d.f[e]==b)return h;return d.f.push(b),function(a){+a==+a&&(b.zIndex=+a)}},k.f=function(a){var b=[].slice.call(arguments,1);return function(){k.apply(null,[a,null].concat(b).concat([].slice.call(arguments,0)))}},k.stop=function(){c=1},k.nt=function(a){return a?new RegExp("(?:\\.|\\/|^)"+a+"(?:\\.|\\/|$)").test(b):b},k.nts=function(){return b.split(f)},k.off=k.unbind=function(a,b){if(!a)return void(k._events=j={n:{}});var c,d,h,i,l,m,n,o=a.split(f),p=[j];for(i=0,l=o.length;l>i;i++)for(m=0;m<p.length;m+=h.length-2){if(h=[m,1],c=p[m].n,o[i]!=g)c[o[i]]&&h.push(c[o[i]]);else for(d in c)c[e](d)&&h.push(c[d]);p.splice.apply(p,h)}for(i=0,l=p.length;l>i;i++)for(c=p[i];c.n;){if(b){if(c.f){for(m=0,n=c.f.length;n>m;m++)if(c.f[m]==b){c.f.splice(m,1);break}!c.f.length&&delete c.f}for(d in c.n)if(c.n[e](d)&&c.n[d].f){var q=c.n[d].f;for(m=0,n=q.length;n>m;m++)if(q[m]==b){q.splice(m,1);break}!q.length&&delete c.n[d].f}}else{delete c.f;for(d in c.n)c.n[e](d)&&c.n[d].f&&delete c.n[d].f}c=c.n}},k.once=function(a,b){var c=function(){return k.unbind(a,c),b.apply(this,arguments)};return k.on(a,c)},k.version=d,k.toString=function(){return"You are running Eve "+d},"undefined"!=typeof module&&module.exports?module.exports=k:"undefined"!=typeof define?define("eve",[],function(){return k}):a.eve=k}(window||this),function(a,b){"function"==typeof define&&define.amd?define(["eve"],function(c){return b(a,c)}):b(a,a.eve||"function"==typeof require&&require("eve"))}(this,function(a,b){function c(a){if(c.is(a,"function"))return u?a():b.on("raphael.DOMload",a);if(c.is(a,V))return c._engine.create[D](c,a.splice(0,3+c.is(a[0],T))).add(a);var d=Array.prototype.slice.call(arguments,0);if(c.is(d[d.length-1],"function")){var e=d.pop();return u?e.call(c._engine.create[D](c,d)):b.on("raphael.DOMload",function(){e.call(c._engine.create[D](c,d))})}return c._engine.create[D](c,arguments)}function d(a){if("function"==typeof a||Object(a)!==a)return a;var b=new a.constructor;for(var c in a)a[z](c)&&(b[c]=d(a[c]));return b}function e(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return a.push(a.splice(c,1)[0])}function f(a,b,c){function d(){var f=Array.prototype.slice.call(arguments,0),g=f.join("␀"),h=d.cache=d.cache||{},i=d.count=d.count||[];return h[z](g)?(e(i,g),c?c(h[g]):h[g]):(i.length>=1e3&&delete h[i.shift()],i.push(g),h[g]=a[D](b,f),c?c(h[g]):h[g])}return d}function g(){return this.hex}function h(a,b){for(var c=[],d=0,e=a.length;e-2*!b>d;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4==d?f[3]={x:+a[0],y:+a[1]}:e-2==d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4==d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push(["C",(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}function i(a,b,c,d,e){var f=-3*b+9*c-9*d+3*e,g=a*f+6*b-12*c+6*d;return a*g-3*b+3*c}function j(a,b,c,d,e,f,g,h,j)
|
|
|
|
|
for(var d,e,f,g,h=O(a.length,b.length),i=[],j=[],k=0;h>k;k++){if(f=a[k]||Ob(b[k]),g=b[k]||Ob(f),f[0]!=g[0]||"r"==f[0].toLowerCase()&&(f[2]!=g[2]||f[3]!=g[3])||"s"==f[0].toLowerCase()&&(f[3]!=g[3]||f[4]!=g[4]))return;for(i[k]=[],j[k]=[],d=0,e=O(f.length,g.length);e>d;d++)d in f&&(i[k][d]=f[d]),d in g&&(j[k][d]=g[d])}return{from:i,to:j}};c._getContainer=function(a,b,d,e){var f;return f=null!=e||c.is(a,"object")?a:A.doc.getElementById(a),null!=f?f.tagName?null==b?{container:f,width:f.style.pixelWidth||f.offsetWidth,height:f.style.pixelHeight||f.offsetHeight}:{container:f,width:b,height:d}:{container:1,x:a,y:b,width:d,height:e}:void 0},c.pathToRelative=Db,c._engine={},c.path2curve=Kb,c.matrix=function(a,b,c,d,e,f){return new o(a,b,c,d,e,f)},function(a){function b(a){return a[0]*a[0]+a[1]*a[1]}function d(a){var c=N.sqrt(b(a));a[0]&&(a[0]/=c),a[1]&&(a[1]/=c)}a.add=function(a,b,c,d,e,f){var g,h,i,j,k=[[],[],[]],l=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],m=[[a,c,e],[b,d,f],[0,0,1]];for(a&&a instanceof o&&(m=[[a.a,a.c,a.e],[a.b,a.d,a.f],[0,0,1]]),g=0;3>g;g++)for(h=0;3>h;h++){for(j=0,i=0;3>i;i++)j+=l[g][i]*m[i][h];k[g][h]=j}this.a=k[0][0],this.b=k[1][0],this.c=k[0][1],this.d=k[1][1],this.e=k[0][2],this.f=k[1][2]},a.invert=function(){var a=this,b=a.a*a.d-a.b*a.c;return new o(a.d/b,-a.b/b,-a.c/b,a.a/b,(a.c*a.f-a.d*a.e)/b,(a.b*a.e-a.a*a.f)/b)},a.clone=function(){return new o(this.a,this.b,this.c,this.d,this.e,this.f)},a.translate=function(a,b){this.add(1,0,0,1,a,b)},a.scale=function(a,b,c,d){null==b&&(b=a),(c||d)&&this.add(1,0,0,1,c,d),this.add(a,0,0,b,0,0),(c||d)&&this.add(1,0,0,1,-c,-d)},a.rotate=function(a,b,d){a=c.rad(a),b=b||0,d=d||0;var e=+N.cos(a).toFixed(9),f=+N.sin(a).toFixed(9);this.add(e,f,-f,e,b,d),this.add(1,0,0,1,-b,-d)},a.x=function(a,b){return a*this.a+b*this.c+this.e},a.y=function(a,b){return a*this.b+b*this.d+this.f},a.get=function(a){return+this[I.fromCharCode(97+a)].toFixed(4)},a.toString=function(){return c.svg?"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")":[this.get(0),this.get(2),this.get(1),this.get(3),0,0].join()},a.toFilter=function(){return"progid:DXImageTransform.Microsoft.Matrix(M11="+this.get(0)+", M12="+this.get(2)+", M21="+this.get(1)+", M22="+this.get(3)+", Dx="+this.get(4)+", Dy="+this.get(5)+", sizingmethod='auto expand')"},a.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},a.split=function(){var a={};a.dx=this.e,a.dy=this.f;var e=[[this.a,this.c],[this.b,this.d]];a.scalex=N.sqrt(b(e[0])),d(e[0]),a.shear=e[0][0]*e[1][0]+e[0][1]*e[1][1],e[1]=[e[1][0]-e[0][0]*a.shear,e[1][1]-e[0][1]*a.shear],a.scaley=N.sqrt(b(e[1])),d(e[1]),a.shear/=a.scaley;var f=-e[0][1],g=e[1][1];return 0>g?(a.rotate=c.deg(N.acos(g)),0>f&&(a.rotate=360-a.rotate)):a.rotate=c.deg(N.asin(f)),a.isSimple=!(+a.shear.toFixed(9)||a.scalex.toFixed(9)!=a.scaley.toFixed(9)&&a.rotate),a.isSuperSimple=!+a.shear.toFixed(9)&&a.scalex.toFixed(9)==a.scaley.toFixed(9)&&!a.rotate,a.noRotation=!+a.shear.toFixed(9)&&!a.rotate,a},a.toTransformString=function(a){var b=a||this[J]();return b.isSimple?(b.scalex=+b.scalex.toFixed(4),b.scaley=+b.scaley.toFixed(4),b.rotate=+b.rotate.toFixed(4),(b.dx||b.dy?"t"+[b.dx,b.dy]:G)+(1!=b.scalex||1!=b.scaley?"s"+[b.scalex,b.scaley,0,0]:G)+(b.rotate?"r"+[b.rotate,0,0]:G)):"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]}}(o.prototype);var Qb=navigator.userAgent.match(/Version\/(.*?)\s/)||navigator.userAgent.match(/Chrome\/(\d+)/);v.safari="Apple Computer, Inc."==navigator.vendor&&(Qb&&Qb[1]<4||"iP"==navigator.platform.slice(0,2))||"Google Inc."==navigator.vendor&&Qb&&Qb[1]<8?function(){var a=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});setTimeout(function(){a.remove()})}:mb;for(var Rb=function(){this.returnValue=!1},Sb=function(){return this.originalEvent.preventDefault()},Tb=function(){this.cancelBubble=!0},Ub=function(){return this.originalEvent.stopPropagation()},Vb=function(a){var b=A.doc.documentElement.scrollTop||A.doc.body.scrollTop,c=A.doc.documentElement.scrollLeft||A.doc.body.scro
|
|
|
|
|
case"opacity":k.gradient&&!k[a]("stroke-opacity")&&q(i,{"stroke-opacity":p>1?p/100:p});case"fill-opacity":if(k.gradient){I=c._g.doc.getElementById(i.getAttribute("fill").replace(/^url\(#|\)$/g,l)),I&&(J=I.getElementsByTagName("stop"),q(J[J.length-1],{"stop-opacity":p}));break}default:"font-size"==o&&(p=e(p,10)+"px");var K=o.replace(/(\-.)/g,function(a){return a.substring(1).toUpperCase()});i.style[K]=p,d._.dirty=1,i.setAttribute(o,p)}}y(d,f),i.style.visibility=m},x=1.2,y=function(d,f){if("text"==d.type&&(f[a]("text")||f[a]("font")||f[a]("font-size")||f[a]("x")||f[a]("y"))){var g=d.attrs,h=d.node,i=h.firstChild?e(c._g.doc.defaultView.getComputedStyle(h.firstChild,l).getPropertyValue("font-size"),10):10;if(f[a]("text")){for(g.text=f.text;h.firstChild;)h.removeChild(h.firstChild);for(var j,k=b(f.text).split("\n"),m=[],n=0,o=k.length;o>n;n++)j=q("tspan"),n&&q(j,{dy:i*x,x:g.x}),j.appendChild(c._g.doc.createTextNode(k[n])),h.appendChild(j),m[n]=j}else for(m=h.getElementsByTagName("tspan"),n=0,o=m.length;o>n;n++)n?q(m[n],{dy:i*x,x:g.x}):q(m[0],{dy:0});q(h,{x:g.x,y:g.y}),d._.dirty=1;var p=d._getBBox(),r=g.y-(p.y+p.height/2);r&&c.is(r,"finite")&&q(m[0],{dy:r})}},z=function(a){return a.parentNode&&"a"===a.parentNode.tagName.toLowerCase()?a.parentNode:a};__Element=function(a,b){this[0]=this.node=a,a.raphael=!0,this.id=c._oid++,a.raphaelid=this.id,this.matrix=c.matrix(),this.realPath=null,this.paper=b,this.attrs=this.attrs||{},this._={transform:[],sx:1,sy:1,deg:0,dx:0,dy:0,dirty:1},!b.bottom&&(b.bottom=this),this.prev=b.top,b.top&&(b.top.next=this),b.top=this,this.next=null},$b=c.el,Element.prototype=$b,$b.constructor=Element,c._engine.path=function(a,b){var c=q("path");b.canvas&&b.canvas.appendChild(c);var d=new __Element(c,b);return d.type="path",w(d,{fill:"none",stroke:"#000",path:a}),d},$b.rotate=function(a,c,e){if(this.removed)return this;if(a=b(a).split(j),a.length-1&&(c=d(a[1]),e=d(a[2])),a=d(a[0]),null==e&&(c=e),null==c||null==e){var f=this.getBBox(1);c=f.x+f.width/2,e=f.y+f.height/2}return this.transform(this._.transform.concat([["r",a,c,e]])),this},$b.scale=function(a,c,e,f){if(this.removed)return this;if(a=b(a).split(j),a.length-1&&(c=d(a[1]),e=d(a[2]),f=d(a[3])),a=d(a[0]),null==c&&(c=a),null==f&&(e=f),null==e||null==f)var g=this.getBBox(1);return e=null==e?g.x+g.width/2:e,f=null==f?g.y+g.height/2:f,this.transform(this._.transform.concat([["s",a,c,e,f]])),this},$b.translate=function(a,c){return this.removed?this:(a=b(a).split(j),a.length-1&&(c=d(a[1])),a=d(a[0])||0,c=+c||0,this.transform(this._.transform.concat([["t",a,c]])),this)},$b.transform=function(b){var d=this._;if(null==b)return d.transform;if(c._extractTransform(this,b),this.clip&&q(this.clip,{transform:this.matrix.invert()}),this.pattern&&s(this),this.node&&q(this.node,{transform:this.matrix}),1!=d.sx||1!=d.sy){var e=this.attrs[a]("stroke-width")?this.attrs["stroke-width"]:1;this.attr({"stroke-width":e})}return this},$b.hide=function(){return!this.removed&&this.paper.safari(this.node.style.display="none"),this},$b.show=function(){return!this.removed&&this.paper.safari(this.node.style.display=""),this},$b.remove=function(){var a=z(this.node);if(!this.removed&&a.parentNode){var b=this.paper;b.__set__&&b.__set__.exclude(this),k.unbind("raphael.*.*."+this.id),this.gradient&&b.defs.removeChild(this.gradient),c._tear(this,b),a.parentNode.removeChild(a),this.removeData();for(var d in this)this[d]="function"==typeof this[d]?c._removedFactory(d):null;this.removed=!0}},$b._getBBox=function(){if("none"==this.node.style.display){this.show();var a=!0}var b,c=!1;this.paper.canvas.parentElement?b=this.paper.canvas.parentElement.style:this.paper.canvas.parentNode&&(b=this.paper.canvas.parentNode.style),b&&"none"==b.display&&(c=!0,b.display="");var d={};try{d=this.node.getBBox()}catch(e){d={x:this.node.clientLeft,y:this.node.clientTop,width:this.node.clientWidth,height:this.node.clientHeight}}finally{d=d||{},c&&(b.display="none")}return a&&this.hide(),d},$b.attr=function(b,d){if(this.removed)return this;if(null==b){var e={};for(var f in this.attrs)this.attrs[a](f)&&(e[f]=this.a
|
|
|
|
|
|
|
|
|
|
/** js sequence diagrams 1.0.4
|
|
|
|
|
* http://bramp.github.io/js-sequence-diagrams/
|
|
|
|
|
* (c) 2012-2013 Andrew Brampton (bramp.net)
|
|
|
|
|
* @license Simplified BSD license.
|
|
|
|
|
*/
|
|
|
|
|
!function(){"use strict";function Diagram(){this.title=void 0,this.actors=[],this.signals=[]}function ParseError(message,hash){_.extend(this,hash),this.name="ParseError",this.message=message||""}Diagram.prototype.getActor=function(alias){var s=/^(.+) as (\S+)$/i.exec(alias.trim());s?(name=s[1].trim(),alias=s[2].trim()):name=alias.trim(),name=name.replace(/\\n/gm,"\n");var i,actors=this.actors;for(i in actors)if(actors[i].alias==alias)return actors[i];return i=actors.push(new Diagram.Actor(alias,name,actors.length)),actors[i-1]},Diagram.prototype.setTitle=function(title){this.title=title},Diagram.prototype.addSignal=function(signal){this.signals.push(signal)},Diagram.Actor=function(alias,name,index){this.alias=alias,this.name=name,this.index=index},Diagram.Signal=function(actorA,signaltype,actorB,message){this.type="Signal",this.actorA=actorA,this.actorB=actorB,this.linetype=3&signaltype,this.arrowtype=3&signaltype>>2,this.message=message},Diagram.Signal.prototype.isSelf=function(){return this.actorA.index==this.actorB.index},Diagram.Note=function(actor,placement,message){if(this.type="Note",this.actor=actor,this.placement=placement,this.message=message,this.hasManyActors()&&actor[0]==actor[1])throw new Error("Note should be over two different actors")},Diagram.Note.prototype.hasManyActors=function(){return _.isArray(this.actor)},Diagram.LINETYPE={SOLID:0,DOTTED:1},Diagram.ARROWTYPE={FILLED:0,OPEN:1},Diagram.PLACEMENT={LEFTOF:0,RIGHTOF:1,OVER:2};var grammar=function(){function Parser(){this.yy={}}var parser={trace:function(){},yy:{},symbols_:{error:2,start:3,document:4,EOF:5,line:6,statement:7,NL:8,participant:9,actor:10,signal:11,note_statement:12,title:13,message:14,note:15,placement:16,over:17,actor_pair:18,",":19,left_of:20,right_of:21,signaltype:22,ACTOR:23,linetype:24,arrowtype:25,LINE:26,DOTLINE:27,ARROW:28,OPENARROW:29,MESSAGE:30,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:"NL",9:"participant",13:"title",15:"note",17:"over",19:",",20:"left_of",21:"right_of",23:"ACTOR",26:"LINE",27:"DOTLINE",28:"ARROW",29:"OPENARROW",30:"MESSAGE"},productions_:[0,[3,2],[4,0],[4,2],[6,1],[6,1],[7,2],[7,1],[7,1],[7,2],[12,4],[12,4],[18,1],[18,3],[16,1],[16,1],[11,4],[10,1],[22,2],[22,1],[24,1],[24,1],[25,1],[25,1],[14,1]],performAction:function(yytext,yyleng,yylineno,yy,yystate,$$){var $0=$$.length-1;switch(yystate){case 1:return yy;case 4:break;case 6:$$[$0];break;case 7:yy.addSignal($$[$0]);break;case 8:yy.addSignal($$[$0]);break;case 9:yy.setTitle($$[$0]);break;case 10:this.$=new Diagram.Note($$[$0-1],$$[$0-2],$$[$0]);break;case 11:this.$=new Diagram.Note($$[$0-1],Diagram.PLACEMENT.OVER,$$[$0]);break;case 12:this.$=$$[$0];break;case 13:this.$=[$$[$0-2],$$[$0]];break;case 14:this.$=Diagram.PLACEMENT.LEFTOF;break;case 15:this.$=Diagram.PLACEMENT.RIGHTOF;break;case 16:this.$=new Diagram.Signal($$[$0-3],$$[$0-2],$$[$0-1],$$[$0]);break;case 17:this.$=yy.getActor($$[$0]);break;case 18:this.$=$$[$0-1]|$$[$0]<<2;break;case 19:this.$=$$[$0];break;case 20:this.$=Diagram.LINETYPE.SOLID;break;case 21:this.$=Diagram.LINETYPE.DOTTED;break;case 22:this.$=Diagram.ARROWTYPE.FILLED;break;case 23:this.$=Diagram.ARROWTYPE.OPEN;break;case 24:this.$=$$[$0].substring(1).trim().replace(/\\n/gm,"\n")}},table:[{3:1,4:2,5:[2,2],8:[2,2],9:[2,2],13:[2,2],15:[2,2],23:[2,2]},{1:[3]},{5:[1,3],6:4,7:5,8:[1,6],9:[1,7],10:11,11:8,12:9,13:[1,10],15:[1,12],23:[1,13]},{1:[2,1]},{5:[2,3],8:[2,3],9:[2,3],13:[2,3],15:[2,3],23:[2,3]},{5:[2,4],8:[2,4],9:[2,4],13:[2,4],15:[2,4],23:[2,4]},{5:[2,5],8:[2,5],9:[2,5],13:[2,5],15:[2,5],23:[2,5]},{10:14,23:[1,13]},{5:[2,7],8:[2,7],9:[2,7],13:[2,7],15:[2,7],23:[2,7]},{5:[2,8],8:[2,8],9:[2,8],13:[2,8],15:[2,8],23:[2,8]},{14:15,30:[1,16]},{22:17,24:18,26:[1,19],27:[1,20]},{16:21,17:[1,22],20:[1,23],21:[1,24]},{5:[2,17],8:[2,17],9:[2,17],13:[2,17],15:[2,17],19:[2,17],23:[2,17],26:[2,17],27:[2,17],30:[2,17]},{5:[2,6],8:[2,6],9:[2,6],13:[2,6],15:[2,6],23:[2,6]},{5:[2,9],8:[2,9],9:[2,9],13:[2,9],15:[2,9],23:[2,9]},{5:[2,24],8:[2,24],9:[2,24],13:[2,24],15:[2,24],23:[2,24]},{10:25,23:[1,13]},{23:[2,19],25:26,28:[1,27],29:[1,28]},{23
|
|
|
|
|
function AssertException(message){this.message=message}function assert(exp,message){if(!exp)throw new AssertException(message)}function getCenterX(box){return box.x+box.width/2}function getCenterY(box){return box.y+box.height/2}var DIAGRAM_MARGIN=10,ACTOR_MARGIN=10,ACTOR_PADDING=10,SIGNAL_MARGIN=5,SIGNAL_PADDING=5,NOTE_MARGIN=10,NOTE_PADDING=5,NOTE_OVERLAP=15,TITLE_MARGIN=0,TITLE_PADDING=5,SELF_SIGNAL_WIDTH=20,PLACEMENT=Diagram.PLACEMENT,LINETYPE=Diagram.LINETYPE,ARROWTYPE=Diagram.ARROWTYPE,LINE={stroke:"#000","stroke-width":2},RECT={fill:"#fff"};AssertException.prototype.toString=function(){return"AssertException: "+this.message},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Raphael.fn.line=function(x1,y1,x2,y2){return assert(_.all([x1,x2,y1,y2],_.isFinite),"x1,x2,y1,y2 must be numeric"),this.path("M{0},{1} L{2},{3}",x1,y1,x2,y2)},Raphael.fn.wobble=function(x1,y1,x2,y2){assert(_.all([x1,x2,y1,y2],_.isFinite),"x1,x2,y1,y2 must be numeric");var wobble=Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/25,r1=Math.random(),r2=Math.random(),xfactor=Math.random()>.5?wobble:-wobble,yfactor=Math.random()>.5?wobble:-wobble,p1={x:(x2-x1)*r1+x1+xfactor,y:(y2-y1)*r1+y1+yfactor},p2={x:(x2-x1)*r2+x1-xfactor,y:(y2-y1)*r2+y1-yfactor};return"C"+p1.x+","+p1.y+" "+p2.x+","+p2.y+" "+x2+","+y2},Raphael.fn.text_bbox=function(text,font){var p;font._obj?p=this.print_center(0,0,text,font._obj,font["font-size"]):(p=this.text(0,0,text),p.attr(font));var bb=p.getBBox();return p.remove(),bb},Raphael.fn.handRect=function(x,y,w,h){return assert(_.all([x,y,w,h],_.isFinite),"x, y, w, h must be numeric"),this.path("M"+x+","+y+this.wobble(x,y,x+w,y)+this.wobble(x+w,y,x+w,y+h)+this.wobble(x+w,y+h,x,y+h)+this.wobble(x,y+h,x,y)).attr(RECT)},Raphael.fn.handLine=function(x1,y1,x2,y2){return assert(_.all([x1,x2,y1,y2],_.isFinite),"x1,x2,y1,y2 must be numeric"),this.path("M"+x1+","+y1+this.wobble(x1,y1,x2,y2))},Raphael.fn.print_center=function(x,y,string,font,size,letter_spacing){var path=this.print(x,y,string,font,size,"baseline",letter_spacing),bb=path.getBBox(),dx=x-bb.x-bb.width/2,dy=y-bb.y-bb.height/2,m=new Raphael.matrix;return m.translate(dx,dy),path.attr("path",Raphael.mapPath(path.attr("path"),m))};var BaseTheme=function(diagram){this.init(diagram)};_.extend(BaseTheme.prototype,{init:function(diagram){this.diagram=diagram,this._paper=void 0,this._font=void 0,this._title=void 0,this._actors_height=0,this._signals_height=0;var a=this.arrow_types={};a[ARROWTYPE.FILLED]="block",a[ARROWTYPE.OPEN]="open";var l=this.line_types={};l[LINETYPE.SOLID]="",l[LINETYPE.DOTTED]="-"},init_paper:function(container){this._paper=new Raphael(container,320,200)},init_font:function(){},draw_line:function(x1,y1,x2,y2){return this._paper.line(x1,y1,x2,y2)},draw_rect:function(x,y,w,h){return this._paper.rect(x,y,w,h)},draw:function(container){var diagram=this.diagram;this.init_paper(container),this.init_font(),this.layout();var title_height=this._title?this._title.height:0;this._paper.setStart(),this._paper.setSize(diagram.width,diagram.height);var y=DIAGRAM_MARGIN+title_height;this.draw_title(),this.draw_actors(y),this.draw_signals(y+this._actors_height),this._paper.setFinish()},layout:function(){function actor_ensure_distance(a,b,d){assert(b>a,"a must be less than or equal to b"),0>a?(b=actors[b],b.x=Math.max(d-b.width/2,b.x)):b>=actors.length?(a=actors[a],a.padding_right=Math.max(d,a.padding_right)):(a=actors[a],a.distances[b]=Math.max(d,a.distances[b]?a.distances[b]:0))}var diagram=this.diagram,paper=this._paper,font=this._font,actors=diagram.actors,signals=diagram.signals;if(diagram.width=0,diagram.height=0,diagram.title){var title=this._title={},bb=paper.text_bbox(diagram.title,font);title.text_bb=bb,title.message=diagram.title,title.width=bb.width+2*(TITLE_PADDING+TITLE_MARGIN),title.height=bb.height+2*(TITLE_PADDING+TITLE_MARGIN),title.x=DIAGRAM_MARGIN,title.y=DIAGRAM_MARGIN,diagram.width+=title.width,diagram.height+=title.height}_.each(actors,function(a){var bb=paper.text_bbox(a.name,font);a.text_bb=bb,a.x=0,a.y=0,a.width=bb.w
|
|
|
|
|
// flowchart, v1.3.4
|
|
|
|
|
// Copyright (c)2014 Adriano Raiano (adrai).
|
|
|
|
|
// Distributed under MIT license
|
|
|
|
|
// http://adrai.github.io/flowchart.js
|
|
|
|
|
!function(){function a(b,c){if(!b||"function"==typeof b)return c;var d={};for(var e in c)d[e]=c[e];for(e in b)b[e]&&(d[e]="object"==typeof d[e]?a(d[e],b[e]):b[e]);return d}function b(a,b){if("function"==typeof Object.create)a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});else{a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}}function c(a,b,c){var d,e,f="M{0},{1}";for(d=2,e=2*c.length+2;e>d;d+=2)f+=" L{"+d+"},{"+(d+1)+"}";var g=[b.x,b.y];for(d=0,e=c.length;e>d;d++)g.push(c[d].x),g.push(c[d].y);var h=a.paper.path(f,g);h.attr("stroke",a.options["element-color"]),h.attr("stroke-width",a.options["line-width"]);var i=a.options.font,j=a.options["font-family"],k=a.options["font-weight"];return i&&h.attr({font:i}),j&&h.attr({"font-family":j}),k&&h.attr({"font-weight":k}),h}function d(a,b,c,d){var e,f;"[object Array]"!==Object.prototype.toString.call(c)&&(c=[c]);var g="M{0},{1}";for(e=2,f=2*c.length+2;f>e;e+=2)g+=" L{"+e+"},{"+(e+1)+"}";var h=[b.x,b.y];for(e=0,f=c.length;f>e;e++)h.push(c[e].x),h.push(c[e].y);var i=a.paper.path(g,h);i.attr({stroke:a.options["line-color"],"stroke-width":a.options["line-width"],"arrow-end":a.options["arrow-end"]});var j=a.options.font,k=a.options["font-family"],l=a.options["font-weight"];if(j&&i.attr({font:j}),k&&i.attr({"font-family":k}),l&&i.attr({"font-weight":l}),d){var m=!1,n=a.paper.text(0,0,d),o=!1,p=c[0];b.y===p.y&&(o=!0);var q=0,r=0;m?(q=b.x>p.x?b.x-(b.x-p.x)/2:p.x-(p.x-b.x)/2,r=b.y>p.y?b.y-(b.y-p.y)/2:p.y-(p.y-b.y)/2,o?(q-=n.getBBox().width/2,r-=a.options["text-margin"]):(q+=a.options["text-margin"],r-=n.getBBox().height/2)):(q=b.x,r=b.y,o?(q+=a.options["text-margin"]/2,r-=a.options["text-margin"]):(q+=a.options["text-margin"]/2,r+=a.options["text-margin"])),n.attr({"text-anchor":"start","font-size":a.options["font-size"],fill:a.options["font-color"],x:q,y:r}),j&&n.attr({font:j}),k&&n.attr({"font-family":k}),l&&n.attr({"font-weight":l})}return i}function e(a,b,c,d,e,f,g,h){var i,j,k,l,m,n={x:null,y:null,onLine1:!1,onLine2:!1};return i=(h-f)*(c-a)-(g-e)*(d-b),0===i?n:(j=b-f,k=a-e,l=(g-e)*j-(h-f)*k,m=(c-a)*j-(d-b)*k,j=l/i,k=m/i,n.x=a+j*(c-a),n.y=b+j*(d-b),j>0&&1>j&&(n.onLine1=!0),k>0&&1>k&&(n.onLine2=!0),n)}function f(a,b){b=b||{},this.paper=new Raphael(a),this.options=r.defaults(b,q),this.symbols=[],this.lines=[],this.start=null}function g(a,b,c){this.chart=a,this.group=this.chart.paper.set(),this.symbol=c,this.connectedTo=[],this.symbolType=b.symbolType,this.flowstate=b.flowstate||"future",this.next_direction=b.next&&b.direction_next?b.direction_next:void 0,this.text=this.chart.paper.text(0,0,b.text),b.key&&(this.text.node.id=b.key+"t"),this.text.node.setAttribute("class",this.getAttr("class")+"t"),this.text.attr({"text-anchor":"start",x:this.getAttr("text-margin"),fill:this.getAttr("font-color"),"font-size":this.getAttr("font-size")});var d=this.getAttr("font"),e=this.getAttr("font-family"),f=this.getAttr("font-weight");d&&this.text.attr({font:d}),e&&this.text.attr({"font-family":e}),f&&this.text.attr({"font-weight":f}),b.link&&this.text.attr("href",b.link),b.target&&this.text.attr("target",b.target);var g=this.getAttr("maxWidth");if(g){for(var h=b.text.split(" "),i="",j=0,k=h.length;k>j;j++){var l=h[j];this.text.attr("text",i+" "+l),i+=this.text.getBBox().width>g?"\n"+l:" "+l}this.text.attr("text",i.substring(1))}if(this.group.push(this.text),c){var m=this.getAttr("text-margin");c.attr({fill:this.getAttr("fill"),stroke:this.getAttr("element-color"),"stroke-width":this.getAttr("line-width"),width:this.text.getBBox().width+2*m,height:this.text.getBBox().height+2*m}),c.node.setAttribute("class",this.getAttr("class")),b.link&&c.attr("href",b.link),b.target&&c.attr("target",b.target),b.key&&(c.node.id=b.key),this.group.push(c),c.insertBefore(this.text),this.text.attr({y:c.getBBox().height/2}),this.initialize()}}function h(a,b){var c=a.paper.rect(0,0,0,0,20);b=b||{},b.text=b.text||"Start",g.call(this,a,b,c)}function i(a,b){var c=a.paper.rect(0,0,0,0,20);b=b||{},b.text=b.text||"E
|
|
|
|
|
/*! jQuery.flowchart.js v1.1.0 | jquery.flowchart.min.js | jQuery plugin for flowchart.js. | MIT License | By: Pandao | https://github.com/pandao/jquery.flowchart.js | 2015-03-09 */
|
|
|
|
|
(function(factory){if(typeof require==="function"&&typeof exports==="object"&&typeof module==="object"){module.exports=factory}else{if(typeof define==="function"){factory(jQuery,flowchart)}else{factory($,flowchart)}}}(function(jQuery,flowchart){(function($){$.fn.flowChart=function(options){options=options||{};var defaults={"x":0,"y":0,"line-width":2,"line-length":50,"text-margin":10,"font-size":14,"font-color":"black","line-color":"black","element-color":"black","fill":"white","yes-text":"yes","no-text":"no","arrow-end":"block","symbols":{"start":{"font-color":"black","element-color":"black","fill":"white"},"end":{"class":"end-element"}},"flowstate":{"past":{"fill":"#CCCCCC","font-size":12},"current":{"fill":"black","font-color":"white","font-weight":"bold"},"future":{"fill":"white"},"request":{"fill":"blue"},"invalid":{"fill":"#444444"},"approved":{"fill":"#58C4A3","font-size":12,"yes-text":"APPROVED","no-text":"n/a"},"rejected":{"fill":"#C45879","font-size":12,"yes-text":"n/a","no-text":"REJECTED"}}};return this.each(function(){var $this=$(this);var diagram=flowchart.parse($this.text());var settings=$.extend(true,defaults,options);$this.html("");diagram.drawSVG(this,settings)})}})(jQuery)}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Editor.md
|
|
|
|
|
*
|
|
|
|
|
* @file editormd.js
|
|
|
|
|
* @version v1.5.0
|
|
|
|
|
* @description Open source online markdown editor.
|
|
|
|
|
* @license MIT License
|
|
|
|
|
* @author Pandao
|
|
|
|
|
* {@link https://github.com/pandao/editor.md}
|
|
|
|
|
* @updateTime 2015-06-09
|
|
|
|
|
*/
|
|
|
|
|
function initEditormdPasteUpload(e,t,i){e.cm.getInputField().addEventListener("paste",function(i){_whenPasterDoUpload(i,t,function(t){t.id&&e.cm.replaceSelection("![](/api/attachments/"+t.id+")")})})}!function(e){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd||define(["../../../../editormd/examples/js/jquery.min"],e):window.editormd=e()}(function(){"use strict";var e="undefined"!=typeof jQuery?jQuery:Zepto;if(void 0!==e){var t,i,o,r=function(e,t){return new r.fn.init(e,t)};r.title=r.$name="Editor.md",r.version="1.5.0",r.homePage="https://pandao.github.io/editor.md/",r.classPrefix="editormd-",r.toolbarModes={full:["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"],simple:["undo","redo","|","bold","del","italic","quote","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","watch","preview","fullscreen","|","help","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},r.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",delay:500,autoLoadModules:!0,watch:!0,placeholder:"Enjoy Markdown! coding now...",gotoLine:!0,codeFold:!1,autoHeight:!1,autoFocus:!0,autoCloseTags:!0,searchReplace:!0,syncScrolling:!0,readOnly:!1,tabSize:4,indentUnit:4,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,showTrailingSpace:!0,matchBrackets:!0,indentWithTabs:!0,styleSelectedText:!0,matchWordHighlight:!0,styleActiveLine:!0,dialogLockScreen:!0,dialogShowMask:!0,dialogDraggable:!0,dialogMaskBgColor:"#fff",dialogMaskOpacity:.1,fontSize:"13px",saveHTMLToTextarea:!1,disabledKeyMaps:[],onload:function(){},onresize:function(){},onchange:function(){},onwatch:null,onunwatch:null,onpreviewing:function(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:"style,iframe|on*",pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return r.toolbarHandlers.ucwords},lowercase:function(){return r.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'<a href="javascript:;" title="Lowercase" unselectable="on"><i class="fa" name="lowercase" style="font-size:24px;margin-top: -10px;">a</i></a>',ucwords:'<a href="javascript:;" title="ucwords" unselectable="on"><i class="fa" name="ucwords" style="font-size:20px;margin-top: -3px;">Aa</i></a>'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:r.classPrefix+"bold",h2:r.classPrefix+"bold",h3:r.classPrefix+"bold",h4:r.classPrefix+"bold",h5:r.classPrefix+"bold",h6:r.classPrefix+"bold","list-ul":"fa-list-ul","list-ol":"fa-list-ol",hr:"fa-minus",link:"fa-link","reference-link":"fa-anchor",image:"fa-picture-o",code:"fa-code","preformatted-text":"fa-file-code-o","code-block":"fa-file-code-o",table:"fa-table",datetime:"fa-clock-o",emoji:"fa-smile-o","html-entities":"fa-copyright",pagebreak:"fa-newspaper-o","goto-line":"fa-terminal",watch:"fa-eye-slash",unwatch:"fa-eye",preview:"fa-desktop",search:"fa-search",fullscreen:"fa-arrows-alt",clear:"fa-eraser",help:"fa-question-circle",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线Markdown编辑器<br/>Open source onl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
|
|
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
|
|
|
|
|
|
|
|
// This is CodeMirror (http://codemirror.net), a code editor
|
|
|
|
|
// implemented in JavaScript on top of the browser's DOM.
|
|
|
|
|
//
|
|
|
|
|
// You can find some technical background for some of the code below
|
|
|
|
|
// at http://marijnhaverbeke.nl/blog/#cm-internals .
|
|
|
|
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.CodeMirror=t()}(this,function(){"use strict";var e=navigator.userAgent,t=navigator.platform,r=/gecko\/\d/i.test(e),n=/MSIE \d/.test(e),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),o=/Edge\/(\d+)/.exec(e),l=n||i||o,s=l&&(n?document.documentMode||6:+(o||i)[1]),a=!o&&/WebKit\//.test(e),u=a&&/Qt\/\d+\.\d+/.test(e),c=!o&&/Chrome\//.test(e),h=/Opera\//.test(e),f=/Apple Computer/.test(navigator.vendor),d=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),p=/PhantomJS/.test(e),g=!o&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e),v=/Android/.test(e),m=g||v||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=g||/Mac/.test(t),b=/\bCrOS\b/.test(e),w=/win/i.test(t),x=h&&e.match(/Version\/(\d*\.\d*)/);x&&(x=Number(x[1])),x&&x>=15&&(h=!1,a=!0);var C=y&&(u||h&&(null==x||x<12.11)),S=r||l&&s>=9;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var T,k=function(e,t){var r=e.className,n=L(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}};function M(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function N(e,t){return M(e).appendChild(t)}function O(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function W(e,t,r,n){var i=O(e,t,r,n);return i.setAttribute("role","presentation"),i}function A(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do{if(11==t.nodeType&&(t=t.host),t==e)return!0}while(t=t.parentNode)}function D(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function H(e,t){var r=e.className;L(t).test(r)||(e.className+=(r?" ":"")+t)}function P(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!L(r[n]).test(t)&&(t+=" "+r[n]);return t}T=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(e){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var E=function(e){e.select()};function F(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function I(e,t,r){for(var n in t||(t={}),e)!e.hasOwnProperty(n)||!1===r&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function z(e,t,r,n,i){null==t&&-1==(t=e.search(/[^\s\u00a0]/))&&(t=e.length);for(var o=n||0,l=i||0;;){var s=e.indexOf("\t",o);if(s<0||s>=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}}g?E=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:l&&(E=function(e){try{e.select()}catch(e){}});var R=function(){this.id=null};function B(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}R.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var G=30,U={toString:function(){return"CodeMirror.Pass"}},V={scroll:!1},K={origin:"*mouse"},j={origin:"+move"};function X(e,t,r){for(var n=0,i=0;;){var o=e.indexOf("\t",n);-1==o&&(o=e.length);var l=o-n;if(o==e.length||i+l>=t)return n+Math.min(l,t-i);if(i+=o-n,n=o+1,(i+=r-i%r)>=t)return n}}var Y=[""];function _(e){for(;Y.length<=e;)Y.push($(Y)+" ");return Y[e]}function $(e){return e[e.length-1]}function q(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function Z(){}function Q(e,t){var r;return Object.create?r=Object.create(e):(Z.prototype=e,r=new Z),t&&I(t,r),r}var J=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function ee(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||J.test(e))}function te(e,t){return t?!!(t.source.indexOf("\\w")>-1&&ee(e))||t.test(e):ee(e)}function re(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ne=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(function(){function diff_match_patch(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=0.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=0.5;this.Patch_Margin=4;this.Match_MaxBits=32}
|
|
|
|
|
diff_match_patch.prototype.diff_main=function(a,b,c,d){"undefined"==typeof d&&(d=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[[0,a]]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b);c=a.substring(0,f);a=a.substring(f);b=b.substring(f);var f=this.diff_commonSuffix(a,b),g=a.substring(a.length-f);a=a.substring(0,a.length-f);b=b.substring(0,b.length-f);a=this.diff_compute_(a,
|
|
|
|
|
b,e,d);c&&a.unshift([0,c]);g&&a.push([0,g]);this.diff_cleanupMerge(a);return a};
|
|
|
|
|
diff_match_patch.prototype.diff_compute_=function(a,b,c,d){if(!a)return[[1,b]];if(!b)return[[-1,a]];var e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=e.indexOf(f);return-1!=g?(c=[[1,e.substring(0,g)],[0,f],[1,e.substring(g+f.length)]],a.length>b.length&&(c[0][0]=c[2][0]=-1),c):1==f.length?[[-1,a],[1,b]]:(e=this.diff_halfMatch_(a,b))?(f=e[0],a=e[1],g=e[2],b=e[3],e=e[4],f=this.diff_main(f,g,c,d),c=this.diff_main(a,b,c,d),f.concat([[0,e]],c)):c&&100<a.length&&100<b.length?this.diff_lineMode_(a,b,
|
|
|
|
|
d):this.diff_bisect_(a,b,d)};
|
|
|
|
|
diff_match_patch.prototype.diff_lineMode_=function(a,b,c){var d=this.diff_linesToChars_(a,b);a=d.chars1;b=d.chars2;d=d.lineArray;a=this.diff_main(a,b,!1,c);this.diff_charsToLines_(a,d);this.diff_cleanupSemantic(a);a.push([0,""]);for(var e=d=b=0,f="",g="";b<a.length;){switch(a[b][0]){case 1:e++;g+=a[b][1];break;case -1:d++;f+=a[b][1];break;case 0:if(1<=d&&1<=e){a.splice(b-d-e,d+e);b=b-d-e;d=this.diff_main(f,g,!1,c);for(e=d.length-1;0<=e;e--)a.splice(b,0,d[e]);b+=d.length}d=e=0;g=f=""}b++}a.pop();return a};
|
|
|
|
|
diff_match_patch.prototype.diff_bisect_=function(a,b,c){for(var d=a.length,e=b.length,f=Math.ceil((d+e)/2),g=f,h=2*f,j=Array(h),i=Array(h),k=0;k<h;k++)j[k]=-1,i[k]=-1;j[g+1]=0;i[g+1]=0;for(var k=d-e,q=0!=k%2,r=0,t=0,p=0,w=0,v=0;v<f&&!((new Date).getTime()>c);v++){for(var n=-v+r;n<=v-t;n+=2){var l=g+n,m;m=n==-v||n!=v&&j[l-1]<j[l+1]?j[l+1]:j[l-1]+1;for(var s=m-n;m<d&&s<e&&a.charAt(m)==b.charAt(s);)m++,s++;j[l]=m;if(m>d)t+=2;else if(s>e)r+=2;else if(q&&(l=g+k-n,0<=l&&l<h&&-1!=i[l])){var u=d-i[l];if(m>=
|
|
|
|
|
u)return this.diff_bisectSplit_(a,b,m,s,c)}}for(n=-v+p;n<=v-w;n+=2){l=g+n;u=n==-v||n!=v&&i[l-1]<i[l+1]?i[l+1]:i[l-1]+1;for(m=u-n;u<d&&m<e&&a.charAt(d-u-1)==b.charAt(e-m-1);)u++,m++;i[l]=u;if(u>d)w+=2;else if(m>e)p+=2;else if(!q&&(l=g+k-n,0<=l&&(l<h&&-1!=j[l])&&(m=j[l],s=g+m-l,u=d-u,m>=u)))return this.diff_bisectSplit_(a,b,m,s,c)}}return[[-1,a],[1,b]]};
|
|
|
|
|
diff_match_patch.prototype.diff_bisectSplit_=function(a,b,c,d,e){var f=a.substring(0,c),g=b.substring(0,d);a=a.substring(c);b=b.substring(d);f=this.diff_main(f,g,!1,e);e=this.diff_main(a,b,!1,e);return f.concat(e)};
|
|
|
|
|
diff_match_patch.prototype.diff_linesToChars_=function(a,b){function c(a){for(var b="",c=0,f=-1,g=d.length;f<a.length-1;){f=a.indexOf("\n",c);-1==f&&(f=a.length-1);var r=a.substring(c,f+1),c=f+1;(e.hasOwnProperty?e.hasOwnProperty(r):void 0!==e[r])?b+=String.fromCharCode(e[r]):(b+=String.fromCharCode(g),e[r]=g,d[g++]=r)}return b}var d=[],e={};d[0]="";var f=c(a),g=c(b);return{chars1:f,chars2:g,lineArray:d}};
|
|
|
|
|
diff_match_patch.prototype.diff_charsToLines_=function(a,b){for(var c=0;c<a.length;c++){for(var d=a[c][1],e=[],f=0;f<d.length;f++)e[f]=b[d.charCodeAt(f)];a[c][1]=e.join("")}};diff_match_patch.prototype.diff_commonPrefix=function(a,b){if(!a||!b||a.charAt(0)!=b.charAt(0))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;c<e;)a.substring(f,e)==b.substring(f,e)?f=c=e:d=e,e=Math.floor((d-c)/2+c);return e};
|
|
|
|
|
diff_match_patch.prototype.diff_commonSuffix=function(a,b){if(!a||!b||a.charAt(a.length-1)!=b.charAt(b.length-1))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;c<e;)a.substring(a.length-e,a.length-f)==b.substring(b.length-e,b.length-f)?f=c=e:d=e,e=Math.floor((d-c)/2+c);return e};
|
|
|
|
|
diff_match_patch.prototype.diff_commonOverlap_=function(a,b){var c=a.length,d=b.length;if(0==c||0==d)return 0;c>d?a=a.substring(c-d):c<d&&(b=b.substring(0,c));c=Math.min(c,d);if(a==b)return c;for(var d=0,e=1;;){var f=a.substring(c-e),f=b.indexOf(f);if(-1==f)return d;e+=f;if(0==f||a.substring(c-e)==b.substring(0,e))d=e,e++}};
|
|
|
|
|
diff_match_patch.prototype.diff_halfMatch_=function(a,b){function c(a,b,c){for(var d=a.substring(c,c+Math.floor(a.length/4)),e=-1,g="",h,j,n,l;-1!=(e=b.indexOf(d,e+1));){var m=f.diff_commonPrefix(a.substring(c),b.substring(e)),s=f.diff_commonSuffix(a.substring(0,c),b.substring(0,e));g.length<s+m&&(g=b.substring(e-s,e)+b.substring(e,e+m),h=a.substring(0,c-s),j=a.substring(c+m),n=b.substring(0,e-s),l=b.substring(e+m))}return 2*g.length>=a.length?[h,j,n,l,g]:null}if(0>=this.Diff_Timeout)return null;
|
|
|
|
|
var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(4>d.length||2*e.length<d.length)return null;var f=this,g=c(d,e,Math.ceil(d.length/4)),d=c(d,e,Math.ceil(d.length/2)),h;if(!g&&!d)return null;h=d?g?g[4].length>d[4].length?g:d:d:g;var j;a.length>b.length?(g=h[0],d=h[1],e=h[2],j=h[3]):(e=h[0],j=h[1],g=h[2],d=h[3]);h=h[4];return[g,d,e,j,h]};
|
|
|
|
|
diff_match_patch.prototype.diff_cleanupSemantic=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=0,h=0,j=0,i=0;f<a.length;)0==a[f][0]?(c[d++]=f,g=j,h=i,i=j=0,e=a[f][1]):(1==a[f][0]?j+=a[f][1].length:i+=a[f][1].length,e&&(e.length<=Math.max(g,h)&&e.length<=Math.max(j,i))&&(a.splice(c[d-1],0,[-1,e]),a[c[d-1]+1][0]=1,d--,d--,f=0<d?c[d-1]:-1,i=j=h=g=0,e=null,b=!0)),f++;b&&this.diff_cleanupMerge(a);this.diff_cleanupSemanticLossless(a);for(f=1;f<a.length;){if(-1==a[f-1][0]&&1==a[f][0]){b=a[f-1][1];c=a[f][1];
|
|
|
|
|
d=this.diff_commonOverlap_(b,c);e=this.diff_commonOverlap_(c,b);if(d>=e){if(d>=b.length/2||d>=c.length/2)a.splice(f,0,[0,c.substring(0,d)]),a[f-1][1]=b.substring(0,b.length-d),a[f+1][1]=c.substring(d),f++}else if(e>=b.length/2||e>=c.length/2)a.splice(f,0,[0,b.substring(0,e)]),a[f-1][0]=1,a[f-1][1]=c.substring(0,c.length-e),a[f+1][0]=-1,a[f+1][1]=b.substring(e),f++;f++}f++}};
|
|
|
|
|
diff_match_patch.prototype.diff_cleanupSemanticLossless=function(a){function b(a,b){if(!a||!b)return 6;var c=a.charAt(a.length-1),d=b.charAt(0),e=c.match(diff_match_patch.nonAlphaNumericRegex_),f=d.match(diff_match_patch.nonAlphaNumericRegex_),g=e&&c.match(diff_match_patch.whitespaceRegex_),h=f&&d.match(diff_match_patch.whitespaceRegex_),c=g&&c.match(diff_match_patch.linebreakRegex_),d=h&&d.match(diff_match_patch.linebreakRegex_),i=c&&a.match(diff_match_patch.blanklineEndRegex_),j=d&&b.match(diff_match_patch.blanklineStartRegex_);
|
|
|
|
|
return i||j?5:c||d?4:e&&!g&&h?3:g||h?2:e||f?1:0}for(var c=1;c<a.length-1;){if(0==a[c-1][0]&&0==a[c+1][0]){var d=a[c-1][1],e=a[c][1],f=a[c+1][1],g=this.diff_commonSuffix(d,e);if(g)var h=e.substring(e.length-g),d=d.substring(0,d.length-g),e=h+e.substring(0,e.length-g),f=h+f;for(var g=d,h=e,j=f,i=b(d,e)+b(e,f);e.charAt(0)===f.charAt(0);){var d=d+e.charAt(0),e=e.substring(1)+f.charAt(0),f=f.substring(1),k=b(d,e)+b(e,f);k>=i&&(i=k,g=d,h=e,j=f)}a[c-1][1]!=g&&(g?a[c-1][1]=g:(a.splice(c-1,1),c--),a[c][1]=
|
|
|
|
|
h,j?a[c+1][1]=j:(a.splice(c+1,1),c--))}c++}};diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;diff_match_patch.whitespaceRegex_=/\s/;diff_match_patch.linebreakRegex_=/[\r\n]/;diff_match_patch.blanklineEndRegex_=/\n\r?\n$/;diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/;
|
|
|
|
|
diff_match_patch.prototype.diff_cleanupEfficiency=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=!1,h=!1,j=!1,i=!1;f<a.length;){if(0==a[f][0])a[f][1].length<this.Diff_EditCost&&(j||i)?(c[d++]=f,g=j,h=i,e=a[f][1]):(d=0,e=null),j=i=!1;else if(-1==a[f][0]?i=!0:j=!0,e&&(g&&h&&j&&i||e.length<this.Diff_EditCost/2&&3==g+h+j+i))a.splice(c[d-1],0,[-1,e]),a[c[d-1]+1][0]=1,d--,e=null,g&&h?(j=i=!0,d=0):(d--,f=0<d?c[d-1]:-1,j=i=!1),b=!0;f++}b&&this.diff_cleanupMerge(a)};
|
|
|
|
|
diff_match_patch.prototype.diff_cleanupMerge=function(a){a.push([0,""]);for(var b=0,c=0,d=0,e="",f="",g;b<a.length;)switch(a[b][0]){case 1:d++;f+=a[b][1];b++;break;case -1:c++;e+=a[b][1];b++;break;case 0:1<c+d?(0!==c&&0!==d&&(g=this.diff_commonPrefix(f,e),0!==g&&(0<b-c-d&&0==a[b-c-d-1][0]?a[b-c-d-1][1]+=f.substring(0,g):(a.splice(0,0,[0,f.substring(0,g)]),b++),f=f.substring(g),e=e.substring(g)),g=this.diff_commonSuffix(f,e),0!==g&&(a[b][1]=f.substring(f.length-g)+a[b][1],f=f.substring(0,f.length-
|
|
|
|
|
g),e=e.substring(0,e.length-g))),0===c?a.splice(b-d,c+d,[1,f]):0===d?a.splice(b-c,c+d,[-1,e]):a.splice(b-c-d,c+d,[-1,e],[1,f]),b=b-c-d+(c?1:0)+(d?1:0)+1):0!==b&&0==a[b-1][0]?(a[b-1][1]+=a[b][1],a.splice(b,1)):b++,c=d=0,f=e=""}""===a[a.length-1][1]&&a.pop();c=!1;for(b=1;b<a.length-1;)0==a[b-1][0]&&0==a[b+1][0]&&(a[b][1].substring(a[b][1].length-a[b-1][1].length)==a[b-1][1]?(a[b][1]=a[b-1][1]+a[b][1].substring(0,a[b][1].length-a[b-1][1].length),a[b+1][1]=a[b-1][1]+a[b+1][1],a.splice(b-1,1),c=!0):a[b][1].substring(0,
|
|
|
|
|
a[b+1][1].length)==a[b+1][1]&&(a[b-1][1]+=a[b+1][1],a[b][1]=a[b][1].substring(a[b+1][1].length)+a[b+1][1],a.splice(b+1,1),c=!0)),b++;c&&this.diff_cleanupMerge(a)};diff_match_patch.prototype.diff_xIndex=function(a,b){var c=0,d=0,e=0,f=0,g;for(g=0;g<a.length;g++){1!==a[g][0]&&(c+=a[g][1].length);-1!==a[g][0]&&(d+=a[g][1].length);if(c>b)break;e=c;f=d}return a.length!=g&&-1===a[g][0]?f:f+(b-e)};
|
|
|
|
|
diff_match_patch.prototype.diff_prettyHtml=function(a){for(var b=[],c=/&/g,d=/</g,e=/>/g,f=/\n/g,g=0;g<a.length;g++){var h=a[g][0],j=a[g][1],j=j.replace(c,"&").replace(d,"<").replace(e,">").replace(f,"¶<br>");switch(h){case 1:b[g]='<ins style="background:#e6ffe6;">'+j+"</ins>";break;case -1:b[g]='<del style="background:#ffe6e6;">'+j+"</del>";break;case 0:b[g]="<span>"+j+"</span>"}}return b.join("")};
|
|
|
|
|
diff_match_patch.prototype.diff_text1=function(a){for(var b=[],c=0;c<a.length;c++)1!==a[c][0]&&(b[c]=a[c][1]);return b.join("")};diff_match_patch.prototype.diff_text2=function(a){for(var b=[],c=0;c<a.length;c++)-1!==a[c][0]&&(b[c]=a[c][1]);return b.join("")};diff_match_patch.prototype.diff_levenshtein=function(a){for(var b=0,c=0,d=0,e=0;e<a.length;e++){var f=a[e][0],g=a[e][1];switch(f){case 1:c+=g.length;break;case -1:d+=g.length;break;case 0:b+=Math.max(c,d),d=c=0}}return b+=Math.max(c,d)};
|
|
|
|
|
diff_match_patch.prototype.diff_toDelta=function(a){for(var b=[],c=0;c<a.length;c++)switch(a[c][0]){case 1:b[c]="+"+encodeURI(a[c][1]);break;case -1:b[c]="-"+a[c][1].length;break;case 0:b[c]="="+a[c][1].length}return b.join("\t").replace(/%20/g," ")};
|
|
|
|
|
diff_match_patch.prototype.diff_fromDelta=function(a,b){for(var c=[],d=0,e=0,f=b.split(/\t/g),g=0;g<f.length;g++){var h=f[g].substring(1);switch(f[g].charAt(0)){case "+":try{c[d++]=[1,decodeURI(h)]}catch(j){throw Error("Illegal escape in diff_fromDelta: "+h);}break;case "-":case "=":var i=parseInt(h,10);if(isNaN(i)||0>i)throw Error("Invalid number in diff_fromDelta: "+h);h=a.substring(e,e+=i);"="==f[g].charAt(0)?c[d++]=[0,h]:c[d++]=[-1,h];break;default:if(f[g])throw Error("Invalid diff operation in diff_fromDelta: "+
|
|
|
|
|
f[g]);}}if(e!=a.length)throw Error("Delta length ("+e+") does not equal source text length ("+a.length+").");return c};diff_match_patch.prototype.match_main=function(a,b,c){if(null==a||null==b||null==c)throw Error("Null input. (match_main)");c=Math.max(0,Math.min(c,a.length));return a==b?0:a.length?a.substring(c,c+b.length)==b?c:this.match_bitap_(a,b,c):-1};
|
|
|
|
|
diff_match_patch.prototype.match_bitap_=function(a,b,c){function d(a,d){var e=a/b.length,g=Math.abs(c-d);return!f.Match_Distance?g?1:e:e+g/f.Match_Distance}if(b.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var e=this.match_alphabet_(b),f=this,g=this.Match_Threshold,h=a.indexOf(b,c);-1!=h&&(g=Math.min(d(0,h),g),h=a.lastIndexOf(b,c+b.length),-1!=h&&(g=Math.min(d(0,h),g)));for(var j=1<<b.length-1,h=-1,i,k,q=b.length+a.length,r,t=0;t<b.length;t++){i=0;for(k=q;i<k;)d(t,c+
|
|
|
|
|
k)<=g?i=k:q=k,k=Math.floor((q-i)/2+i);q=k;i=Math.max(1,c-k+1);var p=Math.min(c+k,a.length)+b.length;k=Array(p+2);for(k[p+1]=(1<<t)-1;p>=i;p--){var w=e[a.charAt(p-1)];k[p]=0===t?(k[p+1]<<1|1)&w:(k[p+1]<<1|1)&w|((r[p+1]|r[p])<<1|1)|r[p+1];if(k[p]&j&&(w=d(t,p-1),w<=g))if(g=w,h=p-1,h>c)i=Math.max(1,2*c-h);else break}if(d(t+1,c)>g)break;r=k}return h};
|
|
|
|
|
diff_match_patch.prototype.match_alphabet_=function(a){for(var b={},c=0;c<a.length;c++)b[a.charAt(c)]=0;for(c=0;c<a.length;c++)b[a.charAt(c)]|=1<<a.length-c-1;return b};
|
|
|
|
|
diff_match_patch.prototype.patch_addContext_=function(a,b){if(0!=b.length){for(var c=b.substring(a.start2,a.start2+a.length1),d=0;b.indexOf(c)!=b.lastIndexOf(c)&&c.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)d+=this.Patch_Margin,c=b.substring(a.start2-d,a.start2+a.length1+d);d+=this.Patch_Margin;(c=b.substring(a.start2-d,a.start2))&&a.diffs.unshift([0,c]);(d=b.substring(a.start2+a.length1,a.start2+a.length1+d))&&a.diffs.push([0,d]);a.start1-=c.length;a.start2-=c.length;a.length1+=
|
|
|
|
|
c.length+d.length;a.length2+=c.length+d.length}};
|
|
|
|
|
diff_match_patch.prototype.patch_make=function(a,b,c){var d;if("string"==typeof a&&"string"==typeof b&&"undefined"==typeof c)d=a,b=this.diff_main(d,b,!0),2<b.length&&(this.diff_cleanupSemantic(b),this.diff_cleanupEfficiency(b));else if(a&&"object"==typeof a&&"undefined"==typeof b&&"undefined"==typeof c)b=a,d=this.diff_text1(b);else if("string"==typeof a&&b&&"object"==typeof b&&"undefined"==typeof c)d=a;else if("string"==typeof a&&"string"==typeof b&&c&&"object"==typeof c)d=a,b=c;else throw Error("Unknown call format to patch_make.");
|
|
|
|
|
if(0===b.length)return[];c=[];a=new diff_match_patch.patch_obj;for(var e=0,f=0,g=0,h=d,j=0;j<b.length;j++){var i=b[j][0],k=b[j][1];!e&&0!==i&&(a.start1=f,a.start2=g);switch(i){case 1:a.diffs[e++]=b[j];a.length2+=k.length;d=d.substring(0,g)+k+d.substring(g);break;case -1:a.length1+=k.length;a.diffs[e++]=b[j];d=d.substring(0,g)+d.substring(g+k.length);break;case 0:k.length<=2*this.Patch_Margin&&e&&b.length!=j+1?(a.diffs[e++]=b[j],a.length1+=k.length,a.length2+=k.length):k.length>=2*this.Patch_Margin&&
|
|
|
|
|
e&&(this.patch_addContext_(a,h),c.push(a),a=new diff_match_patch.patch_obj,e=0,h=d,f=g)}1!==i&&(f+=k.length);-1!==i&&(g+=k.length)}e&&(this.patch_addContext_(a,h),c.push(a));return c};diff_match_patch.prototype.patch_deepCopy=function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=new diff_match_patch.patch_obj;e.diffs=[];for(var f=0;f<d.diffs.length;f++)e.diffs[f]=d.diffs[f].slice();e.start1=d.start1;e.start2=d.start2;e.length1=d.length1;e.length2=d.length2;b[c]=e}return b};
|
|
|
|
|
diff_match_patch.prototype.patch_apply=function(a,b){if(0==a.length)return[b,[]];a=this.patch_deepCopy(a);var c=this.patch_addPadding(a);b=c+b+c;this.patch_splitMax(a);for(var d=0,e=[],f=0;f<a.length;f++){var g=a[f].start2+d,h=this.diff_text1(a[f].diffs),j,i=-1;if(h.length>this.Match_MaxBits){if(j=this.match_main(b,h.substring(0,this.Match_MaxBits),g),-1!=j&&(i=this.match_main(b,h.substring(h.length-this.Match_MaxBits),g+h.length-this.Match_MaxBits),-1==i||j>=i))j=-1}else j=this.match_main(b,h,g);
|
|
|
|
|
if(-1==j)e[f]=!1,d-=a[f].length2-a[f].length1;else if(e[f]=!0,d=j-g,g=-1==i?b.substring(j,j+h.length):b.substring(j,i+this.Match_MaxBits),h==g)b=b.substring(0,j)+this.diff_text2(a[f].diffs)+b.substring(j+h.length);else if(g=this.diff_main(h,g,!1),h.length>this.Match_MaxBits&&this.diff_levenshtein(g)/h.length>this.Patch_DeleteThreshold)e[f]=!1;else{this.diff_cleanupSemanticLossless(g);for(var h=0,k,i=0;i<a[f].diffs.length;i++){var q=a[f].diffs[i];0!==q[0]&&(k=this.diff_xIndex(g,h));1===q[0]?b=b.substring(0,
|
|
|
|
|
j+k)+q[1]+b.substring(j+k):-1===q[0]&&(b=b.substring(0,j+k)+b.substring(j+this.diff_xIndex(g,h+q[1].length)));-1!==q[0]&&(h+=q[1].length)}}}b=b.substring(c.length,b.length-c.length);return[b,e]};
|
|
|
|
|
diff_match_patch.prototype.patch_addPadding=function(a){for(var b=this.Patch_Margin,c="",d=1;d<=b;d++)c+=String.fromCharCode(d);for(d=0;d<a.length;d++)a[d].start1+=b,a[d].start2+=b;var d=a[0],e=d.diffs;if(0==e.length||0!=e[0][0])e.unshift([0,c]),d.start1-=b,d.start2-=b,d.length1+=b,d.length2+=b;else if(b>e[0][1].length){var f=b-e[0][1].length;e[0][1]=c.substring(e[0][1].length)+e[0][1];d.start1-=f;d.start2-=f;d.length1+=f;d.length2+=f}d=a[a.length-1];e=d.diffs;0==e.length||0!=e[e.length-1][0]?(e.push([0,
|
|
|
|
|
c]),d.length1+=b,d.length2+=b):b>e[e.length-1][1].length&&(f=b-e[e.length-1][1].length,e[e.length-1][1]+=c.substring(0,f),d.length1+=f,d.length2+=f);return c};
|
|
|
|
|
diff_match_patch.prototype.patch_splitMax=function(a){for(var b=this.Match_MaxBits,c=0;c<a.length;c++)if(!(a[c].length1<=b)){var d=a[c];a.splice(c--,1);for(var e=d.start1,f=d.start2,g="";0!==d.diffs.length;){var h=new diff_match_patch.patch_obj,j=!0;h.start1=e-g.length;h.start2=f-g.length;""!==g&&(h.length1=h.length2=g.length,h.diffs.push([0,g]));for(;0!==d.diffs.length&&h.length1<b-this.Patch_Margin;){var g=d.diffs[0][0],i=d.diffs[0][1];1===g?(h.length2+=i.length,f+=i.length,h.diffs.push(d.diffs.shift()),
|
|
|
|
|
j=!1):-1===g&&1==h.diffs.length&&0==h.diffs[0][0]&&i.length>2*b?(h.length1+=i.length,e+=i.length,j=!1,h.diffs.push([g,i]),d.diffs.shift()):(i=i.substring(0,b-h.length1-this.Patch_Margin),h.length1+=i.length,e+=i.length,0===g?(h.length2+=i.length,f+=i.length):j=!1,h.diffs.push([g,i]),i==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(i.length))}g=this.diff_text2(h.diffs);g=g.substring(g.length-this.Patch_Margin);i=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);""!==i&&
|
|
|
|
|
(h.length1+=i.length,h.length2+=i.length,0!==h.diffs.length&&0===h.diffs[h.diffs.length-1][0]?h.diffs[h.diffs.length-1][1]+=i:h.diffs.push([0,i]));j||a.splice(++c,0,h)}}};diff_match_patch.prototype.patch_toText=function(a){for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b.join("")};
|
|
|
|
|
diff_match_patch.prototype.patch_fromText=function(a){var b=[];if(!a)return b;a=a.split("\n");for(var c=0,d=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;c<a.length;){var e=a[c].match(d);if(!e)throw Error("Invalid patch string: "+a[c]);var f=new diff_match_patch.patch_obj;b.push(f);f.start1=parseInt(e[1],10);""===e[2]?(f.start1--,f.length1=1):"0"==e[2]?f.length1=0:(f.start1--,f.length1=parseInt(e[2],10));f.start2=parseInt(e[3],10);""===e[4]?(f.start2--,f.length2=1):"0"==e[4]?f.length2=0:(f.start2--,f.length2=
|
|
|
|
|
parseInt(e[4],10));for(c++;c<a.length;){e=a[c].charAt(0);try{var g=decodeURI(a[c].substring(1))}catch(h){throw Error("Illegal escape in patch_fromText: "+g);}if("-"==e)f.diffs.push([-1,g]);else if("+"==e)f.diffs.push([1,g]);else if(" "==e)f.diffs.push([0,g]);else if("@"==e)break;else if(""!==e)throw Error('Invalid patch mode "'+e+'" in: '+g);c++}}return b};diff_match_patch.patch_obj=function(){this.diffs=[];this.start2=this.start1=null;this.length2=this.length1=0};
|
|
|
|
|
diff_match_patch.patch_obj.prototype.toString=function(){var a,b;a=0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1;b=0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2;a=["@@ -"+a+" +"+b+" @@\n"];var c;for(b=0;b<this.diffs.length;b++){switch(this.diffs[b][0]){case 1:c="+";break;case -1:c="-";break;case 0:c=" "}a[b+1]=c+encodeURI(this.diffs[b][1])+"\n"}return a.join("").replace(/%20/g," ")};
|
|
|
|
|
this.diff_match_patch=diff_match_patch;this.DIFF_DELETE=-1;this.DIFF_INSERT=1;this.DIFF_EQUAL=0;})();
|
|
|
|
|
|
|
|
|
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
|
|
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
|
|
|
// merge.js
|
|
|
|
|
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
|
|
|
|
|
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","diff_match_patch"],e):e(CodeMirror)}(function(e){"use strict";var t,i,r,n=e.Pos,o="http://www.w3.org/2000/svg",l=2,a=!0,s=null,c=!1;function h(e,t){this.mv=e,this.type=t,this.classes="left"==t?{chunk:"CodeMirror-merge-l-chunk",start:"CodeMirror-merge-l-chunk-start",end:"CodeMirror-merge-l-chunk-end",insert:"CodeMirror-merge-l-inserted",del:"CodeMirror-merge-l-deleted",connect:"CodeMirror-merge-l-connect"}:{chunk:"CodeMirror-merge-r-chunk",start:"CodeMirror-merge-r-chunk-start",end:"CodeMirror-merge-r-chunk-end",insert:"CodeMirror-merge-r-inserted",del:"CodeMirror-merge-r-deleted",connect:"CodeMirror-merge-r-connect"}}function f(t){t.diffOutOfDate&&(t.diff=I(t.orig.getValue(),t.edit.getValue(),t.mv.options.ignoreWhitespace),t.chunks=N(t.diff),t.diffOutOfDate=!1,e.signal(t.edit,"updateDiff",t.diff))}e.k_init=function(n,o,h){t=h,i="",r=o;var f=function(){if(null==t)return;var o=document.getElementById(n);return o.innerHTML="",f=e.MergeView(o,{value:t,origLeft:3!=l||c||s?null:i,orig:r,lineNumbers:!0,mode:"text/html",theme:"blackboard",matchBrackets:!0,highlightDifferences:a,connect:s,collapseIdentical:c,readOnly:"nocursor",revertButtons:!0}),console.log(f.edit),f}();return f},h.prototype={constructor:h,init:function(t,i,r){this.edit=this.mv.edit,(this.edit.state.diffViews||(this.edit.state.diffViews=[])).push(this),this.orig=e(t,Q({value:i,readOnly:!this.mv.options.allowEditingOriginals},Q(r))),"align"==this.mv.options.connect&&(this.edit.state.trackAlignable||(this.edit.state.trackAlignable=new X(this.edit)),this.orig.state.trackAlignable=new X(this.orig)),this.orig.state.diffViews=[this];var n=r.chunkClassLocation||"background";"[object Array]"!=Object.prototype.toString.call(n)&&(n=[n]),this.classes.classLocation=n,this.diff=I(x(i),x(r.value),this.mv.options.ignoreWhitespace),this.chunks=N(this.diff),this.diffOutOfDate=this.dealigned=!1,this.needsScrollSync=null,this.showDifferences=!1!==r.showDifferences},registerEvents:function(t){this.forceUpdate=function(t){var i,r={from:0,to:0,marked:[]},n={from:0,to:0,marked:[]},o=!1;function l(e){g=!0,o=!1,"full"==e&&(t.svg&&U(t.svg),t.copyButtons&&U(t.copyButtons),p(t.edit,r.marked,t.classes),p(t.orig,n.marked,t.classes),r.from=r.to=n.from=n.to=0),f(t),t.showDifferences&&(k(t.edit,t.diff,r,DIFF_INSERT,t.classes),k(t.orig,t.diff,n,DIFF_DELETE,t.classes)),"align"==t.mv.options.connect&&S(t),w(t),null!=t.needsScrollSync&&d(t,t.needsScrollSync),g=!1}function a(e){g||(t.dealigned=!0,s(e))}function s(e){g||o||(clearTimeout(i),!0===e&&(o=!0),i=setTimeout(l,!0===e?20:250))}function c(e,i){t.diffOutOfDate||(t.diffOutOfDate=!0,r.from=r.to=n.from=n.to=0),a(i.text.length-1!=i.to.line-i.from.line)}function h(){t.diffOutOfDate=!0,t.dealigned=!0,l("full")}t.edit.on("change",c),t.orig.on("change",c),t.edit.on("swapDoc",h),t.orig.on("swapDoc",h),"align"==t.mv.options.connect&&(e.on(t.edit.state.trackAlignable,"realign",a),e.on(t.orig.state.trackAlignable,"realign",a));return t.edit.on("viewportChange",function(){s(!1)}),t.orig.on("viewportChange",function(){s(!1)}),l(),l}(this),m(this,!0,!1),function(e,t){e.edit.on("scroll",function(){d(e,!0)&&w(e)}),e.orig.on("scroll",function(){d(e,!1)&&w(e),t&&d(t,!0)&&w(t)})}(this,t)},setShowDifferences:function(e){(e=!1!==e)!=this.showDifferences&&(this.showDifferences=e,this.forceUpdate("full"))}};var g=!1;function d(e,t){if(e.diffOutOfDate)return e.lockScroll&&null==e.needsScrollSync&&(e.needsScrollSync=t),!1;if(e.needsScrollSync=null,!e.lockScroll)return!0;var i,r,n=+new Date;if(t?(i=e.edit,r=e.orig):(i=e.orig,r=e.edit),i.state.scrollSetBy==e&&(i.state.scrollSetAt||0)+250>n)return!1;var o=i.getScrollInfo();if("align"==e.mv.options.connect)v=o.top;else{var l,a,s=.5*o.clientHeight,c=o.top+s,h=i.lineAtHeight(c,"local"),f=function(e,t,i){for(var r,n,o,l,a=0;a<e.length;a++){var s=e[a],c=i?s.editFrom:s.origFrom,h=i?s.editTo:s.origTo;null==n&&(c>t?(n=s.editFrom,l=s.origFrom):h>t&&(n=s.editTo,l=s.o
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------edu_tpi.js START
|
|
|
|
|
// 实训游戏需要的js功能
|
|
|
|
|
var EXPAND = 0; // 放大
|
|
|
|
|
var SHRINK = 1; // 缩小
|
|
|
|
|
|
|
|
|
|
var repositoryTabHeight = 40
|
|
|
|
|
|
|
|
|
|
$(function(){
|
|
|
|
|
function update_rows_and_cols(rows) {
|
|
|
|
|
// 非iframe模式使用:
|
|
|
|
|
window.postMessage({tp: 'resize', rows: rows, cols: 0}, "*");
|
|
|
|
|
|
|
|
|
|
// iframe模式使用:
|
|
|
|
|
// var _iframe = document.getElementById("game_webssh");
|
|
|
|
|
// if(_iframe == null || _iframe == undefined || _iframe == ""){
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// _iframe.contentWindow.postMessage({tp: 'resize', rows: rows, cols: 0}, "https://webssh.educoder.net");
|
|
|
|
|
}
|
|
|
|
|
window.top.__updateWebsshRows = update_rows_and_cols
|
|
|
|
|
|
|
|
|
|
// TPI拖拽功能 begin
|
|
|
|
|
var doc = $(document);
|
|
|
|
|
var lab = $(".b-label");
|
|
|
|
|
var cen = $(".h-center");
|
|
|
|
|
var nextW2,nextW1;
|
|
|
|
|
var dragging = false;
|
|
|
|
|
var flag = false;
|
|
|
|
|
var wrapWidth;
|
|
|
|
|
var wrapHeight;
|
|
|
|
|
var nRow = 0;
|
|
|
|
|
//var nCol = 0;
|
|
|
|
|
lab.live('mousedown touchstart',function(){
|
|
|
|
|
$('#game_webssh').css('pointer-events', 'none')
|
|
|
|
|
dragging = true;
|
|
|
|
|
leftOffset = $(".labelN").offset().left;
|
|
|
|
|
wrapWidth = $(".labelN").width();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
cen.live('mousedown ',function(){
|
|
|
|
|
// 使得iframe不捕获事件
|
|
|
|
|
$('#game_webssh').css('pointer-events', 'none')
|
|
|
|
|
flag = true;
|
|
|
|
|
topOffset = $(".centerH").offset().top;
|
|
|
|
|
wrapHeight = $(".centerH").height();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// react add TODO react加载完dom再执行
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
$('#games_repository_contents .CodeMirror.cm-s-railscasts').css("height", $("#games_repository_contents").height() - repositoryTabHeight);
|
|
|
|
|
}, 800)
|
|
|
|
|
|
|
|
|
|
// window resize
|
|
|
|
|
$(window).on('resize', function() {
|
|
|
|
|
window._tpiWidthResize && window._tpiWidthResize()
|
|
|
|
|
$('#games_repository_contents .CodeMirror.cm-s-railscasts').css("height", $("#games_repository_contents").height() - repositoryTabHeight);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
var FF = !(window.mozInnerScreenX == null);
|
|
|
|
|
var websshLineHeight = FF ? 19 : 18
|
|
|
|
|
function throttle(method, delay, duration){
|
|
|
|
|
var timer = null, begin = new Date();
|
|
|
|
|
return function(){
|
|
|
|
|
var context = this, args = arguments, current = new Date();
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
if(current-begin >= duration){
|
|
|
|
|
method.apply(context, args);
|
|
|
|
|
begin = current;
|
|
|
|
|
} else {
|
|
|
|
|
timer = setTimeout(function(){
|
|
|
|
|
method.apply(context, args);
|
|
|
|
|
}, delay);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
doc.live('mousemove touchmove',function(e){
|
|
|
|
|
|
|
|
|
|
$(".-brother").show();// 代码行的遮罩显示
|
|
|
|
|
if(dragging) {
|
|
|
|
|
clickX = e.pageX || e.originalEvent.touches[0].pageX;;
|
|
|
|
|
if(clickX > leftOffset+0&&clickX<leftOffset+1600) {
|
|
|
|
|
// console.log('resize')
|
|
|
|
|
lab.css('left', clickX - 7 - leftOffset + 'px');
|
|
|
|
|
$("#game_left_contents").width( clickX-leftOffset + 'px');
|
|
|
|
|
nextW2 = clickX-leftOffset;
|
|
|
|
|
$("#game_right_contents").width( wrapWidth - nextW2 + 'px');
|
|
|
|
|
//console.log(lab.next().width());
|
|
|
|
|
throttle(refresh_editor_monaco, 100, 200)()
|
|
|
|
|
} else {
|
|
|
|
|
lab.css('left', '0px');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(flag){
|
|
|
|
|
clickY = e.pageY;
|
|
|
|
|
if(clickY > topOffset +100) {
|
|
|
|
|
cen.css('top', clickY - 7 - topOffset + 'px');
|
|
|
|
|
$("#games_repository_contents").height( clickY-topOffset + 'px');
|
|
|
|
|
|
|
|
|
|
// react add
|
|
|
|
|
$('.CodeMirror.cm-s-railscasts')
|
|
|
|
|
.css("height", clickY- topOffset - repositoryTabHeight - $('#games_repository_contents .codePath').height() - 12);
|
|
|
|
|
|
|
|
|
|
nextW1 = clickY-topOffset;
|
|
|
|
|
$("#games_valuation_contents").height( wrapHeight - nextW1 + 'px');
|
|
|
|
|
var h = $("#games_repository_contents").height() - $("#top_repository").height() - repositoryTabHeight;
|
|
|
|
|
var m = $("#games_repository_contents").height() - repositoryTabHeight;
|
|
|
|
|
var w = $("#games_repository_contents").width();
|
|
|
|
|
$(".game_webssh").css("min-height", m);
|
|
|
|
|
$(".game_webssh").css("max-height", m);
|
|
|
|
|
throttle(refresh_editor_monaco, 100, 200)(m)
|
|
|
|
|
// refresh_editor_monaco(m)
|
|
|
|
|
// 火狐下行高为19
|
|
|
|
|
// CodeRepositoryView.js有同样的计算逻辑,用来初始化ssh
|
|
|
|
|
var rows = Math.round(m / websshLineHeight);
|
|
|
|
|
//var cols = parseInt(w / 6.2);
|
|
|
|
|
$("#file_entry_content").find(".CodeMirror-scroll").css("min-height", h);
|
|
|
|
|
$("#file_entry_content").find(".CodeMirror-scroll").css("max-height", h);
|
|
|
|
|
} else {
|
|
|
|
|
cen.css('top', '0px');
|
|
|
|
|
}
|
|
|
|
|
// 行高发生变化,则调整webssh的term的高度
|
|
|
|
|
if(nRow != rows){
|
|
|
|
|
//window.frames['game_webssh'].contentWindow.resizeTerminal({rows:rows});
|
|
|
|
|
update_rows_and_cols(rows);
|
|
|
|
|
nRow = rows;
|
|
|
|
|
}else{
|
|
|
|
|
nRow = rows;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
doc.live("mouseup touchend", function(e) {
|
|
|
|
|
// 使得iframe可以继续捕获事件
|
|
|
|
|
$('#game_webssh').css('pointer-events', 'inherit')
|
|
|
|
|
flag = false;
|
|
|
|
|
dragging = false;
|
|
|
|
|
e.cancelBubble = true;
|
|
|
|
|
$(".-brother").hide(); // 代码行的遮罩隐藏
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.__tpiOnResize = function() {
|
|
|
|
|
var m = $("#games_repository_contents").height() - repositoryTabHeight;
|
|
|
|
|
$(".game_webssh").css("min-height", m);
|
|
|
|
|
$(".game_webssh").css("max-height", m);
|
|
|
|
|
|
|
|
|
|
refresh_editor_monaco(m)
|
|
|
|
|
|
|
|
|
|
// var _iframe = document.getElementById("game_webssh");
|
|
|
|
|
// if(!_iframe){
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
var FF = !(window.mozInnerScreenX == null);
|
|
|
|
|
var websshLineHeight = FF ? 19 : 18
|
|
|
|
|
|
|
|
|
|
var rows = Math.floor(m / websshLineHeight);
|
|
|
|
|
window.top.__updateWebsshRows && window.top.__updateWebsshRows(rows)
|
|
|
|
|
}
|
|
|
|
|
window.refresh_editor_monaco = function(height) {
|
|
|
|
|
console.log('refresh_editor_monaco')
|
|
|
|
|
if (window.editor_monaco) {
|
|
|
|
|
height && $('#codetab_con_1').height(height)
|
|
|
|
|
window.editor_monaco.layout();
|
|
|
|
|
}
|
|
|
|
|
// if ($('#game_operate_action').width() < 720) {
|
|
|
|
|
// $('#game_operate_action .time_limit').hide()
|
|
|
|
|
// } else {
|
|
|
|
|
// $('#game_operate_action .time_limit').show()
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
// end;
|
|
|
|
|
//解決IE瀏覽器大小改變時webssh佈局變亂。
|
|
|
|
|
window.onresize = function(){
|
|
|
|
|
__tpiOnResize()
|
|
|
|
|
}
|
|
|
|
|
// 评论区域的回复按钮
|
|
|
|
|
function reply_to_dis(id, name){
|
|
|
|
|
$("#comment_news").attr("placeholder", "回复"+name+":");
|
|
|
|
|
$("#dis_reply_id").val(id);
|
|
|
|
|
$("#comment_news").focus();
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
// 点击全部任务向右侧展开
|
|
|
|
|
$("#all_task_show").on("click", function(e){
|
|
|
|
|
c = 0;
|
|
|
|
|
$("#all_task_tab").removeClass('leftnav-active');
|
|
|
|
|
$("#all_task_show").css("background","rgba(0,0,0,0)");
|
|
|
|
|
$("#all_task_index").css("left", 0).stop().animate({
|
|
|
|
|
left: "-505px"
|
|
|
|
|
}, 400, function(){
|
|
|
|
|
$("#all_task_show").hide();
|
|
|
|
|
fadein = 0;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
// 列表区域阻止事件冒泡
|
|
|
|
|
$("#all_task_index").on("click", function(e){
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
// 下一关增加loading效果
|
|
|
|
|
$("#next_step").live("click", function(){
|
|
|
|
|
nNext = $("#next_step_area");
|
|
|
|
|
html = "<a href='javascript:void(0);' class='task-btn mr15 mt8'>下一关<img src='/images/bigdata/loading2.svg' style='width:25px;float:left;margin-top: 3px' /></a>";
|
|
|
|
|
nNext.html(html);
|
|
|
|
|
});
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
// 上一关增加loading效果
|
|
|
|
|
$("#prev_step").live("click", function(){
|
|
|
|
|
nNext = $("#prev_step_area");
|
|
|
|
|
html = "<a href='javascript:void(0);' class='task-btn mr15 mt8'>上一关<img src='/images/bigdata/loading2.svg' style='width:25px;float:left;margin-top: 3px' /></a>";
|
|
|
|
|
nNext.html(html);
|
|
|
|
|
});
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 查看参考答案
|
|
|
|
|
function open_answer(game, myshixun, choose){
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/myshixuns/" + myshixun + "/stages/" + game + "/answer",
|
|
|
|
|
data:{choose: choose},
|
|
|
|
|
dataType: "script"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 选择题选择答案
|
|
|
|
|
function choice_answer(st, nThis){
|
|
|
|
|
if(st == "2"){
|
|
|
|
|
//$(nThis).hasClass("card-check") ? $(nThis).removeClass("card-check") : $(nThis).addClass("card-check");
|
|
|
|
|
$(nThis).toggleClass("card-check");
|
|
|
|
|
$(nThis).toggleClass("color_white");
|
|
|
|
|
} else if (st == "1"){
|
|
|
|
|
var choice = $(".color_white");
|
|
|
|
|
choice.removeClass("card-check");
|
|
|
|
|
choice.removeClass("color_white");
|
|
|
|
|
$(nThis).addClass("card-check");
|
|
|
|
|
$(nThis).toggleClass("color_white");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
// 评测区域点击TAB切换样式
|
|
|
|
|
function check_tab(allClassName,addClassName,item){
|
|
|
|
|
//点击tab添加样式
|
|
|
|
|
$("."+allClassName).removeClass(addClassName);
|
|
|
|
|
$(item).addClass(addClassName);
|
|
|
|
|
//获取当前点击的tab的索引位置
|
|
|
|
|
var index=$(item).index()+1;
|
|
|
|
|
//显示或隐藏对应的内容块
|
|
|
|
|
$("#"+allClassName+"_"+index).siblings().addClass("undis");
|
|
|
|
|
$("#"+allClassName+"_"+index).removeClass("undis");
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
// 选择题公开的测试集允许展开与隐藏
|
|
|
|
|
function toggle_test_case_choose(t_case, id){
|
|
|
|
|
if(true){
|
|
|
|
|
var nTest = $("#test_case_"+id).parent().prev(".-task-ces-top").children("i:first-child"); //图标节点
|
|
|
|
|
if (nTest.hasClass("fa-caret-down")){
|
|
|
|
|
nTest.addClass("fa-caret-right");
|
|
|
|
|
nTest.removeClass("fa-caret-down");
|
|
|
|
|
}else if( nTest.hasClass("fa-caret-right") ){
|
|
|
|
|
nTest.addClass("fa-caret-down");
|
|
|
|
|
nTest.removeClass("fa-caret-right");
|
|
|
|
|
}
|
|
|
|
|
$("#test_case_"+id).toggle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 公开的测试集允许展开与隐藏
|
|
|
|
|
var dv;
|
|
|
|
|
function toggle_test_case(open, output, actual_output, id, power){
|
|
|
|
|
var base64 = new Base64();
|
|
|
|
|
output = base64.decode(output);
|
|
|
|
|
actual_output = base64.decode(actual_output);
|
|
|
|
|
actual_output = actual_output.replace(/\\r\\n/g, "\r\n").replace(/\\r/g, "\r").replace(/\\n/g, "\n").replace(/\\t/g,"\t").replace(/<\/\/script>/g, "</script>");
|
|
|
|
|
output = output.replace(/\\r\\n/g, "\r\n").replace(/\\r/g, "\r").replace(/\\n/g, "\n").replace(/\\t/g,"\t");
|
|
|
|
|
if(true){
|
|
|
|
|
var nTest = $("#test_case_"+id).parent().prev(".-task-ces-top").children("i:first-child"); //图标节点
|
|
|
|
|
if (nTest.hasClass("fa-caret-down")){
|
|
|
|
|
nTest.addClass("fa-caret-right");
|
|
|
|
|
nTest.removeClass("fa-caret-down");
|
|
|
|
|
$("#result_different_show_"+ id).siblings(".-task-ces-info").attr("style","display:none");
|
|
|
|
|
$("#result_different_show_"+ id).hide();
|
|
|
|
|
$("#test_case_"+id).hide();
|
|
|
|
|
}else if( nTest.hasClass("fa-caret-right") ){
|
|
|
|
|
nTest.addClass("fa-caret-down");
|
|
|
|
|
nTest.removeClass("fa-caret-right");
|
|
|
|
|
$("#result_different_show_"+ id).show();
|
|
|
|
|
$("#test_case_"+id).show();
|
|
|
|
|
$("#result_different_show_"+ id).siblings(".-task-ces-info").attr("style","display:block");
|
|
|
|
|
if(open == 1 || power){
|
|
|
|
|
var id = "result_different_show_" + id;
|
|
|
|
|
//var oldData = "摄氏温度\t\t华氏温度\n********************\n\n-40 \t\t -40.0\n-35 \t\t -31.0\n-30 \t\t -22.0\n-25 \t\t -13.0\n-20 \t\t -4.0\n-15 \t\t 5.0\n-10 \t\t 14.0\n-5 \t\t 23.0\n0 \t\t 32.0\n5 \t\t 41.0\n10 \t\t 50.0\n15 \t\t 59.0\n20 \t\t 68.0\n25 \t\t 77.0\n30 \t\t 86.0\n35 \t\t 95.0\n40 \t\t 104.0\n45 \t\t 113.0\n50 \t\t 122.0\n\n***********************\n\n[0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300]\n\n***********************\n5050 \t\t 5050\n\n***********************\n\n265252859812191058636308480000000\n\n***********************\n\nFalse\nFalse\nFalse\nFalse\nTrue\nTrue\nFalse\nFalse\nFalse\nTrue\n\n***********************\n\n3339 \t\t 333.9\n";
|
|
|
|
|
var oldData = output;
|
|
|
|
|
var orig1 = '';
|
|
|
|
|
var newData = actual_output == "null" ? "" : actual_output;
|
|
|
|
|
//var newData = "摄氏温度\t\t华氏温度\n********************\n-40 \t\t -40.0\n-35 \t\t -31.0\n-30 \t\t -22.0\n-25 \t\t -13.0\n-20 \t\t -4.0\n-15 \t\t 5.0\n-10 \t\t 14.0\n-5 \t\t 23.0\n0 \t\t 32.0\n5 \t\t 41.0\n10 \t\t 50.0\n15 \t\t 59.0\n20 \t\t 68.0\n25 \t\t 77.0\n30 \t\t 86.0\n35 \t\t 95.0\n40 \t\t 104.0\n45 \t\t 113.0\n50 \t\t 122.0\n\n***********************\n\n[0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300]\n\n***********************\n\n5050 \t\t 5050\n\n***********************\n\n265252859812191058636308480000000\n\n***********************\n\nFalse\nFalse\nFalse\nFalse\nTrue\nTrue\nFalse\nFalse\nFalse\nTrue\n\n***********************\n\n3339333.9\n";
|
|
|
|
|
var mv = CodeMirror.k_init(id, newData, oldData);
|
|
|
|
|
if (newData == ""){
|
|
|
|
|
$(".CodeMirror-merge-r-chunk").css("background", "none");
|
|
|
|
|
$(".CodeMirror-merge-r-inserted").css("background-image", "none");
|
|
|
|
|
//$(".CodeMirror-merge-copy").find('i').remove();
|
|
|
|
|
}
|
|
|
|
|
var height=0;
|
|
|
|
|
if($("#"+id).find(".CodeMirror-merge-pane").eq(0).height()>$("#"+id).find(".CodeMirror-merge-pane").eq(1).height()){
|
|
|
|
|
height = parseInt($("#"+id).find(".CodeMirror-merge-pane").eq(0).height());
|
|
|
|
|
}else{
|
|
|
|
|
height = parseInt($("#"+id).find(".CodeMirror-merge-pane").eq(1).height());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#"+id).find(".CodeMirror").height(height);
|
|
|
|
|
$(".CodeMirror-merge-gap").css("height", height);
|
|
|
|
|
$(".CodeMirror-merge-gap").find("svg").css("height", height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
// codemirror渲染textarea
|
|
|
|
|
function CodeMirror_fromTextArea(id){
|
|
|
|
|
var Code = CodeMirror.fromTextArea(document.getElementById(id), {
|
|
|
|
|
/* mode: {name: "text/x-c++src",
|
|
|
|
|
// version: 2,
|
|
|
|
|
singleLineStringErrors: false},*/ // 目前补全js是引入的javascript-hint,因此目前不能指定语言
|
|
|
|
|
lineNumbers: true,
|
|
|
|
|
theme: "railscasts",
|
|
|
|
|
// extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
|
|
|
|
|
indentUnit: 4, //代码缩进为一个tab的距离
|
|
|
|
|
matchBrackets: true,
|
|
|
|
|
autoRefresh: true,
|
|
|
|
|
smartIndent: true,//智能换行
|
|
|
|
|
extraKeys: {"Ctrl-Q": "autocomplete"},
|
|
|
|
|
autofocus: true,
|
|
|
|
|
styleActiveLine: true,
|
|
|
|
|
lint: true,
|
|
|
|
|
gutters: ["CodeMirror-linenumbers", "breakpoints"]
|
|
|
|
|
});
|
|
|
|
|
return Code;
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
var control = 0; // 版本库控制 0表示点击放大 1表示点击缩小
|
|
|
|
|
var control_1 = 0; // 测评控制 0表示点击放大 1表示点击缩小
|
|
|
|
|
// 版本库的放大与缩小
|
|
|
|
|
function repository_extend_and_zoom(){
|
|
|
|
|
var nGameRes = $("#games_repository_contents"); // 版本库区域
|
|
|
|
|
var nGameEva = $("#games_valuation_contents"); // 评测区域
|
|
|
|
|
var nRIcon = $("#extend_and_zoom").children("i"); // 版本库放大缩小按钮
|
|
|
|
|
var nCode = $("#file_entry_content").find(".CodeMirror-scroll"); // 版本库代码区域
|
|
|
|
|
var nMove = $(".h-center");
|
|
|
|
|
if(control == 0){
|
|
|
|
|
nGameRes.addClass("-flex-basic100");
|
|
|
|
|
nGameEva.addClass("-flex-basic0");
|
|
|
|
|
nRIcon.addClass("fa-compress");
|
|
|
|
|
nRIcon.removeClass("fa-expand");
|
|
|
|
|
// $("#extend_and_zoom").attr("data-tip-left","收起");
|
|
|
|
|
nMove.hide();
|
|
|
|
|
control = 1;
|
|
|
|
|
}else if(control == 1){
|
|
|
|
|
nGameRes.removeClass("-flex-basic100");
|
|
|
|
|
nGameEva.removeClass("-flex-basic0");
|
|
|
|
|
nRIcon.removeClass("fa-compress");
|
|
|
|
|
nRIcon.addClass("fa-expand");
|
|
|
|
|
// $("#extend_and_zoom").attr("data-tip-left","展开");
|
|
|
|
|
nMove.show();
|
|
|
|
|
control = 0;
|
|
|
|
|
}
|
|
|
|
|
// react环境下没有window['editor_CodeMirror']
|
|
|
|
|
|
|
|
|
|
var newHeight = $("#games_repository_contents").height() - repositoryTabHeight;
|
|
|
|
|
// react add
|
|
|
|
|
$('.CodeMirror.cm-s-railscasts').css("height", newHeight);
|
|
|
|
|
|
|
|
|
|
window['editor_CodeMirror'] && editor_CodeMirror.setSize("auto", "auto");
|
|
|
|
|
|
|
|
|
|
window.refresh_editor_monaco(newHeight)
|
|
|
|
|
|
|
|
|
|
var h = nGameRes.height() - $("#top_repository").height() - repositoryTabHeight;
|
|
|
|
|
nCode.css("min-height", h);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 测评的扩大与缩小
|
|
|
|
|
function valuation_extend_and_zoom(){
|
|
|
|
|
var nGameRes = $("#games_repository_contents"); // 版本库区域
|
|
|
|
|
var nGameEva = $("#games_valuation_contents"); // 评测区域
|
|
|
|
|
var nVIcon = $("#valuation_extend_and_zoom").children("i"); // 评测放大缩小
|
|
|
|
|
var nMove = $(".h-center");
|
|
|
|
|
if(control_1 == 0){
|
|
|
|
|
nGameRes.addClass("-flex-basic0");
|
|
|
|
|
nGameEva.addClass("-flex-basic100");
|
|
|
|
|
nVIcon.removeClass("fa-expand");
|
|
|
|
|
nVIcon.addClass("fa-compress");
|
|
|
|
|
// $("#valuation_extend_and_zoom").attr("data-tip-left","收起");
|
|
|
|
|
nMove.hide();
|
|
|
|
|
control_1 = 1;
|
|
|
|
|
}else if(control_1 == 1){
|
|
|
|
|
nGameRes.removeClass("-flex-basic0");
|
|
|
|
|
nGameEva.removeClass("-flex-basic100");
|
|
|
|
|
nVIcon.addClass("fa-expand");
|
|
|
|
|
nVIcon.removeClass("fa-compress");
|
|
|
|
|
// $("#valuation_extend_and_zoom").attr("data-tip-left","展开");
|
|
|
|
|
nMove.show();
|
|
|
|
|
control_1 = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
// 点赞与取消点赞
|
|
|
|
|
var h = true;
|
|
|
|
|
function game_praise(obj_id, obj_type){
|
|
|
|
|
if(treadStatus){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/praise_tread/praise_plus?obj_id=" + obj_id + "&obj_type=" + obj_type,
|
|
|
|
|
data: {horizontal: h, game_praise: true},
|
|
|
|
|
success:function(data){
|
|
|
|
|
h = !h;
|
|
|
|
|
var praise_count = $("#game_praise_count");
|
|
|
|
|
if(data.praise){
|
|
|
|
|
praiseStatus = true; //已赞
|
|
|
|
|
praise_count.html(data.praise_tread_count);
|
|
|
|
|
$("#game_praise_tread").children("i").addClass("color-orange03");
|
|
|
|
|
$("#game_praise_tread").attr("data-tip-top", "取消点赞")
|
|
|
|
|
}else{
|
|
|
|
|
praiseStatus = false; //取消赞
|
|
|
|
|
praise_count.html(data.praise_tread_count);
|
|
|
|
|
$("#game_praise_tread").children("i").removeClass("color-orange03");
|
|
|
|
|
$("#game_praise_tread").attr("data-tip-top", "点赞")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// 踩/取消踩功能
|
|
|
|
|
var d = true;
|
|
|
|
|
function game_tread(obj_id){
|
|
|
|
|
if(praiseStatus){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/praise_tread/praise_plus?obj_id=" + obj_id + "&obj_type=ChallengeTread",
|
|
|
|
|
data: {horizontal: d, game_praise: true},
|
|
|
|
|
success:function(data){
|
|
|
|
|
d = !d;
|
|
|
|
|
var tread_count = $("#game_tread_count");
|
|
|
|
|
if(data.praise){
|
|
|
|
|
treadStatus = true; // 取消踩
|
|
|
|
|
tread_count.html(data.praise_tread_count);
|
|
|
|
|
$("#game_tread").children("i").addClass("color-orange");
|
|
|
|
|
$("#game_tread").attr("data-tip-top", "取消踩")
|
|
|
|
|
}else{
|
|
|
|
|
treadStatus = false; // 已踩
|
|
|
|
|
tread_count.html(data.praise_tread_count);
|
|
|
|
|
$("#game_tread").children("i").removeClass("color-orange");
|
|
|
|
|
$("#game_tread").attr("data-tip-top", "踩");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
function setupAjaxIndicatorBase() {
|
|
|
|
|
$('#ajax-indicator-base').bind('ajaxSend', function(event, xhr, settings) {
|
|
|
|
|
if(settings && settings.url
|
|
|
|
|
&& (settings.url.match(/account\/heartbeat$/)
|
|
|
|
|
|| settings.url.match(/file_update/)
|
|
|
|
|
|| settings.url.match(/game_build/)
|
|
|
|
|
|| settings.url.match(/game_status/)
|
|
|
|
|
|| settings.url.match(/refresh_game_list/)
|
|
|
|
|
|| settings.url.match(/next_step/)
|
|
|
|
|
|| settings.url.match(/prev_step/)
|
|
|
|
|
|| settings.url.match(/open_webssh/)
|
|
|
|
|
|| settings.url.match(/repository/)
|
|
|
|
|
|| settings.url.match(/get_waiting_time/)
|
|
|
|
|
)){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
|
|
|
|
|
$('#ajax-indicator-base').css("display","flex").html("<embed src='/images/bigdata/loading2.svg' />").show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#ajax-indicator-base').bind('ajaxStop', function() {
|
|
|
|
|
$('#ajax-indicator-base').html("").hide();
|
|
|
|
|
if(MathJax && MathJax.Hub)
|
|
|
|
|
MathJax.Hub.Queue(['Typeset', MathJax.Hub]); //如果是ajax刷新页面的话,手动执行MathJax的公式显示
|
|
|
|
|
try{
|
|
|
|
|
prettyPrint(); //如果刷新出来的页面如果存在代码行的话,也需要美化
|
|
|
|
|
}catch (e){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function match_specific_symbol(str){
|
|
|
|
|
str = str.replace(/ /g, "<span class=\"empty\"></span>").replace(/\r\n$/, "<i class=\"fa fa-level-down color-grey font-16\" aria-hidden=\"true\"></i>").replace(/\n$/, "<i class=\"fa fa-level-down color-grey font-16\" aria-hidden=\"true\"></i>").replace(/\r$/, "<i class=\"fa fa-level-down color-grey font-16\" aria-hidden=\"true\"></i>").replace(/\r\n/g, "<br>").replace(/\n/g, "<br>").replace(/\r/g, "<br>").replace(/\t/g, "<span class=\"tab-key\"><i class=\"fa fa-long-arrow-right color-grey3\" aria-hidden=\"true\"></i></span>")
|
|
|
|
|
return str
|
|
|
|
|
};
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
var panes = 2, highlight = true, connect = null, collapse = false;
|
|
|
|
|
function initUI(id, value, orig1, orig2, dv, panes, highlight, connect, collapse) {
|
|
|
|
|
if (value == null) return;
|
|
|
|
|
var target = document.getElementById(id);
|
|
|
|
|
target.innerHTML = "";
|
|
|
|
|
dv = CodeMirror.MergeView(target, {
|
|
|
|
|
value: value,
|
|
|
|
|
origLeft: panes == 3 && !collapse && !connect ? orig1 : null,
|
|
|
|
|
orig: orig2,
|
|
|
|
|
lineNumbers: true,
|
|
|
|
|
mode: "text/html",
|
|
|
|
|
highlightDifferences: highlight,
|
|
|
|
|
connect: connect,
|
|
|
|
|
collapseIdentical: collapse
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function toggleDifferences() {
|
|
|
|
|
dv.setShowDifferences(highlight = !highlight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mergeViewHeight(mergeView) {
|
|
|
|
|
function editorHeight(editor) {
|
|
|
|
|
if (!editor) return 0;
|
|
|
|
|
return editor.getScrollInfo().height;
|
|
|
|
|
}
|
|
|
|
|
return Math.max(editorHeight(mergeView.leftOriginal()),
|
|
|
|
|
editorHeight(mergeView.editor()),
|
|
|
|
|
editorHeight(mergeView.rightOriginal()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resize(mergeView) {
|
|
|
|
|
var height = mergeViewHeight(mergeView);
|
|
|
|
|
for(;;) {
|
|
|
|
|
if (mergeView.leftOriginal())
|
|
|
|
|
mergeView.leftOriginal().setSize(null, height);
|
|
|
|
|
mergeView.editor().setSize(null, height);
|
|
|
|
|
if (mergeView.rightOriginal())
|
|
|
|
|
mergeView.rightOriginal().setSize(null, height);
|
|
|
|
|
|
|
|
|
|
var newHeight = mergeViewHeight(mergeView);
|
|
|
|
|
if (newHeight >= height) break;
|
|
|
|
|
else height = newHeight;
|
|
|
|
|
}
|
|
|
|
|
mergeView.wrap.style.height = height + "px";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$(document).ready(setupAjaxIndicatorBase);
|
|
|
|
|
// test_sets:测试集;had_test_count:输出集的个数;test_sets_count:测试集的个数;had_passed_testsests_error_count:测试集报错数;test_sets_hidden_count:隐藏测试集的个数
|
|
|
|
|
// test_sets_public_count:公开测试集的个人;had_passed_testsests_hidden_count:通过的隐藏集个数;had_passed_testsests_public_count:通过的公开测试集个数
|
|
|
|
|
// final_score:最终得经验数;gold:最终得的金币数;latest_output:最新的输出;language:实训的语言, power:是否有权限看隐藏测试集, record:最新的一次的评测时间信息, mirror_name镜像名
|
|
|
|
|
function code_evaluation(test_sets,
|
|
|
|
|
had_test_count,
|
|
|
|
|
test_sets_count,
|
|
|
|
|
had_passed_testsests_error_count,
|
|
|
|
|
test_sets_hidden_count,
|
|
|
|
|
test_sets_public_count,
|
|
|
|
|
had_passed_testsests_hidden_count,
|
|
|
|
|
had_passed_testsests_public_count,
|
|
|
|
|
final_score,
|
|
|
|
|
gold,
|
|
|
|
|
latest_output,
|
|
|
|
|
mirror_name,
|
|
|
|
|
power,
|
|
|
|
|
record
|
|
|
|
|
) {
|
|
|
|
|
//动态加载评测区域
|
|
|
|
|
/**
|
|
|
|
|
* Created by wang on 2017/8/9.
|
|
|
|
|
*/
|
|
|
|
|
//test_sets = [HtmlUtil.htmlDecode(test_sets)];
|
|
|
|
|
var $EffectDisplay , $b, $TestResult, $d, $e, $f, $g, $h, $EvaluationInformation , $n, $i;
|
|
|
|
|
// 第一块 效果显示
|
|
|
|
|
$EffectDisplay = "<div id=\"blacktab_con_1\" class=\"\" ></div>";
|
|
|
|
|
$b = "<div class=\"fit -scroll\">" +
|
|
|
|
|
"<div class=\"-layout-v -fit\">" +
|
|
|
|
|
"<div class=\"-flex -scroll task-padding16 loading-center undis\" id=\"html_ajax_loading\"></div>" +
|
|
|
|
|
"<form id=\"html_form\" method=\"post\" target=\"myFrame\">" +
|
|
|
|
|
"<input type=\"hidden\" name=\"contents\" id=\"data_param\" />" +
|
|
|
|
|
"</form>" +
|
|
|
|
|
"<iframe frameborder=\"0\" name=\"myFrame\" style='background: #fff;height: 100%;'>" +
|
|
|
|
|
"</iframe>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>";
|
|
|
|
|
|
|
|
|
|
if (mirror_name.indexOf("Html") != -1) {
|
|
|
|
|
$EffectDisplay = "<div id=\"blacktab_con_1\" class=\"\" >"+$b+"</div>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//第二块 测试结果
|
|
|
|
|
if (had_test_count != "0") {
|
|
|
|
|
var $t = "";
|
|
|
|
|
if(record != "" && record != null && record != undefined){
|
|
|
|
|
$t = " <span class=\"fr mr5 tab_color\">" + "本次评测耗时:" + record + "秒" + "</span>"
|
|
|
|
|
}
|
|
|
|
|
if (had_passed_testsests_error_count == test_sets_count) {
|
|
|
|
|
$d = $t + "<p class=\"color-light-green mb10\">" +
|
|
|
|
|
"<i class=\"fa fa-check-circle font-16\" ></i>" +
|
|
|
|
|
"<span class=\"ml5 mr5\">" + test_sets_count + "/" + test_sets_count + "</span> 全部通过</p>";
|
|
|
|
|
} else {
|
|
|
|
|
$d = $t + "<p class=\"-text-danger mb10\">" +
|
|
|
|
|
"<i class=\"fa fa-exclamation-circle font-16\" ></i>" +
|
|
|
|
|
" <span class=\"ml5 mr5 -text-danger\">" + had_passed_testsests_error_count + '/' + test_sets_count + "</span>" + latest_output + "</p>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var $forHtml = "";
|
|
|
|
|
var $Bear = "";
|
|
|
|
|
for (var i = 0; i < test_sets.length; i++) {
|
|
|
|
|
if (test_sets[i].result == 0) {
|
|
|
|
|
$g = "<i class=\"fa fa-exclamation-circle -text-danger fr mt8 ml5\" ></i>"
|
|
|
|
|
}else if(test_sets[i].result == 1) {
|
|
|
|
|
$g = "<i class=\"fa fa-check-circle color-light-green fr mt8 ml5 font-16\" ></i>"
|
|
|
|
|
}else{
|
|
|
|
|
$g = ""
|
|
|
|
|
}
|
|
|
|
|
if (test_sets[i].is_public == 0) {
|
|
|
|
|
if(power && power != 'false'){
|
|
|
|
|
$g = "<i class=\"fa fa-unlock fr mt8 ml5\" ></i>" + $g
|
|
|
|
|
}else if(test_sets[i].result == 0 || test_sets[i].result == 1){
|
|
|
|
|
$g = "<i class=\"fa fa-lock fr mt8 ml5\" ></i>" + $g
|
|
|
|
|
}else{
|
|
|
|
|
$g = "<i class=\"fa fa-lock fr mt8\" ></i>"
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(test_sets[i].result != 0 && test_sets[i].result != 1){
|
|
|
|
|
$g = undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(test_sets[i].input == null || test_sets[i].input == ""){
|
|
|
|
|
$i = "";
|
|
|
|
|
}else{
|
|
|
|
|
$i = "<div class=\"clearfix df mt5\">" +
|
|
|
|
|
"<span class=\"color-blue fl fb\">测试输入:</span>" +
|
|
|
|
|
"<p class=\"fl\" style='flex:1'>" + ( (test_sets[i].input == null || test_sets[i].input == "") ? "空" : test_sets[i].input.replace(/\r\n/g, "<br>") ) + " </p>" +
|
|
|
|
|
"</div>"
|
|
|
|
|
}
|
|
|
|
|
if ((test_sets[i].is_public == 1 || power == 'true') || (power && power != 'false')) {
|
|
|
|
|
$h = "<div class=\"-task-ces-info\" style=\"display:none\" id=\"test_case_" + i + "\">" +
|
|
|
|
|
$i +
|
|
|
|
|
"<div class='clearfix'><p class='fl with52 color-blue'>预期输出:</p><p class='fl with48 pl5 color-blue' style='box-sizing:border-box'>实际输出:</p></div>"+
|
|
|
|
|
"</div>" +
|
|
|
|
|
"<div id=\"result_different_show_"+ i + "\"></div>";
|
|
|
|
|
}else if(test_sets[i].is_public == 0) {
|
|
|
|
|
$h = "<div class=\"-task-ces-info undis\" id=\"test_case_" + i + "\">" +
|
|
|
|
|
" <ul class=\"font-14\">" +
|
|
|
|
|
" <li class=\"clearfix\">" +
|
|
|
|
|
"<div class=\"clearfix\">" +
|
|
|
|
|
"<p class=\"fl color-orange\" style=\"margin-left: 34px;\">此为隐藏测试项,<a href=\"javascript:void()\", class=\"color_white test_set_data\" style=\"text-decoration: underline;\">解锁</a></p>" +
|
|
|
|
|
" </div>" +
|
|
|
|
|
"</li>" +
|
|
|
|
|
" </ul>" +
|
|
|
|
|
"</div>";
|
|
|
|
|
}
|
|
|
|
|
$e = "<div class=\"-task-ces-box mb15 clearfix\">"+$h+"</div>";
|
|
|
|
|
// actual_output 正则匹配的目的: 因为字符串拼接\r\n时,会转义导致js截成2断报错.因此需要编码
|
|
|
|
|
var base64 = new Base64();
|
|
|
|
|
var actual_output = test_sets[i].actual_output == null ? "" : base64.encode(test_sets[i].actual_output);
|
|
|
|
|
var output = test_sets[i].output == null ? "" : base64.encode(test_sets[i].output);
|
|
|
|
|
$f = "<div class=\"-task-ces-top clearfix\" onclick='toggle_test_case(" + test_sets[i].is_public + "," + '"' + output+ '"' + "," + '"' + actual_output + '"' + "," + i + "," + power + ")' style=\"cursor:pointer\">" +
|
|
|
|
|
"<i class=\"fa fa-caret-right mr5 font-16\" ></i>" +
|
|
|
|
|
"<span class=\"font-14\">测试集 " + (i + 1) + "</span>" + ($g == undefined ? "" : $g)+"</div>";
|
|
|
|
|
|
|
|
|
|
$forHtml = $f + $e;
|
|
|
|
|
$Bear += $forHtml;
|
|
|
|
|
}
|
|
|
|
|
$TestResult = "<div id=\"blacktab_con_2\" class=\" " + (mirror_name.indexOf("Html") != -1 ? 'undis' : '') + "\">" +
|
|
|
|
|
"<div class=\"fit -scroll\">" +
|
|
|
|
|
"<div class=\"-layout-v -fit\">" +
|
|
|
|
|
"<div class=\"-flex -scroll task-padding16 loading-center undis\" id=\"evaluating_ajax_loading\"></div>" +
|
|
|
|
|
"<div class=\"-flex -scroll task-padding16\" id=\"evaluating_contents\">" + ($d == undefined ? "" : $d) + $Bear + "</div>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>";
|
|
|
|
|
|
|
|
|
|
//第三块 评测信息
|
|
|
|
|
if (had_test_count != "0") {
|
|
|
|
|
if (had_passed_testsests_error_count == test_sets_count) {
|
|
|
|
|
$n = "<p class=\"color-light-green mb10\">" +
|
|
|
|
|
"<i class=\"fa fa-check-circle font-16 \" ></i>" +
|
|
|
|
|
"<span class=\"ml5 mr5\">" + test_sets_count + "/" + test_sets_count + "</span> 全部通过</p>";
|
|
|
|
|
} else {
|
|
|
|
|
$n = "<p class=\"-text-danger mb10\">" +
|
|
|
|
|
"<i class=\"fa fa-exclamation-circle font-16\" ></i>" +
|
|
|
|
|
"<span class=\"ml5 mr5 -text-danger\">" + had_passed_testsests_error_count + "/" + test_sets_count + "</span> " + latest_output + "</p>";
|
|
|
|
|
}
|
|
|
|
|
// $("#evaluating_info").html($n);
|
|
|
|
|
}
|
|
|
|
|
$EvaluationInformation = "<div id=\"blacktab_con_3\" class=\"undis\" >" +
|
|
|
|
|
"<div class=\"fit -scroll\">" +
|
|
|
|
|
"<div class=\"-layout-v -fit\">" +
|
|
|
|
|
"<div class=\"-flex -scroll task-padding16 loading-center undis\" id=\"info_ajax_loading\"></div>" +
|
|
|
|
|
"<div class=\"-flex -scroll task-padding16\" id=\"evaluating_info\">" + ($n == undefined ? "" : $n)+"<div class=\"-task-ces-box mb10 clearfix\">" +
|
|
|
|
|
"<div class=\"-task-ces-info\">" +
|
|
|
|
|
"<ul>" +
|
|
|
|
|
"<li>" +
|
|
|
|
|
"<span class=\"-task-ces-info-left \">公开测试:</span>" +
|
|
|
|
|
"<span class=\"color-light-green\">" + had_passed_testsests_public_count + "/" + test_sets_public_count + "</span>" +
|
|
|
|
|
"</li>" +
|
|
|
|
|
"<li>" +
|
|
|
|
|
"<span class=\"-task-ces-info-left\"> 隐藏测试:</span>" +
|
|
|
|
|
"<span class=\"color-light-green\">" + had_passed_testsests_hidden_count + "/" + test_sets_hidden_count + "</span>" +
|
|
|
|
|
"</li>" +
|
|
|
|
|
"<li>" +
|
|
|
|
|
"<span class=\"-task-ces-info-left\"> 经验值:</span>" +
|
|
|
|
|
"<span class=\"color-light-green\" id=\"experience_value\">+ " + final_score + " </span>" +
|
|
|
|
|
"</li>" +
|
|
|
|
|
"<li>" +
|
|
|
|
|
"<span class=\"-task-ces-info-left\">金币:</span>" +
|
|
|
|
|
"<span class=\""+ (gold >= 0 ? "color-light-green" : "-text-danger") + "\"" +"id=\"grade_value\">" + (gold >= 0 ? ("+ " + gold) : gold) + "</span>" +
|
|
|
|
|
"</li>" +
|
|
|
|
|
"</ul>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>" +
|
|
|
|
|
"</div>";
|
|
|
|
|
|
|
|
|
|
var $html = $EffectDisplay + $TestResult + $EvaluationInformation;
|
|
|
|
|
$("#game_test_set_results").html($html);
|
|
|
|
|
}
|
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $.ajax({
|
|
|
|
|
// url: "http://localhost:3000/api/v1/games/zl6kx8f7vfpo",
|
|
|
|
|
|
|
|
|
|
// // The name of the callback parameter, as specified by the YQL service
|
|
|
|
|
// jsonp: "callback",
|
|
|
|
|
|
|
|
|
|
// // Tell jQuery we're expecting JSONP
|
|
|
|
|
// // dataType: "jsonp",
|
|
|
|
|
|
|
|
|
|
// // Tell YQL what we want and that we want JSON
|
|
|
|
|
// data: {
|
|
|
|
|
// // q: "select title,abstract,url from search.news where query=\"cat\"",
|
|
|
|
|
// format: "json"
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
// // Work with the response
|
|
|
|
|
// success: function( response ) {
|
|
|
|
|
// console.log( response ); // server response
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// ---------------------------------------------------------------------------------edu_tpi.js START
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------- application.js
|
|
|
|
|
//自动保存草稿
|
|
|
|
|
var editor2;
|
|
|
|
|
function elocalStorage(editor,mdu,id){
|
|
|
|
|
if (window.sessionStorage){
|
|
|
|
|
editor2 = editor;
|
|
|
|
|
var oc = window.sessionStorage.getItem('content'+mdu);
|
|
|
|
|
if(oc !== null ){
|
|
|
|
|
var h = '您上次有已保存的数据,是否<a style="cursor: pointer;" class="color-orange05" onclick="rec_data(\'content\',\''+ mdu + '\',\'' + id + '\')">恢复</a> ? / <a style="cursor: pointer;" class="color-orange05" onclick="clear_data(\'content\',\''+ mdu + '\',\'' + id + '\')">不恢复</a>';
|
|
|
|
|
$("#e_tips_"+id).html(h);
|
|
|
|
|
}
|
|
|
|
|
setInterval(function() {
|
|
|
|
|
d = new Date();
|
|
|
|
|
var h = d.getHours();
|
|
|
|
|
var m = d.getMinutes();
|
|
|
|
|
var s = d.getSeconds();
|
|
|
|
|
h = h < 10 ? '0' + h : h;
|
|
|
|
|
m = m < 10 ? '0' + m : m;
|
|
|
|
|
s = s < 10 ? '0' + s : s;
|
|
|
|
|
editor.sync();
|
|
|
|
|
if(!editor.isEmpty()){
|
|
|
|
|
add_data("content",mdu,editor.html());
|
|
|
|
|
var id1 = "#e_tip_"+id;
|
|
|
|
|
var id2 = "#e_tips_"+id;
|
|
|
|
|
$(id1).html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 ");
|
|
|
|
|
$(id2).html("");
|
|
|
|
|
}
|
|
|
|
|
},10000);
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
$('.ke-edit').after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add_data(k,mdu,d){
|
|
|
|
|
window.sessionStorage.setItem(k+mdu,d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 公共弹框样式
|
|
|
|
|
// 建议左右栏的:Width:460,Height:190
|
|
|
|
|
// 建议宽屏对应值:Width:760,Height:500
|
|
|
|
|
function pop_box_new(value, Width, Height){
|
|
|
|
|
if($("#popupAll").length > 0){
|
|
|
|
|
$("#popupAll").remove();
|
|
|
|
|
}
|
|
|
|
|
w = ($(window).width() - Width)/2;
|
|
|
|
|
h = ($(window).height() - Height)/2;
|
|
|
|
|
var html="<div class=\"popupAll none\" id='popupAll'><div class=\"pr\"><div id=\"popupWrap\"></div></div></div>";
|
|
|
|
|
$(document.body).append(html);
|
|
|
|
|
$("#popupWrap").html(value);
|
|
|
|
|
$('#popupWrap').css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed","z-index":"99999","background-color":"#fff","border-radius":"10px"});
|
|
|
|
|
$("#popupWrap").parent().parent().show();
|
|
|
|
|
$('#popupWrap').find("a[class*='pop_close']").click(function(){
|
|
|
|
|
$("#popupAll").hide();
|
|
|
|
|
});
|
|
|
|
|
// w = ($(window).width() - Width)/2;
|
|
|
|
|
// h = ($(window).height() - Height)/2;
|
|
|
|
|
// $("#ajax-modal").html(value);
|
|
|
|
|
// showModal('ajax-modal', Width + 'px');
|
|
|
|
|
// $('#ajax-modal').siblings().remove();
|
|
|
|
|
// $('#ajax-modal').parent().css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed"});
|
|
|
|
|
// $('#ajax-modal').parent().removeClass("resourceUploadPopup popbox_polls popbox");
|
|
|
|
|
// $('#ajax-modal').css({"padding":"0","overflow":"hidden"});
|
|
|
|
|
// $('#ajax-modal').parent().attr("id","popupWrap");
|
|
|
|
|
|
|
|
|
|
//拖拽
|
|
|
|
|
function Drag(id) {
|
|
|
|
|
this.div = document.getElementById(id);
|
|
|
|
|
if (this.div) {
|
|
|
|
|
this.div.style.cursor = "move";
|
|
|
|
|
this.div.style.position = "fixed";
|
|
|
|
|
}
|
|
|
|
|
this.disX = 0;
|
|
|
|
|
this.disY = 0;
|
|
|
|
|
var _this = this;
|
|
|
|
|
this.div.onmousedown = function (evt) {
|
|
|
|
|
_this.getDistance(evt);
|
|
|
|
|
document.onmousemove = function (evt) {
|
|
|
|
|
_this.setPosition(evt);
|
|
|
|
|
};
|
|
|
|
|
_this.div.onmouseup = function () {
|
|
|
|
|
_this.clearEvent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Drag.prototype.getDistance = function (evt) {
|
|
|
|
|
var oEvent = evt || event;
|
|
|
|
|
this.disX = oEvent.clientX - this.div.offsetLeft;
|
|
|
|
|
this.disY = oEvent.clientY - this.div.offsetTop;
|
|
|
|
|
};
|
|
|
|
|
Drag.prototype.setPosition = function (evt) {
|
|
|
|
|
var oEvent = evt || event;
|
|
|
|
|
var l = oEvent.clientX - this.disX;
|
|
|
|
|
var t = oEvent.clientY - this.disY;
|
|
|
|
|
if (l <= 0) {
|
|
|
|
|
l = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (l >= document.documentElement.clientWidth - this.div.offsetWidth) {
|
|
|
|
|
l = document.documentElement.clientWidth - this.div.offsetWidth;
|
|
|
|
|
}
|
|
|
|
|
if (t <= 0) {
|
|
|
|
|
t = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (t >= document.documentElement.clientHeight - this.div.offsetHeight) {
|
|
|
|
|
t = document.documentElement.clientHeight - this.div.offsetHeight;
|
|
|
|
|
}
|
|
|
|
|
this.div.style.left = l + "px";
|
|
|
|
|
this.div.style.top = t + "px";
|
|
|
|
|
};
|
|
|
|
|
Drag.prototype.clearEvent = function () {
|
|
|
|
|
this.div.onmouseup = null;
|
|
|
|
|
document.onmousemove = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
new Drag("popupWrap");
|
|
|
|
|
|
|
|
|
|
$("#popupWrap input, #popupWrap textarea, #popupWrap ul, #popupWrap a").mousedown(function(event){
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
new Drag("popupWrap");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function sure_box_redirect_btn(url, str,btnstr){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-OK clearfix">'+
|
|
|
|
|
'<a href="'+ url +'" class="task-btn task-btn-orange" onclick="hideModal();" target="_blank">'+btnstr+'</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 480, 160);
|
|
|
|
|
}
|
|
|
|
|
function sure_box_redirect_btn2(url, str, btnstr){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:500px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3> <a href="javascript:void(0)" id="closeIcon" style="top: -48px;right: -20px;z-index: 100000;"><i class="iconfont icon-shanchudiao"></i></a></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-submit clearfix" style="width: 150px"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
|
|
|
|
|
'<a href="'+ url +'" class="task-btn task-btn-orange fr" target="_blank" onclick="hideModal();">'+btnstr+'</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 578, 205);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function op_confirm_box_loading(url, str){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:578px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3> <a href="javascript:void(0)" id="closeIcon" style="top: -48px;right: -20px;z-index: 100000;"><i class="iconfont icon-shanchudiao"></i></a></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16 pt15">' + str + '</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
|
|
|
|
|
'<a href="'+ url +'" class="task-btn task-btn-orange fr" onclick="hideModal();$(\'.loading_all\').show();">确定</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 578, 205);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//点击删除时的确认弹框: 走destroy方法,remote为true
|
|
|
|
|
function delete_confirm_box_2(url, str){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3> <a href="javascript:void(0)" id="closeIcon" style="top: -48px;right: -20px;z-index: 100000;"><i class="iconfont icon-shanchudiao"></i></a></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
|
|
|
|
|
'<a href="'+ url +'" class="task-btn task-btn-orange fr pop_close" data-method="delete" data-remote="true">确定</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 480, 160);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//提示框:只有一个确定按钮,点击关闭弹框
|
|
|
|
|
//<a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>
|
|
|
|
|
function notice_box(str){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-sure clearfix">'+
|
|
|
|
|
'<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="hideModal();">确定</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 480, 160);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 长提示框:只有一个确定按钮,点击关闭弹框
|
|
|
|
|
function long_notice_box(str){
|
|
|
|
|
var htmlvalue = '<div id="muban_popup_box" style="width:380px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
|
|
|
|
'<div class="clear mt15"><p class="text_c f14">' + str + '</p><div class="cl"></div>'+
|
|
|
|
|
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10 mr10" onclick="hideModal();" style="margin-right: 164px;">确定</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 380, 140);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function hideModal(el) {
|
|
|
|
|
if($("#popupAll").length > 0){
|
|
|
|
|
$("#popupAll").remove();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
var modal;
|
|
|
|
|
if (el) {
|
|
|
|
|
modal = $(el).parents('.ui-dialog-content');
|
|
|
|
|
} else {
|
|
|
|
|
modal = $('#ajax-modal');
|
|
|
|
|
}
|
|
|
|
|
modal.dialog("close");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
function is_cdn_link(contents){
|
|
|
|
|
if(contents.indexOf("http") != -1
|
|
|
|
|
|| contents.indexOf("com") != -1
|
|
|
|
|
|| contents.indexOf("net") != -1
|
|
|
|
|
|| contents.indexOf("org") != -1
|
|
|
|
|
|| contents.indexOf("cdn") != -1){
|
|
|
|
|
return true;
|
|
|
|
|
}else{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 渲染用户的HTML的CODE。
|
|
|
|
|
function tpi_html_show(newCode){
|
|
|
|
|
//$($(".blacktab_con")[0]).trigger("click");
|
|
|
|
|
var contents = newCode;
|
|
|
|
|
var $htmlForm = $("#html_form");
|
|
|
|
|
var src = contents;
|
|
|
|
|
var arrCSS =[];
|
|
|
|
|
var arrSript = [];
|
|
|
|
|
var patternLink = /<link(?:.*?)href=[\"\‘](.+?)[\"\‘](?!<)(?:.*)\>(?:[\n\r\s]*?)(?:<\/link>)*/im;
|
|
|
|
|
var patternScript = /<script(?:.*?)src=[\"\‘](.+?)[\"\‘](?!<)(?:.*)\>(?:[\n\r\s]*?)(?:<\/script>)*/im;
|
|
|
|
|
var arrayMatchesLink = patternLink.exec(src);
|
|
|
|
|
var arrayMatchesScript = patternScript.exec(src);
|
|
|
|
|
|
|
|
|
|
// css部分
|
|
|
|
|
while(arrayMatchesLink != null){
|
|
|
|
|
if(is_cdn_link(arrayMatchesLink[1])){
|
|
|
|
|
src = src.replace(arrayMatchesLink[0], arrayMatchesLink[0].replace(/link/, "edulink"));
|
|
|
|
|
}else{
|
|
|
|
|
src = src.replace(patternLink, "EDUCODERCSS");
|
|
|
|
|
arrCSS.push(arrayMatchesLink[1]);
|
|
|
|
|
}
|
|
|
|
|
arrayMatchesLink = patternLink.exec(src);
|
|
|
|
|
}
|
|
|
|
|
// js部分
|
|
|
|
|
while(arrayMatchesScript != null){
|
|
|
|
|
if(is_cdn_link(arrayMatchesScript[1])){
|
|
|
|
|
src = src.replace(arrayMatchesScript[0], arrayMatchesScript[0].replace(/script/g,"w3scrw3ipttag"));
|
|
|
|
|
}else{
|
|
|
|
|
src = src.replace(patternScript, "EDUCODERJS");
|
|
|
|
|
arrSript.push(arrayMatchesScript[1]);
|
|
|
|
|
}
|
|
|
|
|
arrayMatchesScript = patternScript.exec(src);
|
|
|
|
|
}
|
|
|
|
|
// html部分 为了防止xss攻击,先将敏感字符转换
|
|
|
|
|
src = src.replace(/=/gi,"w3equalsign").replace(/script/gi,"w3scrw3ipttag");
|
|
|
|
|
|
|
|
|
|
$("#data_param").val(src);
|
|
|
|
|
$("#data_css_param").val(arrCSS);
|
|
|
|
|
$("#data_js_param").val(arrSript);
|
|
|
|
|
// $htmlForm.attr("action", "/iframes/html_content?gpid="+ __myshixun.gpid );
|
|
|
|
|
$htmlForm.submit();
|
|
|
|
|
}
|
|
|
|
|
// 渲染用户的HTML的CODE。--------------------------------------------END
|
|
|
|
|
|
|
|
|
|
//提示框:只有一个知道啦按钮,点击打开新窗口
|
|
|
|
|
//<a href="'+ url +'" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>
|
|
|
|
|
function sure_box_redirect(url, str){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-OK clearfix">'+
|
|
|
|
|
'<a href="'+ url +'" class="task-btn task-btn-orange" onclick="hideModal();" target="_blank">知道啦</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 480, 160);
|
|
|
|
|
}
|
|
|
|
|
// 长提示框:只有一个“知道啦”按钮,点击关闭弹框
|
|
|
|
|
//<a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>
|
|
|
|
|
function yes_notice_box(str){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:575px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-OK clearfix">'+
|
|
|
|
|
'<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="hideModal();">知道啦</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 575, 200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------- --------------------- --------------------- --------------------- START
|
|
|
|
|
function notice_sure_box(str){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3></div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-OK clearfix">'+
|
|
|
|
|
'<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="hideModal();">知道啦</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 480, 160);
|
|
|
|
|
}
|
|
|
|
|
//点击删除时的确认弹框: 走destroy方法,remote为true
|
|
|
|
|
function delete_confirm_box_2_react(url, str, data){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix">提示</div>'+
|
|
|
|
|
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="clearfix edu-txt-center mb20 mt10"><div class="inline"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
|
|
|
|
|
'<a href="javascript:void(0)" onclick="window._triggerEvent(\'' + url +'\', \'' + encodeURIComponent(JSON.stringify(data)) + '\', $(\'body>#root\')[0])" class="task-btn task-btn-orange pop_close ml20" >确定</a></div></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, 480, 160);
|
|
|
|
|
// encodeURIComponent(JSON.stringify(data))
|
|
|
|
|
// "$(window.top).trigger(\'' + url +'\', \'' + url + '\')"
|
|
|
|
|
}
|
|
|
|
|
// https://github.com/facebook/react/issues/3249#issuecomment-177750141
|
|
|
|
|
function _triggerEvent(eventName, data, target) {
|
|
|
|
|
var event = document.createEvent("HTMLEvents");
|
|
|
|
|
event.initEvent(eventName, true, true);
|
|
|
|
|
var target = target || document;
|
|
|
|
|
// $('body>#root').data(eventName, data)
|
|
|
|
|
window[eventName] = data;
|
|
|
|
|
target.dispatchEvent(event);
|
|
|
|
|
|
|
|
|
|
hideModal();
|
|
|
|
|
}
|
|
|
|
|
// --------------------- --------------------- --------------------- --------------------- END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
|
$(function(){ // 这里重新加一次事件监听,不在原有事件的基础上增加代码了
|
|
|
|
|
var doc = $(document);
|
|
|
|
|
var lab = $(".b-label");
|
|
|
|
|
var cen = $(".h-center");
|
|
|
|
|
var dragDom;
|
|
|
|
|
var dragging = false;
|
|
|
|
|
lab.live('mousedown',function(){
|
|
|
|
|
dragging = true;
|
|
|
|
|
dragDom = lab;
|
|
|
|
|
$('#htmlIframe').css('pointer-events', 'none')
|
|
|
|
|
$('#can-drag').show()
|
|
|
|
|
lab.hide()
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
cen.live('mousedown',function(){
|
|
|
|
|
dragging = true;
|
|
|
|
|
dragDom = cen;
|
|
|
|
|
// 使得iframe不捕获事件
|
|
|
|
|
$('#htmlIframe').css('pointer-events', 'none')
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
doc.live("mousemove", function(e) {
|
|
|
|
|
if (dragging === true && lab == dragDom) {
|
|
|
|
|
window._tpiWidthResize && window._tpiWidthResize()
|
|
|
|
|
// React 组件中需要resize,搜索该引用可以找到初始化的位置
|
|
|
|
|
window._currentChildcommentMDEditor && window._currentChildcommentMDEditor.resize()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
doc.live("mouseup", function(e) {
|
|
|
|
|
lab.show()
|
|
|
|
|
// 在大窗口将下边测试集滚动条拖上去后,将窗口缩小,再拖下来就有这种情况 https://www.trustie.net/issues/16326
|
|
|
|
|
if (dragging === true) {
|
|
|
|
|
$('#can-drag').hide()
|
|
|
|
|
|
|
|
|
|
window.editor_CodeMirror && window.editor_CodeMirror.refresh()
|
|
|
|
|
|
|
|
|
|
// 使得iframe可以继续捕获事件
|
|
|
|
|
$('#htmlIframe').css('pointer-events', 'inherit')
|
|
|
|
|
}
|
|
|
|
|
dragging = false;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* 评论使用的mdeditor初始化
|
|
|
|
|
* @param id 渲染DOM的id
|
|
|
|
|
* @param width 宽度
|
|
|
|
|
* @param high 高度
|
|
|
|
|
* @param placeholder
|
|
|
|
|
* @param imageUrl 上传图片的url
|
|
|
|
|
* @returns {*} 返回一个editorMD实例
|
|
|
|
|
*/
|
|
|
|
|
var _path = "/editormd/lib/"
|
|
|
|
|
var _isDev = window.location.port === "3007";
|
|
|
|
|
if (_isDev) {
|
|
|
|
|
_path = 'http://localhost:3000/editormd/lib/'
|
|
|
|
|
}
|
|
|
|
|
function create_editorMD_4comment(id, width, high, placeholder, imageUrl, callback, otherOptions){
|
|
|
|
|
var editorName = window.editormd(id, Object.assign({
|
|
|
|
|
width : width,
|
|
|
|
|
height : high,
|
|
|
|
|
syncScrolling : "single",
|
|
|
|
|
//你的lib目录的路径,我这边用JSP做测试的
|
|
|
|
|
path : _path , // "/editormd/lib/"
|
|
|
|
|
markdown: '',
|
|
|
|
|
tex : true,
|
|
|
|
|
tocm : true,
|
|
|
|
|
emoji : true,
|
|
|
|
|
taskList : true,
|
|
|
|
|
codeFold : true,
|
|
|
|
|
searchReplace : true,
|
|
|
|
|
htmlDecode : "style,script,iframe",
|
|
|
|
|
sequenceDiagram : true,
|
|
|
|
|
autoFocus: false,
|
|
|
|
|
toolbarIcons : function() {
|
|
|
|
|
// Or return editormd.toolbarModes[name]; // full, simple, mini
|
|
|
|
|
// Using "||" set icons align right.
|
|
|
|
|
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|"
|
|
|
|
|
, "testIcon", "testIcon1", '|', "emoji", "image", "table", '|', "watch", "clear" ]
|
|
|
|
|
},
|
|
|
|
|
toolbarCustomIcons : {
|
|
|
|
|
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
|
|
|
|
|
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
|
|
|
|
|
},
|
|
|
|
|
//这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
|
|
|
|
|
saveHTMLToTextarea : true,
|
|
|
|
|
// 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
|
|
|
|
|
dialogMaskOpacity : 0.6,
|
|
|
|
|
placeholder: placeholder,
|
|
|
|
|
imageUpload : true,
|
|
|
|
|
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
|
|
|
|
|
imageUploadURL : imageUrl,//url
|
|
|
|
|
onload: function(){
|
|
|
|
|
// this.previewing();
|
|
|
|
|
$("#"+ id +" [type=\"latex\"]").bind("click", function(){
|
|
|
|
|
editorName.cm.replaceSelection("```latex");
|
|
|
|
|
editorName.cm.replaceSelection("\n");
|
|
|
|
|
editorName.cm.replaceSelection("\n");
|
|
|
|
|
editorName.cm.replaceSelection("```");
|
|
|
|
|
var __Cursor = editorName.cm.getDoc().getCursor();
|
|
|
|
|
editorName.cm.setCursor(__Cursor.line-1, 0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#"+ id +" [type=\"inline\"]").bind("click", function(){
|
|
|
|
|
editorName.cm.replaceSelection("$$$$");
|
|
|
|
|
var __Cursor = editorName.cm.getDoc().getCursor();
|
|
|
|
|
editorName.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
|
|
|
|
editorName.cm.focus();
|
|
|
|
|
});
|
|
|
|
|
$("[type=\"inline\"]").attr("title", "行内公式");
|
|
|
|
|
$("[type=\"latex\"]").attr("title", "多行公式");
|
|
|
|
|
|
|
|
|
|
callback && callback()
|
|
|
|
|
}
|
|
|
|
|
}, otherOptions));
|
|
|
|
|
return editorName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
|
// md编辑器拖拽改变高度,TODO其他初始化参数,高度改变阈值...
|
|
|
|
|
// 写这里,供非react版本时copy一份用
|
|
|
|
|
function initMDEditorDragResize(resizeBarSelector, mdEditor, options) {
|
|
|
|
|
if (!options) {
|
|
|
|
|
options = {}
|
|
|
|
|
}
|
|
|
|
|
if($('#'+ mdEditor.id).length === 0) {
|
|
|
|
|
console.error('未找到editor')
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var doc = $(document);
|
|
|
|
|
var editor__resize = $('#'+ mdEditor.id).parent().find(resizeBarSelector);
|
|
|
|
|
if (editor__resize.length === 0) {
|
|
|
|
|
console.error('未找到resizeBar')
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var dragging = false;
|
|
|
|
|
var topOffset, clickY, initDelta;
|
|
|
|
|
var initHeight = options.initHeight || 240;
|
|
|
|
|
|
|
|
|
|
editor__resize.on('mousedown',function(){
|
|
|
|
|
dragging = true;
|
|
|
|
|
topOffset = editor__resize.offset().top;
|
|
|
|
|
initDelta = $('#' + mdEditor.id).height() - initHeight;
|
|
|
|
|
});
|
|
|
|
|
doc.live('mousemove', function(e){
|
|
|
|
|
if(dragging){
|
|
|
|
|
clickY = e.pageY;
|
|
|
|
|
|
|
|
|
|
var delta = clickY - topOffset + initDelta;
|
|
|
|
|
if (delta > 300 ) {
|
|
|
|
|
delta = 300;
|
|
|
|
|
}
|
|
|
|
|
if (delta < 0) {
|
|
|
|
|
delta = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mdEditor.resize('', (initHeight + delta) + 'px')
|
|
|
|
|
|
|
|
|
|
// $('#memo_comment_editorMd').height(initHeight + delta)
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
doc.live("mouseup", function(e) {
|
|
|
|
|
dragging = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算文本宽度 https://stackoverflow.com/questions/1582534/calculating-text-width
|
|
|
|
|
function _textWidth(text, font) {
|
|
|
|
|
if (!window._fakeEl) window._fakeEl = $('<span>').hide().appendTo(document.body);
|
|
|
|
|
window._fakeEl.text(typeof text == 'object' ? text.val() || text.text() : text ).css('font', font || text.css('font'));
|
|
|
|
|
return window._fakeEl.width();
|
|
|
|
|
}
|
|
|
|
|
|