From 7c5222ffb5621d70a8379ff9aa6948bc121d3d54 Mon Sep 17 00:00:00 2001 From: ctrlcctrlv Date: Sat, 17 Aug 2013 17:36:38 +0000 Subject: Make it so oekaki can be disabled --- templates/post_form.html | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'templates') diff --git a/templates/post_form.html b/templates/post_form.html index 93ca821e..b2e186cc 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -95,20 +95,6 @@ {{ antibot.html() }} - {% if config.oekaki %} - - - {% trans %}Oekaki{% endtrans %} - - - lol what you looking at the source for nerd -


- -

- - - - {% endif %} {% if config.enable_embedding %} -- cgit v1.3 From e3600131fc45cb97f27e216aadcfcd69c761014c Mon Sep 17 00:00:00 2001 From: ctrlcctrlv Date: Sat, 17 Aug 2013 18:00:26 +0000 Subject: Configurable canvas size --- inc/config.php | 13 +++++-------- js/oekaki.js | 6 +++--- templates/main.js | 9 ++++++++- 3 files changed, 16 insertions(+), 12 deletions(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index 686894d1..7f8f4605 100644 --- a/inc/config.php +++ b/inc/config.php @@ -642,15 +642,12 @@ // Allow unfiltered HTML in board subtitle. This is useful for placing icons and links. $config['allow_subtitle_html'] = false; - /* - * Enable oekaki (お絵描き). This puts a drawing field on your board. You can either - * enable it globally or enable it on a per-board basis. Oekaki's color field - * can be greatly enhanced by installing jscolor from http://jscolor.com/ and installing it in js/ - * If you enable oekaki, please remember to also enable its script with: - * $config['additional_javascript'][] = 'js/oekaki.js'; - */ + // Oekaki - To enable oekaki, just enable its script with: + // $config['additional_javascript'][] = 'js/oekaki.js'; + // $config['oekaki'] holds Oekaki options, which are currently just default canvas size. - $config['oekaki'] = false; + $config['oekaki']['height'] = 250; + $config['oekaki']['width'] = 500; /* * ==================== diff --git a/js/oekaki.js b/js/oekaki.js index 028b8f58..eaf98aec 100644 --- a/js/oekaki.js +++ b/js/oekaki.js @@ -6,7 +6,7 @@ var oekaki_form = '\ Oekaki\ \ \ - lol what you looking at the source for nerd\ + lol what you looking at the source for nerd\


\ \

\ @@ -18,7 +18,7 @@ function enable_oekaki() { // Add oekaki after the file input $('input[type="file"]').parent().parent().after(oekaki_form); // Init oekaki vars - canvas = $("#cvs"); + canvas = $("#oekaki_canvas"); context = canvas[0].getContext("2d"); is_drawing = false; text = ""; @@ -98,7 +98,7 @@ function flood_fill(x, y, target){ var data = context.getImageData(n[0], n[1], 1, 1).data; var d = [data[0], data[1], data[2], data[3]]; var t = [target[0], target[1], target[2], target[3]]; - if (arraysEqual(d, t) && n[0] < 500 && n[1] < 250 && n[0] > -1 && n[1] > -1){ + if (arraysEqual(d, t) && n[0] < canvas.width() && n[1] < canvas.height() && n[0] > -1 && n[1] > -1){ context.putImageData(pixel, n[0], n[1]); queue.push([n[0], n[1]-1]); queue.push([n[0], n[1]+1]); diff --git a/templates/main.js b/templates/main.js index 78054a3b..a9343e4a 100644 --- a/templates/main.js +++ b/templates/main.js @@ -265,7 +265,14 @@ function ready() { onready(init); -{% endraw %}{% if config.google_analytics %}{% raw %} +{% endraw %} + +var oekaki_options = { + width: {{config.oekaki.width}}, + height: {{config.oekaki.height}}, +}; + +{% if config.google_analytics %}{% raw %} var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %} -- cgit v1.3 From 6cb863005dff0075b67d3f00fe950640fc153b78 Mon Sep 17 00:00:00 2001 From: ctrlcctrlv Date: Sat, 17 Aug 2013 18:56:16 +0000 Subject: Edit images in thread/board using Oekaki --- js/oekaki.js | 21 ++++++++++++++++++--- templates/main.js | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/js/oekaki.js b/js/oekaki.js index eaf98aec..c610dd6b 100644 --- a/js/oekaki.js +++ b/js/oekaki.js @@ -17,6 +17,8 @@ var oekaki_form = '\ function enable_oekaki() { // Add oekaki after the file input $('input[type="file"]').parent().parent().after(oekaki_form); + // Add "edit in oekaki" links + $(".fileinfo").append(' '+_('Edit in oekaki')+''); // Init oekaki vars canvas = $("#oekaki_canvas"); context = canvas[0].getContext("2d"); @@ -30,7 +32,8 @@ function enable_oekaki() { } function disable_oekaki(){ - $("#oekaki").detach() + $("#oekaki").detach(); + $(".edit_in_oekaki").detach(); localStorage['oekaki'] = false; } @@ -176,6 +179,7 @@ function clear(){ context.beginPath(); context.clearRect(0,0,canvas.width(),canvas.height()); $("#confirm_oekaki").attr("checked",false) + canvas[0].height = oekaki_options.height; canvas[0].width = oekaki_options.width; }; $("#clear").on("click", clear); @@ -213,6 +217,16 @@ $("#getcolor").on("click", function(){ $("#fill").on("click", function(){ fill = true; }); + +$(".edit_in_oekaki").on("click", function(){ + var img_link = $(this).parent().parent().find("a>img.post-image").parent()[0] + var img = new Image(); + img.onload = function() { + canvas[0].width = img.width; canvas[0].height = img.height; + context.drawImage(img, 0, 0); + } + img.src = $(img_link).attr("href"); +}); } function dataURItoBlob(dataURI) { @@ -235,12 +249,13 @@ $("form[name='post']").on("submit", function(e){ fd.append("post", $("input[name='post']").val()); $.ajax({ type: "POST", - url: "/post.php", + url: oekaki_options.root+"post.php", data: fd, processData: false, contentType: false, success: function(data) { - location.reload(); + //location.reload(); + console.log(data); }, error: function(data) {alert("Something went wrong!"); console.log(data)} }); diff --git a/templates/main.js b/templates/main.js index a9343e4a..05a8fd5f 100644 --- a/templates/main.js +++ b/templates/main.js @@ -270,6 +270,7 @@ onready(init); var oekaki_options = { width: {{config.oekaki.width}}, height: {{config.oekaki.height}}, + root: '{{config.root}}' }; {% if config.google_analytics %}{% raw %} -- cgit v1.3