You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2017/01/07 16:02:09 UTC

incubator-ponymail git commit: Fetch URLBase once in Javascript

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 4d165cab2 -> 6eac6ec0f


Fetch URLBase once in Javascript

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/6eac6ec0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/6eac6ec0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/6eac6ec0

Branch: refs/heads/master
Commit: 6eac6ec0fece20d0f2d7a52224edd100e7c3b149
Parents: 4d165ca
Author: Sebb <se...@apache.org>
Authored: Sat Jan 7 16:01:51 2017 +0000
Committer: Sebb <se...@apache.org>
Committed: Sat Jan 7 16:01:51 2017 +0000

----------------------------------------------------------------------
 CHANGELOG.md                             |  1 +
 site/js/dev/ponymail_assign_vars.js      |  2 +
 site/js/dev/ponymail_composer.js         |  5 +--
 site/js/dev/ponymail_email_displays.js   | 26 ++++---------
 site/js/dev/ponymail_helperfuncs.js      | 10 +----
 site/js/dev/ponymail_timetravel.js       |  4 +-
 site/js/dev/ponymail_user_preferences.js |  7 +---
 site/js/ponymail.js                      | 54 ++++++++-------------------
 8 files changed, 33 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c31c0a7..3a1b6e9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -105,6 +105,7 @@
 - pminfo.lua - no need to use scroll unless doc count > 10000 (#321)
 - pminfo.lua - scroll/scan ignores sort order (#322)
 - flat view mode does not show first line of body (#198)
+- Fetch URLBase once in Javascript
 
 ## CHANGES in 0.9b:
 

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/site/js/dev/ponymail_assign_vars.js
----------------------------------------------------------------------
diff --git a/site/js/dev/ponymail_assign_vars.js b/site/js/dev/ponymail_assign_vars.js
index d858d9b..f9709c7 100644
--- a/site/js/dev/ponymail_assign_vars.js
+++ b/site/js/dev/ponymail_assign_vars.js
@@ -60,6 +60,8 @@ var pb_refresh = 0
 var treeview_guard = {}
 var mbox_month = null
 
+var URL_BASE = pm_config.URLBase ? pm_config.URLBase.replace(/\/+/g, "/") : ""
+
 function isStorageAvailable(type) {
     try {
         var storage = window[type],

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/site/js/dev/ponymail_composer.js
----------------------------------------------------------------------
diff --git a/site/js/dev/ponymail_composer.js b/site/js/dev/ponymail_composer.js
index 7eb9b3a..3077bad 100644
--- a/site/js/dev/ponymail_composer.js
+++ b/site/js/dev/ponymail_composer.js
@@ -65,11 +65,8 @@ function sendEmail(form) {
         of.push("alt=" + encodeURIComponent(document.getElementById('alt').options[document.getElementById('alt').selectedIndex].value))
     }
         
-    var base = pm_config.URLBase ? pm_config.URLBase : ""
-    base = base.replace(/\/+/g, "/")
-
     var request = new XMLHttpRequest();
-    request.open("POST", base + "/api/compose.lua");
+    request.open("POST", URL_BASE + "/api/compose.lua");
     request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     request.send(of.join("&")) // send email as a POST string
     

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/site/js/dev/ponymail_email_displays.js
----------------------------------------------------------------------
diff --git a/site/js/dev/ponymail_email_displays.js b/site/js/dev/ponymail_email_displays.js
index e04e605..b491a97 100644
--- a/site/js/dev/ponymail_email_displays.js
+++ b/site/js/dev/ponymail_email_displays.js
@@ -30,10 +30,6 @@ function displayEmail(json, id, level) {
         current_email_msgs.push(json)
     }
     
-    // URI Base
-    var base = pm_config.URLBase ? pm_config.URLBase : ""
-    base = base.replace(/\/+/g, "/")
-    
     // Save the JSON in our JS array so we don't have to fetch it again later
     saved_emails[json.mid] = json
     var estyle = ""
@@ -76,15 +72,13 @@ function displayEmail(json, id, level) {
         if (ebody == null) {ebody = '(null body)'} // temporary hack to deal with broken bodies
         ebody = ebody.replace(/</mg, "&lt;")
         ebody = "\n" + ebody // add a newline at top
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
         // If we're compacting quotes in the email, let's...do so with some fuzzy logic
         if (prefs.compactQuotes == 'yes') {
             ebody = ebody.replace(/((?:\r?\n)((on .+ wrote:[\r\n]+)|(sent from my .+)|(>+[ \t]+[^\r\n]*\r?\n[^\n]*\n*)+)+)+/mgi, function(inner) {
                 var rnd = (Math.random() * 100).toString()
                 inner = inner.replace(/>/g, "&gt;")
                 var html = "<div class='bs-callout bs-callout-default' style='margin: 3px; padding: 2px;' id='parent_" + rnd + "'>" +
-                    "<img src='" + base + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
+                    "<img src='" + URL_BASE + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
                     "<div style='display: none;' id='quote_" + rnd + "'>" + inner + "</div></div>"
                 return html
             })
@@ -139,7 +133,7 @@ function displayEmail(json, id, level) {
                     } else {
                         size = fd.size.toLocaleString() + " bytes"
                     }
-                    thread.innerHTML += "<a href='" + base + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
+                    thread.innerHTML += "<a href='" + URL_BASE + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
                 }
                 thread.innerHTML += "<br/>"
             }
@@ -155,8 +149,8 @@ function displayEmail(json, id, level) {
             thread.style.background = estyle
             thread.style.marginTop = "30px"
             thread.innerHTML += ' &nbsp; <label class="label label-success" onclick="compose(\'' + json.mid + '\');" style="cursor: pointer; float: right; margin-left: 10px;">Reply</label>'
-            thread.innerHTML += ' &nbsp; <a href="' + base + '/thread.html/'+(pm_config.shortLinks ? shortenID(json.mid) : json.mid)+'"><label class="label label-warning" style="cursor: pointer; float: right;">Permalink</label></a>'
-            thread.innerHTML += ' &nbsp; <a href="' + base + '/api/source.lua/'+json.mid+'"><label class="label label-danger" style="cursor: pointer; float: right; margin-right: 10px;">View Source</label></a> &nbsp; '
+            thread.innerHTML += ' &nbsp; <a href="' + URL_BASE + '/thread.html/'+(pm_config.shortLinks ? shortenID(json.mid) : json.mid)+'"><label class="label label-warning" style="cursor: pointer; float: right;">Permalink</label></a>'
+            thread.innerHTML += ' &nbsp; <a href="' + URL_BASE + '/api/source.lua/'+json.mid+'"><label class="label label-danger" style="cursor: pointer; float: right; margin-right: 10px;">View Source</label></a> &nbsp; '
             if (level > 1) {
                 thread.innerHTML += ' &nbsp; <a href="javascript:void(0);" onclick="rollup(\'' + id_sanitised + '\');"><label class="label label-primary" title="roll up" style="cursor: pointer; float: right; margin-right: 10px;"><span id="rollup_' + id_sanitised + '" class="glyphicon glyphicon-chevron-up"> </span></label></a> &nbsp; '
             }
@@ -181,7 +175,7 @@ function displayEmail(json, id, level) {
                 }
             }
             
-            thread.innerHTML += "<b>List: </b><a href='" + base + "/list.html?" + lid + "'>" + lid + "</a><br/>"
+            thread.innerHTML += "<b>List: </b><a href='" + URL_BASE + "/list.html?" + lid + "'>" + lid + "</a><br/>"
             if (json.attachments && json.attachments.length > 0) {
                 thread.innerHTML += "<b>Attachments: </b>"
                 for (var a in json.attachments) {
@@ -192,9 +186,7 @@ function displayEmail(json, id, level) {
                     } else {
                         size = fd.size.toLocaleString() + " bytes"
                     }
-                    var base = pm_config.URLBase ? pm_config.URLBase : ""
-                    base = base.replace(/\/+/g, "/")
-                    thread.innerHTML += "<a href='" + base + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
+                    thread.innerHTML += "<a href='" + URL_BASE + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
                 }
                 thread.innerHTML += "<br/>"
             }
@@ -258,13 +250,11 @@ function displaySingleEmail(json, id) {
         if (ebody == null) {ebody = '(null body)'} // temporary hack to deal with broken bodies
         ebody = ebody.replace(/</, "&lt;")
         ebody = "\n" + ebody
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
         if (true) {
             ebody = ebody.replace(/(?:\r?\n)((>+[ \t]+[^\r\n]*\r?\n+)+)/mg, function(inner) {
                 var rnd = (Math.random() * 100).toString()
                 var html = "<div class='bs-callout bs-callout-default' style='padding: 2px;' id='parent_" + rnd + "'>" +
-                    "<img src='" + base + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
+                    "<img src='" + URL_BASE + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
                     "<div style='display: none;' id='quote_" + rnd + "'>" + inner + "</div></div>"
                 return html
             })
@@ -272,7 +262,7 @@ function displaySingleEmail(json, id) {
 
         ebody = ebody.replace(re_weburl, "<a href=\"$1\">$1</a>")
 
-        thread.innerHTML += "<b>List ID: </b><a href='" + base + "/list.html?" + lid + "'>" + lid + "</a><br/>"
+        thread.innerHTML += "<b>List ID: </b><a href='" + URL_BASE + "/list.html?" + lid + "'>" + lid + "</a><br/>"
         thread.innerHTML += "<br/><pre style='font-family: Hack;'>" + ebody + '</pre>'
     } else {
         alert("Error, " + id + " not found :(")

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/site/js/dev/ponymail_helperfuncs.js
----------------------------------------------------------------------
diff --git a/site/js/dev/ponymail_helperfuncs.js b/site/js/dev/ponymail_helperfuncs.js
index 5a6024d..c611061 100644
--- a/site/js/dev/ponymail_helperfuncs.js
+++ b/site/js/dev/ponymail_helperfuncs.js
@@ -55,10 +55,7 @@ function GetAsync(theUrl, xstate, callback) {
     } else {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
     }
-    if (pm_config.URLBase && pm_config.URLBase.length > 0) {
-        theUrl = pm_config.URLBase + theUrl
-        theUrl = theUrl.replace(/\/+/g, "/")
-    }
+    theUrl = URL_BASE + theUrl
     // Set the start time of the request, used for the 'loading data...' spinner later on
     if (pending_urls) {
         pending_urls[theUrl] = new Date().getTime() / 1000;
@@ -129,12 +126,9 @@ function showSpinner(show) {
     var obj = document.getElementById('spinner')
     // If no such obj yet, create it
     if (!obj) {
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
-
         obj = document.createElement('div')
         obj.setAttribute("id", "spinner")
-        obj.innerHTML = "<img src='" + base + "/images/spinner.gif'><br/>Loading data, please wait..."
+        obj.innerHTML = "<img src='" + URL_BASE + "/images/spinner.gif'><br/>Loading data, please wait..."
         document.body.appendChild(obj)
     }
     // told to show the spinner?

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/site/js/dev/ponymail_timetravel.js
----------------------------------------------------------------------
diff --git a/site/js/dev/ponymail_timetravel.js b/site/js/dev/ponymail_timetravel.js
index d257763..a2ca405 100644
--- a/site/js/dev/ponymail_timetravel.js
+++ b/site/js/dev/ponymail_timetravel.js
@@ -19,9 +19,7 @@
 // simple func that just redirects to the original thread URL we just got if possible
 function timeTravelSingleThreadRedirect(json) {
     if (json && json.thread) {
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
-        location.href = base + "/thread.html/" + (pm_config.shortLinks ? shortenID(json.thread.mid) : json.thread.mid)
+        location.href = URL_BASE + "/thread.html/" + (pm_config.shortLinks ? shortenID(json.thread.mid) : json.thread.mid)
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/site/js/dev/ponymail_user_preferences.js
----------------------------------------------------------------------
diff --git a/site/js/dev/ponymail_user_preferences.js b/site/js/dev/ponymail_user_preferences.js
index 252ee62..7d0e2f8 100644
--- a/site/js/dev/ponymail_user_preferences.js
+++ b/site/js/dev/ponymail_user_preferences.js
@@ -156,13 +156,10 @@ function setupUser() {
     if (!uimg) {
         return
     }
-    var base = pm_config.URLBase ? pm_config.URLBase : ""
-    base = base.replace(/\/+/g, "/")
-    
-    uimg.setAttribute("src", base + "/images/user.png")
+    uimg.setAttribute("src", URL_BASE + "/images/user.png")
     uimg.setAttribute("title", "Logged in as " + login.credentials.fullname)
     if (login.notifications && login.notifications > 0) {
-        uimg.setAttribute("src", base + "/images/user_notif.png")
+        uimg.setAttribute("src", URL_BASE + "/images/user_notif.png")
         uimg.setAttribute("title", "Logged in as " + login.credentials.fullname + " - You have " + login.notifications + " new notifications!")
     }
     var pd = document.getElementById('prefs_dropdown')

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/6eac6ec0/site/js/ponymail.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail.js b/site/js/ponymail.js
index 40ca07d..38b663b 100644
--- a/site/js/ponymail.js
+++ b/site/js/ponymail.js
@@ -68,6 +68,8 @@ var pb_refresh = 0
 var treeview_guard = {}
 var mbox_month = null
 
+var URL_BASE = pm_config.URLBase ? pm_config.URLBase.replace(/\/+/g, "/") : ""
+
 function isStorageAvailable(type) {
     try {
         var storage = window[type],
@@ -159,11 +161,8 @@ function sendEmail(form) {
         of.push("alt=" + encodeURIComponent(document.getElementById('alt').options[document.getElementById('alt').selectedIndex].value))
     }
         
-    var base = pm_config.URLBase ? pm_config.URLBase : ""
-    base = base.replace(/\/+/g, "/")
-
     var request = new XMLHttpRequest();
-    request.open("POST", base + "/api/compose.lua");
+    request.open("POST", URL_BASE + "/api/compose.lua");
     request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     request.send(of.join("&")) // send email as a POST string
     
@@ -1388,10 +1387,6 @@ function displayEmail(json, id, level) {
         current_email_msgs.push(json)
     }
     
-    // URI Base
-    var base = pm_config.URLBase ? pm_config.URLBase : ""
-    base = base.replace(/\/+/g, "/")
-    
     // Save the JSON in our JS array so we don't have to fetch it again later
     saved_emails[json.mid] = json
     var estyle = ""
@@ -1434,15 +1429,13 @@ function displayEmail(json, id, level) {
         if (ebody == null) {ebody = '(null body)'} // temporary hack to deal with broken bodies
         ebody = ebody.replace(/</mg, "&lt;")
         ebody = "\n" + ebody // add a newline at top
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
         // If we're compacting quotes in the email, let's...do so with some fuzzy logic
         if (prefs.compactQuotes == 'yes') {
             ebody = ebody.replace(/((?:\r?\n)((on .+ wrote:[\r\n]+)|(sent from my .+)|(>+[ \t]+[^\r\n]*\r?\n[^\n]*\n*)+)+)+/mgi, function(inner) {
                 var rnd = (Math.random() * 100).toString()
                 inner = inner.replace(/>/g, "&gt;")
                 var html = "<div class='bs-callout bs-callout-default' style='margin: 3px; padding: 2px;' id='parent_" + rnd + "'>" +
-                    "<img src='" + base + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
+                    "<img src='" + URL_BASE + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
                     "<div style='display: none;' id='quote_" + rnd + "'>" + inner + "</div></div>"
                 return html
             })
@@ -1497,7 +1490,7 @@ function displayEmail(json, id, level) {
                     } else {
                         size = fd.size.toLocaleString() + " bytes"
                     }
-                    thread.innerHTML += "<a href='" + base + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
+                    thread.innerHTML += "<a href='" + URL_BASE + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
                 }
                 thread.innerHTML += "<br/>"
             }
@@ -1513,8 +1506,8 @@ function displayEmail(json, id, level) {
             thread.style.background = estyle
             thread.style.marginTop = "30px"
             thread.innerHTML += ' &nbsp; <label class="label label-success" onclick="compose(\'' + json.mid + '\');" style="cursor: pointer; float: right; margin-left: 10px;">Reply</label>'
-            thread.innerHTML += ' &nbsp; <a href="' + base + '/thread.html/'+(pm_config.shortLinks ? shortenID(json.mid) : json.mid)+'"><label class="label label-warning" style="cursor: pointer; float: right;">Permalink</label></a>'
-            thread.innerHTML += ' &nbsp; <a href="' + base + '/api/source.lua/'+json.mid+'"><label class="label label-danger" style="cursor: pointer; float: right; margin-right: 10px;">View Source</label></a> &nbsp; '
+            thread.innerHTML += ' &nbsp; <a href="' + URL_BASE + '/thread.html/'+(pm_config.shortLinks ? shortenID(json.mid) : json.mid)+'"><label class="label label-warning" style="cursor: pointer; float: right;">Permalink</label></a>'
+            thread.innerHTML += ' &nbsp; <a href="' + URL_BASE + '/api/source.lua/'+json.mid+'"><label class="label label-danger" style="cursor: pointer; float: right; margin-right: 10px;">View Source</label></a> &nbsp; '
             if (level > 1) {
                 thread.innerHTML += ' &nbsp; <a href="javascript:void(0);" onclick="rollup(\'' + id_sanitised + '\');"><label class="label label-primary" title="roll up" style="cursor: pointer; float: right; margin-right: 10px;"><span id="rollup_' + id_sanitised + '" class="glyphicon glyphicon-chevron-up"> </span></label></a> &nbsp; '
             }
@@ -1539,7 +1532,7 @@ function displayEmail(json, id, level) {
                 }
             }
             
-            thread.innerHTML += "<b>List: </b><a href='" + base + "/list.html?" + lid + "'>" + lid + "</a><br/>"
+            thread.innerHTML += "<b>List: </b><a href='" + URL_BASE + "/list.html?" + lid + "'>" + lid + "</a><br/>"
             if (json.attachments && json.attachments.length > 0) {
                 thread.innerHTML += "<b>Attachments: </b>"
                 for (var a in json.attachments) {
@@ -1550,9 +1543,7 @@ function displayEmail(json, id, level) {
                     } else {
                         size = fd.size.toLocaleString() + " bytes"
                     }
-                    var base = pm_config.URLBase ? pm_config.URLBase : ""
-                    base = base.replace(/\/+/g, "/")
-                    thread.innerHTML += "<a href='" + base + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
+                    thread.innerHTML += "<a href='" + URL_BASE + "/api/email.lua?attachment=true&id=" + json.tid + "&file=" + fd.hash + "'>" + fd.filename.replace(/</g, "&lt;") + "</a> (" + size + ") &nbsp; "
                 }
                 thread.innerHTML += "<br/>"
             }
@@ -1616,13 +1607,11 @@ function displaySingleEmail(json, id) {
         if (ebody == null) {ebody = '(null body)'} // temporary hack to deal with broken bodies
         ebody = ebody.replace(/</, "&lt;")
         ebody = "\n" + ebody
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
         if (true) {
             ebody = ebody.replace(/(?:\r?\n)((>+[ \t]+[^\r\n]*\r?\n+)+)/mg, function(inner) {
                 var rnd = (Math.random() * 100).toString()
                 var html = "<div class='bs-callout bs-callout-default' style='padding: 2px;' id='parent_" + rnd + "'>" +
-                    "<img src='" + base + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
+                    "<img src='" + URL_BASE + "/images/quote.png' title='show/hide original text' onclick='toggleView(\"quote_" + rnd + "\")'/><br/>" +
                     "<div style='display: none;' id='quote_" + rnd + "'>" + inner + "</div></div>"
                 return html
             })
@@ -1630,7 +1619,7 @@ function displaySingleEmail(json, id) {
 
         ebody = ebody.replace(re_weburl, "<a href=\"$1\">$1</a>")
 
-        thread.innerHTML += "<b>List ID: </b><a href='" + base + "/list.html?" + lid + "'>" + lid + "</a><br/>"
+        thread.innerHTML += "<b>List ID: </b><a href='" + URL_BASE + "/list.html?" + lid + "'>" + lid + "</a><br/>"
         thread.innerHTML += "<br/><pre style='font-family: Hack;'>" + ebody + '</pre>'
     } else {
         alert("Error, " + id + " not found :(")
@@ -2209,10 +2198,7 @@ function GetAsync(theUrl, xstate, callback) {
     } else {
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
     }
-    if (pm_config.URLBase && pm_config.URLBase.length > 0) {
-        theUrl = pm_config.URLBase + theUrl
-        theUrl = theUrl.replace(/\/+/g, "/")
-    }
+    theUrl = URL_BASE + theUrl
     // Set the start time of the request, used for the 'loading data...' spinner later on
     if (pending_urls) {
         pending_urls[theUrl] = new Date().getTime() / 1000;
@@ -2283,12 +2269,9 @@ function showSpinner(show) {
     var obj = document.getElementById('spinner')
     // If no such obj yet, create it
     if (!obj) {
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
-
         obj = document.createElement('div')
         obj.setAttribute("id", "spinner")
-        obj.innerHTML = "<img src='" + base + "/images/spinner.gif'><br/>Loading data, please wait..."
+        obj.innerHTML = "<img src='" + URL_BASE + "/images/spinner.gif'><br/>Loading data, please wait..."
         document.body.appendChild(obj)
     }
     // told to show the spinner?
@@ -4661,9 +4644,7 @@ function showStats(json) {
 // simple func that just redirects to the original thread URL we just got if possible
 function timeTravelSingleThreadRedirect(json) {
     if (json && json.thread) {
-        var base = pm_config.URLBase ? pm_config.URLBase : ""
-        base = base.replace(/\/+/g, "/")
-        location.href = base + "/thread.html/" + (pm_config.shortLinks ? shortenID(json.thread.mid) : json.thread.mid)
+        location.href = URL_BASE + "/thread.html/" + (pm_config.shortLinks ? shortenID(json.thread.mid) : json.thread.mid)
     }
 }
 
@@ -5201,13 +5182,10 @@ function setupUser() {
     if (!uimg) {
         return
     }
-    var base = pm_config.URLBase ? pm_config.URLBase : ""
-    base = base.replace(/\/+/g, "/")
-    
-    uimg.setAttribute("src", base + "/images/user.png")
+    uimg.setAttribute("src", URL_BASE + "/images/user.png")
     uimg.setAttribute("title", "Logged in as " + login.credentials.fullname)
     if (login.notifications && login.notifications > 0) {
-        uimg.setAttribute("src", base + "/images/user_notif.png")
+        uimg.setAttribute("src", URL_BASE + "/images/user_notif.png")
         uimg.setAttribute("title", "Logged in as " + login.credentials.fullname + " - You have " + login.notifications + " new notifications!")
     }
     var pd = document.getElementById('prefs_dropdown')