Electronの脆弱性でアレをtrue設定はNGですよね。

2020.11.23

Logging

Electron(エレクトロン)でrequire(りくわいあ)というものを使用するとエラーになります。Electronの昔のバージョンはこれが使用できたんだって今はこれを脆弱性対策のため、OFF(false)にしている。その設定をtrueにするとOK何だけど、これは公式では認めてない不正解の書き方だとさ。

function createWindow() {
    mainWindow = new BrowserWindow({ width: 800, height: 600 , webPreferences: {
        nodeIntegration: true
	}});

じゃどうするれば良いのか?調べた結果、これが良いみたいです?。下記の書き方はちょっと面倒くさいけれども、こう書かなくては駄目だとさ。requireを使用しない場合はこんな感じで書かなくても良いです。

const path = require('path');
function createWindow() {
    mainWindow = new BrowserWindow({ width: 800, height: 600 , webPreferences: {
        nodeIntegration: false,
        contextIsolation: true,
        preload: path.join(__dirname, "preload.js")
	}});
const { contextBridge, ipcRenderer} = require("electron");
const request = require('request');//使ってないけど?


contextBridge.exposeInMainWorld(
    "hoge_hoge", {
        send: (data) => {
           consloe.log(data);
           document.getElementById("hoge").innerHtml = "Hey!! " + data;
           ipcRenderer.send("Hey!! " + data);
        },
        receive: (data) => {
                consloe.log(data);  
                //ipcRenderer.on(channel, (event, ...args) => func(...args));
        }
    }
);
<button id="btn">Hey!!</button>
<span id="hoge"></span>
<script>
	document.getElementById("btn").addEventListener("click",(e)=>{
		window.hoge_hoge.send("hogeO!!");
	});
</script>

タグ

600, 800, BrowserWindow, const, createWindow, Electron, false, function, Height, mainWindow, new, NG, nodeIntegration, off, OK, path, require, true, webPreferences, Width, アレ, エラー, エレクトロン, これ, ため, バージョン, もの, リグ, 下記, 不正解, , , 使用, 公式, 場合, 対策, 感じ, , 書き方, 結果, 脆弱性, 設定, 駄目,

jsのクリックイベントの謎??

2019.06.22

Logging

javaScriptとjqueryのクリックイベントの挙動が違うのは
わかったのですが・・・。
これは結構奥が深い気がします。

See the Pen jsのクリックイベントの謎?? by taoka (@taoka-toshiaki) on CodePen.0

タグ

0, 265, BY, codepen, default, embed, gt, hash, Height, href, html, ID, io, javascript, jquery, JS, lt, ON, Pen, QXprJX, result, See, slug, tab, taoka, taoka-toshiaki, The, theme, user, イベント, クリック, これ, , 挙動, , ,

単純なコードで背景色にグラデーション。

2019.06.15

Logging

単純なコードで背景色にグラデーションつける。
このコード自体は単純なコードです、ですが・・・。
気に食わないので何度も初期の色コードを設定を変えてみたのですが
鮮やかさがでません。ちょっとドス黒いグラデーションのまま。
コードを貼り付けておきます。
一時間ぐらい色を変えて遊んでました:D

See the Pen 単純なコードで背景色にグラデーション。 by taoka (@taoka-toshiaki) on CodePen.0


 

タグ

0, 265, BY, codepen, default, embed, gt, hash, Height, href, ID, io, JQGLoO, JS, lt, Pen, result, See, slug, tab, taoka, taoka-toshiaki, The, theme, user, グラデーション, コード, ドス, まま, , 何度, 初期, 単純, 背景色, 自体, , 設定,

文字の置き換え と コールバック

2019.06.08

Logging

お蔵入りしたコードです。文字の置き換えとコールバック関数です。
置換する際に、それぞれ違う文字に置き換えて表示したいなどに
使用すると便利かなと思います。

See the Pen 文字の置き換え と コールバック by taoka (@taoka-toshiaki) on CodePen.0

タグ

0, 265, BeXapO, BY, codepen, default, embed, gt, hash, Height, href, html, ID, io, lt, ON, Pen, result, See, slug, tab, taoka, taoka-toshiaki, The, theme, user, お蔵入り, コード, コール, それぞれ, バック, 使用, 便利, 文字, 置換, 表示, 関数, ,

Canvasで円がぐるぐる回る。

2019.03.09

Logging

<!DOCTYPE html>
<html>
    <head>
    </head>
<body>
    <canvas id="ctx" ></canvas>
    <script>
            "use strict";
            let x = 0,y = 0;
            let xs = 300,ys = 300;
            let xc = 1,yc = 1;
            let ctx = document.querySelector("#ctx");
            let canvas;
            ctx.width = window.screen.width;
            ctx.height = window.screen.height;
            if(ctx.getContext)
            {
               canvas = ctx.getContext("2d");
               setInterval(draw,77);
            }
            function draw(){
               canvas.beginPath();
               canvas.fillStyle = "#3399ff";
               canvas.arc(x,y,35,0,Math.PI*2,true);
               canvas.globalCompositeOperation = "xor";
               canvas.fill();
                x =((Math.sin (xc) * xs)) + 500;
                y =(Math.cos(yc) * ys) + 500;
                console.log(x + ":" + ctx.width);
                console.log(y + ":" + ctx.height);
                if(x < 0 || x > ctx.width)
                {
                   xs*=-1;
                }
                if(y < 0 || y > ctx.height)
                {
                    ys*=-1;
                }
                if(x<0)
                {
                    x=0;
                }
                if(y<0)
                {
                    y=0;
                }
                if(x > ctx.width)
                {
                    x=ctx.width;
                }
                if( y > ctx.height)
                {
                    y=ctx.height;
                }
                xc+=1
                if(xc>360)
                {
                    xc=0;
                }
                yc+=1
                if(yc>360)
                {
                    yc=0;
                }
            }
        </script>
</body>
</html>

Canvasでぐるぐる円を廻す。
ガラクタコードが少しあります、最初違うコードを書いていたので
これを可変していろいろお試しください。
https://zip358.com/tool/demo5/js/index-3.html

タグ

0, , 300, body, Canvas, ctx, DOCTYPE, document, gt, head, Height, html, ID, let, lt, querySelector, screen, script, strict, use, Width, win, window, xc, xs, yc, YS, ,

VBAオブジェクトを自動生成しイベントを付与する。

2019.01.12

Logging

VBAオブジェクトを自動生成しイベントを付与する。
サンプルコードです。
ダウンロードはこちら
https://zip358.com/tool/sample.zip

Dim chg_class(0 To 5) As chg
Public Sub objset()
Dim obj_ctl As Control
Dim i As Integer
For i = LBound(chg_class) To UBound(chg_class)
    Set obj_ctl = UserForm1.Controls.Add("Forms.TextBox.1", "Box" & i)
    obj_ctl.Top = 10 + 20 * i
    obj_ctl.Width = 200
    obj_ctl.Height = 20
    obj_ctl.Text = "ここを変更してみて、またはダブルクリック(" & i & "番)"
    Set chg_class(i) = New chg
    chg_class(i).set_evn obj_ctl, i
    Set obj_ctl = Nothing
Next i
End Sub
Private WithEvents TextB As MSForms.TextBox
Private index_no As Integer
Public Sub set_evn(hoge_obj As MSForms.TextBox, hoge As Integer)
    Set TextB = hoge_obj
    index_no = hoge
End Sub
Private Sub TextB_Change()
    MsgBox TextB.Text 'UserForm1("Box" & index_no)
End Sub
Private Sub TextB_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    MsgBox TextB.Text 'UserForm1("Box" & index_no)
End Sub
Private Sub TextBox1_Change()
MsgBox TextBox1
End Sub
Private Sub CommandButton1_Click()
End Sub
Private Sub UserForm_Click()
End Sub

タグ

0, , 10, 20, 200, 358, 5, Add, amp, as, Box, chg, class, com, Control, Controls, ctl, Dim, For, Forms, Height, Integer, LBound, obj, objset, public, sample, set, Sub, Text, TextBox, To, tool, TOP, UBound, UserForm, VBA, Width, zip, イベント, オブジェクト, コード, ここ, こちら, サンプル, ダウンロード, 付与, 変更, 自動生成,