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);
|
||||
// Pull out data parts
|
||||
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;
|
||||
|
||||
// Save the data
|
||||
|
@ -38,8 +38,15 @@
|
||||
color: white;
|
||||
text-align: right;
|
||||
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;
|
||||
color: #999;
|
||||
border-color: #eee;
|
||||
|
20
popup.js
20
popup.js
@ -8,7 +8,7 @@ function publish(content, font) {
|
||||
}
|
||||
|
||||
$publish.classList.add('disabled');
|
||||
$publish.value = "Publishing...";
|
||||
setPublishText(font, true);
|
||||
$publish.disabled = true;
|
||||
|
||||
var post = H.getTitleStrict(content);
|
||||
@ -25,7 +25,7 @@ function publish(content, font) {
|
||||
http.onreadystatechange = function() {
|
||||
if (http.readyState == 4) {
|
||||
$publish.classList.remove('disabled');
|
||||
$publish.value = "Publish";
|
||||
setPublishText(font, false);
|
||||
$publish.disabled = false;
|
||||
|
||||
if (http.status == 201) {
|
||||
@ -34,7 +34,11 @@ function publish(content, font) {
|
||||
data = JSON.parse(http.responseText);
|
||||
// Pull out data parts
|
||||
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;
|
||||
|
||||
document.getElementById("publish-holder").style.display = 'none';
|
||||
@ -57,6 +61,14 @@ function publish(content, font) {
|
||||
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() {
|
||||
$content = document.getElementById("content");
|
||||
$publish = document.getElementById("publish");
|
||||
@ -123,10 +135,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// load font setting
|
||||
H.load(fontRadios, 'font');
|
||||
$content.className = fontRadios.value;
|
||||
setPublishText(fontRadios.value, false);
|
||||
// bind font changing action
|
||||
for(var i = 0; i < fontRadios.length; i++) {
|
||||
fontRadios[i].onclick = function() {
|
||||
$content.className = this.value;
|
||||
setPublishText(this.value, false);
|
||||
H.save(fontRadios, 'font');
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user