Skip to content
Snippets Groups Projects
Commit 7051d619 authored by Sebastien's avatar Sebastien
Browse files

Refactor legacy view

parent 968a9c2d
No related branches found
No related tags found
1 merge request!98refresh the mosaic on annotation modification
......@@ -40,6 +40,7 @@
<script language="javascript" type='text/javascript' src='../shared/js/online-rekall/Timeline.js'></script>
<script language="javascript" type='text/javascript' src="../shared/js/online-rekall/RekallApplication.js"></script>
<script language="javascript" type="text/javascript" src='../shared/js/MosaicPanelWidget.js'></script>
<script language="javascript" type="text/javascript" src='../shared/js/PopupPanelWidget.js'></script>
<script language="javascript" type='text/javascript' src='../shared/js/iannix.js'></script>
<script language="javascript" type='text/javascript' src='../shared/js/online-script.js'></script>
......
This diff is collapsed.
......@@ -39,6 +39,7 @@ function Project(url, rekall) {
});
this.metadata["Title"] = urlItems[urlItems.length - 1];
this.rekall = rekall;
this.labels = [];
}
Project.prototype.addDocument = function (key, document) {
......@@ -70,7 +71,7 @@ Project.prototype.loadXML = function (xml) {
delete this.rekall.project.sources["Files"].documents[rekallDoc.key];
}
} else {
let rekallDoc = new Document();
let rekallDoc = new Document({project: thiss});
counts.documents++;
counts.tags++;
$(this).find('meta').each(function () {
......@@ -129,7 +130,8 @@ Project.prototype.timelineUpdate = function () {
Project.prototype.analyse = function () {
$('#flattentimeline').html("<div id='flattentimeline_highlight'></div>");
let parsed_labels = $('input.annotation_labels').toArray().map(i => i.value);
// let parsed_labels = $('input.annotation_labels').toArray().map(i => i.value);
let parsed_labels = this.labels;
//Analyse
Tags.reset();
......@@ -144,30 +146,13 @@ Project.prototype.analyse = function () {
Tags.push(tag);
let labels = tag.getMetadata('Rekall->Labels');
if (labels && labels != '') {
let input_template = $('input.annotation_labels_template').first();
let html_label_template = $('label.annotation_labels_template').first();
let _labels = labels.split(';');
for (let i in _labels) {
let label = _labels[i];
if (label == '') continue;
if (label.length === 0) continue;
if (parsed_labels.indexOf(label) != -1)
continue;
parsed_labels.push(label);
let inp = input_template.clone();
let id = 'annotation_label_' + parsed_labels.indexOf(label);
inp.attr('id', id);
inp.attr('value', label);
let html_label = html_label_template.clone();
html_label.attr('for', id);
html_label.html(label);
html_label.show();
html_label.addClass('annotation_labels').removeClass('annotation_labels_template');
inp.addClass('annotation_labels').removeClass('annotation_labels_template');
$('#popupLabelsInput').append(inp);
$('#popupLabelsInput').append(html_label);
}
}
}
......@@ -238,130 +223,7 @@ Project.prototype.analyse = function () {
let thumbUrl = Utils.getPreviewPath(tag);
tag.thumbnail = {url: thumbUrl, tag: tag};
if ((tag.getMetadata("Rekall->Highlight") != undefined) && (tag.getMetadata("Rekall->Highlight") != "")) {
//Dom
$('#flattentimeline').append(function () {
let styleColor = "background-color: " + tag.color + ";";
let textColor = "color: " + tag.color + ";";
let colorTransp = "";
let styleColor2 = styleColor;
let styleImage = "";
if (tag.thumbnail.url != undefined) {
styleImage = "background-image: -webkit-linear-gradient(right bottom, rgba(20,46,51,.60) 0%,rgba(20,46,51,.90) 100%), url(" + tag.thumbnail.url + "); background-image: -moz-linear-gradient(right bottom, rgba(20,46,51,.60) 0%,rgba(20,46,51,.90) 100%), url(" + tag.thumbnail.url + "); background-image: -o-linear-gradient(right bottom, rgba(20,46,51,.60) 0%,rgba(20,46,51,.90) 100%), url(" + tag.thumbnail.url + ");";
} else styleImage = "background-color: " + tag.color + "; background-image: -webkit-linear-gradient(right bottom, rgba(20,46,51,.5) 0%,rgba(20,46,51,.8) 100%); background-image: -moz-linear-gradient(right bottom, rgba(20,46,51,.5) 0%,rgba(20,46,51,.8) 100%); background-image: -o-linear-gradient(right bottom, rgba(20,46,51,.5) 0%,rgba(20,46,51,.8) 100%);";//styleColor.replace(/rgb/g, "rgba").replace(/\)/g, ",.85)");//"background-color: rgba(255,255,255,.25)";
let icnType = "";
let tmpType = tag.getMetadata("Rekall->Type");
if (tmpType.indexOf("application/msword") >= 0) icnType = "background-image:url(css/images/icn-word.png);";
else if (tmpType.indexOf("application/pdf") >= 0) icnType = "background-image:url(css/images/icn-pdf.png);";
else if (tmpType.indexOf("application/") >= 0) icnType = "background-image:url(css/images/icn-document.png);";
else if (tmpType.indexOf("audio/") >= 0) icnType = "background-image:url(css/images/icn-music.png);";
else if (tmpType.indexOf("image/") >= 0) icnType = "background-image:url(css/images/icn-image.png);";
else if (tmpType.indexOf("text/x-vcard") >= 0) icnType = "background-image:url(css/images/icn-user.png);";
else if (tmpType.indexOf("text/") >= 0) icnType = "background-image:url(css/images/icn-document.png);";
else if (tmpType.indexOf("video/") >= 0) icnType = "background-image:url(css/images/icn-video.png);";
let typeTxt = tmpType.split("/")[1].replace(/marker/g, "note");
let htmlHighlight = "";
htmlHighlight += "<div draggable=true class='flattentimeline_item flattentimeline_highlightitem' style='" + colorTransp + " " + styleImage + "'>";
htmlHighlight += "<div class='flattentimeline_title' style='" + textColor + "' title='" + tag.getMetadata("Rekall->Name") + "'>" + tag.getMetadata("Rekall->Name") + "</div>";
if (tag.getMetadata("Rekall->Comments") != "") {
let tmpComments = tag.getMetadata("Rekall->Comments");
if (tmpComments.length > 150) {
tmpComments = tmpComments.substring(0, 150) + "...";
}
let tmpcount = 0;
let tmpIndex = tmpComments.indexOf("<br/>");
while ((tmpcount < 3) && (tmpIndex != -1)) {
tmpcount++;
tmpIndex = tmpComments.indexOf("<br/>", tmpIndex + 1);
}
if (tmpIndex != -1) {
tmpComments = tmpComments.substring(0, tmpIndex) + "...";
}
htmlHighlight += "<div class='flattentimeline_description'>" + tmpComments + "</div>";
}
if (tag.getMetadata("Rekall->Author") != "") htmlHighlight += "<div class='flattentimeline_author'>" + tag.getMetadata("Rekall->Author") + "</div>";
htmlHighlight += "<div class='flattentimeline_typeTxt' >" + typeTxt + "</div>";
htmlHighlight += "<div class='flattentimeline_opacifiant' style='" + styleColor2 + "'></div>";
htmlHighlight += "</div>";
tag.flattenTimelineDom = $(htmlHighlight);
tag.flattenTimelineDom.click(function (event) {
tag.openPopupEdit();
});
tag.flattenTimelineDom.on({
dragstart: function (event) {
event.dataTransfer.setData("key", tag.document.key);
event.dataTransfer.setData("version", tag.version);
}
});
return tag.flattenTimelineDom;
});
} else {
//Dom
$('#flattentimeline').append(function () {
let styleColor = "background-color: " + tag.color + ";";
let textColor2 = "color: rgba(255,255,255,.8)";
let styleColor2 = styleColor;
let styleImage = "";
if (tag.thumbnail.url != undefined) {
styleImage = "background-image: url(" + encodeURI(tag.thumbnail.url) + ");";//" opacity: 0.5;";
} else styleImage = "background-color: rgba(255,255,255,.25)";
let icnType = "";
let tmpType = tag.getMetadata("Rekall->Type");
if (tmpType.indexOf("application/msword") >= 0) icnType = "background-image:url(css/images/icn-word.png);";
else if (tmpType.indexOf("application/pdf") >= 0) icnType = "background-image:url(css/images/icn-pdf.png);";
else if (tmpType.indexOf("application/") >= 0) icnType = "background-image:url(css/images/icn-document.png);";
else if (tmpType.indexOf("audio/") >= 0) icnType = "background-image:url(css/images/icn-music.png);";
else if (tmpType.indexOf("image/") >= 0) icnType = "background-image:url(css/images/icn-image.png);";
else if (tmpType.indexOf("text/x-vcard") >= 0) icnType = "background-image:url(css/images/icn-user.png);";
else if (tmpType.indexOf("text/") >= 0) icnType = "background-image:url(css/images/icn-document.png);";
else if (tmpType.indexOf("video/") >= 0) icnType = "background-image:url(css/images/icn-video.png);";
let html = "";
html += "<div draggable=true class='flattentimeline_item' title='" + tag.getMetadata("Rekall->Comments") + "' >";
html += "<div class='flattentimeline_image' style='" + styleImage + "'></div>";
html += "<div class='flattentimeline_opacifiant' style='" + styleColor2 + "'></div>";
html += "<div class='flattentimeline_type' style='" + icnType + "' title='" + tmpType + "'></div>";
html += "<div class='flattentimeline_title' style='" + textColor2 + "' title='" + tag.getMetadata("Rekall->Name") + "'>" + tag.getMetadata("Rekall->Name") + "</div>";
html += "</div>";
tag.flattenTimelineDom = $(html);
tag.flattenTimelineDom.click(function (event) {
tag.openPopupEdit();
});
tag.flattenTimelineDom.on({
dragstart: function (event) {
event.dataTransfer.setData("key", tag.document.key);
event.dataTransfer.setData("version", tag.version);
}
});
return tag.flattenTimelineDom;
});
}
$('#flattentimeline').append(tag.createTimelineDiv.call(tag));
//Ouverture du popup
if ((Tag.keyToOpenAfterLoading != undefined) && (tag.document.key == Tag.keyToOpenAfterLoading)) {
......
......@@ -31,9 +31,10 @@ function Tag(document) {
this.timeEnd = 1;
this.color = "#FFFFFF";
this.shown = false;
this.thumbnail = undefined;
}
Tag.keyToOpenAfterLoading = undefined;
Tag.keyToOpenAfterLoading = undefined;
Tag.prototype.getMetadata = function (metadataKey, metadataValue) {
return this.document.getMetadata(metadataKey, this.version);
......@@ -63,7 +64,23 @@ Tag.prototype.isLink = function() {
return this.document.isLink(this.version);
}
Tag.prototype.getTagGradientColor = function() {
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; // At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
if (isOpera) {
return "-o-linear-gradient(right bottom, rgba(20,46,51,1) 0%, " + this.color + " 100%)";
}
if (isFirefox) {
return "-moz-linear-gradient(right bottom, rgba(20,46,51,1) 0%, " + this.color + " 100%)";
}
if ((isSafari) || (isChrome)) {
return "-webkit-linear-gradient(right bottom, rgba(20,46,51,1) 0%, " + this.color + " 100%)";
}
}
Tag.prototype.getTimeStart = function () {
return this.timeStart;
}
......@@ -78,14 +95,9 @@ Tag.prototype.setTimeEnd = function(val) {
if (!isNaN(val))
this.timeEnd = val;
}
Tag.prototype.isGoodVersion = function () {
return this.version == this.document.goodVersion;
}
Tag.prototype.openFile = function () {
return this.document.openFile();
}
......@@ -110,38 +122,135 @@ Tag.prototype.openBrowser = function() {
Tag.prototype.openPopupEdit = function () {
fillPopupEdit(this);
}
Tag.prototype.update = function (color, strong) {
if (color != undefined) {
this.colorRaw = color;
this.color = color.toString();
this.isMarkerCache = this.isMarker();
/*
if(this.isMarkerCache) {
this.visuel.rect.setCornerRadius(0);
}
else {
this.visuel.rect.setCornerRadius(Tag.tagHeight/3);
}
*/
}
if (this.color == undefined)
this.color = "#000000";
}
Tag.prototype.createTimelineDiv = function () {
let that = this;
let styleColor = "background-color: " + this.color + ";";
let textColor2 = "color: rgba(255,255,255,.8)";
let styleColor2 = styleColor;
let styleImage = "";
if (this.thumbnail.url != undefined) {
styleImage = "background-image: url(" + encodeURI(this.thumbnail.url) + ");";
} else styleImage = "background-color: rgba(255,255,255,.25)";
let icnType = "";
let tmpType = this.getMetadata("Rekall->Type");
if (tmpType.indexOf("application/msword") >= 0) icnType = "background-image:url(css/images/icn-word.png);";
else if (tmpType.indexOf("application/pdf") >= 0) icnType = "background-image:url(css/images/icn-pdf.png);";
else if (tmpType.indexOf("application/") >= 0) icnType = "background-image:url(css/images/icn-document.png);";
else if (tmpType.indexOf("audio/") >= 0) icnType = "background-image:url(css/images/icn-music.png);";
else if (tmpType.indexOf("image/") >= 0) icnType = "background-image:url(css/images/icn-image.png);";
else if (tmpType.indexOf("text/x-vcard") >= 0) icnType = "background-image:url(css/images/icn-user.png);";
else if (tmpType.indexOf("text/") >= 0) icnType = "background-image:url(css/images/icn-document.png);";
else if (tmpType.indexOf("video/") >= 0) icnType = "background-image:url(css/images/icn-video.png);";
var fillColor = '';
var strokeColor = '';
var strokeWidth = 0;
var opacity = 1;
if(this.isGoodVersion()) {
fillColor = this.color;
strokeWidth = 0;
strokeColor = "";
let html = "";
html += "<div draggable=true class='flattentimeline_item' title='" + this.getMetadata("Rekall->Comments") + "' >";
html += "<div class='flattentimeline_image' style='" + styleImage + "'></div>";
html += "<div class='flattentimeline_opacifiant' style='" + styleColor2 + "'></div>";
html += "<div class='flattentimeline_type' style='" + icnType + "' title='" + tmpType + "'></div>";
html += "<div class='flattentimeline_title' style='" + textColor2 + "' title='" + this.getMetadata("Rekall->Name") + "'>" + this.getMetadata("Rekall->Name") + "</div>";
html += "</div>";
this.flattenTimelineDom = $(html);
this.flattenTimelineDom.click(function () {
that.openPopupEdit();
});
this.flattenTimelineDom.on({
dragstart: function (event) {
event.dataTransfer.setData("key", that.document.key);
event.dataTransfer.setData("version", that.version);
}
});
return this.flattenTimelineDom;
}
else {
fillColor = tinycolor(this.colorRaw.toString()).setAlpha(0.1).toString();
strokeColor = this.color;
strokeWidth = 0.8;
function HighLightedTag(data) {
Tag.call(this, data.Document);
}
HighLightedTag.prototype = Object.create(Tag.prototype);
HighLightedTag.prototype.createTimelineDiv = function () {
let that = this;
let styleColor = "background-color: " + this.color + ";";
let textColor = "color: " + this.color + ";";
let colorTransp = "";
let styleColor2 = styleColor;
let styleImage = "";
if (this.thumbnail?.url) {
styleImage = "background-image: -webkit-linear-gradient(right bottom, rgba(20,46,51,.60) 0%,rgba(20,46,51,.90) 100%), url(" + this.thumbnail.url + "); background-image: -moz-linear-gradient(right bottom, rgba(20,46,51,.60) 0%,rgba(20,46,51,.90) 100%), url(" + this.thumbnail.url + "); background-image: -o-linear-gradient(right bottom, rgba(20,46,51,.60) 0%,rgba(20,46,51,.90) 100%), url(" + this.thumbnail.url + ");";
} else {
styleImage = "background-color: " + this.color + "; background-image: -webkit-linear-gradient(right bottom, rgba(20,46,51,.5) 0%,rgba(20,46,51,.8) 100%); background-image: -moz-linear-gradient(right bottom, rgba(20,46,51,.5) 0%,rgba(20,46,51,.8) 100%); background-image: -o-linear-gradient(right bottom, rgba(20,46,51,.5) 0%,rgba(20,46,51,.8) 100%);";
}
let tmpType = this.getMetadata("Rekall->Type");
let typeTxt = tmpType.split("/")[1].replace(/marker/g, "note");
let htmlHighlight = "";
htmlHighlight += "<div draggable=true class='flattentimeline_item flattentimeline_highlightitem' style='" + colorTransp + " " + styleImage + "'>";
htmlHighlight += "<div class='flattentimeline_title' style='" + textColor + "' title='" + this.getMetadata("Rekall->Name") + "'>" + this.getMetadata("Rekall->Name") + "</div>";
if (this.getMetadata("Rekall->Comments") != "") {
let tmpComments = this.getMetadata("Rekall->Comments");
if (tmpComments.length > 150) {
tmpComments = tmpComments.substring(0, 150) + "...";
}
let tmpcount = 0;
let tmpIndex = tmpComments.indexOf("<br/>");
while ((tmpcount < 3) && (tmpIndex != -1)) {
tmpcount++;
tmpIndex = tmpComments.indexOf("<br/>", tmpIndex + 1);
}
if (tmpIndex != -1) {
tmpComments = tmpComments.substring(0, tmpIndex) + "...";
}
htmlHighlight += "<div class='flattentimeline_description'>" + tmpComments + "</div>";
}
if (this.getMetadata("Rekall->Author") != "") htmlHighlight += "<div class='flattentimeline_author'>" + this.getMetadata("Rekall->Author") + "</div>";
htmlHighlight += "<div class='flattentimeline_typeTxt' >" + typeTxt + "</div>";
htmlHighlight += "<div class='flattentimeline_opacifiant' style='" + styleColor2 + "'></div>";
htmlHighlight += "</div>";
this.flattenTimelineDom = $(htmlHighlight);
this.flattenTimelineDom.click(function () {
that.openPopupEdit();
});
this.flattenTimelineDom.on({
dragstart: function (event) {
event.dataTransfer.setData("key", that.document.key);
event.dataTransfer.setData("version", that.version);
}
});
return this.flattenTimelineDom;
}
const TagFactory = function (document) {
if (document.getMetadata("Rekall->Highlight", document.currentVersion)) {
return new HighLightedTag({document: document})
}
return new Tag(document);
}
\ No newline at end of file
var rekall = new Rekall();
var rekall_common = new Object();
var pubSub = null;
var popupPanel = new PopupPanelWidget({ canEdit: () => rekall_common.owner.canEdit });
window.onload = function() {
pubSub = window.top.PubSub;
......@@ -15,9 +16,10 @@ window.onload = function() {
pubSub.subscribe('alert', openAlertWrapper);
pubSub.subscribe('roulette.terminated', rouletteEnd);
pubSub.subscribe('roulette.started', rouletteStart);
};
pubSub.subscribe('tag.metadata.updated', onMetaFromDomUpdated);
pubSub.subscribe('tag.tc.updated', onTcUpdated);
pubSub.subscribe('image.annotation.edit.open', openImageEdition);
$(document).ready(function() {
window.app.rekall.Rekall('init', {
Rekall: rekall
});
......@@ -132,7 +134,7 @@ $(document).ready(function() {
var tmp = shareLink();
openAlert("input",tmp);
});
});
};
function setEditionControls() {
......@@ -187,10 +189,17 @@ function setEditionControls() {
});
$("#flattentimeline").on({
dragenter: function(event) { /*$(".flattentimeline_item").removeClass("draggable").addClass("drag");*/ },
dragleave: function(event) { $("#flattentimeline").removeClass("draggable").removeClass("drag"); },
dragover: function(event) { $("#flattentimeline").removeClass("draggable").addClass("drag"); },
drop: function(event) { $("#flattentimeline").removeClass("draggable").removeClass("drag"); }
dragenter: function (event) { /*$(".flattentimeline_item").removeClass("draggable").addClass("drag");*/
},
dragleave: function (event) {
$("#flattentimeline").removeClass("draggable").removeClass("drag");
},
dragover: function (event) {
$("#flattentimeline").removeClass("draggable").addClass("drag");
},
drop: function (event) {
$("#flattentimeline").removeClass("draggable").removeClass("drag");
}
});
$("#left_menu_item_settings").click(function (event) {
......@@ -335,8 +344,12 @@ function setEditionControls() {
uploadFiles($("#left_menu_item_btn_addfile").get(0).files);
});
$("#btn_add_paste").click(function(event) { pubSub.publish('open_paste_modal'); });
$("#paste_modal button.cancel").click(function(event) { pubSub.publish('close_paste_modal'); });
$("#btn_add_paste").click(function (event) {
pubSub.publish('open_paste_modal');
});
$("#paste_modal button.cancel").click(function (event) {
pubSub.publish('close_paste_modal');
});
$("#paste_modal_content").on("paste", function (event) {
$('#paste_modal_content').empty();
......@@ -388,7 +401,9 @@ function setEditionControls() {
}
});
$('#tab_selector_form').change(function(event) { pubSub.publish(event.target.value) });
$('#tab_selector_form').change(function (event) {
pubSub.publish(event.target.value)
});
$("#popupEdit").click(function (event) {
event.stopPropagation();
......@@ -550,37 +565,6 @@ function setEditionControls() {
console.debug("set playback rate to " + event.target.value);
window.app.rekall.Rekall().videoPlayer.playbackRate(Number(event.target.value));
});
$('#editAnnotationPic').click(function(ev) {
$('#edit_pic_modal').show();
var keyDoc = ev.target.parentElement.parentElement.attributes['keydoc'];
var markerArea = new markerjs2.MarkerArea(document.getElementById('annotation_img_edit'));
markerArea.targetRoot = document.getElementById('edit_pic_modal');
markerArea.addEventListener('render', (event) => {
var state = markerArea.getState();
window.my_current_markerjs_data_in_ugly_global = state;
markerArea.close(true);
setMetaFromDom(keyDoc.value, "Rekall->MarkerjsState", btoa(JSON.stringify(state)));
var b64img = event.dataUrl;
var data = b64img.match(/data:([a-z]+)\/([a-z]+);base64,(.*)/);
var type = data[1], subtype = data[2], b64data = data[3];
var bin_str = atob(b64data);
var n = b64data.length;
var uar = new Uint8Array(n);
while (n--) uar[n] = bin_str.charCodeAt(n);
var file = new File([uar], keyDoc.value.substr(1), {type: type+'/'+subtype});
$('#left_menu_item_btn_addfile').files = [file];
uploadFiles([file], {'edited': 1});
$('#popupImg').attr('src', $('#popupImg').attr('src') + '&time=' + performance.now());
});
markerArea.addEventListener('close', () => $('#edit_pic_modal').hide());
markerArea.renderAtNaturalSize = true;
markerArea.show();
if (window.my_current_markerjs_data_in_ugly_global)
markerArea.restoreState(window.my_current_markerjs_data_in_ugly_global);
})
}
function closeSettingsPopup() {
......@@ -736,97 +720,8 @@ function closeSettingsInputs() {
}
function closeInputs() {
$.each($(".popupInput"), function() {
if($(this).css("display") != "none") {
if($(this).attr("id")=="popupNomInput") {
var keyDoc = $(this).parent().attr("keydoc");
var newName = $(this).val().trim();
$(this).val(newName);
setMetaFromDom(keyDoc, "Rekall->Name", newName);
if(newName!="") $("#popupNom").html(newName).removeClass("empty");
else $("#popupNom").html("+ Add a name").addClass("empty");
} else if($(this).attr("id")=="popupLegendeInput") {
var keyDoc = $(this).parent().attr("keydoc");
var newComment = $(this).val().trim();
$(this).val(newComment);
setMetaFromDom(keyDoc, "Rekall->Comments", newComment.replace(/\n/gi, "<br/>"));
if(newComment!="") $("#popupLegende").html(newComment.replace(/\n/gi, "<br/>")).removeClass("empty");
else $("#popupLegende").html("+ Add a comment").addClass("empty");
} else if($(this).attr("id")=="popupSpeedInput") {
var keyDoc = $(this).parent().attr("keydoc");
var newSpeed = $('#popupSpeedInput input:checked').val();
setMetaFromDom(keyDoc, "Rekall->Speed", newSpeed);
} else if($(this).attr("id")=="popupLabelsInput") {
var keyDoc = $(this).parent().attr("keydoc");
var newLabels = '';
$('input.annotation_labels:checked').toArray().forEach(e => newLabels += e.value + ';')
setMetaFromDom(keyDoc, "Rekall->Labels", newLabels);
} else if($(this).attr("id")=="popupAuthorInput") {
var keyDoc = $(this).parent().attr("keydoc");
var newAuthor = $(this).val().trim();
$(this).val(newAuthor);
setMetaFromDom(keyDoc, "Rekall->Author", newAuthor);
if(newAuthor!="") $("#popupAuthor").html(newAuthor).removeClass("empty");
else $("#popupAuthor").html("+ Add an author").addClass("empty");
} else if($(this).attr("id")=="popupLinkInput") {
var keyDoc = $(this).parent().attr("keydoc");
var newLink = $(this).val().trim();
if(newLink!="") if(newLink.indexOf("http")!=0) newLink = "http://"+newLink;
$(this).val(newLink);
setMetaFromDom(keyDoc, "Rekall->Link", newLink);
if(newLink!="") {
if(rekall_common.owner.canEdit) $("#popupLink").html(newLink).removeClass("empty");
else $("#popupLink").html("<a href='"+newLink+"' target='_blank'>"+newLink+"</a>").removeClass("empty");
}
else $("#popupLink").html("+ Add a link").addClass("empty");
} else if($(this).attr("id")=="popupTCedit") {
var keyDoc = $("#popupRight").attr("keydoc");
var inMin = $("#popupTCinMin").val();
var inSec = $("#popupTCinSec").val();
var outMin = $("#popupTCoutMin").val();
var outSec = $("#popupTCoutSec").val();
var TCin = (inMin*60)+(inSec*1);
var TCout = (outMin*60)+(outSec*1);
var endVideo = Math.ceil(rekall.videoPlayer.duration());
var isReturn = true;
if((inMin>=120)||(inSec>=60)||(outMin>=120)||(outSec>=60)||(inMin<0)||(inSec<0)||(outMin<0)||(outSec<0)) openAlert("Invalid time code", "ok");
else if(TCin>TCout) openAlert("Start time must be set before end time", "ok");
else if(TCout>endVideo) openAlert("End time must not be set after " + convertToTime(endVideo) + " (end of the video)", "ok");
else {
setTCFromDom(keyDoc, TCin, TCout);
$("#popupTCin").html(inMin+":"+inSec);
$("#popupTCout").html(outMin+":"+outSec);
isReturn = false;
}
if(isReturn) return true;
}
}
});
$(".popupInput:not(.popupInputNoHide)").hide();
popupPanel.ensureLastOpenedEditionClosed();
$(".popupRightItem").show();
$("#popupTC").show();
$("#popupTCedit").hide();
}
function closeEdit() {
......@@ -852,132 +747,34 @@ function openMosaic() {
function fillPopupEdit(tag) {
popupPanel.createPopupContent(tag);
var isPaused = rekall.timeline.isPaused();
rekall.timeline.pause();
$("#popupEdit").attr("isPaused",isPaused);
$("#popupTC").css("background",tag.color);
var bgColorLeft = tag.color.replace(/rgb/g, "rgba").replace(/\)/g, ",.35)");
bgColorLeft = getTagGradientColor(tag);
$("#popupLeft").css("background",bgColorLeft);
var type = tag.getMetadata("Rekall->Type");
$("#popupImg").unbind( "click" );
if(tag.isMarker()==true){
$("#popupImg").show();
$("#popupImg").attr("src","../shared/css/images/img-note.png");
} else {
if(tag.thumbnail.url){
$("#popupImg").attr("src", tag.getDownloadLink() || tag.thumbnail.url);
$('#annotation_img_edit').attr('src', tag.getDownloadLink(true));
} else {
if(type.indexOf("image") > -1) $("#popupImg").attr("src","../shared/css/images/img-image.png")
else if(type.indexOf("pdf") > -1) $("#popupImg").attr("src","../shared/css/images/img-pdf.png")
else if(type.indexOf("audio") > -1) $("#popupImg").attr("src","../shared/css/images/img-music.png")
else if(type.indexOf("vcard") > -1) $("#popupImg").attr("src","../shared/css/images/img-user.png")
else if(type.indexOf("video") > -1) $("#popupImg").attr("src","../shared/css/images/img-video.png")
else if(type.indexOf("msword") > -1) $("#popupImg").attr("src","../shared/css/images/img-word.png")
else if(type.indexOf("link") > -1) $("#popupImg").attr("src","../shared/css/images/img-link.png")
else $("#popupImg").attr("src","../shared/css/images/img-document.png");
}
$("#popupImg").click(function(event){
event.stopPropagation();
if(tag.isLink()) {
if(link != "") window.open(link,'_blank');
}
else
window.open($('#popupImg')[0].src, '_blank');
});
}
$("#popupNom").css("color",tag.color);
window.my_current_markerjs_data_in_ugly_global = null;
$('#editAnnotationPic').hide();
$('#linkToOriginalImage').hide();
if (type.split('/')[0] == 'image') {
$('#editAnnotationPic').html('edit');
$('#editAnnotationPic').show();
$('#linkToOriginalImage').show();
$('#linkToOriginalImage').unbind('click');
$('#linkToOriginalImage').click(() => window.open(tag.getDownloadLink(true), '_blank'));
var data = tag.getMetadata('Rekall->MarkerjsState');
if (data)
window.my_current_markerjs_data_in_ugly_global = JSON.parse(atob(data));
}
$("#popupType").html(type).css("color",tag.color);
var name = tag.getMetadata("Rekall->Name");
if(name!="") $("#popupNom").html(name).removeClass("empty");
else $("#popupNom").html("+ Add a name").addClass("empty");
var startVerb = convertToTime(tag.getTimeStart());
$("#popupTCin").html(startVerb);
var endVerb = convertToTime(tag.getTimeEnd());
$("#popupTCout").html(endVerb);
var speed = tag.getMetadata("Rekall->Speed");
if (!speed || speed == '')
speed = 1;
$('#popupSpeedInput input').attr('checked', false);
$('#popupSpeedInput input[value="'+speed+'"]').attr('checked', true);
var labels = tag.getMetadata("Rekall->Labels");
$('input.annotation_labels').attr('checked', false);
if (labels && labels != '') {
var _labels = labels.split(';');
$('input.annotation_labels').toArray().forEach(e => {
e.checked = (_labels.indexOf(e.value) != -1);
})
}
var comments = tag.getMetadata("Rekall->Comments");
if((comments)&&(comments!="")) $("#popupLegende").html(comments).removeClass("empty");
else $("#popupLegende").html("+ Add a comment").addClass("empty");
var author = tag.getMetadata("Rekall->Author");
if((author)&&(author!="")) $("#popupAuthor").html(author).removeClass("empty");
else $("#popupAuthor").html("+ Add an author").addClass("empty");
var link = tag.getMetadata("Rekall->Link");
if((link)&&(link!="")) {
if(rekall_common.owner.canEdit) $("#popupLink").html(link).removeClass("empty");
else $("#popupLink").html("<a href='"+link+"' target='_blank'>"+link+"</a>").removeClass("empty");
}
else $("#popupLink").html("+ Add a link").addClass("empty");
// var labels = tag.getMetadata("Rekall->Labels");
// $('input.annotation_labels').attr('checked', false);
// if (labels && labels != '') {
// var _labels = labels.split(';');
// $('input.annotation_labels').toArray().forEach(e => {
// e.checked = (_labels.indexOf(e.value) != -1);
// })
// }
if(rekall_common.owner.canEdit) {
if(tag.isMarker()==true) $("#popupEditSupprimer").html("Delete Note");
else $("#popupEditSupprimer").html("Delete File");
$(".empty").show();
$(".displayMode").hide();
$("#popupNomInput").val(tag.getMetadata("Rekall->Name"));
$("#popupTCinMin").val(startVerb.split(":")[0]);
$("#popupTCinSec").val(startVerb.split(":")[1]);
$("#popupTCoutMin").val(endVerb.split(":")[0]);
$("#popupTCoutSec").val(endVerb.split(":")[1]);
$("#popupLegendeInput").val(""+comments.replace(/<br\/>/gi, '\n'));
$("#popupAuthorInput").val(""+author);
$("#popupLinkInput").val(""+link);
$("#popupSpeedInput").val(""+speed);
var highlight = tag.getMetadata("Rekall->Highlight");
if(highlight=="true") {
$("#popupSetHighlight").attr("isHighlight","true").addClass("selected");
$("#popupEdit").addClass("highlightPopup");
}
else {
$("#popupSetHighlight").attr("isHighlight","false").removeClass("selected");
$("#popupEdit").removeClass("highlightPopup");
}
} else {
......@@ -986,9 +783,6 @@ function fillPopupEdit(tag) {
$(".displayMode").show();
}
$("#popupLeft") .attr("keydoc", tag.document.key);
$("#popupRight").attr("keydoc", tag.document.key);
$("#popupSpace").show();
$("#popupEdit").show();
}
......@@ -1057,6 +851,14 @@ function setMetaFromDom(keyDoc, metaType, meta) {
});
}
function onMetaFromDomUpdated(message, data){
setMetaFromDom(data.tag.document.key, data.metadata, data.tag.getMetadata(data.metadata));
}
function onTcUpdated(message, data){
setTCFromDom(data.tag.document.key, data.tag.getTimeStart(), data.tag.getTimeEnd());
}
function setTCFromDom(keyDoc, TCin, TCout) {
rouletteStart();
$.ajax("php/project.php", {
......@@ -1100,7 +902,7 @@ function deleteFromDomFinished() {
//Gestion d'upload
var filesToUpload = [], fileIsUploading = false;
function uploadFiles(files, additionnal_post_data={}) {
function uploadFiles(files, additionnal_post_data={}, callBack = undefined) {
$.each(files, function(index, file) {
var formData = new FormData();
......@@ -1173,6 +975,9 @@ function uploadFiles(files, additionnal_post_data={}) {
rouletteEnd();
uploadFilesNext();
if(callBack && typeof callBack === 'function'){
callBack();
}
},
error: function(data) {
openAlert("Uploading error. Try again.");
......@@ -1181,6 +986,9 @@ function uploadFiles(files, additionnal_post_data={}) {
rouletteEnd();
uploadFilesNext();
if(callBack && typeof callBack === 'function'){
callBack();
}
}
});
uploadFilesNext();
......@@ -1260,3 +1068,42 @@ $(window).trigger("resize");
function openPasteModal() { $('#paste_modal').css('display', 'flex'); $('#paste_modal_content').first().focus() }
function closePasteModal() { $('#paste_modal').hide(); $('#paste_modal_content').empty(); }
function openImageEdition(message, tag) {
$('#edit_pic_modal').show();
let keyDoc = tag.document.key;
$('#annotation_img_edit').attr('src', tag.getDownloadLink(true));
let markerArea = new markerjs2.MarkerArea($('#annotation_img_edit')[0]);
let imageState;
if (tag.getMetadata("Rekall->MarkerjsState").length){
imageState = JSON.parse(atob(tag.getMetadata("Rekall->MarkerjsState")));
}
markerArea.targetRoot = document.getElementById('edit_pic_modal');
markerArea.addEventListener('render', (event) => {
imageState = markerArea.getState();
markerArea.close(true);
tag.setMetadata("Rekall->MarkerjsState", btoa(JSON.stringify(imageState)));
let b64img = event.dataUrl;
let data = b64img.match(/data:([a-z]+)\/([a-z]+);base64,(.*)/);
let type = data[1], subtype = data[2], b64data = data[3];
let bin_str = atob(b64data);
let n = b64data.length;
let uar = new Uint8Array(n);
while (n--) uar[n] = bin_str.charCodeAt(n);
let file = new File([uar], keyDoc.substr(1), {type: type+'/'+subtype});
$('#left_menu_item_btn_addfile').files = [file];
uploadFiles([file], {'edited': 1}, function(){$('#popupImg').attr('src', tag.getDownloadLink());});
setMetaFromDom(tag.document.key, "Rekall->MarkerjsState", tag.getMetadata('Rekall->MarkerjsState'));
});
markerArea.addEventListener('close', () => {
$('#edit_pic_modal').hide();
});
markerArea.renderAtNaturalSize = true;
markerArea.show();
if (imageState)
markerArea.restoreState(imageState);
}
\ No newline at end of file
......@@ -21,13 +21,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function Document() {
function Document(data) {
this.tags = new Array();
this.metadatas = new Array();
this.currentVersion = 0;
this.goodVersion = 0;
this.setMetadata("Rekall->Group", "");
this.setMetadata("Rekall->Visibility", "");
this.project = data.project;
}
Document.prototype.addTag = function(tag) {
this.tags.push(tag);
......@@ -88,7 +89,7 @@ Document.prototype.isLink = function(version) {
}
Document.prototype.getDownloadLink = function(original = false) {
var path = Utils.getLocalFilePath(this, "file");
return original ? path.replace('file.php?r=', 'file.php?r=rk_original_af7ef02e_') : path;
return original ? path.replace('file.php?r=', 'file.php?r=rk_original_af7ef02e_') : path + '&timegeneration=' + performance.now();
}
Document.prototype.getFileName = function() {
var path = Utils.getLocalFilePath(this, "file");
......@@ -152,7 +153,7 @@ Document.prototype.addVersion = function(document) {
for (var index in this.tags) {
var tag = this.tags[index];
if(tag.version == thisVersion) {
var newTag = new Tag(this);
var newTag = TagFactory(this);
newTag.timeStart = tag.getTimeStart();
newTag.timeEnd = tag.getTimeEnd();
this.addTag(newTag);
......
......@@ -35,7 +35,7 @@ Source.prototype.addDocument = function(document) {
if(this.documents[document.key] == undefined) {
if(document.tags.length == 0) {
var tag = new Tag(document);
var tag = TagFactory(document);
document.addTag(tag);
}
document.metadatas[-1] = document.cloneMetadatas();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment