From 6fd202fe36730d7ed5ead208046de827674865f5 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sun, 22 Sep 2013 15:27:10 -0400 Subject: [PATCH] closed #321, removed cheerio use altogether, and made changes to the client side to ajaxify the user to /outgoing when an external link is clicked --- public/src/ajaxify.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 5cf650703a..77b91d5d25 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -102,26 +102,29 @@ var ajaxify = {}; // Enhancing all anchors to ajaxify... $(document.body).on('click', 'a', function(e) { - function hrefEmpty(href) { return href == 'javascript:;' || href == window.location.href + "#" || href.slice(-1) === "#"; } if (hrefEmpty(this.href)) return; - - var url = this.href.replace(rootUrl + '/', ''); - if (this.target !== '') return; + if (this.protocol === 'javascript:') return; if (!e.ctrlKey && e.which === 1) { - if (ajaxify.go(url)) { + if (this.host === window.location.host) { + var url = this.href.replace(rootUrl + '/', ''); + + if (ajaxify.go(url)) { + e.preventDefault(); + } + } else { + ajaxify.go('outgoing?url=' + encodeURIComponent(this.href)); e.preventDefault(); } } }); }); - function exec_body_scripts(body_el) { // modified from http://stackoverflow.com/questions/2592092/executing-script-elements-inserted-with-innerhtml