From 63a75b121204d83f5898a2f63dfb06cf86a36b0a Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Tue, 21 Oct 2014 08:49:51 +0100 Subject: [PATCH] Make sure getURL withRevision --- public/js/chrome/archive.js | 4 ++-- public/js/chrome/download.js | 2 +- public/js/chrome/issue.js | 2 +- public/js/chrome/keys.js | 4 ++-- public/js/chrome/save.js | 6 +++--- public/js/editors/editors.js | 2 +- public/js/jsbin.js | 8 +++++--- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/public/js/chrome/archive.js b/public/js/chrome/archive.js index 3032a7bd..f3f1de84 100644 --- a/public/js/chrome/archive.js +++ b/public/js/chrome/archive.js @@ -3,7 +3,7 @@ function archive(unarchive) { 'use strict'; var type = unarchive === false ? 'unarchive' : 'archive'; var text = unarchive === false ? 'restore from archive' : 'archiving'; - analytics[type](jsbin.getURL({ revision: true })); + analytics[type](jsbin.getURL({ withRevision: true })); if (!jsbin.user.name) { $document.trigger('tip', { type: 'notication', @@ -12,7 +12,7 @@ function archive(unarchive) { } else if (jsbin.owner()) { $.ajax({ type: 'POST', - url: jsbin.getURL({ revision: true }) + '/' + type, + url: jsbin.getURL({ withRevision: true }) + '/' + type, error: function () { $document.trigger('tip', { type: 'error', diff --git a/public/js/chrome/download.js b/public/js/chrome/download.js index d6c04bce..f741c60a 100644 --- a/public/js/chrome/download.js +++ b/public/js/chrome/download.js @@ -1,5 +1,5 @@ $('#download').click(function (event) { event.preventDefault(); - window.location = jsbin.getURL({ revision: true }) + '/download'; + window.location = jsbin.getURL({ withRevision: true }) + '/download'; analytics.download(); }); diff --git a/public/js/chrome/issue.js b/public/js/chrome/issue.js index b1d1b966..6f9bf21d 100644 --- a/public/js/chrome/issue.js +++ b/public/js/chrome/issue.js @@ -11,7 +11,7 @@ var githubIssue = (function () { (jsbin.user && jsbin.user.name ? '* ' + jsbin.user.name : ''), '\n'].join(''); - return url + '?body=' + encodeURIComponent(body.replace(/%url%/g, jsbin.getURL({ revision: true }))); + return url + '?body=' + encodeURIComponent(body.replace(/%url%/g, jsbin.getURL({ withRevision: true }))); } var $newissue = $('#newissue'); diff --git a/public/js/chrome/keys.js b/public/js/chrome/keys.js index 2c9c7f5d..3fe26e1c 100644 --- a/public/js/chrome/keys.js +++ b/public/js/chrome/keys.js @@ -11,7 +11,7 @@ jsbin.keys = (function () { var keys = {}; var find = function (url) { - var key = keys[url || jsbin.getURL({ revision: true, withoutRoot: true })] || {}; + var key = keys[url || jsbin.getURL({ withRevision: true, withoutRoot: true })] || {}; return key.c; }; @@ -28,7 +28,7 @@ jsbin.keys = (function () { } $document.on('saved', function () { - keys[jsbin.getURL({ revision: false, withoutRoot: true })] = { s: jsbin.state.revsion, c: jsbin.state.checksum, d: (new Date()).getTime() }; + keys[jsbin.getURL({ withRevision: false, withoutRoot: true })] = { s: jsbin.state.revsion, c: jsbin.state.checksum, d: (new Date()).getTime() }; localStorage.keys = JSON.stringify(keys); }); diff --git a/public/js/chrome/save.js b/public/js/chrome/save.js index e6ac9f73..8b7f595b 100644 --- a/public/js/chrome/save.js +++ b/public/js/chrome/save.js @@ -76,7 +76,7 @@ function updateSavedState() { }).get().join(','); $shareLinks.each(function () { var path = this.getAttribute('data-path'); - var url = jsbin.getURL({ revision: withRevision }) + path + (query && this.id !== 'livepreview' ? '?' + query : ''), + var url = jsbin.getURL({ withRevision: withRevision }) + path + (query && this.id !== 'livepreview' ? '?' + query : ''), nodeName = this.nodeName; var hash = panels.getHighlightLines(); @@ -280,7 +280,7 @@ function updateCode(panelId, callback) { } $.ajax({ - url: jsbin.getURL({ revision: true }) + '/save', + url: jsbin.getURL({ withRevision: true }) + '/save', data: data, type: 'post', dataType: 'json', @@ -402,7 +402,7 @@ function saveCode(method, ajax, ajaxCallback) { jsbin.state.revision = data.revision; jsbin.state.latest = true; // this is never not true...end of conversation! jsbin.state.metadata = { name: jsbin.user.name }; - $form.attr('action', jsbin.getURL({ revision: true }) + '/save'); + $form.attr('action', jsbin.getURL({ withRevision: true }) + '/save'); if (window.history && window.history.pushState) { // updateURL(edit); diff --git a/public/js/editors/editors.js b/public/js/editors/editors.js index cb7bbf88..0bbc706b 100644 --- a/public/js/editors/editors.js +++ b/public/js/editors/editors.js @@ -347,7 +347,7 @@ panels.updateQuery = throttle(function updateQuery() { if (jsbin.state.code) { $.ajax({ - url: jsbin.getURL({ revision: true }) + '/settings', + url: jsbin.getURL({ withRevision: true }) + '/settings', type: 'PUT', data: { panels: visible.map(function (p) { return p.id; }) }, success: function () {} diff --git a/public/js/jsbin.js b/public/js/jsbin.js index f3fde1cc..dcca5ffa 100644 --- a/public/js/jsbin.js +++ b/public/js/jsbin.js @@ -233,8 +233,10 @@ jsbin.getURL = function (options) { if (state.code) { url += '/' + state.code; - if (!state.latest || options.revision) { //} && state.revision !== 1) { - url += '/' + (state.revision || 1); + if (!state.latest || options.withRevision) { //} && state.revision !== 1) { + if (options.withRevision !== false) { + url += '/' + (state.revision || 1); + } } } return url; @@ -248,7 +250,7 @@ jsbin.state.updateSettings = throttle(function updateBinSettingsInner(update, me if (jsbin.state.code) { $.ajax({ type: method, // consistency ftw :-\ - url: jsbin.getURL({ revision: true }) + '/settings', + url: jsbin.getURL({ withRevision: true }) + '/settings', data: update }); }