Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/cache.appcache

This file was deleted.

39 changes: 38 additions & 1 deletion src/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ nav .brand-logo {
font-size: 1.8rem!important;
}

@media only screen and (max-width: 992px){
nav .brand-logo {
left: 6rem!important;
padding-left: 1rem !important;
font-size: 1.8rem!important;
}
}

nav i, nav i.material-icons {
display: inline !important;
}
Expand All @@ -29,8 +37,17 @@ nav i, nav i.material-icons {
}

.horizontal {
flex-direction: row;
flex-direction: row;
}

@media (max-width:600px){
.horizontal {
flex-direction: column;
}
}



.vertical {
flex-direction: column;
}
Expand All @@ -43,6 +60,10 @@ nav i, nav i.material-icons {
white-space: nowrap;
}

.zoom-button{
margin: 2px;
}

.errorloc{
border-bottom-width: 3px;
border-bottom-style: solid;
Expand Down Expand Up @@ -90,6 +111,22 @@ nav i, nav i.material-icons {
z-index:997;
}

.mobile-button{
left: 92%;
}

@media (max-width:450px){
.mobile-button{
left: 90%;
}
}

@media (max-width:350px){
.mobile-button{
left: 87%;
}
}

select {
display: block !important;
}
Expand Down
76 changes: 53 additions & 23 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<!DOCTYPE html>
<html manifest="cache.appcache">
<html>
<head>
<title>OCaml toplevel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>BetterOCaml</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="manifest" href="manifest.json">
<link rel="apple-touch-icon" sizes="180x180" href="icon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="icon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="icon/favicon-16x16.png">
Expand All @@ -22,22 +24,13 @@
<script src="js/codemirror/jump-to-line.js"></script>
<script src="js/resizer.js"></script>
<script async defer src="js/buttons.js"></script>
<script type="text/javascript">
function load_script(url) {
var fileref = document.createElement('script');
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", url);
document.getElementsByTagName("head")[0].appendChild(fileref);
}

load_script("js/toplevel-4.08.js");
</script>
<script src="js/toplevel-4.08.js"></script>
</head>
<body>

<nav class="nav-extended">
<div class="nav-wrapper">
<a href="#!" class="brand-logo hide-on-small-only">BetterOCaml</a>
<a href="#!" class="brand-logo hide-on-small-and-down">BetterOCaml</a>
<ul class="right">
<li>
<a onclick="editors[Math.max(...Object.keys(editors).map(x => +x))+1] = create_editor(id = Math.max(...Object.keys(editors).map(x => +x))+1, name = 'untitled.ml', theme= editors[Math.min(...Object.keys(editors).map(x => +x))].getOption('theme'));"><i
Expand All @@ -55,20 +48,20 @@
<li><a class="modal-trigger" href="#help"><i class="material-icons">settings</i></a></li>
</ul>
</div>
<div class="nav-content">
<div class="nav-content">
<ul id="editor-files" class="tabs">
</ul>
</div>
</nav>

<div class="fixedab" style="bottom: 15px; left: 15px;">
<div class="fixedab hide-on-small-and-down" style="bottom: 15px; left: 15px;">
<a class="btn-floating btn-small waves-effect waves-light zoom-button" onclick="changefontsize('box_1', 1.1)"><i
class="material-icons">add</i></a>
<a class="btn-floating btn-small waves-effect waves-light zoom-button" onclick="changefontsize('box_1', 0.9)"><i
class="material-icons">remove</i></a>
</div>

<div class="fixed-action-btn" style="bottom: 15px; right: 15px;">
<div class="fixed-action-btn hide-on-small-and-down" style="bottom: 15px; right: 15px;">
<a class="btn-floating btn-small waves-effect waves-light zoom-button" onclick="document.getElementById('output').innerHTML=''"><i
class="material-icons">delete</i></a>
<a class="btn-floating btn-small waves-effect waves-light zoom-button" onclick="changefontsize('box_2', 1.1)"><i
Expand All @@ -77,6 +70,13 @@
class="material-icons">remove</i></a>
</div>

<div class="fixed-action-btn mobile-button hide-on-med-and-up" style="bottom: 15px; right: 15px;">
<a class="btn-floating btn-small waves-effect waves-light zoom-button" onclick="exec_all(editors[actual_editor()])"><i
class="material-icons">play_arrow</i></a>
<a class="btn-floating btn-small waves-effect waves-light zoom-button" onclick="document.getElementById('output').innerHTML=''"><i
class="material-icons">delete</i></a>
</div>

<div id="help" class="modal help">
<div class="modal-content">

Expand Down Expand Up @@ -124,7 +124,7 @@ <h4>Enregistrer sous ...</h4>


<div class="container horizontal">
<div id="box_1" class="box" style="display:flex;flex-direction:column">
<div id="box_1" class="box editor-box" style="display:flex;flex-direction:column">


<div class="editorCollection" id="editorCollection">
Expand All @@ -133,7 +133,7 @@ <h4>Enregistrer sous ...</h4>

<div name="resizerH1"></div>

<div id="box_2" class="box">
<div id="box_2" class="box console-box">
<div id="toplevel-container" ondrop="dropHandler(event);" ondragover="dragOverHandler(event);">
<pre id="output"></pre>
<div>
Expand Down Expand Up @@ -173,19 +173,49 @@ <h4>Enregistrer sous ...</h4>
</script>
<script>
// Chargement et events
function change_resize_bar(resize_obj, type) {
resize_obj.resizer.type = type;
resize_obj.resizer.node.setAttribute('data-resizer-type', type);
}

window.addEventListener("load", function () {
new Resizer(document.querySelector('[name=resizerH1]'), 'H');
resize_bar = new Resizer(document.querySelector('[name=resizerH1]'), 'H');
if (window.innerWidth <= 600){
change_resize_bar(resize_bar, "V")
}
else{
change_resize_bar(resize_bar, "H")
}
document.getElementById('box_1').style.fontSize = "1.2em";
document.getElementById('box_2').style.fontSize = "1.2em";

if('serviceWorker' in navigator){
try {
navigator.serviceWorker.register('serviceWorker.js');
console.log("Service Worker Registered");
} catch (error) {
console.log("Service Worker Registration Failed");
}
}
}, false);

//window.onbeforeunload = function () {
// return 'Are you sure you want to leave?';
//};
window.onbeforeunload = function () {
return 'Are you sure you want to leave?';
};

window.onresize = function () {
if (window.innerWidth <= 600){
change_resize_bar(resize_bar, "V")
}
else{
change_resize_bar(resize_bar, "H")
}
};

$(document).ready(function () {
$('.modal').modal();
$('.tabs').tabs();
$('.sidenav').sidenav();
autoload_theme();
});

Expand Down
9 changes: 8 additions & 1 deletion src/js/editor_change.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ let line_with_last = function (instance) {

let exec_last = function (instance) {
let beforecur = instance.getRange({line: 0, ch: 0}, {line: line_with_last(instance)});
parse(clean_content(beforecur).slice(-1)[0], instance); // Remove comments
if ($(window).width() < 600){
parse(clean_content(beforecur).slice(-1)[0]); // Remove comments
}
else{
parse(clean_content(beforecur).slice(-1)[0], instance); // Remove comments
}

};
let exec_all = function (instance) {
let commands = clean_content(instance.getValue());
Expand Down Expand Up @@ -266,3 +272,4 @@ function change_name(id, name) {
}



10 changes: 8 additions & 2 deletions src/js/resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if (typeof Resizer === 'undefined') {
this.afterBox.node.style.flexBasis = 0;
// ajout des events
this.resizer.node.addEventListener('mousedown', this.startProcess.bind(this), false);
this.resizer.node.addEventListener('touchdown', this.startProcess.bind(this), false);
};

Resizer.prototype = {
Expand All @@ -60,8 +61,10 @@ if (typeof Resizer === 'undefined') {
// lancer le processus
this.stopProcessFunctionBinded = this.stopProcess.bind(this);
document.addEventListener('mouseup', this.stopProcessFunctionBinded, false);
document.addEventListener('touchend', this.stopProcessFunctionBinded, false);
this.processFunctionBinded = this.process.bind(this);
document.addEventListener('mousemove', this.processFunctionBinded, false);
document.addEventListener('touchmove', this.processFunctionBinded, false);
},
process: function(event) {
if (!this.processing) {
Expand Down Expand Up @@ -94,9 +97,11 @@ if (typeof Resizer === 'undefined') {
},
stopProcess: function(event) {
// stopper le processus
document.removeEventListener('mousemove', this.processFunctionBinded, false);
document.removeEventListener('mousemove', this.processFunctionBinded, false);
document.removeEventListener('touchmove', this.processFunctionBinded, false);
this.processFunctionBinded = null;
document.removeEventListener('mouseup', this.stopProcessFunctionBinded, false);
document.removeEventListener('touchend', this.stopProcessFunctionBinded, false);
this.stopProcessFunctionBinded = null;
// afficher la barre
if (this.hidebar) {
Expand All @@ -112,4 +117,5 @@ if (typeof Resizer === 'undefined') {
};
} else {
console.error('"Resizer" class already exists !');
}
}

22 changes: 22 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"short_name": "BetterOCaml",
"name": "BetterOCaml, offline OCaml IDE",
"icons": [
{
"src": "icon/android-chrome-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "icon/android-chrome-512x512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/index.html",
"background_color": "#263238",
"display": "standalone",
"scope": "/index.html",
"theme_color": "#263238",
"description": "A small but efficient, intuitive and responsive OCaml IDE right in your browser! Ships OCaml v4.08.1, interpreter by your browser (so it works offline!), compiled with js_of_ocaml. Open-source on <a href='https://github.com/jbdo99/BetterOCaml'>GitHub.com/jbdo99/BetterOCaml</a>",
}
Loading