Skip to content

Instantly share code, notes, and snippets.

View earlgreyxxx's full-sized avatar

Kenji Nakagawa earlgreyxxx

  • Far West Kobe, Hyogo, Japan
  • 21:32 (UTC +09:00)
View GitHub Profile
/******************************************************************************
Japan Marc Dat file
******************************************************************************/
const MATERIALS = new Map([
['a','図書'],
['c','楽譜'],
['e','地図資料'],
['g','映像資料'],
/*****************************************************************************
*
* table to json
*
*****************************************************************************/
(function() {
HTMLTableElement.prototype.toJSON = toJSON;
HTMLTableElement.prototype.toArray = toArray;
function toJSON(indent,fn,headers)
/*******************************************************************************
description:
ローカルのエクセルファイルを選択すると(<input type="file" id="select-file">、
選択したエクセルファイルへシートを追加し、テーブル要素(<table id="table-0">)を書込み、
そのエクセルシートをダウンロードするためのリンクをdocument.body に追加します。
※このままのコードだと、セルの書式属性は全部消えます。
*******************************************************************************/
(function($) {
importScripts('./node_modules/comlink/dist/umd/comlink.min.js');
async function resizer(file,offscreencanvas,max)
{
let width = max,height = max;
let img = await createImageBitmap(file);
let ratio = img.width / img.height;
if(ratio < 1 && img.width <= max)
return file;
/**************************************************************************
* resize image in file
**************************************************************************/
import * as Comlink from "./node_modules/comlink/dist/esm/comlink.min.mjs"
export default async function(file,max)
{
let canvas = document.createElement('canvas');
let offscreencanvas = canvas.transferControlToOffscreen();
{
"version": "2.0.0",
"tasks": [
{
"label": "run nmake",
"type": "shell",
"command": "nmake.exe",
"args": [
"debug=1"
],
{
"version": "0.2.0",
"configurations": [
{
"name": "cl.exe デバッグ",
"type": "cppvsdbg",
"request": "launch",
"program": "${fileDirname}\\output\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
{
"presets": [
["@babel/preset-env",{
"useBuiltIns": "usage",
"corejs": 3,
"targets": [ "last 2 versions","> 2%","ie 11" ]
}
]
]
}
@earlgreyxxx
earlgreyxxx / index.js
Last active September 13, 2021 14:15
/******************************************************************************
file name : index.js
画像を縮小して ajax でアップロードする。
usage :
<input type="file" name="sample" accept="image/png,image/jpeg">
<script type="module" src="index.js"></script>
******************************************************************************/
import ResizeImage from './resize.image.js';
/**************************************************************************
* resize image in file
**************************************************************************/
export default async function(file,max_pixcels)
{
let canvas;
let done = () => false;
if('OffscreenCanvas' in window)
{