mirror of
https://github.com/jsbin/jsbin.git
synced 2026-01-25 15:38:56 +00:00
Merge pull request #2059 from jsbin/fix/2058
Make sure getURL withRevision
This commit is contained in:
commit
82bdf8d6e5
@ -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',
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -347,7 +347,7 @@ panels.updateQuery = throttle(function updateQuery() {
|
||||
|
||||
if (jsbin.state.code && jsbin.state.owner) {
|
||||
$.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 () {}
|
||||
|
||||
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user