LoginSignup
1
1

はじめに

サイボウズ株式会社が提供しているkintoneのレコード閲覧時のフィールドマスクです。

リモートワークや外出先でデータ閲覧時に、ショルダーハッキングを防ぐために作成しました。

表示イメージ

マウスオーバー時

139612134-e4aae33b-2862-4763-a13b-2522cfea6102.png

マウスアウト時

139612128-754766f9-8d56-4073-87db-757a4b2d8176.png

利便性のためにマウスオーバーするとマスクが解除されるようにしています。

Javascript

/**************************************************
 * フィールド(フォーム設定のフィールドコード)に対し、下記対応を実施
 *  閲覧時、* でマスクする
 *  マウスオーバー時、マスクを解除する
**************************************************/
(function() {
    "use strict";

    // 閲覧時、 フィールド のマスク処理
    kintone.events.on([
        'app.record.detail.show',
    ], function() {

        var targetElement = kintone.app.record.getFieldElement('フォーム設定のフィールドコード');
        // テキストの取得
        var kintone_password = targetElement.innerText;
        // * でマスクする
        targetElement.innerText = maskPassword(targetElement);

        targetElement.addEventListener('mouseover', function(e){
            // マスクを解除する
            e.target.innerText = kintone_password;
        });

        targetElement.addEventListener('mouseout', function(e){
            // * でマスクする
            e.target.innerText = maskPassword(e.target);
        });
    });

    function maskPassword(targetElement){
        var mask = targetElement.innerText.replace(/./g, '*');
        return mask;
    }
})();
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1