...
 
Commits (2)
<html><head><script src="/__makeserver__/links.js"></script><link href="/2017/08/cceditor/README.md?edit" rel="alternate" title="Edit source" type="text/html"><meta charset="utf-8"></head><body></body></html>
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var timecode = require("./timecode.js");
function strip_fragment (url) {
var p = url.indexOf("#");
if (p >= 0) { return url.substring(0, p); }
return url;
}
class CCFrame {
constructor (elt) {
// console.log("ccframe", elt);
......@@ -69,9 +75,10 @@ class CCFrame {
this._clear();
this.url = url;
var urlnf = strip_fragment(url);
for (var type in viewers) {
var v = viewers[type],
m = (v.pattern instanceof RegExp) ? v.pattern.exec(url) : v.pattern.call(this, url);
m = (v.pattern instanceof RegExp) ? v.pattern.exec(urlnf) : v.pattern.call(this, urlnf);
if (m) {
v.viewer.call(this, m);
return this;
......@@ -231,6 +238,7 @@ function post (url, data, callback) {
function trim_parentheses (m) { return m.replace(/^\((.+)\)$/, "$1") }
// nb: trims []:? ... ie optional trailing colon too!
function trim_brackets (m) { return m.replace(/^\[(.+)\]:?$/, "$1") }
function extract_reflink_definitions (text) {
......@@ -276,12 +284,21 @@ var player = new CCFrame(document.getElementById("player")),
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
});
function strip_fragment (url) {
var p = url.indexOf("#");
if (p >= 0) { return url.substring(0, p); }
return url;
}
/* Keys */
editor.setOption("extraKeys", {
"Ctrl-Down": function(cm) {
// todo: get current url + hash... use reflink if available
console.log("player", player);
cm.replaceSelection(player.fragment); // "" + timecode.seconds_to_timecode(player.currentTime));
var reflinks = extract_reflink_definitions(editor.getValue());
var ret = compactRefLink(strip_fragment(player.url)+player.fragment, reflinks);
// cm.replaceSelection(player.fragment); // "" + timecode.seconds_to_timecode(player.currentTime));
cm.replaceSelection("["+ret+"]\n");
},
"Ctrl-Up": function(cm) {
player.toggle();
......@@ -301,7 +318,7 @@ function xpandRefLink (href, reflinks) {
if (href.indexOf("#") >= 0) {
var hrefp = href.split("#", 2);
href = hrefp[0];
hsh = hrefp[1];
var hsh = hrefp[1];
var reflink = reflinks[href.toLowerCase()];
if (reflink !== undefined) {
// reflink DEFINED!!!!
......@@ -318,6 +335,27 @@ function xpandRefLink (href, reflinks) {
return href;
}
function compactRefLink (href, reflinks) {
console.log("compactRefLink", href);
var hrefb, hsh = '';
if (href.indexOf("#") >= 0) {
var hrefp = href.split("#", 2);
hrefb = hrefp[0];
hsh = hrefp[1];
} else {
hrefb = href;
}
for (var label in reflinks) {
var v = reflinks[label];
console.log("checking", v.url, hrefb);
if (v.url == hrefb) {
console.log("MATCH", v.label);
return v.label + (hsh ? "#"+hsh : "");
}
}
return href;
}
/* Map URL and timecode clicks */
function clicker (e) {
var href, hsh;
......
<https://www.youtube.com/watch?v=Pb0iAFkiEv4>
[link](https://codemirror.net/doc/manual.html#api)
<http://sicv.activearchives.org/share/myfatherisavandal.jpg>
[movie](http://sicv.activearchives.org/share/output-3.mp4)
<http://sicv.activearchives.org/share/visual_vocabularies.pdf>
So imagine typing over this to annotate it now.
Cool eh?
00:00:01
00:00:30
00:01:00
<http://sicv.activearchives.org/st/video/2017-12-13/MVI_0011.web.mp4>
docs @ f35c6b3b
Subproject commit f35c6b3b868eb2492a4e1d4c2e48b0215e16e428
var timecode = require("./timecode.js");
function strip_fragment (url) {
var p = url.indexOf("#");
if (p >= 0) { return url.substring(0, p); }
return url;
}
class CCFrame {
constructor (elt) {
// console.log("ccframe", elt);
......@@ -68,9 +74,10 @@ class CCFrame {
this._clear();
this.url = url;
var urlnf = strip_fragment(url);
for (var type in viewers) {
var v = viewers[type],
m = (v.pattern instanceof RegExp) ? v.pattern.exec(url) : v.pattern.call(this, url);
m = (v.pattern instanceof RegExp) ? v.pattern.exec(urlnf) : v.pattern.call(this, urlnf);
if (m) {
v.viewer.call(this, m);
return this;
......
......@@ -49,6 +49,7 @@ function post (url, data, callback) {
function trim_parentheses (m) { return m.replace(/^\((.+)\)$/, "$1") }
// nb: trims []:? ... ie optional trailing colon too!
function trim_brackets (m) { return m.replace(/^\[(.+)\]:?$/, "$1") }
function extract_reflink_definitions (text) {
......@@ -94,12 +95,21 @@ var player = new CCFrame(document.getElementById("player")),
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
});
function strip_fragment (url) {
var p = url.indexOf("#");
if (p >= 0) { return url.substring(0, p); }
return url;
}
/* Keys */
editor.setOption("extraKeys", {
"Ctrl-Down": function(cm) {
// todo: get current url + hash... use reflink if available
console.log("player", player);
cm.replaceSelection(player.fragment); // "" + timecode.seconds_to_timecode(player.currentTime));
var reflinks = extract_reflink_definitions(editor.getValue());
var ret = compactRefLink(strip_fragment(player.url)+player.fragment, reflinks);
// cm.replaceSelection(player.fragment); // "" + timecode.seconds_to_timecode(player.currentTime));
cm.replaceSelection("["+ret+"]\n");
},
"Ctrl-Up": function(cm) {
player.toggle();
......@@ -119,7 +129,7 @@ function xpandRefLink (href, reflinks) {
if (href.indexOf("#") >= 0) {
var hrefp = href.split("#", 2);
href = hrefp[0];
hsh = hrefp[1];
var hsh = hrefp[1];
var reflink = reflinks[href.toLowerCase()];
if (reflink !== undefined) {
// reflink DEFINED!!!!
......@@ -136,6 +146,27 @@ function xpandRefLink (href, reflinks) {
return href;
}
function compactRefLink (href, reflinks) {
console.log("compactRefLink", href);
var hrefb, hsh = '';
if (href.indexOf("#") >= 0) {
var hrefp = href.split("#", 2);
hrefb = hrefp[0];
hsh = hrefp[1];
} else {
hrefb = href;
}
for (var label in reflinks) {
var v = reflinks[label];
console.log("checking", v.url, hrefb);
if (v.url == hrefb) {
console.log("MATCH", v.label);
return v.label + (hsh ? "#"+hsh : "");
}
}
return href;
}
/* Map URL and timecode clicks */
function clicker (e) {
var href, hsh;
......