CoolFace
Apppublic

coolspaces/windows3.1

sourceHugging Faceupdated 5y agoView on Hugging Face
11likes
code.js62 linesDownload Raw Back to root
1// New window: show and bring to top2function newWindow(element) {3    $(element).show();4    $(element).selectWindow();5 6    if (element == '#doom') {7    	loadDoom();8    }9}10 11 12// Load DOOM, because we can13function loadDoom() {14	$.getScript('https://js-dos.com/6.22/current/js-dos.js', function() {15		Dos(document.getElementById("doomcanvas"), {16	        wdosboxUrl: "https://js-dos.com/6.22/current/wdosbox.js",17	        cycles: 1000,18	        autolock: false,19	    }).ready(function (fs, main) {20	      fs.extract("https://js-dos.com/cdn/upload/DOOM-@evilution.zip").then(function () {21	        main(["-c", "cd DOOM", "-c", "DOOM.EXE"]).then(function (ci) {22	            window.ci = ci;23	        });24	      });25	    });26	});27}28 29$( function() {30    // Window drag31    $( ".window" ).draggable({ handle: "div.windowtitle" });32 33    // Window resize34    $( ".window" ).resizable({ handles: "all", alsoresize: ".windowinner" });35 36    // Window close37    $('.windowclose').on("dblclick", function () { $(this).parents('div.window').hide(); });38 39    // Window click-to-bring-to-top40    (function() {41        var highest = 100;42 43        $.fn.selectWindow = function() {44            // Make top45            this.css('z-index', ++highest);46            // Make this window selected and others not47            this.addClass('selectedwindow');48            $('.window').not(this).each(function(){49                $(this).removeClass('selectedwindow');50             });51        };52    })();53    $('.window').mousedown(function() {54        $(this).selectWindow();55    });56 57    // Icon single click58    $('.icon').click(function() {59      $(this).find('p').toggleClass('highlight');60    });61} );62