|
34 | 34 | var url;
|
35 | 35 | var lastSaved;
|
36 | 36 |
|
37 |
| - function log(msg) { |
38 |
| - return $(".console").removeClass("error").html(msg); |
39 |
| - } |
| 37 | + // function log(msg) { |
| 38 | + // return $(".console").removeClass("error").html(msg); |
| 39 | + // } |
40 | 40 |
|
41 |
| - function error(msg) { |
42 |
| - return log(msg).addClass("error"); |
43 |
| - } |
| 41 | + // function error(msg) { |
| 42 | + // return log(msg).addClass("error"); |
| 43 | + // } |
44 | 44 |
|
45 | 45 | function doJSON() {
|
46 | 46 | // get input JSON, try to parse it
|
|
54 | 54 | return;
|
55 | 55 | }
|
56 | 56 |
|
| 57 | + console.log("ordered to parse JSON..."); |
| 58 | + |
57 | 59 | var json = jsonFrom(input);
|
58 | 60 |
|
59 | 61 | // if succeeded, prettify and highlight it
|
|
73 | 75 |
|
74 | 76 | // show rendered JSON
|
75 | 77 | function showJSON(rendered) {
|
| 78 | + console.log("ordered to show JSON: " + rendered); |
76 | 79 | if (rendered) {
|
77 | 80 | if ($(".json code").html()) {
|
| 81 | + console.log("there's code to show, showing..."); |
78 | 82 | $(".json .rendered").show();
|
79 | 83 | $(".json .editing").hide();
|
80 | 84 | }
|
|
151 | 155 | renderCSV(outArray.slice(0, excerptRows));
|
152 | 156 | showCSV(true);
|
153 | 157 |
|
| 158 | + // show raw data if people really want it |
| 159 | + $(".csv textarea").val(csv); |
| 160 | + |
| 161 | + // download link to entire CSV as data |
154 | 162 | // thanks to http://jsfiddle.net/terryyounghk/KPEGU/
|
155 | 163 | // and http://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side
|
156 | 164 | var uri = "data:text/csv;charset=utf-8," + encodeURIComponent(csv);
|
157 |
| - |
158 |
| - $(".csv textarea").val(csv); |
159 | 165 | $(".csv a.download").attr("href", uri);
|
160 | 166 | }
|
161 | 167 |
|
|
214 | 220 | if (history && history.pushState)
|
215 | 221 | history.pushState({id: id}, null, "?id=" + id);
|
216 | 222 |
|
217 |
| - log("Permalink created! (Copy from the location bar.)") |
| 223 | + // log("Permalink created! (Copy from the location bar.)") |
218 | 224 | }
|
219 | 225 |
|
220 | 226 | // check query string for gist ID
|
|
254 | 260 | $(".save a").click(saveJSON);
|
255 | 261 |
|
256 | 262 | // transform the JSON whenever it's pasted/edited
|
257 |
| - $(".json textarea").keyup(doJSON); |
| 263 | + $(".json textarea") |
| 264 | + .on('paste', function() { |
| 265 | + // delay the showing so the paste is pasted by then |
| 266 | + setTimeout(function() { |
| 267 | + doJSON(); |
| 268 | + // showJSON(true); |
| 269 | + $(".json textarea").blur(); |
| 270 | + }, 1); |
| 271 | + }) |
| 272 | + .keyup(doJSON); // harmless to repeat doJSON |
258 | 273 |
|
259 | 274 | // highlight CSV on click
|
260 | 275 | $(".csv textarea").click(function() {
|
|
0 commit comments