mirror of
https://github.com/writeas/paste-chrome
synced 2018-07-20 11:45:21 +00:00
Add "Paste" mode for code and mono posts
Users will see paste.as returned, instead of write.as.
This commit is contained in:
parent
f169ee4b10
commit
fd150bef65
@ -20,7 +20,11 @@ function publish(content, font) {
|
|||||||
data = JSON.parse(http.responseText);
|
data = JSON.parse(http.responseText);
|
||||||
// Pull out data parts
|
// Pull out data parts
|
||||||
id = data.data.id;
|
id = data.data.id;
|
||||||
url = "https://write.as/"+id;
|
if (font == 'code' || font === 'mono') {
|
||||||
|
url = "https://paste.as/"+id;
|
||||||
|
} else {
|
||||||
|
url = "https://write.as/"+id;
|
||||||
|
}
|
||||||
editToken = data.data.token;
|
editToken = data.data.token;
|
||||||
|
|
||||||
// Save the data
|
// Save the data
|
||||||
|
@ -38,8 +38,15 @@
|
|||||||
color: white;
|
color: white;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
margin-left: 0.5em;
|
margin-left: 0.5em;
|
||||||
|
width: 7em;
|
||||||
|
text-align: center;
|
||||||
|
transition: all .2s ease-out;
|
||||||
|
border-radius: .25em;
|
||||||
}
|
}
|
||||||
input[type=submit].disabled {
|
input[type=submit]:hover {
|
||||||
|
background-color: #7d82c4;
|
||||||
|
}
|
||||||
|
input[type=submit].disabled, input[type=submit].disabled:hover {
|
||||||
background: #ddd;
|
background: #ddd;
|
||||||
color: #999;
|
color: #999;
|
||||||
border-color: #eee;
|
border-color: #eee;
|
||||||
|
20
popup.js
20
popup.js
@ -8,7 +8,7 @@ function publish(content, font) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$publish.classList.add('disabled');
|
$publish.classList.add('disabled');
|
||||||
$publish.value = "Publishing...";
|
setPublishText(font, true);
|
||||||
$publish.disabled = true;
|
$publish.disabled = true;
|
||||||
|
|
||||||
var post = H.getTitleStrict(content);
|
var post = H.getTitleStrict(content);
|
||||||
@ -25,7 +25,7 @@ function publish(content, font) {
|
|||||||
http.onreadystatechange = function() {
|
http.onreadystatechange = function() {
|
||||||
if (http.readyState == 4) {
|
if (http.readyState == 4) {
|
||||||
$publish.classList.remove('disabled');
|
$publish.classList.remove('disabled');
|
||||||
$publish.value = "Publish";
|
setPublishText(font, false);
|
||||||
$publish.disabled = false;
|
$publish.disabled = false;
|
||||||
|
|
||||||
if (http.status == 201) {
|
if (http.status == 201) {
|
||||||
@ -34,7 +34,11 @@ function publish(content, font) {
|
|||||||
data = JSON.parse(http.responseText);
|
data = JSON.parse(http.responseText);
|
||||||
// Pull out data parts
|
// Pull out data parts
|
||||||
id = data.data.id;
|
id = data.data.id;
|
||||||
url = "https://write.as/"+id;
|
if (font == 'code' || font === 'mono') {
|
||||||
|
url = "https://paste.as/"+id;
|
||||||
|
} else {
|
||||||
|
url = "https://write.as/"+id;
|
||||||
|
}
|
||||||
editToken = data.data.token;
|
editToken = data.data.token;
|
||||||
|
|
||||||
document.getElementById("publish-holder").style.display = 'none';
|
document.getElementById("publish-holder").style.display = 'none';
|
||||||
@ -57,6 +61,14 @@ function publish(content, font) {
|
|||||||
http.send(params);
|
http.send(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPublishText(font, isPublishing) {
|
||||||
|
if (font === 'code' || font === 'mono') {
|
||||||
|
$publish.value = isPublishing ? 'Pasting...' : 'Paste';
|
||||||
|
} else {
|
||||||
|
$publish.value = isPublishing ? 'Publishing...' : 'Publish';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
$content = document.getElementById("content");
|
$content = document.getElementById("content");
|
||||||
$publish = document.getElementById("publish");
|
$publish = document.getElementById("publish");
|
||||||
@ -123,10 +135,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
// load font setting
|
// load font setting
|
||||||
H.load(fontRadios, 'font');
|
H.load(fontRadios, 'font');
|
||||||
$content.className = fontRadios.value;
|
$content.className = fontRadios.value;
|
||||||
|
setPublishText(fontRadios.value, false);
|
||||||
// bind font changing action
|
// bind font changing action
|
||||||
for(var i = 0; i < fontRadios.length; i++) {
|
for(var i = 0; i < fontRadios.length; i++) {
|
||||||
fontRadios[i].onclick = function() {
|
fontRadios[i].onclick = function() {
|
||||||
$content.className = this.value;
|
$content.className = this.value;
|
||||||
|
setPublishText(this.value, false);
|
||||||
H.save(fontRadios, 'font');
|
H.save(fontRadios, 'font');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user