Commit d43e3d07 by murtaugh

editor improved font + sticky settings

parent 779690db
(function () {
function post (url, data, callback) {
var request = new XMLHttpRequest();
request.open('POST', url, true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
// request.setRequestHeader('Content-Type', 'application/octet-stream');
request.onload = function() {
if (request.readyState == XMLHttpRequest.DONE && request.status >= 200 && request.status < 400) {
// Success!
var resp = request.responseText;
callback(null, resp);
} else {
callback("server error");
}
};
request.onerror = function() {
callback("connection error");
};
var sdata = "";
for (var key in data) {
if (data.hasOwnProperty(key)) {
sdata += (sdata?"&":"") + key+"="+encodeURIComponent(data[key]);
}
}
request.send(sdata);
}
function aa_secondsToTimecode (ss, style) {
style = timecode_styles[style || 'html5'];
......@@ -29,7 +55,6 @@ timecode_styles = {
}
}
function aa_timecodeToSeconds (tc) {
var tcpat = /^(?:(\d\d):)?(\d\d):(\d\d(?:[\.,](?:\d{1,3}))?)$/,
groups = tcpat.exec(tc);
......@@ -84,6 +109,11 @@ function parse_href (href) {
return that;
}
function editor (elt, ace) {
ace = ace || window.ace;
......@@ -106,6 +136,7 @@ function editor (elt, ace) {
savecopy = document.getElementById("savecopybutton"),
status = document.getElementById("status"),
theme_select = document.getElementById("theme"),
font_select = document.getElementById("font"),
font_size_select = document.getElementById("fontsize"),
wrap = document.getElementById("wrap"),
show_invisible = document.getElementById("showinvisibles");
......@@ -114,31 +145,57 @@ function editor (elt, ace) {
return sessionsByHref[href];
}
// Trigger to display controls
ctrigger.addEventListener("mouseenter", function () {
controls.style.display = "block";
});
controls.addEventListener("mouseleave", function () {
controls.style.display = "none";
});
aceeditor = ace.edit(body);
$(document).bind("resize", function (e) { aceeditor.resize(); });
var cur_font = localStorage.getItem("makeserver_editor_font") || "Hack Bold";
aceeditor.setOptions({fontFamily: cur_font});
font_select.value = cur_font;
font_select.addEventListener("change", function () {
aceeditor.setOptions({fontFamily: this.value });
localStorage.setItem("makeserver_editor_font", this.value);
});
aceeditor.setFontSize(parseInt(font_size_select.value));
var cur_font_size = localStorage.getItem("makeserver_editor_font_size") || "12px";
aceeditor.setFontSize(parseInt(cur_font_size));
font_size_select.value = cur_font_size;
font_size_select.addEventListener("change", function () {
aceeditor.setFontSize(parseInt(this.value));
localStorage.setItem("makeserver_editor_font_size", this.value);
});
show_invisible.checked = aceeditor.getShowInvisibles();
var cur_show_invisibles = (localStorage.getItem("makeserver_editor_show_invisibles") == "true");
show_invisible.checked = cur_show_invisibles;
aceeditor.setShowInvisibles(cur_show_invisibles);
show_invisible.addEventListener("change", function () {
aceeditor.setShowInvisibles(this.checked);
})
wrap.checked = aceeditor.getOption("wrap");
localStorage.setItem("makeserver_editor_show_invisibles", this.checked ? "true" : "");
});
var cur_wrap = (localStorage.getItem("makeserver_editor_wrap") == "true");
wrap.checked = cur_wrap;
aceeditor.setOption("wrap", cur_wrap);
wrap.addEventListener("change", function () {
aceeditor.setOption("wrap", this.checked);
})
gutter.checked = aceeditor.renderer.getShowGutter();
localStorage.setItem("makeserver_editor_wrap", this.checked ? "true" : "");
});
var cur_gutter = (localStorage.getItem("makeserver_editor_gutter") == "true");
gutter.checked = cur_gutter;
aceeditor.renderer.setShowGutter(cur_gutter);
gutter.addEventListener("change", function () {
aceeditor.renderer.setShowGutter(this.checked);
})
localStorage.setItem("makeserver_editor_gutter", this.checked ? "true" : "");
});
activeline.checked = false;
if (activeline.checked) {
aceeditor.setHighlightActiveLine(true);
......@@ -147,13 +204,33 @@ function editor (elt, ace) {
aceeditor.setHighlightActiveLine(this.checked);
})
window.aceeditor = aceeditor;
// Mode
modeselector.addEventListener("change", function () {
aceeditor.getSession().setMode(this.value);
}, false);
for (var i=0, l=modelist.modes.length; i<l; i++) {
var opt = document.createElement("option"),
d = modelist.modes[i];
opt.value = d.mode;
opt.textContent = d.caption;
modeselector.appendChild(opt);
}
function init () {
aceeditor.setOption("wrap", true);
aceeditor.renderer.setShowPrintMargin(false);
// Theme (sticky)
var cur_theme = localStorage.getItem("makeserver_editor_theme", this.value);
if (cur_theme) {
aceeditor.setTheme(cur_theme)
theme.value = cur_theme;
}
init();
theme.addEventListener("change", function () {
aceeditor.setTheme(this.value)
localStorage.setItem("makeserver_editor_theme", this.value);
});
aceeditor.renderer.setShowPrintMargin(false);
// debugging
window.aceeditor = aceeditor;
tokenclicks = new TokenClicks(aceeditor, {
tokenChange: function (token) {
......@@ -203,46 +280,6 @@ function editor (elt, ace) {
}))
}
});
$(document).bind("resize", function (e) { aceeditor.resize(); });
// MODE SELECTOR
modeselector.addEventListener("change", function () {
aceeditor.getSession().setMode(this.value);
}, false);
for (var i=0, l=modelist.modes.length; i<l; i++) {
var opt = document.createElement("option"),
d = modelist.modes[i];
opt.value = d.mode;
opt.textContent = d.caption;
modeselector.appendChild(opt);
}
function post (url, data, callback) {
var request = new XMLHttpRequest();
request.open('POST', url, true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
// request.setRequestHeader('Content-Type', 'application/octet-stream');
request.onload = function() {
if (request.readyState == XMLHttpRequest.DONE && request.status >= 200 && request.status < 400) {
// Success!
var resp = request.responseText;
callback(null, resp);
} else {
callback("server error");
}
};
request.onerror = function() {
callback("connection error");
};
var sdata = "";
for (var key in data) {
if (data.hasOwnProperty(key)) {
sdata += (sdata?"&":"") + key+"="+encodeURIComponent(data[key]);
}
}
request.send(sdata);
}
function do_save () {
var text = aceeditor.getValue();
......@@ -256,7 +293,6 @@ function editor (elt, ace) {
}
})
}
function do_save_as (msg, reset_current) {
var newname = prompt(msg),
text = aceeditor.getValue(),
......@@ -275,7 +311,6 @@ function editor (elt, ace) {
}
})
}
save.addEventListener("click", do_save, false);
saveas.addEventListener("click", function () {
do_save_as("save as...", true);
......@@ -284,10 +319,6 @@ function editor (elt, ace) {
do_save_as("save a copy...", false);
});
theme.addEventListener("change", function () {
console.log("theme", this.value);
aceeditor.setTheme(this.value)
});
function highlight(s, e) {
var session = aceeditor.getSession();
......@@ -458,4 +489,8 @@ function editor (elt, ace) {
bind_keys(aceeditor);
return that;
}
\ No newline at end of file
}
window.editor = editor;
})();
<html>
<head>
<meta charset="utf-8">
<title>editor</title>
<title>makeserver editor</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<base href="/__makeserver__/editor/">
<style media="screen" type="text/css">
@font-face {
font-family: "Hack";
src: url("lib/Hack-Regular.ttf");
}
@font-face {
font-family: "Hack Bold";
src: url("lib/Hack-Bold.ttf");
}
body {
overflow: hidden;
}
......@@ -17,18 +29,28 @@
right: 0;
}
#editorbody {
font-family: monospace;
}
#controls {
position: absolute;
height: auto;
bottom: 0px;
left: 20px;
right: 30px;
padding: 10px;
z-index: 1001;
background: #f0f0f0;
background: #FFFFFF;
color: black;
font-family: Hack Bold, monospace;
font-size: 12px;
border-top: 2px solid black;
overflow: auto;
display: none;
}
#controls button, #controls select {
font-family: Hack Bold, monospace;
font-size: 12px;
}
#controltrigger {
position: absolute;
left: 0px;
......@@ -41,7 +63,6 @@
z-index: 1000;
}
</style>
<base href="/__makeserver__/editor/">
</head>
<body>
<div id="controltrigger"></div>
......@@ -95,7 +116,12 @@
</select>
</div>
<div>
Font Size
Font
<select id="font" size="1">
<option value="Hack Bold">Hack Bold</option>
<option value="Hack">Hack</option>
<option value="monospace">monospace</option>
</select>
<select id="fontsize" size="1">
<option value="10px">10px</option>
<option value="11px">11px</option>
......@@ -120,7 +146,7 @@
<div>
<input type="checkbox" id="activeline" /> <label for="activeline">Highlight active line</label>
</div>
<div>
<div style="display: none">
Key binding
<select id="keybinding" size="1">
<option value="ace">Ace</option>
......@@ -128,7 +154,7 @@
<option value="emacs">Emacs</option>
</select>
</div>
<div>
<div style="padding-top: 10px">
Press CTRL-F to find, and CTRL-H to find/replace.
</div>
<div>
......
No preview for this file type
No preview for this file type
Thank you for downloading Silkscreen, a type family for your Web graphics
by Jason Kottke (jason@kottke.org).
To install the Silkscreen type family, unzip this file and drag the files
into the Fonts folder in the Control Panel.
If you encounter any problems in using this font, please email me and I'll
see if I can try and fix it. Please note that I can't help you with any
installation issues. Please consult your system's help files for assistance.
This font is free for personal and corporate use and may be redistributed in
this unmodified form on your Web site. I would ask that you not modify and
then redistribute this font...although you may modify it for your own
personal use. If you really like this font and use it often, feel free to
mail me (e- or snail mail) some small token of your appreciation. A URL
of your work using Silkscreen would be appreciated as well.
All future bug fixes, updates, and additions to the Silkscreen type family
will be available on my Web site at the following URL:
http://www.kottke.org/plus/type/silkscreen/index.html
Again, thanks for downloading Silkscreen. Enjoy!
-jason
\ No newline at end of file
Modified Version ("Hack") Copyright (c) 2015, Christopher Simpkins with Reserved Font Name Hack.
Original Version Copyright (c) 2003 Bitstream Inc. and licensed under the Bitstream Vera License
DejaVu modifications of the original Bitstream Vera Mono typeface have been committed to the public domain.
This Font Software is licensed under a modified version of the SIL Open Font License, Version 1.1 and the Bitstream Vera License.
The modifications to the SIL Open Font License permit the use of multiple font licenses for the release of modified or unmodified versions of this font, in part or in whole. These changes are in the preamble and section 5 of the accompanying modified SIL Open Font License text below.
These licenses are copied below.
MODIFIED SIL OPEN FONT LICENSE
(Original Version 1.1 - 26 February 2007)
(Modified Version 06 June 2015)
PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed under this license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION This license becomes null and void if any of the above conditions are not met.
DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
BITSTREAM VERA LICENSE
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera".
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names.
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment