diff --git a/amd/build/vplide.min.js b/amd/build/vplide.min.js index 24d12fbeb768483870d7981eb1e773a10f9c80d3..d0c6617a733bde4f8e35de9cfbd4a50a0a33b5d1 100644 --- a/amd/build/vplide.min.js +++ b/amd/build/vplide.min.js @@ -1 +1 @@ -define(["jquery","jqueryui","mod_vpl/vplutil","mod_vpl/vplidefile","mod_vpl/vplidebutton","mod_vpl/vplterminal","mod_vpl/vplvnc"],function(a,b,c,d,e,f,g){if("undefined"!=typeof i)return i;var h,i=function(b,i){var j,k,l,m,n,o=this,p=i.minfiles||0,q=i.maxfiles||0,r=i.restrictededitor||i.example,s=i.example,t=!1,u=c.scrollBarWidth();c.setStr(i.i18n);var v,w=c.str,x=a("#"+b);if(v="undefined"==typeof c.get_absolute_path()?"../editor/VPLIDE.css":c.get_absolute_path()+"/editor/VPLIDE.css",a("head").append('<meta name="viewport" content="initial-scale=1">').append('<meta name="viewport" width="device-width">').append('<link rel="stylesheet" href="'+v+'"/>'),"object"!=typeof x)throw"VPL: constructor tag_id not found";var y,z={new:!0,rename:!0,delete:!0,save:!0,run:!0,edit:!0,debug:!0,evaluate:!0,import:!0,resetfiles:!0,correctedfiles:!0,sort:!0,multidelete:!0,acetheme:!0,console:!0,comments:!0};function A(a){return!z[a]||i[a]}function B(a){a.originalEvent.dataTransfer.dropEffect=r?"none":"copy",a.preventDefault()}function C(a){if(r)return a.stopImmediatePropagation(),!1;for(var b=[],d=function(a,c=""){return new Promise(function(e){if(a.isFile)a.file(function(a){var d=c+a.name;Object.defineProperty(a,"name",{get:function(){return d}}),b.push(a),e()});else if(a.isDirectory){a.createReader().readEntries(function(b){for(var f=[],g=0;g<b.length;g++)f.push(d(b[g],c+a.name+"/"));Promise.all(f).then(e)})}else e()})},e=a.originalEvent.dataTransfer,f=[],g=0;g<e.items.length;g++)f.push(d(e.items[g].webkitGetAsEntry()));return e.files.length>0?(Promise.all(f).then(function(){c.readSelectedFiles(b,function(a){return j.addFile(a,!0,n,m)},function(){j.fileListVisibleIfNeeded()})}),a.stopImmediatePropagation(),!1):void 0}function D(a){if(r)return a.stopPropagation(),!1}"undefined"==typeof i.loadajaxurl&&(i.loadajaxurl=i.ajaxurl),y=p<q,i.new=y,i.rename=y,i.delete=y,i.comments=i.comments&&!i.example,i.acetheme=!0,i.sort=q-p>=2,i.multidelete=i.sort,i.import=!r,i.console=A("run")||A("debug"),"undefined"==typeof i.fontSize&&(i.fontSize=12),i.fontSize=parseInt(i.fontSize),x.on("drop",C),x.on("dragover",B);var E=a("#vpl_menu"),F=new e(E,A),G=a("#vpl_tr"),H=a("#vpl_filelist"),I=a("#vpl_filelist_header"),J=a("#vpl_filelist_content"),K=a("#vpl_tabs_ul"),L=a("#vpl_tabs"),M=a("#vpl_results"),N=a("#vpl_results_accordion");H.vpl_minWidth=80,M.vpl_minWidth=100,this.updateEvaluationNumber=function(a){if("undefined"!=typeof a.nevaluations){var b=a.nevaluations;"undefined"!=typeof a.reductionbyevaluation&&a.reductionbyevaluation>""&&0!=a.reductionbyevaluation&&(0!=a.freeevaluations&&(b=b+"/"+a.freeevaluations),b=b+" -"+a.reductionbyevaluation),F.setExtracontent("evaluate",b)}},this.lastResult=null,this.getTerminal=function(){return ma},this.setResultGrade=function(a,b){var c="vpl_ide_accordion_t_grade";if(0==N.find(".vpl_ide_accordion_c_grade").length&&(N.append('<div class="'+c+'"></div>'),N.append('<div class="vpl_ide_accordion_c_grade"></div>')),"undefined"==typeof b)return N.find("h4."+c).length>0;var d=N.find("."+c);return a>""?(d.replaceWith('<h4 class="'+c+'">'+a+"</h4>"),!0):(d.replaceWith('<div class="'+c+'"></div>'),!1)},this.setResultTab=function(b,c,d){var e="vpl_ide_accordion_t_"+b,f="vpl_ide_accordion_c_"+b;if(0==N.find("."+f).length&&(N.append('<div class="'+e+'"></div>'),N.append('<div class="'+f+'"></div>')),"undefined"==typeof d)return N.find("h4."+e).length>0;var g=N.find("."+e),h=N.find("."+f),i=a("<div>"+c+"</div>");return i.find("h4").replaceWith(function(){return a("<h5>").append(a(this).contents())}),h.html()==i.html()?c>"":c>""?(g.replaceWith('<h4 class="'+e+'">'+w(b)+"</h4>"),h.replaceWith('<div class="ui-widget '+f+'">'+i.html()+"</div>"),!0):(g.replaceWith('<div class="'+e+'"></div>'),h.replaceWith('<div class="'+f+'"></div>'),!1)},this.setResult=function(a,b){o.updateEvaluationNumber(a);var d,e=j.getFiles(),f=[];for(d=0;d<e.length;d++)f[d]=e[d].getFileName(),e[d].clearAnnotations();var g,h,k,m=!1,n=c.sanitizeText(a.grade);if(h=o.setResultGrade(n,a.grade),m=m||h,g=o.setResultTab("variables",a.variables,a.variables),m=m||g,k=c.processResult(a.compilation,f,e,!0,!1),g=o.setResultTab("compilation",k,a.compilation),m=m||g,k=c.processResult(a.evaluation,f,e,!1,!1),g=o.setResultTab("comments",k,a.evaluation),m=m||g,k=c.sanitizeText(a.execution),g=o.setResultTab("execution",k,a.execution),m=m||g,g=o.setResultTab("description",i.description,i.description),m=m||g){for(M.show(),M.vpl_visible=!0,N.accordion("refresh"),N.accordion("option","active",h?1:0),d=0;d<e.length;d++)for(var p=e[d].getAnnotations(),q=0;q<p.length;q++)if(b||"error"==p[q].type){j.gotoFile(d,p[q].row+1);break}}else M.hide(),M.vpl_visible=!1;c.delay("autoResizeTab",l)},N.accordion({heightStyle:"fill",header:"h4",animate:!1,beforeActivate:function(a,b){if("newHeader"in b&&b.newHeader.hasClass("vpl_ide_accordion_t_grade"))return!1}}),M.width(2*M.vpl_minWidth),N.on("click","a",function(a){a.preventDefault(),j.gotoFileLink(a.currentTarget)}),M.vpl_visible=!1,M.hide(),H.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"),I.text(w("filelist")),I.html(c.iconFolder()+I.html()),I.addClass("ui-widget-header ui-button-text-only ui-corner-all"),J.addClass("ui-widget ui-corner-all"),H.width(2*H.vpl_minWidth),H.on("click","a",function(a){a.preventDefault(),j.gotoFileLink(a.currentTarget)}),H.vpl_visible=!1,H.hide(),L.tabs({classes:{"ui-tabs-panel":null}});var O=!1;function P(){return!1===O&&(O=(L.outerWidth(!0)-L.width())/2),O}function Q(a,b){var c,d=b.position.left-b.originalPosition.left;if(0!==d)c=L.width()+H.width()-H.vpl_minWidth,L.resizable("option","maxWidth",c),H.width(H.vpl_original_width+d);else{c=L.width()+M.width()-M.vpl_minWidth,L.resizable("option","maxWidth",c);var e=b.size.width-b.originalSize.width;M.width(M.vpl_original_width-e)}j.currentFile("adjustSize")}var R={containment:"parent",resize:Q,start:function(){a(window).off("resize",l),L.resizable("option","minWidth",100),M.vpl_visible&&(M.vpl_original_width=M.width()),H.vpl_visible&&(H.vpl_original_width=H.width())},stop:function(b,c){Q(0,c),L.resizable("option","maxWidth",1e5),L.resizable("option","minWidth",0),l(),a(window).on("resize",l)},handles:""};function S(){j.currentFile("focus")}L.resizable(R),k=function(b){var c=L.width(),d=0;K.width(1e5);var e=K.children("li:visible").last();if(e.length){var f=K.parent().scrollLeft();d=f+e.position().left+e.width()+O,K.width(d);var g=j.currentFile();if(g&&b){var h=a(g.getTabNameId()),i=f+h.position().left;(i-=(c-h.outerWidth())/2)<0&&(i=0),K.parent().finish().animate({scrollLeft:i},"slow")}}d<c&&K.width("")},l=function(){var b,c=L.width(),d=E.width(),e=!1;if(b=0,b+=H.vpl_visible?1:0,b+=M.vpl_visible?2:0,L.resizable("destroy"),R.handles=["e","w","e","e, w"][b],R.disable=0===b,L.resizable(R),G.width(E.outerWidth()),H.vpl_visible){var f=H.outerWidth()+O;c+=f,f>=100?(d-=f,L.css("left",f)):e=!0}else L.css("left",0);if(M.vpl_visible){var g=M.outerWidth()+O;c+=g,(d-=g)<100&&(e=!0)}if(e){var h=E.width()/c,i=0;H.vpl_visible&&(i=H.width()*h,H.width(i-O),i+=O,L.css("left",i)),L.width(L.width()*h),M.vpl_visible&&M.width(E.width()-(i+L.width()+O))}else L.width(d);k(!0),function(){var b=a(window).outerHeight();(b-=E.offset().top+E.height()+(t?P():20))<150&&(b=150),G.height(b);var c=b-3*P();L.height(c),M.vpl_visible&&(M.height(c+P()),N.accordion("refresh")),H.vpl_visible&&(J.height(c-(I.outerHeight()+P())),H.height(c))}(),j.currentFile("adjustSize")};var T=a.extend({},{close:S},c.dialogbaseOptions);function U(b,d){return c.showMessage(b,a.extend({},T,d))}m=function(a){return c.showErrorMessage(a,{close:S})};var V=a("#vpl_ide_dialog_new");function W(b){if("click"==b.type||"keypress"==b.type&&13==b.keyCode){V.dialog("close");var c={name:a("#vpl_ide_input_newfilename").val(),contents:"",encoding:0},d=j.addFile(c,!1,n,m);return d&&(j.open(d),L.tabs("option","active",j.getTabPos(d)),d.focus()),!1}}var X={};X[w("ok")]=W,X[w("cancel")]=function(){a(this).dialog("close")},V.find("input").on("keypress",W),V.dialog(a.extend({},T,{title:w("create_new_file"),buttons:X}));var Y=a("#vpl_ide_dialog_rename");function Z(b){("click"==b.type||"keypress"==b.type&&13==b.keyCode)&&(Y.dialog("close"),j.renameFile(j.currentFile("getFileName"),a("#vpl_ide_input_renamefilename").val(),m),b.preventDefault())}Y.find("input").on("keypress",Z),X[w("ok")]=Z,Y.dialog(a.extend({},T,{open:function(){a("#vpl_ide_input_renamefilename").val(j.currentFile("getFileName"))},title:w("rename_file"),buttons:X})),X[w("ok")]=function(){a(this).dialog("close")};var $=a("#vpl_ide_dialog_comments");$.dialog(a.extend({},T,{title:w("comments"),width:"40em",buttons:X})),a("#vpl_ide_input_comments").width("30em");var _=a("#vpl_ide_dialog_about"),aa={};aa[w("ok")]=function(){a(this).dialog("close")};var ba=a("#vpl_ide_dialog_shortcuts");ba.dialog(a.extend({},T,{open:function(){var b=F.getShortcuts(j.currentFile("getEditor"));a("#vpl_ide_dialog_shortcuts").html(b)},title:w("shortcuts"),width:400,height:300,buttons:aa})),ba.dialog("option","height",300),aa[w("shortcuts")]=function(){a(this).dialog("close"),ba.dialog("open")},_.dialog(a.extend({},T,{open:function(){var b=F.getShortcuts(j.currentFile("getEditor"));_.next().find("button").filter(function(){return a(this).text()==w("shortcuts")}).button(""!=b?"enable":"disable")},title:w("about"),width:400,height:300,buttons:aa})),_.dialog("option","height",300);var ca=a("#vpl_ide_dialog_sort"),da={};da[w("ok")]=function(){var b=j.getFiles(),d=/[^\d]*/,e=[],f=0,g=a("#vpl_sort_list li");if(g.length==b.length){for(g.each(function(){var a=parseInt(this.id.replace(d,""));e.push(b[a])}),f=0;f<g.length;f++)b[f]=e[f];j.setModified(),c.delay("updateMenu",n),c.delay("updateFileList",j.updateFileList),a(this).dialog("close")}},da[w("cancel")]=function(){a(this).dialog("close")},ca.dialog(a.extend({},T,{title:w("sort"),buttons:da,open:function(){var b=a("#vpl_sort_list");b.html("");for(var c=j.getFiles(),d=0;d<c.length;d++){var e=a('<li id="vpl_fsort_'+d+'"class="ui-widget-content"></li>');d<p&&e.addClass("ui-state-disabled"),e.text(d+1+"-"+c[d].getFileName()),b.append(e)}b.sortable({items:"li:not(.ui-state-disabled)",placeholder:"ui-state-highlight",start:function(a,b){b.item.addClass("ui-state-highlight")},stop:function(a,b){b.item.removeClass("ui-state-highlight")}}),b.disableSelection()},maxHeight:400}));var ea=a("#vpl_ide_dialog_multidelete"),fa={};fa[w("selectall")]=function(){a(this).find("input").prop("checked",!0)},fa[w("deselectall")]=function(){a(this).find("input").prop("checked",!1)},fa[w("deleteselected")]=function(){var b=j.getFiles(),d=[];a("#vpl_multidelete_list label").each(function(){var c=a(this);if(c.find("input").prop("checked")){var e=c.data("fileid");d.push(b[e].getFileName())}});for(var e=0;e<d.length;e++)j.deleteFile(d[e],!1,m);c.delay("updateMenu",n),c.delay("updateFileList",j.updateFileList),a(this).dialog("close")},fa[w("cancel")]=function(){a(this).dialog("close")},ea.dialog(a.extend({},T,{title:w("multidelete"),buttons:fa,open:function(){var b=a("#vpl_multidelete_list");b.html("");for(var d=j.getFiles(),e=p;e<d.length;e++){var f=c.sanitizeText(d[e].getFileName()),g=a('<label><input type="checkbox"> '+f+"</label>");g.data("fileid",e),b.append(g),b.append("<br>")}b.find("label").button()},maxHeight:400,maxWidth:400}));var ga=a("#vpl_ide_dialog_fontsize"),ha=a("#vpl_ide_dialog_fontsize .vpl_fontsize_slider"),ia={};ia[w("ok")]=function(){var b=ha.slider("value");j.setFontSize(b),a(this).dialog("close"),a.ajax({async:!0,type:"POST",url:"../editor/userpreferences.json.php",data:JSON.stringify({fontSize:b}),contentType:"application/json; charset=utf-8",dataType:"json"})},ia[w("cancel")]=function(){j.setFontSize(ha.data("vpl_fontsize")),a(this).dialog("close")},ia[w("reset")]=function(){ha.slider("value",12)},ga.dialog(a.extend({},T,{title:w("fontsize"),buttons:ia,open:function(){ha.data("vpl_fontsize",j.getFontSize()),ha.slider("value",j.getFontSize())}})),ha.slider({min:1,max:48,change:function(){var a=ha.slider("value");j.setFontSize(a),ga.find(".vpl_fontsize_slider_value").text(a)}});var ja=a("#vpl_ide_dialog_acetheme"),ka=a("#vpl_ide_dialog_acetheme select"),la={};la[w("ok")]=function(){j.setTheme(ka.val()),a(this).dialog("close"),a.ajax({async:!0,type:"POST",url:"../editor/userpreferences.json.php",data:JSON.stringify({aceTheme:ka.val()}),contentType:"application/json; charset=utf-8",dataType:"json"})},la[w("cancel")]=function(){j.setTheme(ka.data("acetheme")),a(this).dialog("close")},la[w("reset")]=function(){ka.val(ka.data("acetheme")),j.setTheme(ka.val())},ja.dialog(a.extend({},T,{title:w("theme"),buttons:la,modal:!1,open:function(){ka.data("acetheme",j.getTheme()),ka.val(j.getTheme())}})),ka.on("change",function(){j.setTheme(ka.val())});var ma=new f("vpl_dialog_terminal","vpl_terminal",w),na=new g("vpl_dialog_vnc",w),oa=ma,pa=a("#vpl_ide_input_file");function qa(){c.requestAction("resetfiles","",{},i.ajaxurl).done(function(a){var b=a.files;for(var d in b)b.hasOwnProperty(d)&&j.addFile(b[d],!0,c.doNothing,m);j.fileListVisibleIfNeeded(),c.delay("updateMenu",n)}).fail(m)}function ra(){c.requestAction("correctedfiles","",{},i.ajaxurl).done(function(a){var b=a.files;for(var d in b)j.addFile(b[d],!0,c.doNothing,m);j.fileListVisibleIfNeeded()}).fail(m)}pa.on("change",function(){c.readSelectedFiles(this.files,function(a){return j.addFile(a,!0,n,m)},function(){j.fileListVisibleIfNeeded()})}),F.add({name:"filelist",originalAction:function(){j.fileListVisible(!j.isFileListVisible()),c.delay("updateMenu",n),c.delay("autoResizeTab",l),c.delay("updateFileList",j.updateFileList)},bindKey:{win:"Ctrl-L",mac:"Ctrl-L"}}),F.add({name:"new",originalAction:function(){j.length()<q&&V.dialog("open")},bindKey:{win:"Alt-N",mac:"Option-N"}}),F.add({name:"rename",originalAction:function(){var a=j.currentFile();a&&j.getFilePosById(a.getId())>=p&&Y.dialog("open")},bindKey:{win:"Ctrl-R",mac:"Ctrl-R"}}),F.add({name:"delete",originalAction:function(){var a=j.currentFile();if(a){var b=a.getFileName();U(w("delete_file_fq").replace(/\{\$a\}/g,b),{ok:function(){j.deleteFile(b,m)},title:w("delete_file_q"),icon:"trash"})}},bindKey:{win:"Ctrl-D",mac:"Ctrl-D"}}),F.add({name:"close",originalAction:function(){var a=j.currentFile();a&&j.close(a)},bindKey:{win:"Alt-W",mac:"Option-W"}}),F.add({name:"import",originalAction:function(){pa.val(""),pa.trigger("click")},bindKey:{win:"Ctrl-I",mac:"Ctrl-I"}}),F.add({name:"sort",originalAction:function(){ca.dialog("open")},bindKey:{win:"Ctrl-O",mac:"Ctrl-O"}}),F.add({name:"multidelete",originalAction:function(){ea.dialog("open")}}),F.add({name:"fontsize",originalAction:function(){ga.dialog("open")}}),F.add({name:"acetheme",originalAction:function(){ja.dialog("open")}}),F.add({name:"print",originalAction:function(){window.print()},bindKey:{win:"Alt-P",mac:"Command-P"}}),F.add({name:"undo",originalAction:function(){j.currentFile("undo")}}),F.add({name:"redo",originalAction:function(){j.currentFile("redo")}}),F.add({name:"select_all",editorName:"selectall",originalAction:function(){j.currentFile("selectAll")}}),F.add({name:"find",originalAction:function(){j.currentFile("find")}}),F.add({name:"find_replace",editorName:"replace",originalAction:function(){j.currentFile("replace")}}),F.add({name:"next",editorName:"findnext",originalAction:function(){j.currentFile("next")}}),F.add({name:"fullscreen",originalAction:function(){var b="header, footer, aside, #page-header, div.navbar, #nav-drawer";b+=", div.tabtree, #dock, .breadcrumb-nav, .moodle-actionmenu",t?(x.removeClass("vpl_ide_root_fullscreen"),a("body").removeClass("vpl_body_fullscreen"),F.setText("fullscreen","fullscreen"),a(b).show(),a("#vpl_ide_user").hide(),t=!1):(a("body").addClass("vpl_body_fullscreen").scrollTop(0),a(b).hide(),x.addClass("vpl_ide_root_fullscreen"),F.setText("fullscreen","regularscreen"),i.username&&a("#vpl_ide_user").show(),t=!0),S(),setTimeout(l,10)},bindKey:{win:"Alt-F",mac:"Ctrl-F"}}),F.add({name:"download",originalAction:function(){window.location=i.download}}),F.add({name:"correctedfiles",originalAction:function(){U(w("surecorrectedfiles"),{title:w("correctedfiles"),ok:ra})}}),F.add({name:"resetfiles",originalAction:function(){U(w("sureresetfiles"),{title:w("resetfiles"),ok:qa})}}),F.add({name:"save",originalAction:function(){var b={files:j.getFilesToSave(),comments:a("#vpl_ide_input_comments").val()};c.requestAction("save","saving",b,i.ajaxurl).done(function(a){j.resetModified(),F.setTimeLeft(a),c.delay("updateMenu",n)}).fail(m)},bindKey:{win:"Ctrl-S",mac:"Command-S"}});var sa={getConsole:function(){return oa},setResult:o.setResult,ajaxurl:i.ajaxurl,run:function(a,b,c){"terminal"==a?(oa=ma,ma.connect(b.executionURL,function(){c.close(),S()})):(oa=na,na.connect(b.secure,b.server,b.portToUse,b.VNCpassword,b.executionPath,function(){c.close(),S()}))},lastAction:!1,getLastAction:function(){var a=this.lastAction;return this.lastAction=!1,a},setLastAction:function(a){this.lastAction=a}};function ta(a,b,d){d||(d={}),oa.isConnected()||c.requestAction(a,"",d,i.ajaxurl).done(function(d){c.webSocketMonitor(d,a,b,sa)}).fail(m)}function ua(){ta("run","running",{XGEOMETRY:na.getCanvasSize()})}function va(){ta("debug","debugging",{XGEOMETRY:na.getCanvasSize()})}function wa(){ta("evaluate","evaluating")}F.add({name:"run",originalAction:function(){sa.setLastAction(ua),ua()},bindKey:{win:"Ctrl-F11",mac:"Command-U"}}),F.add({name:"debug",originalAction:function(){sa.setLastAction(va),va()},bindKey:{win:"Alt-F11",mac:"Option-U"}}),F.add({name:"evaluate",originalAction:function(){sa.setLastAction(wa),wa()},bindKey:{win:"Shift-F11",mac:"Command-Option-U"}}),F.add({name:"comments",originalAction:function(){$.dialog("open")}}),F.add({name:"console",originalAction:function(){oa.show()}}),F.add({name:"user"}),F.add({name:"about",originalAction:function(){_.dialog("open")}}),F.add({name:"timeleft",originalAction:function(){F.toggleTimeLeft()}}),F.add({name:"more",originalAction:function(){var b=a("#vpl_ide_menuextra");b.is(":visible")?(F.setText("more","more",c.str("more")),b.hide()):(F.setText("more","less",c.str("less")),b.show()),c.delay("updateMenu",n),c.delay("autoResizeTab",l)}}),E.addClass("ui-widget-header ui-corner-all");var xa="";xa+=F.getHTML("more"),xa+=F.getHTML("save"),xa+="<span id='vpl_ide_mexecution'>",xa+=F.getHTML("run"),xa+=F.getHTML("debug"),xa+=F.getHTML("evaluate"),xa+=F.getHTML("comments"),xa+=F.getHTML("console"),xa+="</span> ",xa+="<span id='vpl_ide_menuextra'>",xa+="<span id='vpl_ide_file'>",xa+=F.getHTML("filelist"),xa+=F.getHTML("new"),xa+=F.getHTML("rename"),xa+=F.getHTML("delete"),xa+=F.getHTML("import"),xa+=F.getHTML("download"),xa+=F.getHTML("resetfiles"),xa+=F.getHTML("correctedfiles"),xa+=F.getHTML("sort"),xa+=F.getHTML("multidelete"),xa+=F.getHTML("fontsize"),xa+=F.getHTML("acetheme"),xa+="</span> ",xa+="<span id='vpl_ide_edit'>",xa+=F.getHTML("undo"),xa+=F.getHTML("redo"),xa+=F.getHTML("select_all"),xa+=F.getHTML("find"),xa+=F.getHTML("find_replace"),xa+=F.getHTML("next"),xa+="</span> ",xa+="</span> ",xa+=F.getHTML("fullscreen")+" ",xa+=F.getHTML("about")+" ",xa+=F.getHTML("user")+" ",xa+=F.getHTML("timeleft"),xa+='<div class="clearfix"></div>',E.append(xa),a("#vpl_ide_more").button(),a("#vpl_ide_save").button(),a("#vpl_ide_menuextra").hide(),a("#vpl_ide_file").controlgroup(),a("#vpl_ide_edit").controlgroup(),a("#vpl_ide_mexecution").controlgroup(),a("#vpl_ide_fullscreen").button(),a("#vpl_ide_acetheme").button(),a("#vpl_ide_about").button(),a("#vpl_ide_user").button().css("float","right").hide(),a("#vpl_ide_timeleft").button().css("float","right").hide(),a("#vpl_menu .ui-button").css("padding","6px"),a("#vpl_menu .ui-button-text").css("padding","0");for(var ya=["filelist","more","fullscreen","about","resetfiles","download","comments","console","import","fontsize"],za=0;za<ya.length;za++)F.enable(ya[za],!0);F.setExtracontent("user",i.username),F.setTimeLeft(i),n=function(){var a,b=j.currentFile(),d=j.length();d?L.show():L.hide(),j.isFileListVisible()?F.setText("filelist","filelistclose",c.str("filelist")):F.setText("filelist","filelist",c.str("filelist")),c.log("updateMenu",!0);var e,f=j.isModified();if(F.enable("save",f),F.enable("run",!f),F.enable("debug",!f),F.enable("evaluate",!f),F.enable("download",!f),F.enable("new",d<q),F.enable("sort",d-p>1),F.enable("multidelete",d-p>1),F.enable("acetheme",!0),F.enable("correctedfiles",i.correctedfiles),b&&0!==d){var g=j.getFilePosById(b.getId());F.enable("rename",g>=p&&0!==d),F.enable("delete",g>=p&&0!==d),F.enable("undo",b.hasUndo()),F.enable("redo",b.hasRedo()),F.enable("select_all",b.hasSelectAll()),F.enable("find",b.hasFind()),F.enable("find_replace",b.hasFindReplace()),F.enable("next",b.hasNext()),c.delay("updateFileList",j.updateFileList)}else for(e=["rename","delete","undo","redo","select_all","find","find_replace","next"],a=0;a<e.length;a++)F.enable(e[a],!1)},L.on("tabsactivate",function(){j.currentFile("focus"),c.delay("updateMenu",n),c.delay("autoResizeTab",l)});var Aa=a(window);Aa.on("resize",l),i.example||Aa.on("beforeunload",function(){if(j.isModified())return w("changesNotSaved")}),j=new function(){var b=a("#vpl_tabs_ul"),e=a("#vpl_tabs").tabs("widget"),f=[],g=[],m=!0,o=this;function t(a){for(var b=a.toLowerCase()+"/",c=0;c<f.length;c++){var d=f[c].getFileName().toLowerCase()+"/";if(0===d.indexOf(b)||0===b.indexOf(d))return!0}return!1}function v(a,b){if(c.isBlockly(a))return!1;if(c.isBlockly(b))for(var d=0;d<f.length;d++)if(c.isBlockly(f[d].getFileName()))return!0;return!1}this.updateFileList=function(){o.generateFileList()},this.fileNameExists=function(a){for(var b=a.toLowerCase(),c=0;c<f.length;c++)if(f[c].getFileName().toLowerCase()==b)return c;return-1},this.restrictedPaste=D,this.dropHandler=C,this.dragoverHandler=B,this.readOnly=s,this.restrictedEdit=r,this.adjustTabsTitles=k,this.minNumberOfFiles=p,this.scrollBarWidth=u;var x="";this.setClipboard=function(a){x=a},this.getClipboard=function(){return x},this.getTabPos=function(a){for(var b=0;b<g.length;b++)if(g[b]==a)return b;return g.length},this.getTheme=function(){return i.theme},this.setTheme=function(a){i.theme=a;for(var b=0;b<f.length;b++)f[b].setTheme(a)},this.addTab=function(a){var c='<a href="#vpl_file'+a+'"></a>';b.append('<li id="vpl_tab_name'+a+'">'+c+"</li>"),e.append('<div id="vpl_file'+a+'" class="vpl_ide_file"></div>')},this.removeTab=function(a){b.find("#vpl_tab_name"+a).remove(),e.find("#vpl_file"+a).remove()},this.open=function(a){var b;if(!(b="object"==typeof a?a:f[a]).isOpen()){var d=b.getId();o.addTab(d),g.push(b),F.setGetkeys(b.open()),e.tabs("refresh"),k(!1),c.delay("updateMenu",n),c.delay("updateFileList",o.updateFileList)}},this.close=function(a){if(a.isOpen()){var b,d=a.getId();a.close(),o.removeTab(d);var f=o.getTabPos(a);return g.splice(f,1),e.tabs("refresh"),k(!1),o.fileListVisible(!0),c.delay("updateFileList",o.updateFileList),c.delay("adjustTabsTitles",k,!1),g.length>f?(b=o.getFilePosById(g[f].getId()),void o.gotoFile(b,"c")):f>0?(b=o.getFilePosById(g[f-1].getId()),void o.gotoFile(b,"c")):void 0}},this.isClosed=function(a){return!f[a].isOpen()},this.fileListVisible=function(a){a!==H.vpl_visible&&(H.vpl_visible=a,a?(H.show(),l()):(H.hide(),l()))},this.isFileListVisible=function(){return H.vpl_visible},this.fileListVisibleIfNeeded=function(){if(!this.isFileListVisible())for(var a=0;a<f.length;a++)if(!f[a].isOpen())return void this.fileListVisible(!0)},this.setFontSize=function(a){i.fontSize=a;for(var b=0;b<f.length;b++)f[b].setFontSize(a)},this.getFontSize=function(){return i.fontSize},this.addFile=function(a,b,e,g){if("string"!=typeof a.name||!c.validPath(a.name))return g(w("incorrect_file_name")+" ("+a.name+")"),!1;!0!==b&&(b=!1);var j=this.fileNameExists(a.name);if(-1!=j)return b?(f[j].setContent(a.contents),o.setModified(),e(),c.delay("updateFileList",o.updateFileList),a):(g(w("filenotadded").replace(/\{\$a\}/g,a.name)),!1);if(t(a.name)||v("",a.name))return g(w("filenotadded").replace(/\{\$a\}/g,a.name)),!1;if(f.length>=q)return g(w("maxfilesexceeded")+" ("+q+")"),!1;var k=c.getUniqueId(),l=new d(k,a.name,a.contents,this,h,i.id);return 1==a.encoding?l.extendToBinary():c.isBlockly(a.name)?l.extendToBlockly():l.extendToCodeEditor(),f.push(l),o.setModified(),f.length>5&&o.fileListVisible(!0),e(),c.delay("updateFileList",o.updateFileList),l},this.renameFile=function(a,b,d){var e=this.fileNameExists(a);try{if(-1==e)throw"";if(e<p)throw"";if(f[e].getFileName()==b)return!0;if(!c.validPath(b)||t(b)||v(a,b))throw w("incorrect_file_name");if(c.isBinary()&&c.fileExtension(a)!=c.fileExtension(b))throw w("incorrect_file_name");if(!c.isBlockly(a)&&c.isBlockly(b)||c.isBlockly(a)&&!c.isBlockly(b))throw w("incorrect_file_name");f[e].setFileName(b)}catch(a){return d(w("filenotrenamed").replace(/\{\$a\}/g,b)+": "+a),!1}return o.setModified(),k(!1),c.delay("updateFileList",o.updateFileList),!0},this.deleteFile=function(a,b,d){var e=this.fileNameExists(a);return-1==e?(d(w("filenotdeleted").replace(/\{\$a\}/g,a)),!1):e<p?(d(w("filenotdeleted").replace(/\{\$a\}/g,a)),!1):(o.setModified(),o.close(f[e]),f.splice(e,1),c.delay("updateFileList",o.updateFileList),!0)},this.currentFile=function(){var a=e.tabs("option","active");if(a in g){var b=g[a];if(0===arguments.length)return b;var c=arguments[0];if("function"==typeof b[c]){var d=b[c],f=Array.prototype.slice(arguments);return f.shift(),d.apply(b,f)}}return!1},this.currentPos=function(){return e.tabs("option","active")},this.getFileTab=function(a){for(var b=0;b<g.length;b++)if(g[b].getId()==a)return b;return-1},this.getFilePosById=function(a){for(var b=0;b<f.length;b++)if(f[b].getId()==a)return b;return-1},this.gotoFile=function(a,b){var c=f[a];o.open(c),e.tabs("option","active",o.getFileTab(c.getId())),"c"!==b&&c.gotoLine(parseInt(b,10)),c.focus()},this.gotoFileLink=function(b){var c=a(b),d=c.data("file"),e=-1;if((e=d>""?this.fileNameExists(d):o.getFilePosById(c.data("fileid")))>=0){var f=c.data("line");"undefined"==typeof f&&(f="c"),o.gotoFile(e,f)}},this.getFilesToSave=function(){for(var a=[],b=0;b<f.length;b++){var c={};c.name=f[b].getFileName(),c.contents=f[b].getContent(),c.encoding=f[b].isBinary()?1:0,a.push(c)}return a},this.resetModified=function(){m=!1;for(var a=0;a<f.length;a++)f[a].resetModified();c.delay("updateMenu",n),c.delay("updateFileList",o.updateFileList)},this.setModified=function(){m||(m=!0,c.delay("updateFileList",o.updateFileList)),c.delay("updateMenu",n)},this.isModified=function(){return m},this.length=function(){return f.length},this.clearAnnotations=function(){for(var a=0;a<f.length;a++)f[a].clearAnnotations()},this.getFile=function(a){return f[a]},this.getFiles=function(){return f},this.getDirectoryStructure=function(){var a={isDir:!0,content:{}};for(var b in f)if(f.hasOwnProperty(b)){var c=f[b],d=c.getFileName().split("/"),e=a;for(var g in d)if(d.hasOwnProperty(g)){var h=d[g];g==d.length-1?e.content[h]={isDir:!1,content:c,pos:b}:(e.content[h]||(e.content[h]={isDir:!0,content:{}}),e=e.content[h])}}return a},this.generateFileList=function(){if(o.isFileListVisible()){var a='<span class="vpl_ide_dirindent"></span>',b=[],d="";!function b(d,e,f){for(var g in d.content)if(d.content.hasOwnProperty(g)){var h=d.content[g];if(h.isDir)f.push(e+c.iconFolder()+c.sanitizeText(g)),b(h,e+a,f);else{var i=h.content,j=c.sanitizeText(g),k=c.sanitizeText(i.getFileName());i.isOpen()&&(j="<b>"+j+"</b>");var l='<a href="#" data-fileid="'+i.getId()+'" title="'+k+'">'+j+"</a>";i.isModified()&&(l=c.iconModified()+l),h.pos<p&&(l+=c.iconRequired()),f.push(e+l)}}}(o.getDirectoryStructure(),"",b);for(var e=0;e<b.length;e++)d+=b[e]+"<br />";J.html("<div>"+d+"</div>")}},b.on("click","span.vpl_ide_closeicon",function(){j.close(j.currentFile())}),b.on("dblclick","span.vpl_ide_closeicon",F.getAction("delete")),b.on("dblclick","a",F.getAction("rename")),J.on("dblclick","a",F.getAction("rename"))},l(),function(){var a=E.width();function b(){var b=E.width();a!=b&&(a=b,l())}b(),setInterval(b,1e3)}(),j.resetModified(),c.requestAction("load","loading",i,i.loadajaxurl).done(function(b){for(var d=!0,e=b.files,f=0;f<e.length;f++){var g=e[f],h=j.addFile(g,!1,n,m);h?(h.resetModified(),f<p||e.length<=5?j.open(h):j.fileListVisible(!0)):d=!1}c.delay("updateMenu",n),j.generateFileList(),L.tabs("option","active",0),b.compilationexecution&&o.setResult(b.compilationexecution,!1),F.setTimeLeft(b),b.comments>""&&a("#vpl_ide_input_comments").val(b.comments),d?j.resetModified():j.setModified(),0===j.length()&&q>0?F.getAction("new")():i.saved||j.setModified()}).fail(m)};return window.VPLIDE=i,{init:function(a,b){h=new i(a,b)}}}); \ No newline at end of file +define(["jquery","jqueryui","mod_vpl/vplutil","mod_vpl/vplidefile","mod_vpl/vplidebutton","mod_vpl/vplterminal","mod_vpl/vplvnc"],function(a,b,c,d,e,f,g){if("undefined"!=typeof i)return i;var h,i=function(b,i){var j,k,l,m,n,o=this,p=i.minfiles||0,q=i.maxfiles||0,r=i.restrictededitor||i.example,s=i.example,t=!1,u=c.scrollBarWidth();c.setStr(i.i18n);var v=c.str,w=a("#"+b);if(a("head").append('<meta name="viewport" content="initial-scale=1">').append('<meta name="viewport" width="device-width">'),"object"!=typeof w)throw"VPL: constructor tag_id not found";var x,y={new:!0,rename:!0,delete:!0,save:!0,run:!0,edit:!0,debug:!0,evaluate:!0,import:!0,resetfiles:!0,correctedfiles:!0,sort:!0,multidelete:!0,acetheme:!0,console:!0,comments:!0};function z(a){return!y[a]||i[a]}function A(a){a.originalEvent.dataTransfer.dropEffect=r?"none":"copy",a.preventDefault()}function B(a){if(r)return a.stopImmediatePropagation(),!1;for(var b=[],d=function(a,c=""){return new Promise(function(e){if(a.isFile)a.file(function(a){var d=c+a.name;Object.defineProperty(a,"name",{get:function(){return d}}),b.push(a),e()});else if(a.isDirectory){a.createReader().readEntries(function(b){for(var f=[],g=0;g<b.length;g++)f.push(d(b[g],c+a.name+"/"));Promise.all(f).then(e)})}else e()})},e=a.originalEvent.dataTransfer,f=[],g=0;g<e.items.length;g++)f.push(d(e.items[g].webkitGetAsEntry()));return e.files.length>0?(Promise.all(f).then(function(){c.readSelectedFiles(b,function(a){return j.addFile(a,!0,n,m)},function(){j.fileListVisibleIfNeeded()})}),a.stopImmediatePropagation(),!1):void 0}function C(a){if(r)return a.stopPropagation(),!1}"undefined"==typeof i.loadajaxurl&&(i.loadajaxurl=i.ajaxurl),x=p<q,i.new=x,i.rename=x,i.delete=x,i.comments=i.comments&&!i.example,i.acetheme=!0,i.sort=q-p>=2,i.multidelete=i.sort,i.import=!r,i.console=z("run")||z("debug"),"undefined"==typeof i.fontSize&&(i.fontSize=12),i.fontSize=parseInt(i.fontSize),w.on("drop",B),w.on("dragover",A);var D=a("#vpl_menu"),E=new e(D,z),F=a("#vpl_tr"),G=a("#vpl_filelist"),H=a("#vpl_filelist_header"),I=a("#vpl_filelist_content"),J=a("#vpl_tabs_ul"),K=a("#vpl_tabs"),L=a("#vpl_results"),M=a("#vpl_results_accordion");G.vpl_minWidth=80,L.vpl_minWidth=100,this.updateEvaluationNumber=function(a){if("undefined"!=typeof a.nevaluations){var b=a.nevaluations;"undefined"!=typeof a.reductionbyevaluation&&a.reductionbyevaluation>""&&0!=a.reductionbyevaluation&&(0!=a.freeevaluations&&(b=b+"/"+a.freeevaluations),b=b+" -"+a.reductionbyevaluation),E.setExtracontent("evaluate",b)}},this.lastResult=null,this.getTerminal=function(){return la},this.setResultGrade=function(a,b){var c="vpl_ide_accordion_t_grade";if(0==M.find(".vpl_ide_accordion_c_grade").length&&(M.append('<div class="'+c+'"></div>'),M.append('<div class="vpl_ide_accordion_c_grade"></div>')),"undefined"==typeof b)return M.find("h4."+c).length>0;var d=M.find("."+c);return a>""?(d.replaceWith('<h4 class="'+c+'">'+a+"</h4>"),!0):(d.replaceWith('<div class="'+c+'"></div>'),!1)},this.setResultTab=function(b,c,d){var e="vpl_ide_accordion_t_"+b,f="vpl_ide_accordion_c_"+b;if(0==M.find("."+f).length&&(M.append('<div class="'+e+'"></div>'),M.append('<div class="'+f+'"></div>')),"undefined"==typeof d)return M.find("h4."+e).length>0;var g=M.find("."+e),h=M.find("."+f),i=a("<div>"+c+"</div>");return i.find("h4").replaceWith(function(){return a("<h5>").append(a(this).contents())}),h.html()==i.html()?c>"":c>""?(g.replaceWith('<h4 class="'+e+'">'+v(b)+"</h4>"),h.replaceWith('<div class="ui-widget '+f+'">'+i.html()+"</div>"),!0):(g.replaceWith('<div class="'+e+'"></div>'),h.replaceWith('<div class="'+f+'"></div>'),!1)},this.setResult=function(a,b){o.updateEvaluationNumber(a);var d,e=j.getFiles(),f=[];for(d=0;d<e.length;d++)f[d]=e[d].getFileName(),e[d].clearAnnotations();var g,h,k,m=!1,n=c.sanitizeText(a.grade);if(h=o.setResultGrade(n,a.grade),m=m||h,g=o.setResultTab("variables",a.variables,a.variables),m=m||g,k=c.processResult(a.compilation,f,e,!0,!1),g=o.setResultTab("compilation",k,a.compilation),m=m||g,k=c.processResult(a.evaluation,f,e,!1,!1),g=o.setResultTab("comments",k,a.evaluation),m=m||g,k=c.sanitizeText(a.execution),g=o.setResultTab("execution",k,a.execution),m=m||g,g=o.setResultTab("description",i.description,i.description),m=m||g){for(L.show(),L.vpl_visible=!0,M.accordion("refresh"),M.accordion("option","active",h?1:0),d=0;d<e.length;d++)for(var p=e[d].getAnnotations(),q=0;q<p.length;q++)if(b||"error"==p[q].type){j.gotoFile(d,p[q].row+1);break}}else L.hide(),L.vpl_visible=!1;c.delay("autoResizeTab",l)},M.accordion({heightStyle:"fill",header:"h4",animate:!1,beforeActivate:function(a,b){if("newHeader"in b&&b.newHeader.hasClass("vpl_ide_accordion_t_grade"))return!1}}),L.width(2*L.vpl_minWidth),M.on("click","a",function(a){a.preventDefault(),j.gotoFileLink(a.currentTarget)}),L.vpl_visible=!1,L.hide(),G.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"),H.text(v("filelist")),H.html(c.iconFolder()+H.html()),H.addClass("ui-widget-header ui-button-text-only ui-corner-all"),I.addClass("ui-widget ui-corner-all"),G.width(2*G.vpl_minWidth),G.on("click","a",function(a){a.preventDefault(),j.gotoFileLink(a.currentTarget)}),G.vpl_visible=!1,G.hide(),K.tabs({classes:{"ui-tabs-panel":null}});var N=!1;function O(){return!1===N&&(N=(K.outerWidth(!0)-K.width())/2),N}function P(a,b){var c,d=b.position.left-b.originalPosition.left;if(0!==d)c=K.width()+G.width()-G.vpl_minWidth,K.resizable("option","maxWidth",c),G.width(G.vpl_original_width+d);else{c=K.width()+L.width()-L.vpl_minWidth,K.resizable("option","maxWidth",c);var e=b.size.width-b.originalSize.width;L.width(L.vpl_original_width-e)}j.currentFile("adjustSize")}var Q={containment:"parent",resize:P,start:function(){a(window).off("resize",l),K.resizable("option","minWidth",100),L.vpl_visible&&(L.vpl_original_width=L.width()),G.vpl_visible&&(G.vpl_original_width=G.width())},stop:function(b,c){P(0,c),K.resizable("option","maxWidth",1e5),K.resizable("option","minWidth",0),l(),a(window).on("resize",l)},handles:""};function R(){j.currentFile("focus")}K.resizable(Q),k=function(b){var c=K.width(),d=0;J.width(1e5);var e=J.children("li:visible").last();if(e.length){var f=J.parent().scrollLeft();d=f+e.position().left+e.width()+N,J.width(d);var g=j.currentFile();if(g&&b){var h=a(g.getTabNameId()),i=f+h.position().left;(i-=(c-h.outerWidth())/2)<0&&(i=0),J.parent().finish().animate({scrollLeft:i},"slow")}}d<c&&J.width("")},l=function(){var b,c=K.width(),d=D.width(),e=!1;if(b=0,b+=G.vpl_visible?1:0,b+=L.vpl_visible?2:0,K.resizable("destroy"),Q.handles=["e","w","e","e, w"][b],Q.disable=0===b,K.resizable(Q),F.width(D.outerWidth()),G.vpl_visible){var f=G.outerWidth()+N;c+=f,f>=100?(d-=f,K.css("left",f)):e=!0}else K.css("left",0);if(L.vpl_visible){var g=L.outerWidth()+N;c+=g,(d-=g)<100&&(e=!0)}if(e){var h=D.width()/c,i=0;G.vpl_visible&&(i=G.width()*h,G.width(i-N),i+=N,K.css("left",i)),K.width(K.width()*h),L.vpl_visible&&L.width(D.width()-(i+K.width()+N))}else K.width(d);k(!0),function(){var b=(t?1:.7)*(a(window).innerHeight()-D.height()-O());b<150&&(b=150),F.height(b);var c=b-3*O();K.height(c),L.vpl_visible&&(L.height(c+O()),M.accordion("refresh")),G.vpl_visible&&(I.height(c-(H.outerHeight()+O())),G.height(c))}(),j.currentFile("adjustSize")};var S=a.extend({},{close:R},c.dialogbaseOptions);function T(b,d){return c.showMessage(b,a.extend({},S,d))}m=function(a){return c.showErrorMessage(a,{close:R})};var U=a("#vpl_ide_dialog_new");function V(b){if("click"==b.type||"keypress"==b.type&&13==b.keyCode){U.dialog("close");var c={name:a("#vpl_ide_input_newfilename").val(),contents:"",encoding:0},d=j.addFile(c,!1,n,m);return d&&(j.open(d),K.tabs("option","active",j.getTabPos(d)),d.focus()),!1}}var W={};W[v("ok")]=V,W[v("cancel")]=function(){a(this).dialog("close")},U.find("input").on("keypress",V),U.dialog(a.extend({},S,{title:v("create_new_file"),buttons:W}));var X=a("#vpl_ide_dialog_rename");function Y(b){("click"==b.type||"keypress"==b.type&&13==b.keyCode)&&(X.dialog("close"),j.renameFile(j.currentFile("getFileName"),a("#vpl_ide_input_renamefilename").val(),m),b.preventDefault())}X.find("input").on("keypress",Y),W[v("ok")]=Y,X.dialog(a.extend({},S,{open:function(){a("#vpl_ide_input_renamefilename").val(j.currentFile("getFileName"))},title:v("rename_file"),buttons:W})),W[v("ok")]=function(){a(this).dialog("close")};var Z=a("#vpl_ide_dialog_comments");Z.dialog(a.extend({},S,{title:v("comments"),width:"40em",buttons:W})),a("#vpl_ide_input_comments").width("30em");var $=a("#vpl_ide_dialog_about"),_={};_[v("ok")]=function(){a(this).dialog("close")};var aa=a("#vpl_ide_dialog_shortcuts");aa.dialog(a.extend({},S,{open:function(){var b=E.getShortcuts(j.currentFile("getEditor"));a("#vpl_ide_dialog_shortcuts").html(b)},title:v("shortcuts"),width:400,height:300,buttons:_})),aa.dialog("option","height",300),_[v("shortcuts")]=function(){a(this).dialog("close"),aa.dialog("open")},$.dialog(a.extend({},S,{open:function(){var b=E.getShortcuts(j.currentFile("getEditor"));$.next().find("button").filter(function(){return a(this).text()==v("shortcuts")}).button(""!=b?"enable":"disable")},title:v("about"),width:400,height:300,buttons:_})),$.dialog("option","height",300);var ba=a("#vpl_ide_dialog_sort"),ca={};ca[v("ok")]=function(){var b=j.getFiles(),d=/[^\d]*/,e=[],f=0,g=a("#vpl_sort_list li");if(g.length==b.length){for(g.each(function(){var a=parseInt(this.id.replace(d,""));e.push(b[a])}),f=0;f<g.length;f++)b[f]=e[f];j.setModified(),c.delay("updateMenu",n),c.delay("updateFileList",j.updateFileList),a(this).dialog("close")}},ca[v("cancel")]=function(){a(this).dialog("close")},ba.dialog(a.extend({},S,{title:v("sort"),buttons:ca,open:function(){var b=a("#vpl_sort_list");b.html("");for(var c=j.getFiles(),d=0;d<c.length;d++){var e=a('<li id="vpl_fsort_'+d+'"class="ui-widget-content"></li>');d<p&&e.addClass("ui-state-disabled"),e.text(d+1+"-"+c[d].getFileName()),b.append(e)}b.sortable({items:"li:not(.ui-state-disabled)",placeholder:"ui-state-highlight",start:function(a,b){b.item.addClass("ui-state-highlight")},stop:function(a,b){b.item.removeClass("ui-state-highlight")}}),b.disableSelection()},maxHeight:400}));var da=a("#vpl_ide_dialog_multidelete"),ea={};ea[v("selectall")]=function(){a(this).find("input").prop("checked",!0)},ea[v("deselectall")]=function(){a(this).find("input").prop("checked",!1)},ea[v("deleteselected")]=function(){var b=j.getFiles(),d=[];a("#vpl_multidelete_list label").each(function(){var c=a(this);if(c.find("input").prop("checked")){var e=c.data("fileid");d.push(b[e].getFileName())}});for(var e=0;e<d.length;e++)j.deleteFile(d[e],!1,m);c.delay("updateMenu",n),c.delay("updateFileList",j.updateFileList),a(this).dialog("close")},ea[v("cancel")]=function(){a(this).dialog("close")},da.dialog(a.extend({},S,{title:v("multidelete"),buttons:ea,open:function(){var b=a("#vpl_multidelete_list");b.html("");for(var d=j.getFiles(),e=p;e<d.length;e++){var f=c.sanitizeText(d[e].getFileName()),g=a('<label><input type="checkbox"> '+f+"</label>");g.data("fileid",e),b.append(g),b.append("<br>")}b.find("label").button()},maxHeight:400,maxWidth:400}));var fa=a("#vpl_ide_dialog_fontsize"),ga=a("#vpl_ide_dialog_fontsize .vpl_fontsize_slider"),ha={};ha[v("ok")]=function(){var b=ga.slider("value");j.setFontSize(b),a(this).dialog("close"),a.ajax({async:!0,type:"POST",url:"../editor/userpreferences.json.php",data:JSON.stringify({fontSize:b}),contentType:"application/json; charset=utf-8",dataType:"json"})},ha[v("cancel")]=function(){j.setFontSize(ga.data("vpl_fontsize")),a(this).dialog("close")},ha[v("reset")]=function(){ga.slider("value",12)},fa.dialog(a.extend({},S,{title:v("fontsize"),buttons:ha,open:function(){ga.data("vpl_fontsize",j.getFontSize()),ga.slider("value",j.getFontSize())}})),ga.slider({min:1,max:48,change:function(){var a=ga.slider("value");j.setFontSize(a),fa.find(".vpl_fontsize_slider_value").text(a)}});var ia=a("#vpl_ide_dialog_acetheme"),ja=a("#vpl_ide_dialog_acetheme select"),ka={};ka[v("ok")]=function(){j.setTheme(ja.val()),a(this).dialog("close"),a.ajax({async:!0,type:"POST",url:"../editor/userpreferences.json.php",data:JSON.stringify({aceTheme:ja.val()}),contentType:"application/json; charset=utf-8",dataType:"json"})},ka[v("cancel")]=function(){j.setTheme(ja.data("acetheme")),a(this).dialog("close")},ka[v("reset")]=function(){ja.val(ja.data("acetheme")),j.setTheme(ja.val())},ia.dialog(a.extend({},S,{title:v("theme"),buttons:ka,modal:!1,open:function(){ja.data("acetheme",j.getTheme()),ja.val(j.getTheme())}})),ja.on("change",function(){j.setTheme(ja.val())});var la=new f("vpl_dialog_terminal","vpl_terminal",v),ma=new g("vpl_dialog_vnc",v),na=la,oa=a("#vpl_ide_input_file");function pa(){c.requestAction("resetfiles","",{},i.ajaxurl).done(function(a){var b=a.files;for(var d in b)b.hasOwnProperty(d)&&j.addFile(b[d],!0,c.doNothing,m);j.fileListVisibleIfNeeded(),c.delay("updateMenu",n)}).fail(m)}function qa(){c.requestAction("correctedfiles","",{},i.ajaxurl).done(function(a){var b=a.files;for(var d in b)j.addFile(b[d],!0,c.doNothing,m);j.fileListVisibleIfNeeded()}).fail(m)}oa.on("change",function(){c.readSelectedFiles(this.files,function(a){return j.addFile(a,!0,n,m)},function(){j.fileListVisibleIfNeeded()})}),E.add({name:"filelist",originalAction:function(){j.fileListVisible(!j.isFileListVisible()),c.delay("updateMenu",n),c.delay("autoResizeTab",l),c.delay("updateFileList",j.updateFileList)},bindKey:{win:"Ctrl-L",mac:"Ctrl-L"}}),E.add({name:"new",originalAction:function(){j.length()<q&&U.dialog("open")},bindKey:{win:"Alt-N",mac:"Option-N"}}),E.add({name:"rename",originalAction:function(){var a=j.currentFile();a&&j.getFilePosById(a.getId())>=p&&X.dialog("open")},bindKey:{win:"Ctrl-R",mac:"Ctrl-R"}}),E.add({name:"delete",originalAction:function(){var a=j.currentFile();if(a){var b=a.getFileName();T(v("delete_file_fq").replace(/\{\$a\}/g,b),{ok:function(){j.deleteFile(b,m)},title:v("delete_file_q"),icon:"trash"})}},bindKey:{win:"Ctrl-D",mac:"Ctrl-D"}}),E.add({name:"close",originalAction:function(){var a=j.currentFile();a&&j.close(a)},bindKey:{win:"Alt-W",mac:"Option-W"}}),E.add({name:"import",originalAction:function(){oa.val(""),oa.trigger("click")},bindKey:{win:"Ctrl-I",mac:"Ctrl-I"}}),E.add({name:"sort",originalAction:function(){ba.dialog("open")},bindKey:{win:"Ctrl-O",mac:"Ctrl-O"}}),E.add({name:"multidelete",originalAction:function(){da.dialog("open")}}),E.add({name:"fontsize",originalAction:function(){fa.dialog("open")}}),E.add({name:"acetheme",originalAction:function(){ia.dialog("open")}}),E.add({name:"print",originalAction:function(){window.print()},bindKey:{win:"Alt-P",mac:"Command-P"}}),E.add({name:"undo",originalAction:function(){j.currentFile("undo")}}),E.add({name:"redo",originalAction:function(){j.currentFile("redo")}}),E.add({name:"select_all",editorName:"selectall",originalAction:function(){j.currentFile("selectAll")}}),E.add({name:"find",originalAction:function(){j.currentFile("find")}}),E.add({name:"find_replace",editorName:"replace",originalAction:function(){j.currentFile("replace")}}),E.add({name:"next",editorName:"findnext",originalAction:function(){j.currentFile("next")}}),E.add({name:"fullscreen",originalAction:function(){var b="header, footer, aside, #page-header, div.navbar, #nav-drawer";b+=", div.tabtree, #dock, .breadcrumb-nav, .moodle-actionmenu",t?(w.removeClass("vpl_ide_root_fullscreen"),a("body").removeClass("vpl_body_fullscreen"),E.setText("fullscreen","fullscreen",c.str("fullscreen")),a(b).show(),a("#vpl_ide_user").hide(),t=!1):(a("body").addClass("vpl_body_fullscreen").scrollTop(0),a(b).hide(),w.addClass("vpl_ide_root_fullscreen"),E.setText("fullscreen","regularscreen",c.str("regularscreen")),i.username&&a("#vpl_ide_user").show(),t=!0),R(),setTimeout(l,10)},bindKey:{win:"Alt-F",mac:"Ctrl-F"}}),E.add({name:"download",originalAction:function(){window.location=i.download}}),E.add({name:"correctedfiles",originalAction:function(){T(v("surecorrectedfiles"),{title:v("correctedfiles"),ok:qa})}}),E.add({name:"resetfiles",originalAction:function(){T(v("sureresetfiles"),{title:v("resetfiles"),ok:pa})}}),E.add({name:"save",originalAction:function(){var b={files:j.getFilesToSave(),comments:a("#vpl_ide_input_comments").val()};c.requestAction("save","saving",b,i.ajaxurl).done(function(a){j.resetModified(),E.setTimeLeft(a),c.delay("updateMenu",n)}).fail(m)},bindKey:{win:"Ctrl-S",mac:"Command-S"}});var ra={getConsole:function(){return na},setResult:o.setResult,ajaxurl:i.ajaxurl,run:function(a,b,c){"terminal"==a?(na=la,la.connect(b.executionURL,function(){c.close(),R()})):(na=ma,ma.connect(b.secure,b.server,b.portToUse,b.VNCpassword,b.executionPath,function(){c.close(),R()}))},lastAction:!1,getLastAction:function(){var a=this.lastAction;return this.lastAction=!1,a},setLastAction:function(a){this.lastAction=a}};function sa(a,b,d){d||(d={}),na.isConnected()||c.requestAction(a,"",d,i.ajaxurl).done(function(d){c.webSocketMonitor(d,a,b,ra)}).fail(m)}function ta(){sa("run","running",{XGEOMETRY:ma.getCanvasSize()})}function ua(){sa("debug","debugging",{XGEOMETRY:ma.getCanvasSize()})}function va(){sa("evaluate","evaluating")}E.add({name:"run",originalAction:function(){ra.setLastAction(ta),ta()},bindKey:{win:"Ctrl-F11",mac:"Command-U"}}),E.add({name:"debug",originalAction:function(){ra.setLastAction(ua),ua()},bindKey:{win:"Alt-F11",mac:"Option-U"}}),E.add({name:"evaluate",originalAction:function(){ra.setLastAction(va),va()},bindKey:{win:"Shift-F11",mac:"Command-Option-U"}}),E.add({name:"comments",originalAction:function(){Z.dialog("open")}}),E.add({name:"console",originalAction:function(){na.show()}}),E.add({name:"user"}),E.add({name:"about",originalAction:function(){$.dialog("open")}}),E.add({name:"timeleft",originalAction:function(){E.toggleTimeLeft()}}),E.add({name:"more",originalAction:function(){var b=a("#vpl_ide_menuextra");b.is(":visible")?(E.setText("more","more",c.str("more")),b.hide()):(E.setText("more","less",c.str("less")),b.show()),c.delay("updateMenu",n),c.delay("autoResizeTab",l)}}),D.addClass("ui-widget-header ui-corner-all");var wa="";wa+=E.getHTML("more"),wa+=E.getHTML("save"),wa+="<span id='vpl_ide_mexecution'>",wa+=E.getHTML("run"),wa+=E.getHTML("debug"),wa+=E.getHTML("evaluate"),wa+=E.getHTML("comments"),wa+=E.getHTML("console"),wa+="</span> ",wa+="<span id='vpl_ide_menuextra'>",wa+="<span id='vpl_ide_file'>",wa+=E.getHTML("filelist"),wa+=E.getHTML("new"),wa+=E.getHTML("rename"),wa+=E.getHTML("delete"),wa+=E.getHTML("import"),wa+=E.getHTML("download"),wa+=E.getHTML("resetfiles"),wa+=E.getHTML("correctedfiles"),wa+=E.getHTML("sort"),wa+=E.getHTML("multidelete"),wa+=E.getHTML("fontsize"),wa+=E.getHTML("acetheme"),wa+="</span> ",wa+="<span id='vpl_ide_edit'>",wa+=E.getHTML("undo"),wa+=E.getHTML("redo"),wa+=E.getHTML("select_all"),wa+=E.getHTML("find"),wa+=E.getHTML("find_replace"),wa+=E.getHTML("next"),wa+="</span> ",wa+="</span> ",wa+=E.getHTML("fullscreen")+" ",wa+=E.getHTML("about")+" ",wa+=E.getHTML("user")+" ",wa+=E.getHTML("timeleft"),wa+='<div class="clearfix"></div>',D.append(wa),a("#vpl_ide_more").button(),a("#vpl_ide_save").button(),a("#vpl_ide_menuextra").hide(),a("#vpl_ide_file").controlgroup(),a("#vpl_ide_edit").controlgroup(),a("#vpl_ide_mexecution").controlgroup(),a("#vpl_ide_fullscreen").button(),a("#vpl_ide_acetheme").button(),a("#vpl_ide_about").button(),a("#vpl_ide_user").button().css("float","right").hide(),a("#vpl_ide_timeleft").button().css("float","right").hide(),a("#vpl_menu .ui-button").css("padding","6px"),a("#vpl_menu .ui-button-text").css("padding","0");for(var xa=["filelist","more","fullscreen","about","resetfiles","download","comments","console","import","fontsize"],ya=0;ya<xa.length;ya++)E.enable(xa[ya],!0);E.setExtracontent("user",i.username),E.setTimeLeft(i),n=function(){var a,b=j.currentFile(),d=j.length();d?K.show():K.hide(),j.isFileListVisible()?E.setText("filelist","filelistclose",c.str("filelist")):E.setText("filelist","filelist",c.str("filelist")),c.log("updateMenu",!0);var e,f=j.isModified();if(E.enable("save",f),E.enable("run",!f),E.enable("debug",!f),E.enable("evaluate",!f),E.enable("download",!f),E.enable("new",d<q),E.enable("sort",d-p>1),E.enable("multidelete",d-p>1),E.enable("acetheme",!0),E.enable("correctedfiles",i.correctedfiles),b&&0!==d){var g=j.getFilePosById(b.getId());E.enable("rename",g>=p&&0!==d),E.enable("delete",g>=p&&0!==d),E.enable("undo",b.hasUndo()),E.enable("redo",b.hasRedo()),E.enable("select_all",b.hasSelectAll()),E.enable("find",b.hasFind()),E.enable("find_replace",b.hasFindReplace()),E.enable("next",b.hasNext()),c.delay("updateFileList",j.updateFileList)}else for(e=["rename","delete","undo","redo","select_all","find","find_replace","next"],a=0;a<e.length;a++)E.enable(e[a],!1)},K.on("tabsactivate",function(){j.currentFile("focus"),c.delay("updateMenu",n),c.delay("autoResizeTab",l)});var za=a(window);za.on("resize",l),i.example||za.on("beforeunload",function(){if(j.isModified())return v("changesNotSaved")}),j=new function(){var b=a("#vpl_tabs_ul"),e=a("#vpl_tabs").tabs("widget"),f=[],g=[],m=!0,o=this;function t(a){for(var b=a.toLowerCase()+"/",c=0;c<f.length;c++){var d=f[c].getFileName().toLowerCase()+"/";if(0===d.indexOf(b)||0===b.indexOf(d))return!0}return!1}function w(a,b){if(c.isBlockly(a))return!1;if(c.isBlockly(b))for(var d=0;d<f.length;d++)if(c.isBlockly(f[d].getFileName()))return!0;return!1}this.updateFileList=function(){o.generateFileList()},this.fileNameExists=function(a){for(var b=a.toLowerCase(),c=0;c<f.length;c++)if(f[c].getFileName().toLowerCase()==b)return c;return-1},this.restrictedPaste=C,this.dropHandler=B,this.dragoverHandler=A,this.readOnly=s,this.restrictedEdit=r,this.adjustTabsTitles=k,this.minNumberOfFiles=p,this.scrollBarWidth=u;var x="";this.setClipboard=function(a){x=a},this.getClipboard=function(){return x},this.getTabPos=function(a){for(var b=0;b<g.length;b++)if(g[b]==a)return b;return g.length},this.getTheme=function(){return i.theme},this.setTheme=function(a){i.theme=a;for(var b=0;b<f.length;b++)f[b].setTheme(a)},this.addTab=function(a){var c='<a href="#vpl_file'+a+'"></a>';b.append('<li id="vpl_tab_name'+a+'">'+c+"</li>"),e.append('<div id="vpl_file'+a+'" class="vpl_ide_file"></div>')},this.removeTab=function(a){b.find("#vpl_tab_name"+a).remove(),e.find("#vpl_file"+a).remove()},this.open=function(a){var b;if(!(b="object"==typeof a?a:f[a]).isOpen()){var d=b.getId();o.addTab(d),g.push(b),E.setGetkeys(b.open()),e.tabs("refresh"),k(!1),c.delay("updateMenu",n),c.delay("updateFileList",o.updateFileList)}},this.close=function(a){if(a.isOpen()){var b,d=a.getId();a.close(),o.removeTab(d);var f=o.getTabPos(a);return g.splice(f,1),e.tabs("refresh"),k(!1),o.fileListVisible(!0),c.delay("updateFileList",o.updateFileList),c.delay("adjustTabsTitles",k,!1),g.length>f?(b=o.getFilePosById(g[f].getId()),void o.gotoFile(b,"c")):f>0?(b=o.getFilePosById(g[f-1].getId()),void o.gotoFile(b,"c")):void 0}},this.isClosed=function(a){return!f[a].isOpen()},this.fileListVisible=function(a){a!==G.vpl_visible&&(G.vpl_visible=a,a?(G.show(),l()):(G.hide(),l()))},this.isFileListVisible=function(){return G.vpl_visible},this.fileListVisibleIfNeeded=function(){if(!this.isFileListVisible())for(var a=0;a<f.length;a++)if(!f[a].isOpen())return void this.fileListVisible(!0)},this.setFontSize=function(a){i.fontSize=a;for(var b=0;b<f.length;b++)f[b].setFontSize(a)},this.getFontSize=function(){return i.fontSize},this.addFile=function(a,b,e,g){if("string"!=typeof a.name||!c.validPath(a.name))return g(v("incorrect_file_name")+" ("+a.name+")"),!1;!0!==b&&(b=!1);var j=this.fileNameExists(a.name);if(-1!=j)return b?(f[j].setContent(a.contents),o.setModified(),e(),c.delay("updateFileList",o.updateFileList),a):(g(v("filenotadded").replace(/\{\$a\}/g,a.name)),!1);if(t(a.name)||w("",a.name))return g(v("filenotadded").replace(/\{\$a\}/g,a.name)),!1;if(f.length>=q)return g(v("maxfilesexceeded")+" ("+q+")"),!1;var k=c.getUniqueId(),l=new d(k,a.name,a.contents,this,h,i.id);return 1==a.encoding?l.extendToBinary():c.isBlockly(a.name)?l.extendToBlockly():l.extendToCodeEditor(),f.push(l),o.setModified(),f.length>5&&o.fileListVisible(!0),e(),c.delay("updateFileList",o.updateFileList),l},this.renameFile=function(a,b,d){var e=this.fileNameExists(a);try{if(-1==e)throw"";if(e<p)throw"";if(f[e].getFileName()==b)return!0;if(!c.validPath(b)||t(b)||w(a,b))throw v("incorrect_file_name");if(c.isBinary()&&c.fileExtension(a)!=c.fileExtension(b))throw v("incorrect_file_name");if(!c.isBlockly(a)&&c.isBlockly(b)||c.isBlockly(a)&&!c.isBlockly(b))throw v("incorrect_file_name");f[e].setFileName(b)}catch(a){return d(v("filenotrenamed").replace(/\{\$a\}/g,b)+": "+a),!1}return o.setModified(),k(!1),c.delay("updateFileList",o.updateFileList),!0},this.deleteFile=function(a,b,d){var e=this.fileNameExists(a);return-1==e?(d(v("filenotdeleted").replace(/\{\$a\}/g,a)),!1):e<p?(d(v("filenotdeleted").replace(/\{\$a\}/g,a)),!1):(o.setModified(),o.close(f[e]),f.splice(e,1),c.delay("updateFileList",o.updateFileList),!0)},this.currentFile=function(){var a=e.tabs("option","active");if(a in g){var b=g[a];if(0===arguments.length)return b;var c=arguments[0];if("function"==typeof b[c]){var d=b[c],f=Array.prototype.slice(arguments);return f.shift(),d.apply(b,f)}}return!1},this.currentPos=function(){return e.tabs("option","active")},this.getFileTab=function(a){for(var b=0;b<g.length;b++)if(g[b].getId()==a)return b;return-1},this.getFilePosById=function(a){for(var b=0;b<f.length;b++)if(f[b].getId()==a)return b;return-1},this.gotoFile=function(a,b){var c=f[a];o.open(c),e.tabs("option","active",o.getFileTab(c.getId())),"c"!==b&&c.gotoLine(parseInt(b,10)),c.focus()},this.gotoFileLink=function(b){var c=a(b),d=c.data("file"),e=-1;if((e=d>""?this.fileNameExists(d):o.getFilePosById(c.data("fileid")))>=0){var f=c.data("line");"undefined"==typeof f&&(f="c"),o.gotoFile(e,f)}},this.getFilesToSave=function(){for(var a=[],b=0;b<f.length;b++){var c={};c.name=f[b].getFileName(),c.contents=f[b].getContent(),c.encoding=f[b].isBinary()?1:0,a.push(c)}return a},this.resetModified=function(){m=!1;for(var a=0;a<f.length;a++)f[a].resetModified();c.delay("updateMenu",n),c.delay("updateFileList",o.updateFileList)},this.setModified=function(){m||(m=!0,c.delay("updateFileList",o.updateFileList)),c.delay("updateMenu",n)},this.isModified=function(){return m},this.length=function(){return f.length},this.clearAnnotations=function(){for(var a=0;a<f.length;a++)f[a].clearAnnotations()},this.getFile=function(a){return f[a]},this.getFiles=function(){return f},this.getDirectoryStructure=function(){var a={isDir:!0,content:{}};for(var b in f)if(f.hasOwnProperty(b)){var c=f[b],d=c.getFileName().split("/"),e=a;for(var g in d)if(d.hasOwnProperty(g)){var h=d[g];g==d.length-1?e.content[h]={isDir:!1,content:c,pos:b}:(e.content[h]||(e.content[h]={isDir:!0,content:{}}),e=e.content[h])}}return a},this.generateFileList=function(){if(o.isFileListVisible()){var a='<span class="vpl_ide_dirindent"></span>',b=[],d="";!function b(d,e,f){for(var g in d.content)if(d.content.hasOwnProperty(g)){var h=d.content[g];if(h.isDir)f.push(e+c.iconFolder()+c.sanitizeText(g)),b(h,e+a,f);else{var i=h.content,j=c.sanitizeText(g),k=c.sanitizeText(i.getFileName());i.isOpen()&&(j="<b>"+j+"</b>");var l='<a href="#" data-fileid="'+i.getId()+'" title="'+k+'">'+j+"</a>";i.isModified()&&(l=c.iconModified()+l),h.pos<p&&(l+=c.iconRequired()),f.push(e+l)}}}(o.getDirectoryStructure(),"",b);for(var e=0;e<b.length;e++)d+=b[e]+"<br />";I.html("<div>"+d+"</div>")}},b.on("click","span.vpl_ide_closeicon",function(){j.close(j.currentFile())}),b.on("dblclick","span.vpl_ide_closeicon",E.getAction("delete")),b.on("dblclick","a",E.getAction("rename")),I.on("dblclick","a",E.getAction("rename"))},l(),function(){var a=D.width();function b(){var b=D.width();a!=b&&(a=b,l())}b(),setInterval(b,1e3)}(),j.resetModified(),c.requestAction("load","loading",i,i.loadajaxurl).done(function(b){for(var d=!0,e=b.files,f=0;f<e.length;f++){var g=e[f],h=j.addFile(g,!1,n,m);h?(h.resetModified(),f<p||e.length<=5?j.open(h):j.fileListVisible(!0)):d=!1}c.delay("updateMenu",n),j.generateFileList(),K.tabs("option","active",0),b.compilationexecution&&o.setResult(b.compilationexecution,!1),E.setTimeLeft(b),b.comments>""&&a("#vpl_ide_input_comments").val(b.comments),d?j.resetModified():j.setModified(),0===j.length()&&q>0?E.getAction("new")():i.saved||j.setModified()}).fail(m)};return window.VPLIDE=i,{init:function(a,b){h=new i(a,b)}}}); \ No newline at end of file diff --git a/amd/src/vplide.js b/amd/src/vplide.js index d659f962112b62963cebb13f0d777a92d3cc5abe..0d9d37bae7ac63e0df3a44900c1abb3586534e59 100644 --- a/amd/src/vplide.js +++ b/amd/src/vplide.js @@ -51,17 +51,9 @@ define(['jquery', VPLUtil.setStr(options.i18n); var str = VPLUtil.str; var rootObj = $('#' + root_id); - var URL_CSS; - - if (typeof VPLUtil.get_absolute_path() === "undefined") { - URL_CSS = '../editor/VPLIDE.css'; - } else { - URL_CSS = VPLUtil.get_absolute_path() + '/editor/VPLIDE.css'; - } $("head").append('<meta name="viewport" content="initial-scale=1">') - .append('<meta name="viewport" width="device-width">') - .append('<link rel="stylesheet" href="'+URL_CSS+'"/>'); + .append('<meta name="viewport" width="device-width">'); if (typeof rootObj != 'object') { throw "VPL: constructor tag_id not found"; } @@ -868,8 +860,7 @@ define(['jquery', tabs.resizable(resizableOptions); } function resizeHeight() { - var newHeight = $(window).outerHeight(); - newHeight -= menu.offset().top + menu.height() + (fullScreen ? getTabsAir() : 20); + var newHeight = (fullScreen ? 1 : 0.7) * ($(window).innerHeight() - menu.height() - getTabsAir()); if (newHeight < 150) { newHeight = 150; } @@ -1429,7 +1420,7 @@ define(['jquery', if (fullScreen) { rootObj.removeClass('vpl_ide_root_fullscreen'); $('body').removeClass('vpl_body_fullscreen'); - menuButtons.setText('fullscreen', 'fullscreen'); + menuButtons.setText('fullscreen', 'fullscreen', VPLUtil.str('fullscreen')); $(tags).show(); $('#vpl_ide_user').hide(); fullScreen = false; @@ -1437,7 +1428,7 @@ define(['jquery', $('body').addClass('vpl_body_fullscreen').scrollTop(0); $(tags).hide(); rootObj.addClass('vpl_ide_root_fullscreen'); - menuButtons.setText('fullscreen', 'regularscreen'); + menuButtons.setText('fullscreen', 'regularscreen', VPLUtil.str('regularscreen')); if ( options.username ) { $('#vpl_ide_user').show(); } diff --git a/css/checkjailservers.css b/css/checkjailservers.css deleted file mode 100644 index 77910386ec7c273bf82c595d6446faf48612e742..0000000000000000000000000000000000000000 --- a/css/checkjailservers.css +++ /dev/null @@ -1,4 +0,0 @@ -.vpl_server_failed { - background-color: #f00; - color: #fff; -} diff --git a/css/grade.css b/css/grade.css deleted file mode 100644 index d6f02858e33d1e1c613fbcff05abdff1c21e88fa..0000000000000000000000000000000000000000 --- a/css/grade.css +++ /dev/null @@ -1,18 +0,0 @@ -#vpl_grade_view { - position: relative; - display: flex; -} -#vpl_grade_form { - width: auto; -} -#vpl_grade_form textarea { - resize: both; - margin: 0 1em; -} -#vpl_grade_comments { - height: 10em; - overflow: auto; -} -#vpl_submission_view { - clear: both; -} diff --git a/css/index.css b/css/index.css deleted file mode 100644 index 8075aff73f3f16d6f1152731f0c44bd76c6cb663..0000000000000000000000000000000000000000 --- a/css/index.css +++ /dev/null @@ -1,4 +0,0 @@ -.vpl_nm { - background-color: red; - color: white; -} diff --git a/css/sh.css b/css/sh.css deleted file mode 100644 index 01180b9d11342f3f208d52f49da9dc9ebe922407..0000000000000000000000000000000000000000 --- a/css/sh.css +++ /dev/null @@ -1,17 +0,0 @@ -.vpl_sh { - direction: ltr; - text-align: left; -} - -.vpl_sh div { - display: inline-block; -} - -.vpl_g, -.vpl_g * { - font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; - font-size: 12px; - line-height: normal; - white-space: pre; - word-wrap: normal; -} diff --git a/css/similarity.css b/css/similarity.css deleted file mode 100644 index 0369a988e815151815ad0332ebeb8ddfbd962834..0000000000000000000000000000000000000000 --- a/css/similarity.css +++ /dev/null @@ -1,120 +0,0 @@ -.vpl_sim0, -.vpl_sim1, -.vpl_sim2, -.vpl_sim3, -.vpl_sim4, -.vpl_sim5, -.vpl_sim6, -.vpl_sim7, -.vpl_sim8, -.vpl_sim9, -.vpl_sim10, -.vpl_sim11 { - color: #fff; - font-size: small; - height: 3em; -} - -.vpl_sim0 { - background-color: #f000; -} - -.vpl_sim0 a { - color: #fff; -} - -.vpl_sim0 a:hover { - color: #0f0; -} - -.vpl_sim1 { - background-color: #ff1010; -} - -.vpl_sim1 a { - color: #fff; -} - -.vpl_sim1 a:hover { - color: #0f0; -} - -.vpl_sim2 { - background-color: #ff2828; -} - -.vpl_sim2 a { - color: #fff; -} - -.vpl_sim2 a:hover { - color: #0f0; -} - -.vpl_sim3 { - background-color: #ff4040; -} - -.vpl_sim3 a { - color: #fff; -} - -.vpl_sim3 a:hover { - color: #0f0; -} - -.vpl_sim4 { - background-color: #ff5858; -} - -.vpl_sim4 a { - color: #fff; -} - -.vpl_sim4 a:hover { - color: #0f0; -} - -.vpl_sim5 { - background-color: #ff7070; -} - -.vpl_sim5 a { - color: #fff; -} - -.vpl_sim5 a:hover { - color: #0f0; -} - -.vpl_sim6 { - background-color: #f88; -} - -.vpl_sim6 a { - color: #fff; -} - -.vpl_sim6 a:hover { - color: #0f0; -} - -.vpl_sim7 { - background-color: #ffa0a0; -} - -.vpl_sim8 { - background-color: #ffb8b8; -} - -.vpl_sim9 { - background-color: #ffd0d0; -} - -.vpl_sim10 { - background-color: #ffe8e8; -} - -.vpl_sim11 { - background-color: #fff; -} diff --git a/editor/VPLIDE.css b/editor/VPLIDE.css deleted file mode 100644 index 6f2783d81358f927463339c90efa64fcb4ceb178..0000000000000000000000000000000000000000 --- a/editor/VPLIDE.css +++ /dev/null @@ -1,315 +0,0 @@ -.vpl_ide_root { - direction: ltr; - text-align: left; - width: 100%; -} - -.vpl_body_fullscreen { - overflow: hidden; -} - -.vpl_ide_root_fullscreen { - background-color: white; - height: 100%; - left: 0; - position: fixed; - top: 0; - width: 100%; - z-index: 90; -} - -.vpl_ide_dialog { - z-index: 999; -} -#vpl_ide_dialog_about { - width: 400px; - height: 260px; -} -#vpl_menu .ui-button-text-only, -#vpl_menu .ui-button-text { - padding: 0.4em; -} - -.vpl_ide_menu { - font-size: 110%; - min-width: 340px; - padding: 0.2em; -} - -.vpl_ide_tr { - border: 0; - margin: 0; - min-width: 330px; - padding: 0; - position: relative; - width: 100%; -} - -#vpl_filelist { - display: none; - left: 0; - position: absolute; - top: 0; -} - -#vpl_filelist_header { - padding-left: 0.5em; -} - -#vpl_filelist_content { - overflow: auto; - padding-left: 0.5em; - white-space: pre; -} - -.vpl_ide_dirindent { - display: inline-block; - width: 1.5em; -} - -.vpl_ide_tabs { - position: absolute; - top: 0; -} - -#vpl_tabs_scroll { - overflow: auto; -} - -.vpl_ide_tabs li { - line-height: 1ex; -} - -.vpl_ide_charicon { - color: gray; -} - -.vpl_ide_closeicon { - color: white; - text-shadow: - 1px 0 1px gray, - 0 1px 1px gray, - 0 -1px 1px gray, - -1px 0 1px gray; -} -div.vpl_ide_dialog_content { - height: 250px; - overflow: scroll; - width: 350px; -} - -.vpl_ide_closeicon:hover { - color: gray; - cursor: pointer; - text-shadow: none; -} - -.vpl_ide .ui-widget { - font-size: 12px; -} - -.vpl_ide .ui-widget-content { - font-size: 12px; -} - -.vpl_ide .ui-dialog-titlebar { - font-size: 13px; - padding: 0 1em 0 1em; -} - -.vpl_ide .ui-button { - font-size: 14px; -} - -.ui-tabs .ui-tabs-panel { - padding: 0; -} -/*Resolve problem with essential theme*/ -.vpl_ide_file * { - font-family: - 'Monaco', - 'Menlo', - 'Ubuntu Mono', - 'Consolas', - 'source-code-pro', - monospace; -} - -.vpl_ide_file { - font-family: - 'Monaco', - 'Menlo', - 'Ubuntu Mono', - 'Consolas', - 'source-code-pro', - monospace; - margin: 2px; - padding: 0; - z-index: 0; -} - -.vpl_ide_binary { - font-size: 300%; - line-height: 200%; - margin: auto; - text-align: center; - z-index: 0; -} - -.vpl_ide_img { - overflow: auto; -} - -img.vpl_ide_file { - display: block; - height: auto; - padding: 2px; - width: auto; - z-index: 0; -} - -.vpl_ide_results { - height: 100%; - min-width: 100px; - position: absolute; - right: 0; - top: 0; -} - -.vpl_ide_results a { - border-bottom: solid 1px; - padding: 1px 2px; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4); -} - -.vpl_ide_results pre { - line-height: 100%; - white-space: pre; - word-break: normal; - word-wrap: normal; -} - -.vpl_ide_progressbar { - min-width: 100px; - position: relative; -} - -.vpl_ide_progressbaricon { - margin: 0; - padding: 0; - position: absolute; - width: 2em; -} - -.vpl_ide_progressbarlabel { - border: 0; - display: block; - font-weight: bold; - margin: 0 1em 0 1em; - padding: 0 1em 0 1em; - text-align: center; -} - -.vpl_icon_repeat { - left: -0.7em; - position: absolute; -} - -.vpl_ide { - font-size: 12px; -} -.vpl_ide .ui-dialog-titlebar { - padding: 0.15em; -} -.ace_gutter-tooltip { - white-space: pre-wrap; -} - -.vpl_ide_accordion_c_compilation, -.vpl_ide_accordion_c_execution { - font-family: - 'Monaco', - 'Menlo', - 'Ubuntu Mono', - 'Consolas', - 'source-code-pro', - monospace; - max-width: 120em; - white-space: pre; -} - -.vpl_vnc { - position: fixed; - width: auto; - z-index: 1000; -} - -.vpl_vnc .ui-dialog-content { - padding: 0; -} -.vpl_noVNC_canvas { - cursor: none; - height: 600px; - width: 800px; -} - -.vpl_vnc .ui-button-text-only .ui-button-text { - padding: 0.15em; -} -#vpl_dialog_terminal { - display: none; -} -.vpl_terminal { - background-color: black; - border: 0; - margin: 0; - padding: 0; - z-index: 1000; -} -.vpl_clipboard { - display: none; - z-index: 1010; -} -.vpl_clipboard_label1.ui-button-text, -.vpl_clipboard_label1.ui-button-text { - padding: 0.15em; -} -.vpl_clipboard .vpl_clipboard_entry1, -.vpl_clipboard .vpl_clipboard_entry2 { - height: 50px; - width: 200px; -} - -/*Resolve problem with essential theme*/ -pre.vpl_terminal * { - border: 0; - font: 1em/1.2 monospace; - margin: 0; - padding: 0; -} - -pre.vpl_terminal { - display: inline-block; - font: 1em/1.2 monospace; - font-size: 12px; - padding: 2px; -} -.vpl_buttonleft_orange { - background-color: orange; - color: white; - font-weight: bold; -} -.vpl_buttonleft_red { - background-color: red; - color: white; - font-weight: bold; -} -.vpl_buttonleft_black { - background-color: black; - color: white; - font-weight: bold; -} - -.ace-changed { - background-color: #aaa; -} diff --git a/editor/editor_utility.php b/editor/editor_utility.php index cbf993de0dcdaf329a2ecacd60ed82e4db4321f7..d16a6ae80266abfae0fcc6aecc1f60627361349b 100644 --- a/editor/editor_utility.php +++ b/editor/editor_utility.php @@ -33,9 +33,7 @@ class vpl_editor_util { $PAGE->requires->jquery_plugin('ui-touch', 'mod_vpl'); } public static function generate_requires_evaluation() { - global $PAGE; self::generate_jquery(); - $PAGE->requires->css( new moodle_url( '/mod/vpl/editor/VPLIDE.css' ) ); } public static function generate_requires($options) { global $PAGE, $CFG; diff --git a/forms/gradesubmission.php b/forms/gradesubmission.php index 3c3206f27f25dbce44e395b64cf1b927f7e05bcb..4f5193127decbba7cb2b16c0df08f89df5ce2e88 100644 --- a/forms/gradesubmission.php +++ b/forms/gradesubmission.php @@ -13,7 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with VPL for Moodle. If not, see <http://www.gnu.org/licenses/>. - + /** * Grade submission * @@ -22,14 +22,14 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos RodrÃguez-del-Pino <jcrodriguez@dis.ulpgc.es> */ - + require_once(dirname(__FILE__).'/../../../config.php'); require_once(dirname(__FILE__).'/../locallib.php'); require_once(dirname(__FILE__).'/grade_form.php'); require_once(dirname(__FILE__).'/../vpl.class.php'); require_once(dirname(__FILE__).'/../vpl_submission.class.php'); require_once(dirname(__FILE__).'/../views/sh_factory.class.php'); - + function vpl_grade_header($vpl, $inpopup) { if ($inpopup) { $vpl->print_header_simple(); @@ -39,12 +39,10 @@ function vpl_grade_header($vpl, $inpopup) { } } require_login(); -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/grade.css' ) ); vpl_include_jsfile( 'grade.js', false ); -vpl_include_jsfile( 'hide_footer.js', false ); vpl_include_jsfile( 'updatesublist.js', false ); vpl_sh_factory::include_js(); - + $id = required_param( 'id', PARAM_INT ); $userid = required_param( 'userid', PARAM_INT ); $vpl = new mod_vpl( $id ); @@ -52,7 +50,7 @@ $vpl->prepare_page( 'forms/gradesubmission.php', array ( 'id' => $id, 'userid' => $userid ) ); - + $jscript = ''; $inpopup = optional_param( 'inpopup', 0, PARAM_INT ); $vpl->require_capability( VPL_GRADE_CAPABILITY ); @@ -72,7 +70,7 @@ if (! $subinstance) { vpl_redirect( $link, get_string( 'nosubmission', VPL ), 'error'); } $submissionid = $subinstance->id; - + if ($vpl->is_inconsistent_user( $subinstance->userid, $userid )) { vpl_grade_header( $vpl, $inpopup ); vpl_redirect( $link, 'vpl submission user inconsistence', 'error' ); @@ -125,7 +123,7 @@ if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subin if (! isset( $fromform->grade ) && ! isset( $fromform->savenext )) { vpl_redirect( $link, get_string( 'badinput' ), 'error' ); } - + if ($submission->is_graded()) { $action = 'update grade'; } else { @@ -144,7 +142,7 @@ if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subin } else { \mod_vpl\event\submission_grade_updated::log( $submission ); } - + if ($inpopup) { // Change grade info at parent window. $text = $submission->get_grade_core(); @@ -169,7 +167,7 @@ if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subin } else { // Show grade form. vpl_grade_header( $vpl, $inpopup ); - + \mod_vpl\event\submission_grade_viewed::log($submission); $data = new stdClass(); $data->id = $vpl->get_course_module()->id; @@ -207,8 +205,8 @@ if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subin $vpl->print_variation( $subinstance->userid ); $submission->print_submission(); echo '</div>'; - $jscript .= 'VPL.hlrow(' . $submissionid . ');'; - $jscript .= 'window.onunload= function(){VPL.unhlrow(' . $submissionid . ');};'; + $jscript .= 'VPL.sethlrow(' . $submissionid . ', true);'; + $jscript .= 'window.onunload= function(){VPL.sethlrow(' . $submissionid . ', false);};'; if ($inpopup) { $jscript .= 'VPL.removeHeaderFooter();'; } @@ -219,5 +217,4 @@ if ($subinstance->dategraded == 0 || $subinstance->grader == $USER->id || $subin $vpl->print_footer_simple(); vpl_sh_factory::syntaxhighlight(); echo vpl_include_js( $jscript ); - - \ No newline at end of file + diff --git a/index.php b/index.php index d7436958a9a0ee4ad340094ff759fbf0502dc448..2fb5ee932468a8ea347f52a3703107263c5370b0 100644 --- a/index.php +++ b/index.php @@ -55,7 +55,6 @@ $strnopls = get_string( 'novpls', VPL ); $PAGE->set_url( '/mod/vpl/index.php', array ( 'id' => $id ) ); $PAGE->navbar->add( $strvpls ); -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/index.css' ) ); $PAGE->set_title( $strvpls ); $PAGE->set_heading( $course->fullname ); echo $OUTPUT->header(); diff --git a/jscript/updatesublist.js b/jscript/updatesublist.js index 7f7afb46e8508d2dbf6f78358486e08f64268f1a..4eeac82229ace30130cdcff16cb31576f483a9dc 100644 --- a/jscript/updatesublist.js +++ b/jscript/updatesublist.js @@ -27,57 +27,14 @@ if (typeof VPL != 'object') { VPL = {}; } - /** - * Highlight row - * @param subid submission identification - */ - VPL.hlrow = function(subid){ - if(opener === null){ - return; - } - var ssubid = "" + subid; - var divgrade = opener.document.getElementById('g' + ssubid); - var divgrader = opener.document.getElementById('m' + ssubid); - var divgradeon = opener.document.getElementById('o' + ssubid); - if (divgrade) { - divgrade.style.backgroundColor = 'yellow'; - divgrade.style.color = 'black'; - } - if (divgrader) { - divgrader.style.backgroundColor = 'yellow'; - divgrader.style.color = 'black'; - } - if (divgradeon) { - divgradeon.style.backgroundColor = 'yellow'; - divgradeon.style.color = 'black'; - } - }; - /** - * Unhighlight row - * @param subid submission identification - */ - VPL.unhlrow = function(subid){ + VPL.sethlrow = function(subid, hl){ if(opener === null){ return; } - var ssubid = "" + subid; - var divgrade = opener.document.getElementById('g' + ssubid); - var divgrader = opener.document.getElementById('m' + ssubid); - var divgradeon = opener.document.getElementById('o' + ssubid); - if (divgrade) { - divgrade.style.backgroundColor = ''; - divgrade.style.color = ''; - } - if (divgrader) { - divgrader.style.backgroundColor = ''; - divgrader.style.color = ''; - } - if (divgradeon) { - divgradeon.style.backgroundColor = ''; - divgradeon.style.color = ''; - } - }; + var divsgrade = opener.document.getElementsByClassName('gd' + subid); + Array.from(divsgrade).forEach(element => element.classList[hl ? 'add' : 'remove']('gradehighlight')); + } /** * Update submission list grade @@ -93,19 +50,14 @@ var divgradeon = opener.document.getElementById('o' + ssubid); if (divgrade) { divgrade.innerHTML = grade; - divgrade.style.backgroundColor = ''; - divgrade.style.color = ''; } if (divgrader) { divgrader.innerHTML = grader; - divgrader.style.backgroundColor = ''; - divgrader.style.color = ''; } if (divgradeon) { divgradeon.innerHTML = gradeon; - divgradeon.style.backgroundColor = ''; - divgradeon.style.color = ''; } + VPL.sethlrow(subid, false); }; /** diff --git a/similarity/diff.php b/similarity/diff.php index a19820c300c29349a499fe9b81eb10617b8f9670..2de75aaad472411ba99d9595d855705c4afa1f05 100644 --- a/similarity/diff.php +++ b/similarity/diff.php @@ -31,7 +31,6 @@ require_once(dirname(__FILE__).'/diff.class.php'); require_course_login( $COURSE ); $strdiff = get_string( 'diff', VPL ); $PAGE->set_url( '/mod/vpl/similarity/diff.php' ); -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/sh.css' ) ); $PAGE->set_title( $strdiff ); $PAGE->set_pagelayout( 'popup' ); vpl_sh_factory::include_js(); diff --git a/similarity/listsimilarity.php b/similarity/listsimilarity.php index 1d30c642805dafc7161b81d57449b8cbca805ba7..f37859d80050e98e79e0a7dfd72ba1a4259efe1a 100644 --- a/similarity/listsimilarity.php +++ b/similarity/listsimilarity.php @@ -47,7 +47,6 @@ $vpl->prepare_page( 'similarity/listsimilarity.php', array ( $vpl->require_capability( VPL_SIMILARITY_CAPABILITY ); \mod_vpl\event\vpl_similarity_report_viewed::log( $vpl ); // Print header. -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/similarity.css' ) ); $vpl->print_header( get_string( 'listsimilarity', VPL ) ); $vpl->print_view_tabs( basename( __FILE__ ) ); $form = new vpl_similarity_form( 'listsimilarity.php', $vpl ); @@ -56,7 +55,7 @@ if (! ($fromform = $form->get_data())) { } // Get filelist names to scan. $filesselected = array (); -$filelist = $vpl->get_fgm('required')->getFileList(); +$filelist = $vpl->get_fgm('required')->getFileList(); $num = 0; foreach ($filelist as $filename) { if (isset( $fromform->{'file' . $num} )) { diff --git a/similarity/similarity_base.class.php b/similarity/similarity_base.class.php index bc6e59f9c85ea5b52d5ecf3b2e0868ab738468de..a228f1016857d5626ee9edd4b93aef356e60d85c 100644 --- a/similarity/similarity_base.class.php +++ b/similarity/similarity_base.class.php @@ -270,15 +270,15 @@ class vpl_files_pair { } public function get_link() { global $OUTPUT; - $text = '<spam class="vpl_sim' . ( int ) $this->get_level1() . '">'; + $text = '<spam class="vpl_sim vpl_sim' . ( int ) $this->get_level1() . '">'; $text .= ( int ) $this->s1; $text .= '</spam>'; $text .= '|'; - $text .= '<spam class="vpl_sim' . ( int ) $this->get_level2() . '">'; + $text .= '<spam class="vpl_sim vpl_sim' . ( int ) $this->get_level2() . '">'; $text .= ( int ) $this->s2; $text .= '</spam>'; $text .= '|'; - $text .= '<spam class="vpl_sim' . ( int ) $this->get_level3() . '">'; + $text .= '<spam class="vpl_sim vpl_sim' . ( int ) $this->get_level3() . '">'; $text .= ( int ) $this->s3; $text .= '</spam>'; if ($this->first->can_access() && $this->second->can_access()) { @@ -289,7 +289,7 @@ class vpl_files_pair { foreach ($this->second->link_parms( '2' ) as $parm => $value) { $url = vpl_url_add_param( $url, $parm, $value ); } - $options = array ( + $popupoptions = array ( 'height' => 800, 'width' => 900, 'directories' => 0, @@ -299,7 +299,7 @@ class vpl_files_pair { 'status' => 0, 'toolbar' => 0 ); - $action = new popup_action( 'click', $url, 'viewdiff' . $this->id, $options ); + $action = new popup_action( 'click', $url, 'viewdiff' . $this->id, $popupoptions ); $html = $OUTPUT->action_link( $url, $text, $action ); } else { $html = $text; @@ -307,7 +307,7 @@ class vpl_files_pair { $html .= $this->s1 >= self::$mins1 ? '*' : ''; $html .= $this->s2 >= self::$mins2 ? '*' : ''; $html .= $this->s3 >= self::$mins3 ? '*' : ''; - $html = '<div class="vpl_sim' . ( int ) $this->get_level() . '">' . $html . '</div>'; + $html = '<div class="vpl_sim vpl_sim' . ( int ) $this->get_level() . '">' . $html . '</div>'; return $html; } // Return normalize levels to 0-11. diff --git a/similarity/user_similarity.php b/similarity/user_similarity.php index b272bc35d4dc70bfb88de86e97404c01995712f3..1e2252d28cb8755274e38600bcb102f5a4e6188e 100644 --- a/similarity/user_similarity.php +++ b/similarity/user_similarity.php @@ -60,7 +60,6 @@ $PAGE->set_url( '/mod/vpl/similarity/user_similarity.php', array ( 'userid' => $userid ) ); $PAGE->navbar->add( $strtitle ); -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/similarity.css' ) ); $PAGE->set_title( fullname( $user ) . ':' . $strtitle ); $PAGE->set_heading( $course->fullname ); diff --git a/styles.css b/styles.css new file mode 100644 index 0000000000000000000000000000000000000000..c308d635ab53b92f22d605b9292621b098adfacc --- /dev/null +++ b/styles.css @@ -0,0 +1,430 @@ +/* ############################## */ +/* # Submissions list highlight # */ +/* ############################## */ + +.path-mod-vpl .gradehighlight { + background-color: yellow; + color: black; +} + +/* ############################## */ +/* ############ IDE ############ */ +/* ############################## */ + +.path-mod-vpl .vpl_ide_root { + direction: ltr; + text-align: left; + width: 100%; +} + +.path-mod-vpl.vpl_body_fullscreen { + overflow: hidden; +} + +.path-mod-vpl .vpl_ide_root_fullscreen { + background-color: white; + height: 100%; + left: 0; + position: fixed; + top: 0; + width: 100%; + z-index: 1040; +} + +.path-mod-vpl .vpl_ide_dialog { + z-index: 999; +} +.path-mod-vpl #vpl_ide_dialog_about { + width: 400px; + height: 260px; +} +.path-mod-vpl #vpl_menu .ui-button-text-only, +.path-mod-vpl #vpl_menu .ui-button-text { + padding: 0.4em; +} + +.path-mod-vpl .vpl_ide_menu { + font-size: 110%; + min-width: 340px; + padding: 0.2em; +} + +.path-mod-vpl .vpl_ide_tr { + border: 0; + margin: 0; + min-width: 330px; + padding: 0; + position: relative; + width: 100%; +} + +.path-mod-vpl #vpl_filelist { + display: none; + left: 0; + position: absolute; + top: 0; +} + +.path-mod-vpl #vpl_filelist_header { + padding-left: 0.5em; +} + +.path-mod-vpl #vpl_filelist_content { + overflow: auto; + padding-left: 0.5em; + white-space: pre; +} + +.path-mod-vpl .vpl_ide_dirindent { + display: inline-block; + width: 1.5em; +} + +.path-mod-vpl .vpl_ide_tabs { + position: absolute; + top: 0; +} + +.path-mod-vpl #vpl_tabs_scroll { + overflow: auto; +} + +.path-mod-vpl .vpl_ide_tabs li { + line-height: 1ex; +} + +.path-mod-vpl .vpl_ide_charicon { + color: gray; +} + +.path-mod-vpl .vpl_ide_closeicon { + color: white; + text-shadow: + 1px 0 1px gray, + 0 1px 1px gray, + 0 -1px 1px gray, + -1px 0 1px gray; +} +.path-mod-vpl div.vpl_ide_dialog_content { + height: 250px; + overflow: scroll; + width: 350px; +} + +.path-mod-vpl .vpl_ide_closeicon:hover { + color: gray; + cursor: pointer; + text-shadow: none; +} + +.path-mod-vpl .vpl_ide .ui-widget { + font-size: 12px; +} + +.path-mod-vpl .vpl_ide .ui-widget-content { + font-size: 12px; +} + +.path-mod-vpl .vpl_ide .ui-dialog-titlebar { + font-size: 13px; + padding: 0 1em 0 1em; +} + +.path-mod-vpl .vpl_ide .ui-button { + font-size: 14px; +} + +.path-mod-vpl .ui-tabs .ui-tabs-panel { + padding: 0; +} +/*Resolve problem with essential theme*/ +.path-mod-vpl .vpl_ide_file * { + font-family: + 'Monaco', + 'Menlo', + 'Ubuntu Mono', + 'Consolas', + 'source-code-pro', + monospace; +} + +.path-mod-vpl .vpl_ide_file { + font-family: + 'Monaco', + 'Menlo', + 'Ubuntu Mono', + 'Consolas', + 'source-code-pro', + monospace; + margin: 2px; + padding: 0; + z-index: 0; +} + +.path-mod-vpl .vpl_ide_binary { + font-size: 300%; + line-height: 200%; + margin: auto; + text-align: center; + z-index: 0; +} + +.path-mod-vpl .vpl_ide_img { + overflow: auto; +} + +.path-mod-vpl img.vpl_ide_file { + display: block; + height: auto; + padding: 2px; + width: auto; + z-index: 0; +} + +.path-mod-vpl .vpl_ide_results { + height: 100%; + min-width: 100px; + position: absolute; + right: 0; + top: 0; +} + +.path-mod-vpl .vpl_ide_results a { + border-bottom: solid 1px; + padding: 1px 2px; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4); +} + +.path-mod-vpl .vpl_ide_results pre { + line-height: 100%; + white-space: pre; + word-break: normal; + word-wrap: normal; +} + +.path-mod-vpl .vpl_ide_progressbar { + min-width: 100px; + position: relative; +} + +.path-mod-vpl .vpl_ide_progressbaricon { + margin: 0; + padding: 0; + position: absolute; + width: 2em; +} + +.path-mod-vpl .vpl_ide_progressbarlabel { + border: 0; + display: block; + font-weight: bold; + margin: 0 1em 0 1em; + padding: 0 1em 0 1em; + text-align: center; +} + +.path-mod-vpl .vpl_icon_repeat { + left: -0.7em; + position: absolute; +} + +.path-mod-vpl .vpl_ide { + font-size: 12px; +} +.path-mod-vpl .vpl_ide .ui-dialog-titlebar { + padding: 0.15em; +} +.path-mod-vpl .ace_gutter-tooltip { + white-space: pre-wrap; +} + +.path-mod-vpl .vpl_ide_accordion_c_compilation, +.path-mod-vpl .vpl_ide_accordion_c_execution { + font-family: + 'Monaco', + 'Menlo', + 'Ubuntu Mono', + 'Consolas', + 'source-code-pro', + monospace; + max-width: 120em; + white-space: pre; +} + +.path-mod-vpl .vpl_vnc { + position: fixed; + width: auto; + z-index: 1000; +} + +.path-mod-vpl .vpl_vnc .ui-dialog-content { + padding: 0; +} +.path-mod-vpl .vpl_noVNC_canvas { + cursor: none; + height: 600px; + width: 800px; +} + +.path-mod-vpl .vpl_vnc .ui-button-text-only .ui-button-text { + padding: 0.15em; +} +.path-mod-vpl #vpl_dialog_terminal { + display: none; +} +.path-mod-vpl .vpl_terminal { + background-color: black; + border: 0; + margin: 0; + padding: 0; + z-index: 1000; +} +.path-mod-vpl .vpl_clipboard { + display: none; + z-index: 1010; +} +.path-mod-vpl .vpl_clipboard_label1.ui-button-text, +.path-mod-vpl .vpl_clipboard_label1.ui-button-text { + padding: 0.15em; +} +.path-mod-vpl .vpl_clipboard .vpl_clipboard_entry1, +.path-mod-vpl .vpl_clipboard .vpl_clipboard_entry2 { + height: 50px; + width: 200px; +} + +/*Resolve problem with essential theme*/ +.path-mod-vpl pre.vpl_terminal * { + border: 0; + font: 1em/1.2 monospace; + margin: 0; + padding: 0; +} + +.path-mod-vpl pre.vpl_terminal { + display: inline-block; + font: 1em/1.2 monospace; + font-size: 12px; + padding: 2px; +} +.path-mod-vpl .vpl_ide .vpl_ide_menu .vpl_buttonleft_orange { + background-color: orange; + color: white; + font-weight: bold; +} +.path-mod-vpl .vpl_ide .vpl_ide_menu .vpl_buttonleft_red { + background-color: red; + color: white; + font-weight: bold; +} +.path-mod-vpl .vpl_ide .vpl_ide_menu .vpl_buttonleft_black { + background-color: black; + color: white; + font-weight: bold; +} + +.path-mod-vpl .ace-changed { + background-color: #aaa; +} + +/* ############################## */ +/* ## checkjailservers, index ## */ +/* ############################## */ +.path-mod-vpl .vpl_server_failed, +.path-mod-vpl .vpl_nm { + background-color: red; + color: white; +} + +/* ############################## */ +/* ############# sh ############# */ +/* ############################## */ +.path-mod-vpl .vpl_sh { + direction: ltr; + text-align: left; +} + +.path-mod-vpl .vpl_sh div { + display: inline-block; +} + +.path-mod-vpl .vpl_g, +.path-mod-vpl .vpl_g * { + font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + font-size: 12px; + line-height: normal; + white-space: pre; + word-wrap: normal; +} + +/* ############################## */ +/* ######### similarity ######### */ +/* ############################## */ +.path-mod-vpl .vpl_sim { + font-size: small; + height: 3em; +} + +.path-mod-vpl .vpl_sim a { + color: inherit; +} + +.path-mod-vpl .vpl_sim0 { + color: white; + background-color: #f00; +} + +.path-mod-vpl .vpl_sim1 { + color: white; + background-color: #ff1010; +} + +.path-mod-vpl .vpl_sim2 { + color: white; + background-color: #ff2828; +} + +.path-mod-vpl .vpl_sim3 { + color: white; + background-color: #ff4040; +} + +.path-mod-vpl .vpl_sim4 { + color: white; + background-color: #ff5858; +} + +.path-mod-vpl .vpl_sim5 { + color: white; + background-color: #ff7070; +} + +.path-mod-vpl .vpl_sim6 { + color: black; + background-color: #f88; +} + +.path-mod-vpl .vpl_sim7 { + color: black; + background-color: #ffa0a0; +} + +.path-mod-vpl .vpl_sim8 { + color: black; + background-color: #ffb8b8; +} + +.path-mod-vpl .vpl_sim9 { + color: black; + background-color: #ffd0d0; +} + +.path-mod-vpl .vpl_sim10 { + color: black; + background-color: #ffe8e8; +} + +.path-mod-vpl .vpl_sim11 { + color: black; + background-color: #fff; +} diff --git a/version.php b/version.php index 0589f32c217a04882437186efc6289a43414e0cb..7d3f191cc2f8bd5a9af3405049bb6db4f5345aad 100644 --- a/version.php +++ b/version.php @@ -26,10 +26,10 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018011317; +$plugin->version = 2018011319; $plugin->cron = 300; // Cron check this plugin every 5 minutes. $plugin->requires = 2014051200; // Moodle 2.7! $plugin->maturity = MATURITY_STABLE; -$plugin->release = '3.3.2'; +$plugin->release = '3.4.dev'; $plugin->component = 'mod_vpl'; diff --git a/view.php b/view.php index f1779144bdf9b94c108f1bef439ca432ae7bef97..258ec612c5c97d8eaa33ed251cc171a7080b0de3 100644 --- a/view.php +++ b/view.php @@ -67,7 +67,6 @@ if ( $showfr || $showfe ) { } // Print the page header. -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/sh.css' ) ); $vpl->print_header( get_string( 'description', VPL ) ); // Print the main part of the page. diff --git a/views/checkjailservers.php b/views/checkjailservers.php index 33122e60250cebcc8acd65a554e594f874d7c581..a1060c8fe5db2c5dc6d995a34acc429de5ef6e13 100644 --- a/views/checkjailservers.php +++ b/views/checkjailservers.php @@ -38,7 +38,6 @@ $vpl->prepare_page( 'views/checkjailservers.php', array ( $vpl->require_capability( VPL_MANAGE_CAPABILITY ); // Display page. -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/checkjailservers.css' ) ); $course = $vpl->get_course(); $vpl->print_header( get_string( 'check_jail_servers', VPL ) ); $vpl->print_heading_with_help( 'check_jail_servers' ); diff --git a/views/previoussubmissionslist.php b/views/previoussubmissionslist.php index 8e3d163f2eca11ad9770204c7ada085a1ea0664f..fef1aa5106a780796e17166e367c5a76ba441d70 100644 --- a/views/previoussubmissionslist.php +++ b/views/previoussubmissionslist.php @@ -13,7 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with VPL for Moodle. If not, see <http://www.gnu.org/licenses/>. - + /** * List previous submissions for a vpl and user * @@ -22,14 +22,14 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Juan Carlos RodrÃguez-del-Pino <jcrodriguez@dis.ulpgc.es> */ - + require_once(dirname(__FILE__).'/../../../config.php'); require_once(dirname(__FILE__).'/../locallib.php'); require_once(dirname(__FILE__).'/../vpl.class.php'); require_once(dirname(__FILE__).'/../vpl_submission.class.php'); - + require_login(); - + $id = required_param( 'id', PARAM_INT ); $userid = required_param( 'userid', PARAM_INT ); $detailed = abs( optional_param( 'detailed', 0, PARAM_INT ) ) % 2; @@ -38,7 +38,7 @@ $vpl->prepare_page( 'views/previoussubmissionslist.php', array ( 'id' => $id, 'userid' => $userid ) ); - + $course = $vpl->get_course(); if($USER->id != $userid /*|| !$vpl->get_instance()->allowshowprevious*/){ //Not owner $vpl->require_capability(VPL_GRADE_CAPABILITY); @@ -54,11 +54,10 @@ if ($detailed) { require_once(dirname(__FILE__).'/../views/sh_factory.class.php'); vpl_sh_factory::include_js(); } -$PAGE->requires->css( new moodle_url( '/mod/vpl/css/sh.css' ) ); - + $vpl->print_header( get_string( 'previoussubmissionslist', VPL ) ); $vpl->print_view_tabs( basename( __FILE__ ) ); - + $table = new html_table(); $table->head = array ( '#', @@ -99,7 +98,7 @@ foreach ($submissionslist as $submission) { s( $sub->get_detail() ) ); } - + echo '<div class="clearer"> </div>'; echo '<div style="text-align: center">'; echo '<img src="' . vpl_rel_url( 'submissionsgraph.php', 'id', $id, 'userid', $userid ) . '" alt="files size evolution" />'; @@ -126,7 +125,7 @@ if ($detailed) { $nsub = count( $submissionslist ); foreach ($submissions as $index => $sub) { echo '<hr><h2><a name="f' . $nsub . '"># ' . $nsub . '</a></h2>'; - + $nsub --; $sub->print_submission(); }