1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-02 12:57:35 +01:00

Merge pull request #867 from perdedora/tegaki

Add tegaki support
This commit is contained in:
Lorenzo Yario 2024-12-26 00:25:33 -06:00 committed by GitHub
commit 06986637b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 815 additions and 7 deletions

View File

@ -6,6 +6,8 @@
* $config['additional_javascript'][] = 'js/ajax.js';
* $config['additional_javascript'][] = 'js/file-selector.js';
*/
var FileSelector = {};
function init_file_selector(max_images) {
// Temporarily block iOS
@ -52,7 +54,7 @@ var files = [];
$('#upload_file').remove(); // remove the original file selector
$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix
function addFile(file) {
FileSelector.addFile = function addFile(file) {
if (files.length == max_images)
return;
@ -60,7 +62,8 @@ function addFile(file) {
addThumb(file);
}
function removeFile(file) {
FileSelector.removeFile = function removeFile(file) {
getThumbElement(file).remove();
files.splice(files.indexOf(file), 1);
}
@ -138,7 +141,7 @@ var dropHandlers = {
var fileList = e.originalEvent.dataTransfer.files;
for (var i=0; i<fileList.length; i++) {
addFile(fileList[i]);
FileSelector.addFile(fileList[i]);
}
}
};
@ -153,7 +156,7 @@ $(document).on('click', '.dropzone .remove-btn', function (e) {
var file = $(e.target).parent().data('file-ref');
getThumbElement(file).remove();
removeFile(file);
FileSelector.removeFile(file);
});
$(document).on('keypress click', '.dropzone', function (e) {
@ -169,7 +172,7 @@ $(document).on('keypress click', '.dropzone', function (e) {
$fileSelector.on('change', function (e) {
if (this.files.length > 0) {
for (var i=0; i<this.files.length; i++) {
addFile(this.files[i]);
FileSelector.addFile(this.files[i]);
}
}
$(this).remove();
@ -189,7 +192,7 @@ $(document).on('paste', function (e) {
//convert blob to file
var file = new File([clipboard.items[i].getAsFile()], 'ClipboardImage.png', {type: 'image/png'});
addFile(file);
FileSelector.addFile(file);
}
}
});

View File

@ -252,6 +252,11 @@
$(this).remove();
}
// Remove tegaki if existent
if ($(this).is('#tegaki-form')) {
$(this).remove();
}
// Remove upload selection
if ($td.is('#upload_selection')) {
$(this).remove();

115
js/tegaki.js Normal file
View File

@ -0,0 +1,115 @@
/*
* tegaki.js - Add support for tegaki drawing
*
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js'; (required if both below are in use)
* $config['additional_javascript'][] = 'js/ajax.js'; // (optional) to clear state after upload
* $config['additional_javascript'][] = 'js/file-selector.js'; // (optional) for thumbnails
* $config['additional_javascript'][] = 'js/tegaki/tegaki.min.js';
* $config['additional_javascript'][] = 'js/tegaki.js';
*/
function clearTegaki(blob = null) {
const edit = document.getElementById('tegaki-edit');
const clear = document.getElementById('tegaki-clear');
const start = document.getElementById('tegaki-start');
const fileInput = document.getElementById('upload_file');
if (typeof FileSelector !== 'undefined' && FileSelector.removeFile) {
FileSelector.removeFile(blob);
} else {
fileInput.value = '';
}
toggleButtonState(start, true);
toggleButtonState(edit, false, true);
toggleButtonState(clear, false, true);
}
function toggleButtonState(button, isVisible, isDisabled = false) {
button.style.display = isVisible ? '' : 'none';
button.disabled = isDisabled;
}
function initializeTegaki() {
if (!['thread', 'index', 'ukko', 'catalog'].includes(active_page)) return;
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = `${configRoot}js/tegaki/tegaki.css`;
document.head.appendChild(link);
const upload = document.querySelector('#upload');
upload.insertAdjacentHTML('afterend', `
<tr id="tegaki-form">
<th>Tegaki</th>
<td id="tegaki-buttons">
<input type="text" id="width-tegaki" title="${_('Width')}" class="tegaki-input" size="4" maxlength="4" value="800"> x
<input type="text" id="height-tegaki" title="${_('Height')}" class="tegaki-input" size="4" maxlength="4" value="800">
<input type="button" id="tegaki-start" value="${_('Draw')}">
<input type="button" id="tegaki-edit" style="display: none;" value="${_('Edit')}" disabled>
<input type="button" id="tegaki-clear" style="display: none;" value="${_('Clear')}" disabled>
</td>
</tr>
`);
document.getElementById('tegaki-start').addEventListener('click', startTegaki);
}
function afterDraw(blob) {
const edit = document.getElementById('tegaki-edit');
const clear = document.getElementById('tegaki-clear');
const start = document.getElementById('tegaki-start');
toggleButtonState(clear, true);
toggleButtonState(edit, true);
toggleButtonState(start, false, true);
edit.addEventListener('click', () => {
clearTegaki(blob);
startTegaki();
});
clear.addEventListener('click', () => {
clearTegaki(blob);
});
}
function startTegaki() {
if (typeof Tegaki === 'undefined') {
console.error('Tegaki library is not loaded.');
return;
}
Tegaki.open({
onDone: () => {
Tegaki.flatten().toBlob((blob) => {
const tmp = new File([blob], "Tegaki.png", { type: 'image/png' });
if (typeof FileSelector !== 'undefined' && FileSelector.addFile) {
FileSelector.addFile(tmp);
} else {
const fileInput = document.getElementById('upload_file');
const dataTransfer = new DataTransfer();
dataTransfer.items.add(tmp);
fileInput.files = dataTransfer.files;
}
afterDraw(tmp);
}, 'image/png');
},
onCancel: () => {
console.log('Closing...');
},
width: document.getElementById('width-tegaki')?.value.trim() || '800',
height: document.getElementById('height-tegaki')?.value.trim() || '800'
});
}
if (typeof jQuery !== 'undefined') {
$(document).on('ajax_after_post', () => {
clearTegaki();
});
}
onReady(initializeTegaki);

670
js/tegaki/tegaki.css Normal file
View File

@ -0,0 +1,670 @@
/*! Contains fonts from Font Awesome (Copyright (C) 2016 by Dave Gandy), Entypo (Copyright (C) 2012 by Daniel Bruce) */
@font-face {
font-family: 'tegaki';
src: url('data:application/octet-stream;base64,d09GRgABAAAAAAw4AAsAAAAAEpQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADsAAABUIIslek9TLzIAAAFEAAAAQwAAAFY+IFLIY21hcAAAAYgAAAC+AAACptXj0XhnbHlmAAACSAAABtcAAAnIF+/SeGhlYWQAAAkgAAAAMwAAADYXAPWXaGhlYQAACVQAAAAgAAAAJAd1A5tobXR4AAAJdAAAAEAAAABcShf/3GxvY2EAAAm0AAAAMAAAADAZpBxobWF4cAAACeQAAAAfAAAAIAExAGtuYW1lAAAKBAAAAX4AAAK17cxnR3Bvc3QAAAuEAAAAswAAAPr4ELHkeJxjYGR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9nyIM9HzXKH+6LmGqXj2XMeF+Bqa1dbGYeTk5bApu+1OT75upaEUpyqRau0iYzM5kHOTOp0kJpiZpdOheo8nOlwnyhZBcU61zWKTyk7QLoSxTrVVTr/tumabsOvcXM6tWcqR7ydX1iz0zAWRc6t+q7X/HQxhsMIWFjFCRHCQuKTa5LuLNjrokV7pkHQWrhgpFBIqCmtWRHkmYzzgnjNKqWo6EnKAGc9lroSseGf9JOc184qV+5l9npJ3feO8o+QsASfad4zJae5Suf72O2uGDV1dqo4T7aay+RQSoz/zSd5/l1tQmVEP8r/gqPbR4vrnPj+rn3wZAAB4nG2NWVLDMBBE1YktLySBbIRL+FCyMiYqFEk1GuHi9iT4l/fTS1VXq5Va6NX/XLDCGhVqaDRo0aHHCzbYYodXvGGPA4444Yx3XPChtDXBkq+SL7m+u1DyOlHornEOQ3y4pqQ/7T19kx+evX5E654T86PHYr9I6mRKpmr0hVuJQxbD0s9GiG30kSuJgVrjeOSSb81ksgzTvOg4d54mWU7Yfd4Wq4lNJm6SSyRCSv0C/DA9cAA=') format('woff');
font-weight: normal;
font-style: normal;
}
.tegaki-icon:before {
font-family: 'tegaki';
font-style: normal;
font-weight: normal;
speak: none;
display: inline-block;
text-align: center;
font-variant: normal;
text-transform: none;
line-height: 1em;
}
.tegaki-cancel:before { content: '\e800'; } /* '' */
.tegaki-plus:before { content: '\e801'; } /* '' */
.tegaki-minus:before { content: '\e802'; } /* '' */
.tegaki-pen:before { content: '\e803'; } /* '' */
.tegaki-down-open:before { content: '\e804'; } /* '' */
.tegaki-up-open:before { content: '\e805'; } /* '' */
.tegaki-level-down:before { content: '\e806'; } /* '' */
.tegaki-pencil:before { content: '\e807'; } /* '' */
.tegaki-play:before { content: '\e808'; } /* '' */
.tegaki-bucket:before { content: '\e809'; } /* '' */
.tegaki-pause:before { content: '\e80a'; } /* '' */
.tegaki-blur:before { content: '\e80b'; } /* '' */
.tegaki-to-start:before { content: '\e80c'; } /* '' */
.tegaki-watercolor:before { content: '\e80d'; } /* '' */
.tegaki-tone:before { content: '\e80e'; } /* '' */
.tegaki-airbrush:before { content: '\e80f'; } /* '' */
.tegaki-fast-fw:before { content: '\e810'; } /* '' */
.tegaki-fast-bw:before { content: '\e811'; } /* '' */
.tegaki-left-open:before { content: '\e812'; } /* '' */
.tegaki-right-open:before { content: '\e813'; } /* '' */
.tegaki-eraser:before { content: '\f12d'; } /* '' */
.tegaki-pipette:before { content: '\f1fb'; } /* '' */
.tegaki-disabled,
.tegaki-disabled::after,
.tegaki-disabled::before {
opacity: 0.45;
}
.tegaki-hidden {
display: none !important;
}
.tegaki-invis {
visibility: hidden !important;
width: 0 !important;
height: 0 !important;
}
.tegaki-replay-mode #tegaki-tools-cnt,
.tegaki-replay-mode #tegaki-toolmode-bar,
.tegaki-replay-mode .tegaki-ctrlgrp,
.tegaki-replay-mode .tegaki-layers-cell,
.tegaki-replay-mode #tegaki-layers-ctrl {
pointer-events: none;
}
.tegaki-replay-mode #tegaki-ctrlgrp-zoom,
.tegaki-replay-mode #tegaki-ctrlgrp-layers {
pointer-events: auto;
}
#tegaki {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #a3b1bf;
color: #222;
font-family: arial, sans-serif;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
z-index: 9999;
display: grid;
grid-template-columns: 40px 1fr 160px;
grid-template-rows: 24px 1fr 18px;
grid-gap: 2px;
}
#tegaki input {
color: inherit;
}
#tegaki > div {
background-color: #8d99a6;
}
#tegaki-menu-cnt {
grid-area: 1 / 1 / 2 / 4;
white-space: nowrap;
overflow: hidden;
display: flex;
}
#tegaki-tools-cnt {
grid-area: 2 / 1 / 4 / 2;
padding: 4px;
}
#tegaki-canvas-cnt {
grid-area: 2 / 2 / 3 / 3;
overflow: auto;
display: flex;
}
#tegaki-ctrl-cnt {
grid-area: 2 / 3 / 4 / 4;
padding: 6px;
overflow: hidden auto;
}
#tegaki-status-cnt {
grid-area: 3 / 2 / 4 / 3;
line-height: 18px;
display: flex;
}
#tegaki-status-cnt > div {
padding: 0 4px;
}
#tegaki-status-replay {
color: #a61930;
}
#tegaki-status-output {
font-size: 11px;
font-weight: bold;
}
#tegaki-status-version {
color: #adbdcc;
font-size: 11px;
margin-left: auto;
}
#tegaki-menu-bar {
font-size: 12px;
padding-left: 4px;
padding-right: 18px;
border-right: 2px solid #a3b1bf;
}
.tegaki-replay-mode #tegaki-menu-bar {
padding-right: 4px;
}
.tegaki-menu-lbl {
margin: 0 2px;
vertical-align: middle;
}
#tegaki-replay-controls {
padding-right: 10px;
padding-left: 10px;
border-right: 2px solid #a3b1bf;
font-size: 11px;
}
#tegaki-replay-timeline {
display: inline-block;
width: 100px;
height: 24px;
margin: 0 4px;
border-left: 1px solid #a3b1bf;
border-right: 1px solid #a3b1bf;
/*background-color: rgba(0, 0, 0, 0.25);*/
}
#tegaki-replay-timeline-fill {
display: inline-block;
width: 36px;
height: 100%;
background-color: #a3b1bf;
}
#tegaki-replay-controls > span {
vertical-align: middle;
}
#tegaki-replay-controls .tegaki-ui-cb-w {
margin-right: 4px;
}
#tegaki-replay-speed-lbl {
width: 28px;
display: inline-block;
text-align: center;
}
#tegaki-replay-speed-lbl::before {
content: '×';
}
#tegaki-replay-now-lbl,
#tegaki-replay-end-lbl {
display: inline-block;
max-width: 50px;
min-width: 30px;
overflow: hidden;
text-align: center;
margin: 0 4px;
}
#tegaki-toolmode-bar {
font-size: 11px;
margin-left: 4px;
line-height: 24px;
}
.tegaki-toolmode-lbl {
margin-right: 6px;
}
.tegaki-toolmode-lbl::after {
content: ':';
}
.tegaki-toolmode-grp {
border-left: 1px solid #a3b1bf;
padding: 0 18px;
}
#tegaki canvas {
image-rendering: optimizeSpeed;
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: pixelated;
-ms-interpolation-mode: nearest-neighbor;
}
.tegaki-tool-active {
color: #f2f3f4;
}
.tegaki-tool-btn {
width: 32px;
height: 32px;
display: block;
margin: auto;
}
.tegaki-tool-btn:hover {
background-color: rgba(0, 0, 0, 0.15);
}
.tegaki-tool-btn:before {
font-size: 20px;
width: 32px;
height: 32px;
line-height: 32px;
}
.tegaki-mb-btn {
cursor: default;
text-decoration: none;
display: inline-block;
padding: 0 6px;
word-spacing: -1px;
position: relative;
line-height: 24px;
height: 24px;
}
.tegaki-mb-btn:hover:not(.tegaki-disabled),
.tegaki-ui-btn:hover:not(.tegaki-disabled) {
background-color: rgba(0, 0, 0, 0.10);
}
.tegaki-sw-btn {
display: inline;
padding: 2px 6px;
margin: 0 2px;
box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15), -1px -1px 0 rgba(255, 255, 255, 0.15);
}
.tegaki-sw-btn:hover:not(.tegaki-sw-btn-a) {
background-color: rgba(0, 0, 0, 0.05);
}
.tegaki-sw-btn-a {
background-color: rgba(0, 0, 0, 0.1);
box-shadow: -1px -1px 0 rgba(0, 0, 0, 0.15), 1px 1px 0 rgba(255, 255, 255, 0.15);
}
#tegaki-toolmode-bar .tegaki-mb-btn-a {
color: inherit;
background-color: rgba(0, 0, 0, 0.10);
}
#tegaki-toolmode-bar .tegaki-mb-btn.tegaki-mb-btn-a:hover {
color: inherit;
}
#tegaki-debug {
position: absolute;
left: 0;
top: 0;
}
#tegaki-debug canvas {
width: 75px;
height: 75px;
display: block;
border: 1px solid black;
}
.tegaki-backdrop {
overflow: hidden;
}
.tegaki-hidden {
display: none !important;
}
.tegaki-strike {
text-decoration: line-through;
}
#tegaki-layers {
position: relative;
font-size: 0;
box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.25);
contain: content;
}
#tegaki-layers canvas {
width: 100%;
height: 100%;
}
#tegaki-layers:empty {
display: none;
}
#tegaki-layers-wrap {
margin: auto;
padding: 50px;
pointer-events: none;
}
#tegaki-layers canvas {
position: absolute;
left: 0;
top: 0;
}
#tegaki-finish-btn {
font-weight: bold;
}
#tegaki-cursor-layer {
position: absolute;
mix-blend-mode: difference;
touch-action: none;
}
/* generic ui */
.tegaki-alpha-bg,
.tegaki-alpha-bg-xs {
background-color: #fefefe;
background-image:
linear-gradient(45deg, #cacaca 25%, transparent 25%, transparent 75%, #cacaca 75%, #cacaca),
linear-gradient(45deg, #cacaca 25%, transparent 25%, transparent 75%, #cacaca 75%, #cacaca);
}
.tegaki-alpha-bg {
background-size: 16px 16px;
background-position: 0 0, 8px 8px;
}
.tegaki-alpha-bg-xs {
background-size: 6px 6px;
background-position: 0 0, 3px 3px;
}
.tegaki-ellipsis {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.tegaki-ui-cb {
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
border: 1px solid #222;
cursor: default;
margin-right: 4px;
}
.tegaki-ui-cb::after,
.tegaki-ui-cb-a::after {
display: block;
content: ' ';
width: 6px;
height: 6px;
margin-top: 2px;
margin-left: 2px;
}
.tegaki-ui-cb-a::after {
background-color: #222;
}
.tegaki-ui-cb-w:hover .tegaki-ui-cb::after,
.tegaki-ui-cb:hover::after {
background-color: #555;
}
.tegaki-ui-ellipsis::after {
content: '...';
letter-spacing: -1px;
}
.tegaki-ui-borderless {
border: none;
}
.tegaki-ui-btn {
display: inline-block;
}
.tegaki-ui-btn:before {
height: 24px;
width: 24px;
line-height: 24px;
font-size: 14px;
}
.tegaki-stealth-input {
border: 0;
margin: 0;
padding: 0;
background: none;
}
.tegaki-stealth-input:hover:not(.tegaki-disabled) {
background-color: rgba(0, 0, 0, 0.1);
}
.tegaki-range-lbl,
.tegaki-range-lbl-xs {
display: inline-block;
text-align: center;
vertical-align: top;
}
.tegaki-range-lbl {
width: 28px;
font-size: 12px;
margin-left: 4px;
}
.tegaki-range-lbl-xs {
width: 20px;
font-size: 10px;
}
.tegaki-label-xs {
font-size: 10px;
vertical-align: top;
}
.tegaki-lbl-c::after {
content: ':';
}
.tegaki-lbl-p::after {
content: '%';
margin-left: 1px;
}
.tegaki-drag-lbl:not(.tegaki-disabled) {
cursor: ew-resize;
}
.tegaki-disabled .tegaki-drag-lbl {
cursor: auto;
}
/* control groups */
.tegaki-ctrlgrp {
margin-bottom: 10px;
}
.tegaki-ctrlgrp:last-child {
margin-bottom: 0;
}
.tegaki-ctrlgrp-title {
font-size: 12px;
font-weight: bold;
margin-bottom: 6px;
background-color: #a3b1bf;
padding: 1px 4px;
}
.tegaki-ctrlrow {
font-size: 11px;
}
.tegaki-ctrlrow:not(:last-child) {
margin-bottom: 6px;
}
.tegaki-ctrl-range {
width: calc(100% - 34px);
padding: 0;
margin: 0;
height: 14px;
}
/* zoom ctrl group */
#tegaki-zoom-lbl {
display: inline-block;
font-size: 12px;
float: right;
height: 24px;
line-height: 24px;
}
/* color ctrl group */
#tegaki-color-ctrl {
display: flex;
}
#tegaki-palette-switcher {
align-self: center;
margin-left: auto;
}
.tegaki-color-grid {
display: grid;
grid-gap: 4px;
margin-top: 6px;
}
.tegaki-color-grid-20 {
grid-template-columns: repeat(auto-fill, 20px);
grid-auto-rows: 20px;
}
.tegaki-color-grid-15 {
grid-template-columns: repeat(auto-fill, 15px);
grid-auto-rows: 15px;
}
.tegaki-color-btn {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
#tegaki-color,
#tegaki-colorpicker {
padding: 0;
border: 0;
display: block;
width: 28px;
height: 28px;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
/* layers ctrl group */
#tegaki-ctrlgrp-layers {
position: relative;
}
#tegaki-layers-opts {
height: 18px;
display: flex;
}
#tegaki-layer-alpha-cell {
margin-left: auto;
}
#tegaki-layers-ctrl {
margin-top: 4px;
}
#tegaki-layers-grid {
height: 84px;
min-height: 84px;
overflow: auto;
background-color: #8d99a6;
display: flex;
flex-direction: column;
border: 1px solid #a3b1bf;
resize: vertical;
}
.tegaki-layers-cell {
box-sizing: border-box;
box-shadow: 0 1px 0 0px #a3b1bf;
padding: 0;
height: 28px;
flex-shrink: 0;
overflow: hidden;
display: flex;
align-items: center;
}
.tegaki-layers-cell-s,
.tegaki-layers-cell-a {
background-color: #a3b1bf7f;
}
.tegaki-layers-cell-a {
font-weight: bold;
}
.tegaki-layers-cell-v {
margin: 0 6px 0 4px;
}
.tegaki-layers-cell-v .tegaki-ui-cb {
vertical-align: unset;
margin: 0;
}
.tegaki-layers-cell-p {
margin-right: 6px;
}
.tegaki-layers-cell-p canvas {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
vertical-align: middle;
}
.tegaki-layers-cell-s .tegaki-layers-cell-p canvas {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 1.0);
}
.tegaki-layers-cell-n {
font-size: 11px;
margin-right: 1px;
min-width: 20px;
}
.tegaki-layers-cell-d {
box-shadow: inset 0 -2px 0 0 #000;
z-index: 2;
}
#tegaki-layers-grid.tegaki-layers-cell-d {
box-shadow: 0 -2px 0 0px #000;
}
#tegaki-layers-cell-dx {
position: absolute;
background: transparent;
width: 100%;
height: 32px;
margin-top: -32px;
}

5
js/tegaki/tegaki.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,7 @@ $(function(){
var enabled_url = $("#upload_url").length > 0;
var enabled_embed = $("#upload_embed").length > 0;
var enabled_oekaki = typeof window.oekaki != "undefined";
var enabled_tegaki = $("#tegaki-form").length > 0;
var disable_all = function() {
$("#upload").hide();
@ -26,6 +27,7 @@ $(function(){
$("#upload_embed").hide();
$(".add_image").hide();
$(".dropzone-wrap").hide();
$("#tegaki-form").hide();
$('[id^=upload_file]').each(function(i, v) {
$(v).val('');
@ -66,7 +68,12 @@ $(function(){
window.oekaki.init();
};
if (enabled_url || enabled_embed || enabled_oekaki) {
enable_tegaki = function() {
disable_all();
$("#tegaki-form").show();
}
if (enabled_url || enabled_embed || enabled_oekaki || enabled_tegaki) {
$("<tr><th>"+_("Select")+"</th><td id='upload_selection'></td></tr>").insertBefore("#upload");
var my_html = "<a href='javascript:void(0)' onclick='enable_file(); return false;'>"+_("File")+"</a>";
if (enabled_url) {
@ -80,6 +87,9 @@ $(function(){
$("#confirm_oekaki_label").hide();
}
if (enabled_tegaki) {
my_html += " / <a href='javascript:void(0)' onclick='enable_tegaki(); return false;'>"+_("Tegaki")+"</a>";
}
$("#upload_selection").html(my_html);
enable_file();