From ff9b684f7e8812387e2d158cc0850c6180f7ecba Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 29 Jan 2014 22:59:29 +0100 Subject: [PATCH] remove old oekaki; see vichan-devel#20 --- inc/config.php | 9 - js/jscolor/arrow.gif | Bin 66 -> 0 bytes js/jscolor/cross.gif | Bin 83 -> 0 bytes js/jscolor/hs.png | Bin 2684 -> 0 bytes js/jscolor/hv.png | Bin 2865 -> 0 bytes js/jscolor/jscolor.js | 995 ------------------------------------------ js/oekaki.js | 278 ------------ templates/main.js | 6 - 8 files changed, 1288 deletions(-) delete mode 100644 js/jscolor/arrow.gif delete mode 100644 js/jscolor/cross.gif delete mode 100644 js/jscolor/hs.png delete mode 100644 js/jscolor/hv.png delete mode 100644 js/jscolor/jscolor.js delete mode 100644 js/oekaki.js 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 246478a864f812d93d4cd0e0d0ad1c8e2d09c825..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 66 zcmZ?wbhEHbWM|-JSjfb{z`*eT|Nj*>6)S8i6o0ZXaxpM5=zv5)@(fJEJ}nXjJKr?q SYyUH_EM dkN*vF4%41#_Gw-zytPEKz-IruP-#{MYXG_x9vzp#K6GN!f$$!fq~1})5S5Q;?~=_w~Lgu zd0bhaBtH9Z|LuwD*-DRFj4gT%Ewfh@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eiUWdRLC%g^R0gl zPwoA9hmCU@Di&=v+NBwMQlhH)t#plr063N}@V~hFYT19!E7?ZcHNK)7PPolJ##o@X zMSUZ8$y)ht_tGqp8*Q=z`R^;_zPKeBzlgHen6pz{bVg4x!;v%7@5pyovu%;yC|4f zt}9P3?O{KE>cq5;-wXbBzFo-u_rmoQb+0n+`Lk;6|INK%cVyZH#pgW#<^IbZd0emS Xaop<7PcCl;1_lOCS3j3^P6-2 diff --git a/js/jscolor/hv.png b/js/jscolor/hv.png deleted file mode 100644 index 1c5e01f8bcecc4cf835e8eeeaa43ef2c06789022..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2865 zcmeAS@N?(olHy`uVBq!ia0y~yVA#sQz>vzp#K6GN!f$$!fr0CXr;B4q#jUq<-%fh6 zhPRb}p6}DUtM2??oA#gK=f}M7Ne=M}UuUSq#_IK#Z+pIxYjtZM%Sxsn+&{Q~c*@s% z?RSv*&-n}vTnx7^|P^Zgc&E}mKT`oRMC-LKaF|25ID`s(kEXZr41 z`}bWweRuco2UdRy@2>t^|91DC^UJ^dEIapL+kC^in)VBllU3Og+gC1ipX_a>XFPk# z!}tC^_j>wI-P+05yx8kXq?=w#;IeD$?l{=7Sv5#-H2(`UkbcQiH*wyvw#nZmTkANE zKi^O^@3BEfev$%D)sMQB%>SnB^?0|wQsgwx{&Rc2a@bX6Ukj~vp04pi_R$?-=EQ0H ze)C^A(Rx7s%A%`f zF(8Y1y?ddr(2QL+n*S`A!Qr{@H@{k$)~*{?=jD&C;a=Ij`QN7iNLZfe5A6=IlfAcd z`Yxm2uccP*$qME??yy^kIq`zaUv?2on?S`An60URZ zNonBy`_%D5;t>Z4lehL8ymF`P+QZuWdBOJ1slV=UnaI`~6zd;*z4Gf{Em5_Ez*7vm zsUcTI!X;mcnmO+kH~E-$u4&(VSzX^V@g_U>I;qSQ`RW)d#FlV5{z!gt+LVX|tNqRf zgwI>@!g&9=SNg4jY_Edy`h7!R2UnE_)>|^)ni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Lv}|`~ITGMrzOIZM)7bV|n-fqf18qBZrKnT6SO0QmGZz-&EGm zS|-wM^JRLv<8GnsYs;fs)P703-1wMuoUiigmQ~s3Z^UIi-Fd<9NaF?X-_<^e>G|KQ ze)oP|x=-G!M}nhy+ONgeK8P;1+T{Am=7sGehm4i`g>>F`{I9#a|J3GwAZs|p2dYr)4s}Dz533{_ThSGruUBxe{Ibc zY_{LR{jotVHM6W%LaTf-+mmnZUlvE*3Ek+ScYdGU|H}(~k7SlHUvRoEn{o7?oXA&^ zpMCLWEsQyD-+v5vk(yL+|S_Z*s(8#?tq{ytDkQg3Cj{=l;y$z84h#gpDa=@83)R^vY`d|Id zz76-@NF-dod+Y4t2+^Bg_Ws&wTBh|9rCcUk2w(zos&!vV(J-m)Dm@mCyRSqh_Lq zTz;Gk%dg1`k~h($ 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 %}