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|-JSjfZx1poj4Utv=LM2bII7`Ygj7<53QAbAERVV@R>f}L*~a`L;Z PKCZl?^}@uHk--`OML81Y diff --git a/js/jscolor/cross.gif b/js/jscolor/cross.gif deleted file mode 100644 index 0ee9c7ac517bee40b78aea03afa809631f0b69fa..0000000000000000000000000000000000000000 GIT binary patch literal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?M|9Ladf4zeO?n&EMM2JE0Q6A5#?^TU3!~Vl zs4+YvJ!u|5x*cR;3M`2ol(60+K1QomP+|c!3SOBpo`2I4Al%NaA;URpKsgTQ`um*) z$$0jzaM_tG3$^<%+IquqoA<(IXZhE{tm>@gJUP5p{A3J6+&@8B1Ab`k#pS#XQGLsb z!I1N@6}*sK$&^j&E9UfVBsE3Cy09vRRbP@j2V8RUyS}$EzQISB8Wob;L&@gXJ0-qG zN5LYq5L0xS_C~Y5ieq)J$^evnrYxC3DF5rA^JvXg$)Z@TW4d~?c5Fm1;n8+WV9n3A zREIvTfx}B&q+1AP^S|orTG__8w)t@5vGN(1#THk!CKLHp`#)!zH7z`x^Y2abdkC%N zVpo9#I|*N>2gAEStK;2nH>2-d8UgV}Ce62}O-VSnpIx1GP7~)f>xpwmI^Gq>t9ccs zdo47kYWW=g+WUVuK=)o4jL>*SZet8NcRq)42(#4#7K&?jfMC8bH5#uho9aCC9Sc8| z&eN*3Xr9L%twp11piU_UMd7cxt!d0dy(tNJ+3&*_^j;1X9gV|DYj@pg2={0^wT+T5 z?Xw4UzW(|>jIRGsKJaB+PUaLZQP!rJ26J1VGh%$e>x-WKf|{S*YSJH@EETJjsGMoT zZ6{6eiS3#V@YL5Z@Hgy9@bEpRGI;>Z_}tQa8IhV#m14ak_?Dm8Rb(N8c>8!Bbg8nV z@Fnflx2C1NJLL_>Z|O7~CV@n+T&C@vpgqh~t(`X)qaj=ypFdgdNZsNlmAwU7;S#iO z`J>RxSlI>*l1c;-I(BztG~ID9hmZHLX}mTDprkNW`2*nM`NCrG^K)aoYd*>U5=8}T zz<8Trh(5#1==-ntBY@u7k%!+X7o>B<{Wf^*@YzUESz$bKtAufemd7|St0063A+%|% YzFqsNg>|5V=vOIWZ|#VBZRvIQe;Bk#LI3~& diff --git a/js/jscolor/hv.png b/js/jscolor/hv.png deleted file mode 100644 index 1c5e01f8bcecc4cf835e8eeeaa43ef2c06789022..0000000000000000000000000000000000000000 GIT binary patch literal 0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l>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 %}