Просмотр исходного кода

Added "Raw text" button.

(cherry picked from commit 00cfcafc996c55afd069b665ad3875693e22d36d)

Conflicts:
	css/zerobin.css
	js/zerobin.js
	tpl/page.html
Sebastien SAUVAGE 13 лет назад
Родитель
Сommit
fdc87a7fcf
4 измененных файлов с 22 добавлено и 4 удалено
  1. 5 1
      css/zerobin.css
  2. BIN
      img/icon_raw.png
  3. 13 0
      js/zerobin.js
  4. 4 3
      tpl/page.html

+ 5 - 1
css/zerobin.css

@@ -178,7 +178,7 @@ button img {
 	top: 2px;
 }
 
-#expiration, #burnafterreadingoption, #opendisc { 
+#expiration, #rawtextbutton, #burnafterreadingoption, #opendisc { 
 	background-color: #414d5a; 
 	padding: 6px 8px;
 	margin: 0 5px 0 0;
@@ -198,6 +198,10 @@ button img {
 	background: #414d5a;
 }
 
+#rawtextbutton img {
+	padding: 1px 0 1px 0;
+}
+
 #remainingtime {
 	color: #94a3b4; 
 	display: inline;

BIN
img/icon_raw.png


+ 13 - 0
js/zerobin.js

@@ -381,6 +381,7 @@ function selectText(element) {
 function stateNewPaste() {
     $('button#sendbutton').removeClass('hidden');
     $('button#clonebutton').addClass('hidden');
+    $('button#rawtextbutton').addClass('hidden');
     $('div#expiration').removeClass('hidden');
     $('div#remainingtime').addClass('hidden');
     $('div#burnafterreadingoption').removeClass('hidden');
@@ -408,6 +409,7 @@ function stateExistingPaste() {
     else {
         $('button#clonebutton').removeClass('hidden');
     }
+    $('button#rawtextbutton').show();
 
     $('div#expiration').addClass('hidden');
     $('div#burnafterreadingoption').addClass('hidden');
@@ -419,6 +421,17 @@ function stateExistingPaste() {
     $('div#prettymessage').removeClass('hidden');
 }
 
+/** Return raw text
+  */
+function rawText()
+{
+    history.replaceState(document.title, document.title, 'document.txt');
+    var paste = $('div#cleartext').text();
+    var newDoc = document.open('text/plain', 'replace');
+    newDoc.write(paste);
+    newDoc.close();
+}
+
 /**
  * Clone the current paste.
  */

+ 4 - 3
tpl/page.html

@@ -46,9 +46,10 @@
 				<div id="status">{$STATUS|htmlspecialchars}</div>
 				<div id="errormessage" class="hidden">{$ERROR|htmlspecialchars}</div>
 				<div id="toolbar">
-					<button id="newbutton" onclick="window.location.href=scriptLocation();return false;" class="hidden"><img src="img/icon_new.png#" width="11" height="15" alt="" />New</button>
-					<button id="sendbutton" onclick="send_data();return false;" class="hidden"><img src="img/icon_send.png#" width="18" height="15" alt="" />Send</button>
-					<button id="clonebutton" onclick="clonePaste();return false;" class="hidden"><img src="img/icon_clone.png#" width="15" height="17" alt="" />Clone</button>
+					<button id="newbutton" onclick="window.location.href=scriptLocation();return false;" class="hidden"><img src="img/icon_new.png" width="11" height="15" alt="" />New</button>
+					<button id="sendbutton" onclick="send_data();return false;" class="hidden"><img src="img/icon_send.png" width="18" height="15" alt="" />Send</button>
+					<button id="clonebutton" onclick="clonePaste();return false;" class="hidden"><img src="img/icon_clone.png" width="15" height="17" alt="" />Clone</button>
+					<button id="rawtextbutton" onclick="rawText();return false;" class="hidden"><img src="img/icon_raw.png" width="15" height="15" alt="" />Raw text</button>
 					<div id="expiration" class="hidden">Expires: 
 						<select id="pasteExpiration" name="pasteExpiration">
 {loop="EXPIRE"}