Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
take signature into account when inserting links into email
Browse files Browse the repository at this point in the history
  • Loading branch information
barrydegraaff committed Apr 17, 2017
1 parent f8e77f3 commit 5d56e9e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 22 deletions.
72 changes: 51 additions & 21 deletions zimlet/OwnCloudTabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,33 @@ OwnCloudTabView.prototype._attachFiles =
} else {
sep = "<br>";
}

//Try and add link above signature
if(content.indexOf(linkData) < 0)
{
if(appCtxt.getCurrentView().getSignatureContent())
{
//remove cr lf from begin and end of signature for regex matching, as these are not preserved in content of html composer
content = content.replace(appCtxt.getCurrentView().getSignatureContent().replace(/^\s+|\s+$/g, ''), linkData + sep + appCtxt.getCurrentView().getSignatureContent());
}
}

if(content.indexOf('<hr id="') > 0) {
content = content.replace('<hr id="', linkData + sep + '<hr id="');
} else if(content.indexOf('<div id="') > 0) {
content = content.replace('<div id="', linkData + sep + '<div id="');
} else if(content.indexOf('</body') > 0) {
content = content.replace('</body', linkData + sep + '</body');
} else if(content.indexOf('----') > 0) {
content = content.replace('----', linkData + sep + '----');
} else {
content = content + sep + linkData + sep;
}
//signature not matched, try this:
if(content.indexOf(linkData) < 0)
{

if(content.indexOf('<hr id="') > 0) {
content = content.replace('<hr id="', linkData + sep + '<hr id="');
} else if(content.indexOf('<div id="') > 0) {
content = content.replace('<div id="', linkData + sep + '<div id="');
} else if(content.indexOf('</body') > 0) {
content = content.replace('</body', linkData + sep + '</body');
} else if(content.indexOf('----') > 0) {
content = content.replace('----', linkData + sep + '----');
} else {
content = content + sep + linkData + sep;
}
}
composeView.getHtmlEditor().setContent(content);
}
return;
Expand Down Expand Up @@ -327,22 +342,37 @@ OwnCloudTabView.prototype._appendSharedLink =
if(url.link.match(/http:\/\/|https:\/\//i))
{
linkData = url.name + " "+passwordText+" : " + url.link;

if(composeMode == 'text/plain') {
sep = "\r\n";
} else {
sep = "<br>";
}

if(content.indexOf('<hr id="') > 0) {
content = content.replace('<hr id="', linkData + sep + '<hr id="');
} else if(content.indexOf('<div id="') > 0) {
content = content.replace('<div id="', linkData + sep + '<div id="');
} else if(content.indexOf('</body') > 0) {
content = content.replace('</body', linkData + sep + '</body');
} else if(content.indexOf('----') > 0) {
content = content.replace('----', linkData + sep + '----');
} else {
content = content + sep + linkData + sep;
//Try and add link above signature
if(content.indexOf(linkData) < 0)
{
if(appCtxt.getCurrentView().getSignatureContent())
{
//remove cr lf from begin and end of signature for regex matching, as these are not preserved in content of html composer
content = content.replace(appCtxt.getCurrentView().getSignatureContent().replace(/^\s+|\s+$/g, ''), linkData + sep + appCtxt.getCurrentView().getSignatureContent());
}
}

//signature not matched, try this:
if(content.indexOf(linkData) < 0)
{
if(content.indexOf('<hr id="') > 0) {
content = content.replace('<hr id="', linkData + sep + '<hr id="');
} else if(content.indexOf('<div id="') > 0) {
content = content.replace('<div id="', linkData + sep + '<div id="');
} else if(content.indexOf('</body') > 0) {
content = content.replace('</body', linkData + sep + '</body');
} else if(content.indexOf('----') > 0) {
content = content.replace('----', linkData + sep + '----');
} else {
content = content + sep + linkData + sep;
}
}
composeView.getHtmlEditor().setContent(content);
}
Expand Down
2 changes: 1 addition & 1 deletion zimlet/tk_barrydegraaff_owncloud_zimlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
-->
<zimlet name="tk_barrydegraaff_owncloud_zimlet"
version="0.7.9"
version="0.8.0"
target="main compose-window view-window"
label="WebDAV"
description="Attach from and save to WebDAV">
Expand Down

0 comments on commit 5d56e9e

Please sign in to comment.