Use the bounce app to open links from inner

This commit is contained in:
yflory
2017-11-27 14:44:44 +01:00
parent 812df7de6f
commit 644f6e9985
7 changed files with 42 additions and 39 deletions

View File

@@ -1,6 +1,5 @@
define([
'jquery',
'/common/cryptpad-common.js',
'/customize/messages.js',
'/common/common-util.js',
'/common/common-interface.js',
@@ -8,36 +7,11 @@ define([
'/common/hyperscript.js',
'/bower_components/marked/marked.min.js',
'/common/media-tag.js',
], function ($, Cryptpad, Messages, Util, UI, Notifier, h, Marked, MediaTag) {
], function ($, Messages, Util, UI, Notifier, h, Marked, MediaTag) {
'use strict';
var MessengerUI = {};
var m = function (md) {
var d = h('div.cp-app-contacts-content');
try {
d.innerHTML = Marked(md || '');
var $d = $(d);
// remove potentially malicious elements
$d.find('script, iframe, object, applet, video, audio').remove();
// override link clicking, because we're in an iframe
$d.find('a').each(function () {
var href = $(this).click(function (e) {
e.preventDefault();
window.open(href);
}).attr('href');
});
// activate media-tags
$d.find('media-tag').each(function (i, e) { MediaTag(e); });
} catch (e) {
console.error(md);
console.error(e);
}
return d;
};
var dataQuery = function (curvePublic) {
return '[data-key="' + curvePublic + '"]';
};
@@ -81,6 +55,31 @@ define([
find.inList(curvePublic).removeClass('cp-app-contacts-notify');
};
var m = function (md) {
var d = h('div.cp-app-contacts-content');
try {
d.innerHTML = Marked(md || '');
var $d = $(d);
// remove potentially malicious elements
$d.find('script, iframe, object, applet, video, audio').remove();
// override link clicking, because we're in an iframe
$d.find('a').each(function () {
var href = $(this).click(function (e) {
e.preventDefault();
common.openUnsafeURL(href);
}).attr('href');
});
// activate media-tags
$d.find('media-tag').each(function (i, e) { MediaTag(e); });
} catch (e) {
console.error(md);
console.error(e);
}
return d;
};
var markup = {};
markup.message = function (msg) {
var curvePublic = msg.author;
@@ -510,7 +509,7 @@ define([
console.error('TODO show something if that chatbox was active');
});
Cryptpad.onDisplayNameChanged(function () {
common.getMetadataMgr().onChange(function () {
//messenger.checkNewFriends();
messenger.updateMyData();
});