diff --git a/inc/config.php b/inc/config.php index 486d4892..1bf55fb7 100644 --- a/inc/config.php +++ b/inc/config.php @@ -751,15 +751,6 @@ // Allow unfiltered HTML in board subtitle. This is useful for placing icons and links. $config['allow_subtitle_html'] = false; - // Oekaki - To enable oekaki, just enable its script with: - // $config['additional_javascript'][] = 'js/oekaki.js'; - // Color selection in oekaki can be greatly improved by including the bundled jscolor script. - // $config['additional_javascript'][] = 'js/jscolor/jscolor.js'; - // $config['oekaki'] holds Oekaki options, which are currently just default canvas size. - - $config['oekaki']['height'] = 250; - $config['oekaki']['width'] = 500; - /* * ==================== * Display settings diff --git a/js/jscolor/arrow.gif b/js/jscolor/arrow.gif deleted file mode 100644 index 246478a8..00000000 Binary files a/js/jscolor/arrow.gif and /dev/null differ diff --git a/js/jscolor/cross.gif b/js/jscolor/cross.gif deleted file mode 100644 index 0ee9c7ac..00000000 Binary files a/js/jscolor/cross.gif and /dev/null differ diff --git a/js/jscolor/hs.png b/js/jscolor/hs.png deleted file mode 100644 index 3d94486c..00000000 Binary files a/js/jscolor/hs.png and /dev/null differ diff --git a/js/jscolor/hv.png b/js/jscolor/hv.png deleted file mode 100644 index 1c5e01f8..00000000 Binary files a/js/jscolor/hv.png and /dev/null differ diff --git a/js/jscolor/jscolor.js b/js/jscolor/jscolor.js deleted file mode 100644 index 712ab9a3..00000000 --- a/js/jscolor/jscolor.js +++ /dev/null @@ -1,995 +0,0 @@ -/** - * jscolor, JavaScript Color Picker - * - * @version 1.4.1 - * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html - * @author Jan Odvarko, http://odvarko.cz - * @created 2008-06-15 - * @updated 2013-04-08 - * @link http://jscolor.com - */ - - -var jscolor = { - - - dir : '', // location of jscolor directory (leave empty to autodetect) - bindClass : 'color', // class name - binding : true, // automatic binding via - preloading : true, // use image preloading? - - - install : function() { - jscolor.addEvent(window, 'load', jscolor.init); - }, - - - init : function() { - if(jscolor.binding) { - jscolor.bind(); - } - if(jscolor.preloading) { - jscolor.preload(); - } - }, - - - getDir : function() { - if(!jscolor.dir) { - var detected = jscolor.detectDir(); - jscolor.dir = detected!==false ? detected : 'jscolor/'; - } - return jscolor.dir; - }, - - - detectDir : function() { - var base = location.href; - - var e = document.getElementsByTagName('base'); - for(var i=0; i vs[a] ? - (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) : - tp[a], - -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ? - (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) : - (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c) - ]; - } - drawPicker(pp[a], pp[b]); - } - }; - - - this.importColor = function() { - if(!valueElement) { - this.exportColor(); - } else { - if(!this.adjust) { - if(!this.fromString(valueElement.value, leaveValue)) { - styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; - styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; - styleElement.style.color = styleElement.jscStyle.color; - this.exportColor(leaveValue | leaveStyle); - } - } else if(!this.required && /^\s*$/.test(valueElement.value)) { - valueElement.value = ''; - styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; - styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; - styleElement.style.color = styleElement.jscStyle.color; - this.exportColor(leaveValue | leaveStyle); - - } else if(this.fromString(valueElement.value)) { - // OK - } else { - this.exportColor(); - } - } - }; - - - this.exportColor = function(flags) { - if(!(flags & leaveValue) && valueElement) { - var value = this.toString(); - if(this.caps) { value = value.toUpperCase(); } - if(this.hash) { value = '#'+value; } - valueElement.value = value; - } - if(!(flags & leaveStyle) && styleElement) { - styleElement.style.backgroundImage = "none"; - styleElement.style.backgroundColor = - '#'+this.toString(); - styleElement.style.color = - 0.213 * this.rgb[0] + - 0.715 * this.rgb[1] + - 0.072 * this.rgb[2] - < 0.5 ? '#FFF' : '#000'; - } - if(!(flags & leavePad) && isPickerOwner()) { - redrawPad(); - } - if(!(flags & leaveSld) && isPickerOwner()) { - redrawSld(); - } - }; - - - this.fromHSV = function(h, s, v, flags) { // null = don't change - if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); } - if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); } - if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); } - - this.rgb = HSV_RGB( - h===null ? this.hsv[0] : (this.hsv[0]=h), - s===null ? this.hsv[1] : (this.hsv[1]=s), - v===null ? this.hsv[2] : (this.hsv[2]=v) - ); - - this.exportColor(flags); - }; - - - this.fromRGB = function(r, g, b, flags) { // null = don't change - if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); } - if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); } - if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); } - - var hsv = RGB_HSV( - r===null ? this.rgb[0] : r, - g===null ? this.rgb[1] : g, - b===null ? this.rgb[2] : b - ); - if(hsv[0] !== null) { - this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0])); - } - if(hsv[2] !== 0) { - this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1])); - } - this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2])); - - // update RGB according to final HSV, as some values might be trimmed - var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]); - this.rgb[0] = rgb[0]; - this.rgb[1] = rgb[1]; - this.rgb[2] = rgb[2]; - - this.exportColor(flags); - }; - - - this.fromString = function(hex, flags) { - var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i); - if(!m) { - return false; - } else { - if(m[1].length === 6) { // 6-char notation - this.fromRGB( - parseInt(m[1].substr(0,2),16) / 255, - parseInt(m[1].substr(2,2),16) / 255, - parseInt(m[1].substr(4,2),16) / 255, - flags - ); - } else { // 3-char notation - this.fromRGB( - parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255, - parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255, - parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255, - flags - ); - } - return true; - } - }; - - - this.toString = function() { - return ( - (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) + - (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) + - (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1) - ); - }; - - - function RGB_HSV(r, g, b) { - var n = Math.min(Math.min(r,g),b); - var v = Math.max(Math.max(r,g),b); - var m = v - n; - if(m === 0) { return [ null, 0, v ]; } - var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m); - return [ h===6?0:h, m/v, v ]; - } - - - function HSV_RGB(h, s, v) { - if(h === null) { return [ v, v, v ]; } - var i = Math.floor(h); - var f = i%2 ? h-i : 1-(h-i); - var m = v * (1 - s); - var n = v * (1 - s*f); - switch(i) { - case 6: - case 0: return [v,n,m]; - case 1: return [n,v,m]; - case 2: return [m,v,n]; - case 3: return [m,n,v]; - case 4: return [n,m,v]; - case 5: return [v,m,n]; - } - } - - - function removePicker() { - delete jscolor.picker.owner; - document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB); - } - - - function drawPicker(x, y) { - if(!jscolor.picker) { - jscolor.picker = { - box : document.createElement('div'), - boxB : document.createElement('div'), - pad : document.createElement('div'), - padB : document.createElement('div'), - padM : document.createElement('div'), - sld : document.createElement('div'), - sldB : document.createElement('div'), - sldM : document.createElement('div'), - btn : document.createElement('div'), - btnS : document.createElement('span'), - btnT : document.createTextNode(THIS.pickerCloseText) - }; - for(var i=0,segSize=4; i - * Copyright (c) 2013-2014 Marcin Ɓabanowski - * - * Usage: (it wouldn't work when mixed with ajax.js) - * $config['additional_javascript'][] = 'js/jquery.min.js'; - * $config['additional_javascript'][] = 'js/oekaki.js'; - * $config['additional_javascript'][] = 'js/jscolor/jscolor.js'; - * //$config['additional_javascript'][] = 'js/upload-selection.js'; - */ - -$(function() { -// Init -var oekaki_form = '\ - \ - \ - Oekaki\ - \ - \ - \ -


\ - \ -

\ - \ - \ - ' - -function init_oekaki() { - // Add oekaki after the file input - $('form[name="post"]:not(#quick-reply) input[type="file"]').parent().parent().after(oekaki_form); - // Add "edit in oekaki" links - $(".fileinfo .unimportant").append(' ['+_('Edit in oekaki')+']'); - // Init oekaki vars - canvas = $("#oekaki_canvas"); - context = canvas[0].getContext("2d"); - is_drawing = false; - text = ""; - eraser = getcolor = fill = false; - context.strokeStyle = context.fillStyle = "black"; - // Attach canvas events - attach_events(); -} - -if (active_page == 'index' || active_page == 'thread') { - init_oekaki(); -} - -//http://stackoverflow.com/a/5624139/1901658 -function hexToRgb(hex) { - var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); - return result ? { - r: parseInt(result[1], 16), - g: parseInt(result[2], 16), - b: parseInt(result[3], 16) - } : null; -} - -//http://stackoverflow.com/a/4025958/1901658 -function arraysEqual(arr1, arr2) { - if(arr1.length !== arr2.length) - return false; - for(var i = arr1.length; i--;) { - if(arr1[i] !== arr2[i]) - return false; - } - - return true; -} - -function getmousepos(e){ - var r = canvas[0].getBoundingClientRect(); - mouseX = Math.round(e.clientX - r.left); - mouseY = Math.round(e.clientY - r.top); -} - -function setcolor(){ - context.strokeStyle = context.fillStyle = "#"+$(".color").val(); -} - -function flood_fill(x, y, target){ - var pixel = context.createImageData(1,1); - var color = hexToRgb("#"+$(".color").val()); - pixel.data[0] = color.r; pixel.data[1] = color.g; pixel.data[2] = color.b; pixel.data[3] = 255; - var queue = []; - var node = [x, y]; - queue.push(node); - //var iters = 0; - while (queue.length > 0) { - var n = queue.pop(); - 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] < 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]); - queue.push([n[0]-1, n[1]]); - queue.push([n[0]+1, n[1]]); - //iters++; - } - //if (iters%100===0){console.log(n[0]);console.log(n[1])} - - } - return; -} - -function color_under_pixel(x, y){ - return context.getImageData(x, y, 1, 1).data; -} - -function attach_events(){ - -canvas.on("mousedown", function(e){ - getmousepos(e); - $(this).css("cursor","none"); - if (getcolor) { - var imagedata = color_under_pixel(mouseX, mouseY); - $("#color")[0].color.fromRGB(imagedata[0], imagedata[1], imagedata[2]); - getcolor = false; - setcolor(); - } - else if (fill && !eraser) { - flood_fill(mouseX, mouseY, color_under_pixel(mouseX, mouseY)); - fill = false; - } - else { - is_drawing = true; - context.beginPath(); - context.moveTo(mouseX,mouseY); - context.fillText(text,mouseX,mouseY); - $("#confirm_oekaki").attr("checked",true); - } - -}); - -canvas.on("mousemove", function(e){ - getmousepos(e); - if (is_drawing) { - context.lineTo(mouseX,mouseY); - context.stroke() - } -}); - -canvas.on("mouseup mouseout", function(e){ - context.stroke() - $(this).css("cursor","auto"); - is_drawing = false; -}); - -$("#brushsize").on("click",function(){ - var size = prompt("Enter brush size"); - if (parseInt(size) == NaN) { - return - } - else { - context.lineWidth = size; - } -}); - -$(".color").on("change", setcolor); - -$("#text").on("click", function(e){ - text = prompt(_("Enter some text")) || ""; - context.font = prompt(_("Enter font or leave empty"), context.font) -}); - -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); - -$("#save").on("click",function(){ - $("#savebox").val(canvas[0].toDataURL()); -}); - -$("#load").on("click", function(){ - clear(); - var img = new Image(); - img.src = $("#savebox").val(); - img.onload = function(){context.drawImage(img,0,0);}; - $("#confirm_oekaki").attr("checked",true) -}); - -$("#eraser").on("click", function(){ - if (eraser) { - eraser = false; - context.strokeStyle = context.fillStyle = "#"+$(".color").val(); - context.globalCompositeOperation = old_gco; - } - else { - eraser = true; - old_gco = context.globalCompositeOperation; - context.globalCompositeOperation = "destination-out"; - context.strokeStyle = "rgba(0,0,0,1)"; - } -}); - -$("#getcolor").on("click", function(){ - getcolor = true; -}); - -$("#fill").on("click", function(){ - fill = true; -}); - -$(".edit_in_oekaki").on("click", function(){ - var img_link = $(this).parent().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"); - - if (typeof enable_oekaki === 'function') { // for upload-selection.js - enable_oekaki(); - } - return false; -}); -} - -function dataURItoBlob(dataURI) { - var binary = atob(dataURI.split(',')[1]); - var array = new Array(binary.length); - for(var i = 0; i < binary.length; i++) { - array[i] = binary.charCodeAt(i); - } - return new Blob([new Uint8Array(array)], {type: 'image/jpeg'}); -} - -$("form[name='post']").on("submit", function(e){ - if ($("#confirm_oekaki").is(":checked")) { - e.preventDefault(); - $("input[type='file']").remove(); - var dataURL = canvas[0].toDataURL(); - var blob = dataURItoBlob(dataURL); - var fd = new FormData(document.forms[0]); - fd.append("file", blob, "Oekaki.png"); - fd.append("post", $("input[name='post']").val()); - $.ajax({ - type: "POST", - url: oekaki_options.root+"post.php", - data: fd, - processData: false, - contentType: false, - success: function(data) { - location.reload(); - }, - error: function(jq, data, et) { -if (jq.responseText == '' && data == 'error') { -//probably jquery bug, ignore -location.reload(); -} -else -{ - alert($('h2',jq.responseText).text()); -} -} - }); - } - - else { - return true; - }; -}); -}); diff --git a/templates/main.js b/templates/main.js index 83365ff2..54018e37 100644 --- a/templates/main.js +++ b/templates/main.js @@ -292,12 +292,6 @@ onready(init); {% endraw %} -var oekaki_options = { - width: {{config.oekaki.width}}, - height: {{config.oekaki.height}}, - root: '{{config.root}}' -}; - {% 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://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %}