summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortimb <opuscule@gmail.com>2015-08-11 11:43:42 -0700
committertimb <opuscule@gmail.com>2015-08-11 11:43:42 -0700
commit4f655ddbae201aecfac7965b91ae1d155d4a0594 (patch)
treecb98dceaa349373bb89177f5618ba3ac76caa6b4
parent39091f9703c00bcadd369b1c710c75905ff47c2e (diff)
show warning when text output is cutoff, never cutoff output when making png
-rw-r--r--index.html3
-rw-r--r--js/clipboard.js9
-rw-r--r--js/matrix.js46
3 files changed, 37 insertions, 21 deletions
diff --git a/index.html b/index.html
index 900463b..a801384 100644
--- a/index.html
+++ b/index.html
@@ -50,7 +50,7 @@
<span id="webcam_el" class="tool">webcam</span>
<span id="load_el" class="tool">load</span>
<span id="save_el" class="tool">save</span>
- <span id="clear_el" class="tool">clear</span><br>
+ <span id="clear_el" class="tool">clear</span><br>
</div>
<div id="import_rapper">
@@ -66,6 +66,7 @@
<button id="save_button">save</button>
<button id="upload_button">upload</button>
</div><br>
+ <div id="cutoff_warning_el">colorcode is too wide for irc and is cutoff</div>
<textarea id="import_textarea"></textarea>
</div>
diff --git a/js/clipboard.js b/js/clipboard.js
index 29c4ecc..577c695 100644
--- a/js/clipboard.js
+++ b/js/clipboard.js
@@ -43,6 +43,7 @@ var clipboard = (function () {
clipboard.importing = true
gallery_rapper.style.display = 'none'
format_el.style.display = 'none'
+ cutoff_warning_el.style.display = 'none'
import_buttons.style.display = "inline"
import_textarea.value = ""
},
@@ -51,6 +52,7 @@ var clipboard = (function () {
clipboard.importing = false
import_buttons.style.display = "none"
format_el.style.display = 'inline'
+ cutoff_warning_el.style.display = 'none'
gallery_rapper.style.display = 'inline'
clipboard.export_data()
},
@@ -210,12 +212,15 @@ var clipboard = (function () {
output = canvas.ascii()
break
case 'mirc':
- output = canvas.mirc()
+ output = canvas.mirc({cutoff: 400})
break
case 'irssi':
- output = canvas.irssi()
+ output = canvas.irssi({cutoff: 400})
break
}
+ if (output.cutoff){
+ cutoff_warning_el.style.display = 'block'
+ }
import_textarea.value = output
clipboard.focus()
return output
diff --git a/js/matrix.js b/js/matrix.js
index 6994327..4c8976c 100644
--- a/js/matrix.js
+++ b/js/matrix.js
@@ -231,10 +231,6 @@ Matrix.prototype.resize_rapper = function(){
// canvas_rapper.style.left = "auto"
}
}
-
-
-//
-
Matrix.prototype.ascii = function () {
var lines = this.aa.map(function(row, y){
var last, line = ""
@@ -246,26 +242,37 @@ Matrix.prototype.ascii = function () {
var txt = lines.join("\n")
return txt
}
-Matrix.prototype.mirc = function () {
+Matrix.prototype.mirc = function (opts) {
+ var cutoff = false
var lines = this.aa.map(function(row, y){
var last, line = ""
row.forEach(function(lex, x) {
if (lex.eqColor(last)) {
line += lex.sanitize()
- }
+ }
else {
- // if (x > 0 && last) line += "\x03"
line += lex.mirc()
last = lex
}
})
- // if (last && ! last.isClear()) { line += "\x03" }
- return line.substr(0,400)
- }).filter(function(line){ return line.length > 0 })
- return lines.join("\n")
+ if (opts && opts.cutoff && line.length > opts.cutoff) {
+ cutoff = true
+ return line.substr(0, opts.cutoff)
+ }
+ return line
+ })
+
+ var txt = lines.filter(function(line){ return line.length > 0 }).join('\n')
+
+ if (cutoff) {
+ txt = new String(txt)
+ txt.cutoff = true
+ }
+ return txt
}
-Matrix.prototype.irssi = function(){
- var txt = this.mirc()
+Matrix.prototype.irssi = function(opts){
+ var mirc = this.mirc(opts)
+ var txt = mirc
// .replace(/\%/g, '%%')
.replace(/\\/g, '\\x5C')
.replace(/\"/g, '\\\"')
@@ -278,9 +285,12 @@ Matrix.prototype.irssi = function(){
.replace(/\n/g, '\\n')
.replace(/\x02/g, '\\x02')
.replace(/\x03/g, '\\x03')
- // console.log(txt.length)
-
- var escaped_txt = unicode.escapeToEscapedBytes(txt)
-
- return '/exec -out printf "%b" "' + escaped_txt + '"\n'
+
+ txt = unicode.escapeToEscapedBytes(txt)
+ txt = '/exec -out printf "%b" "' + txt + '"\n'
+ if (mirc.cutoff){
+ txt = new String(txt)
+ txt.cutoff = true
+ }
+ return txt
}