mirror of
https://github.com/UnickSoft/graphonline.git
synced 2025-07-04 00:36:45 +00:00
2 lines
5.4 KiB
JavaScript
Executable File
2 lines
5.4 KiB
JavaScript
Executable File
(function(){CKEDITOR.plugins.add("mrmonkey",{icons:"togglemrmonkey,mrmonkeysettings",init:function(d){var g={pasteLoremIpsumInterval:1000*2,typeRandomInterval:1000*2,selectionChangeInterval:1000*2,pasteLoremIpsum:false,typeRandom:true,selectionChange:true,typeRandomMaxKeyStrokesAtOnce:10,typeRandomKeyStrokeInterval:1000,pasteLoremIpsumBlockSize:200,typeRandomKeys:[13,32,"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],pasteLoremIpsumText:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel scelerisque nunc. Integer condimentum quam ut velit lobortis at tincidunt felis viverra. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque auctor mauris sed urna dictum fringilla. Donec vel egestas quam. Maecenas faucibus pulvinar ante vitae imperdiet. Sed a augue ac nisl volutpat mattis eu a nisl. Mauris consectetur suscipit neque, eu fermentum elit sollicitudin eu.\nProin porttitor fermentum tincidunt. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec sapien ipsum, feugiat eget ornare ac, facilisis et nulla. Donec vel ante diam. Ut dui est, consequat eu placerat ut, varius et tortor. Vivamus dictum eros ac ante aliquet ut bibendum libero egestas. Vivamus accumsan dignissim accumsan.\nPellentesque consectetur tellus quis orci ultrices vitae lacinia risus lacinia. Vestibulum gravida mi rhoncus dolor porta aliquet. Phasellus nec vulputate dolor. Sed in massa ac massa blandit imperdiet. Vestibulum mollis rhoncus rhoncus. Integer turpis ligula, condimentum venenatis rhoncus non, vestibulum a velit. Pellentesque nulla ipsum, convallis at cursus non, pharetra eget dolor. Proin suscipit urna tempus erat eleifend non consequat augue fringilla. Nam at imperdiet neque. Donec vulputate, leo quis posuere varius, est ipsum congue mi, in suscipit urna nulla sit amet tellus. Donec ut libero velit. Ut et massa lectus. Integer pretium commodo nulla a mollis."};var c={};if((typeof(Storage)!=="undefined")&&localStorage.mrMonkeySettings){c=JSON.parse(localStorage.mrMonkeySettings)}CKEDITOR.tools.extend(CKEDITOR.editor.prototype,{getMrMonkeySettings:function(){return CKEDITOR.tools.extend(CKEDITOR.tools.extend(CKEDITOR.tools.extend({},c),d.config.mrmonkey||{}),g)},getMrMonkeySetting:function(h){if(c[h]!==undefined){return c[h]}else{if(d.config.mrmonkey&&(d.config.mrmonkey[h]!=undefined)){return d.config.mrmonkey[h]}else{return g[h]}}},setMrMonkeySetting:function(h,i){c[h]=i},setMrMonkeySettings:function(h){c=h;if(typeof(Storage)!=="undefined"){localStorage.mrMonkeySettings=JSON.stringify(c)}},isMrMonkeyRunning:function(){return this.getCommand("toggleMrMonkey").state==CKEDITOR.TRISTATE_ON}});function e(h){CKEDITOR.tools.setTimeout(function(){if(h.isMrMonkeyRunning()){h.fire("mrmonkey:pasteLoremIpsum")}},h.getMrMonkeySetting("pasteLoremIpsumInterval"))}function a(h){CKEDITOR.tools.setTimeout(function(){if(h.isMrMonkeyRunning()){h.fire("mrmonkey:randomTyping")}},h.getMrMonkeySetting("typeRandomInterval"))}function b(h){CKEDITOR.tools.setTimeout(function(){if(h.isMrMonkeyRunning()){h.fire("mrmonkey:changeSelection")}},h.getMrMonkeySetting("selectionChangeInterval"))}d.on("mrmonkey:randomTyping",function(i){var h=Math.round(Math.random()*d.getMrMonkeySetting("typeRandomMaxKeyStrokesAtOnce"));var j=0;while(h>=0){j+=Math.round(Math.random()*d.getMrMonkeySetting("typeRandomKeyStrokeInterval"));CKEDITOR.tools.setTimeout(function(){var n=d.getSelection();if(n&&(n.getRanges().length>0)){var o=d.getMrMonkeySetting("typeRandomKeys");var k=o.length-1;var l=Math.round(Math.random()*k);var m=o[l];var p=null;if((typeof m)=="number"){p=m}else{p=m.charCodeAt(0)}d.fire("key",{keyCode:p});d.insertHtml(String.fromCharCode(p))}else{d.fire("mrmonkey:changeSelection")}},j);h--}a(i.editor)});d.on("mrmonkey:pasteLoremIpsum",function(k){var j=d.getMrMonkeySetting("pasteLoremIpsumText");var m=j.length;var i=d.getMrMonkeySetting("pasteLoremIpsumBlockSize");var h=Math.round((Math.random()*i)+1);var n=Math.round(Math.random()*(m-h)-1);var l=j.substring(n,n+h);d.fire("beforePaste",{type:"auto"});d.fire("paste",{type:"auto",dataValue:l});e(k.editor)});d.on("mrmonkey:changeSelection",function(m){function o(q){var p=q.getChildren();if(p.count()==0){return q}else{var r=p.getItem(Math.round(Math.random()*(p.count()-1)));if(r.type==CKEDITOR.NODE_ELEMENT){return o(r)}else{return r}}}var n=(d.getMrMonkeySetting("selectRanges"));var l=d.getSelection();var i=new CKEDITOR.dom.range(d.document);var k=o(d.document.getBody());if(k.type==CKEDITOR.NODE_TEXT){var h=k.getLength();var j=Math.round(Math.random()*(h-1));i.setStart(k,j);i.setEnd(k,j)}else{i.selectNodeContents(k)}l.selectRanges([i]);b(m.editor)});CKEDITOR.dialog.add("myMonkeySettingsDialog",this.path+"dialogs/settings.js");var f=new CKEDITOR.command(d,{exec:function(h){this.toggleState();if(h.isMrMonkeyRunning()){if(h.getMrMonkeySetting("pasteLoremIpsum")){e(h)}if(h.getMrMonkeySetting("typeRandom")){a(h)}if(h.getMrMonkeySetting("selectionChange")){b(h)}}}});d.addCommand("toggleMrMonkey",f);d.addCommand("mrMonkeySettings",new CKEDITOR.dialogCommand("myMonkeySettingsDialog"));d.ui.addButton("ToggleMrMonkey",{label:"Toggle Mr. Monkey",command:"toggleMrMonkey",toolbar:"others"});d.ui.addButton("MrMonkeySettings",{label:"Mr. Monkey Settings",command:"mrMonkeySettings",toolbar:"others"})}})}).call(this);
|