Commit 3868f1fd authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

shift to localStorage ipv postWindow events

parent e724d91c
......@@ -152,6 +152,13 @@ function editor (elt, ace) {
startNormalized: t,
start: aa_secondsToTimecode(t)
}, "*");
var tc = aa_secondsToTimecode(t);
console.log("aafragment", tc);
localStorage.setItem("aafragment", JSON.stringify({
time: t,
timecode: tc,
event: "tokenclick"
}));
// var href = current_href.replace(/\.srt$/, '');
// $(editor.elt).trigger("fragmentclick", { href: href+"#t="+aa.secondsToTimecode(t) });
} else {
......@@ -374,15 +381,21 @@ function editor (elt, ace) {
var mode = aceeditor.getSession().getMode().$id,
link,
t;
console.log("paste", window, window.parent);
if (last_fragment && last_fragment.hash.t.length) {
t = last_fragment.hash.t[0];
console.log("paste using localStorage", window, window.parent);
var cchref = localStorage.getItem("cchref"),
ccfragment = localStorage.getItem("ccfragment");
if (cchref) {
if (mode == "ace/mode/srtmd") {
link = aa_secondsToTimecode(t.startNormalized)+" -->\n";
link = ccfragment+" -->\n";
} else if (mode == "ace/mode/markdown") {
link = "["+last_fragment.value+"]("+last_fragment.value+")";
if (ccfragment) {
link = "[#"+ccfragment+"]("+cchref+"#"+ccfragment+")";
} else {
link = "["+cchref+"]("+cchref+")";
}
} else {
link = last_fragment.value;
link = cchref+"#"+ccfragment;
}
aceeditor.insert(link);
}
......@@ -402,6 +415,7 @@ function editor (elt, ace) {
bindKey: {win: 'ctrl-shift-up', mac: 'command-shift-up'},
exec: function () {
window.postMessage({msg: "cc_toggle", origin: window.name}, "*");
localStorage.setItem("cccontrol", JSON.stringify({cmd: "toggle", time: new Date()}));
},
readOnly: true // false if this command should not apply in readOnly mode
});
......@@ -410,6 +424,7 @@ function editor (elt, ace) {
bindKey: {win: 'ctrl-shift-left', mac: 'command-shift-left'},
exec: function () {
window.postMessage({msg: "cc_left", origin: window.name}, "*");
localStorage.setItem("cccontrol", JSON.stringify({cmd: "left", time: new Date()}));
},
readOnly: true // false if this command should not apply in readOnly mode
});
......@@ -418,6 +433,7 @@ function editor (elt, ace) {
bindKey: {win: 'ctrl-shift-right', mac: 'command-shift-right'},
exec: function () {
window.postMessage({msg: "cc_right", origin: window.name}, "*");
localStorage.setItem("cccontrol", JSON.stringify({cmd: "right", time: new Date()}));
},
readOnly: true // false if this command should not apply in readOnly mode
});
......
......@@ -2,6 +2,7 @@
<html>
<head>
<meta charset="utf-8" />
<title>editor</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style type="text/css" media="screen">
body {
......
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 to comment