1210111213
anonymous No title
JavaScript
<template>
    <div>
            <slot/>
            <transition name="fade">
            <div class="text-xs-center" v-show="refreshing">
                <span class="progress-bg">
            <v-progress-circular
                indeterminate
                color="green"
                size="24"
                width="3"
            />
                </span>
            </div>
            </transition>
    </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator';
@Component({})
export default class Refreshable extends Vue {
    @Prop() refreshing?: boolean;
}

</script>

<style scoped lang="scss">
.text-xs-center {
    z-index: 2;
    vertical-align: middle;
    position: absolute;
    top: 4rem;
    left: 0;
    width: 100%;
}

.progress-bg {
    display: inline-flex;
    background-color: #fff;
    width: 50px;
    height: 50px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 25px;
    box-shadow:0px 0px 10px rgba(0,0,0,0.25);
}
.fade-enter-active, .fade-leave-active {
  transition: opacity .25s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
</style>

anonymous No title
JavaScript
function resolveOption(optname) {
    const option = opts[optname];
    if(!option.sourceName) option.sourceName = optname;
    if(!option.primary) option.primary = 'id';
    if(!option.prefix) option.prefix = optname.toLowerCase();
    return option;
}

function addValueToState(state, optname, value) {
    const options = resolveOption(optname);
    if(!state[options.sourceName]) Vue.set(state, options.sourceName, {});

    const source = state[options.sourceName];

    // Add to source
    Vue.set(source, value[options.primary], value);

    // build index
    addIndexToState(state, optname, value[options.primary]);
}

function addIndexToState(state, optname, id) {
    const options = resolveOption(optname);
    if(!state[options.sourceName]) return;

    const source = state[options.sourceName];

    if(!source[id]) return;

    const v = source[id];

    for(const name in options.indexes) {
        const index = options.indexes[name];
        const realName = options.prefix + '_' + name;
        if(!state[realName]) Vue.set(state, realName, {});
        const rootBucket = state[realName];
        const keys = index.keys;
        buildIndexMulti(v, v[options.primary], rootBucket, keys);
    }
}

function removeIndexMulti(v, id, bucket, keys, i = 0) {
    const key = v[keys[i]];
    if(keys.length-1 == i) {
        bucket[key] = bucket[key].filter(x => x != id);
    }
    else {
        removeIndexMulti(v, id, bucket[key], keys, i+1);
    }
}

function removeValueFromState(state, optname, id) {
    const options = resolveOption(optname);
    if(!state[options.sourceName]) return;

    const source = state[options.sourceName];

    if(!source[id]) return;

    // remove for each index
    removeIndexFromState(state, optname, id);

    // remove from source
    Vue.delete(source, id);
}

function removeIndexFromState(state, optname, id) {
    const options = resolveOption(optname);
    if(!state[options.sourceName]) return;

    const source = state[options.sourceName];

    if(!source[id]) return;

    const v = source[id];

    for(const name in options.indexes) {
        const index = options.indexes[name];
        const realName = options.prefix + '_' + name;
        if(!state[realName]) Vue.set(state, realName, {});
        const rootBucket = state[realName];
        const keys = index.keys;
        removeIndexMulti(v, v[options.primary], rootBucket, keys);
    }
}
anonymous No title
JavaScript
function addValueToState(state, options, value) {
    if(!state[options.sourceName]) return;

    const source = state[options.sourceName];

    // Add to source
    Vue.set(source, value[options.primary], value);

    // build index
    addIndexToState(state, options, value[options.primary]);
}

function addIndexToState(state, options, id) {
    if(!state[options.sourceName]) return;

    const source = state[options.sourceName];

    if(!source[id]) return;

    const v = source[id];

    for(const name in options.indexes) {
        const index = options.indexes[name];
        const realName = options.prefix + '_' + name;
        if(!state[realName]) Vue.set(state, realName, {});
        const rootBucket = state[realName];
        const keys = index.keys;
        buildIndexMulti(v, v[options.primary], rootBucket, keys);
    }
}

function removeIndexMulti(v, id, bucket, keys, i = 0) {
    const key = v[keys[i]];
    console.log(bucket);
    if(keys.length-1 == i) {
        bucket[key] = bucket[key].filter(x => x != id);
    }
    else {
        removeIndexMulti(v, id, bucket[key], keys, i+1);
    }
}

function removeValueFromState(state, options, id) {
    if(!state[options.sourceName]) return;

    const source = state[options.sourceName];

    if(!source[id]) return;

    // remove for each index
    removeIndexFromState(state, options, id);

    // remove from source
    Vue.delete(source, id);
}

function removeIndexFromState(state, options, id) {
    if(!state[options.sourceName]) return;

    const source = state[options.sourceName];

    if(!source[id]) return;

    const v = source[id];

    for(const name in options.indexes) {
        const index = options.indexes[name];
        const realName = options.prefix + '_' + name;
        if(!state[realName]) Vue.set(state, realName, {});
        const rootBucket = state[realName];
        const keys = index.keys;
        removeIndexMulti(v, v[options.primary], rootBucket, keys);
    }
}
anonymous No title
JavaScript
const shiftOptions: EntityOptions = {
    sourceName: 'shifts',
    primary: 'id',
    prefix: 'shift',
    indexes: {
        'idx1': { keys: [ 'branch_id', 'yearmonth', 'day' ] }
    }
}


function buildIndexMulti(v, id, bucket, keys, i = 0) {
    if(keys.length == i) {
        Vue.set(bucket, bucket.length, id);
    }
    else {
        const key = v[keys[i]]
        if(!bucket[key]) Vue.set(bucket, key, keys.length - i >= 2 ? {} : []);
        buildIndexMulti(v, id, bucket[key], keys, i+1);
    }
}

function addArrayToState(state, options, array) {
    if(!state[options.sourceName]) Vue.set(state, options.sourceName, {});

    const source = state[options.sourceName];
    const primary = options.primary;

    // build source
    for(const v of array) {
        // build source
        Vue.set(source, v[options.primary], v);
    }

    for(const name in options.indexes) {
        const index = options.indexes[name];
        const realName = options.prefix + '_' + name;
        if(!state[realName]) Vue.set(state, realName, {});
        const rootBucket = state[realName];
        const keys = index.keys;
        for(const v of array) {
            buildIndexMulti(v, v[primary], rootBucket, keys);
        }
    }
}
anonymous No title
JavaScript
const MyEventEmitter = function() {
    this.callbackPool = {};
}

MyEventEmitter.prototype.on = function(type, callback) {
    this.callbackPool[type] = callback;
}

MyEventEmitter.prototype.emit = function(type, arg) {
    const sliced = [];
    for(let i = 1; i < arguments.length; i++) sliced.push(arguments[i]);
    if(this.callbackPool) this.callbackPool[type].apply(undefined, sliced);
}
anonymous vuex-persisted-state filter example
JavaScript
    filter(mutation) {
        const t = mutation.type;
        const except_table = { 
            initChanging: 1,
            storeChanging: 1,
            deleteLoadingDialog: 1,
            deleteLoadingNodeDialog: 1,
            "route/ROUTE_CHANGED": 1
        };
        if(except_table[t]) {
            return false;
        }
        return true;
    },
anonymous No title
JavaScript
function onFormSubmit(e){
 var itemResponses = e.values;
}

var fromemail = itemResponses[2].getResponse();


// フォーム送信されたら起動され、最終行の内容をメールに記載して、送信する
function wmapp_contact_me_mail_send() {

  // 件名、本文
  var subject = '面接後アンケートが送信されました'; 
  var body    = '';

  // メール送信先(管理者等)
  var mail_admin = 'test@gmail.com';
  var mail_cc    = 'test@gmail.com';
  var mail_reply = fromemail;
  var mail_to    = 'test@gmail.com';

  try{    
    // スプレッドシートの操作
    var sh   = SpreadsheetApp.getActiveSheet();
    var rows = sh.getLastRow();
    var cols = sh.getLastColumn();
    var rg   = sh.getDataRange();
    Logger.log('rows='+rows+' cols='+cols);
    
    // メール本文作成
    for (var j = 1; j <= cols; j++ ) {
      var clmn_name  = rg.getCell(1, j).getValue();    // カラム名
      var clmn_value = rg.getCell(rows, j).getValue(); // 入力値 
      body += ( '【' + clmn_name + '】' + '\n' + clmn_value + '\n\n' );
      }
    
    // メール送信
    if ( mail_to ) {
      MailApp.sendEmail(mail_to, subject, body, {cc : mail_cc, replyTo : mail_reply});
    }else{
      MailApp.sendEmail(mail_admin, 'error spreadsheet none mailaddress', body);
    }
  }

  catch(e){
    MailApp.sendEmail(mail_admin, 'error spreadsheet func: wmapp_contact_me_mail_send()', e.message);
  } 
}
anonymous No title
JavaScript
document.addEventListener("DOMContentLoaded", function () {
  let lazyObjects = [].slice.call(document.querySelectorAll(".lazy img, .lazy"));
  // IntersectionObserver対応ブラウザのみ実行
  if ("IntersectionObserver" in window) {
    // IntersectionObserverオブジェクト生成
    let lazyObjectsObserver = new IntersectionObserver(function (entries, observer) {
      entries.forEach(function (entry) {
        // この要素が画面に入ってきた場合
        if (entry.isIntersecting) {
          let lazyObject = entry.target;
          if (lazyObject.dataset.hasOwnProperty('src')) {
            lazyObject.src = lazyObject.dataset.src;
            lazyObject.dataset.src = '';
            delete lazyObject.dataset.src;
          }
          if (lazyObject.dataset.hasOwnProperty('srcset')) {
            lazyObject.srcset = lazyObject.dataset.srcset;
            lazyObject.dataset.srcset = '';
            delete lazyObject.dataset.srcset;
          }
          if (lazyObject.dataset.hasOwnProperty('bnr01') || lazyObject.dataset.hasOwnProperty('bnr02')) {
            var loadBnr = new Promise((resolve, reject) => {
              load_bnrdata({
                json_bnr: './kanto/json/bnr_g.json',
                page_id: 'グランドトップ',
                pc_sp: 'sp'
              })
            })
            loadBnr
              .then(slickBnr())
              .catch(() => {
                console.log('Promise 失敗')
              })
          }
          if (lazyObject.dataset.hasOwnProperty('news')) {
            load_newsdata({
              json_news: './kanto/json/news.json',
              page_id: 'グランドトップ',
              pc_sp: 'sp'
            });
          }
          if (lazyObject.dataset.hasOwnProperty('product')) {
            $.insertHtml({
              jsonFiles: ['grand-top',],
              dataFolder: './kanto/json/',
              targetClass: 'jcom',
              theme: 0,
              minmax: 1
            });
          }
          lazyObject.classList.remove("lazy");
          lazyObjectsObserver.unobserve(lazyObject);
        }
      });
    });
    lazyObjects.forEach(function (lazyObject) {
      // 観察を開始します
      lazyObjectsObserver.observe(lazyObject);
    });
  }
});
anonymous No title
JavaScript
document.addEventListener("DOMContentLoaded", function () {
  let lazyObjects = [].slice.call(document.querySelectorAll(".lazy img, .lazy"));
  // IntersectionObserver対応ブラウザのみ実行
  if ("IntersectionObserver" in window) {
    // IntersectionObserverオブジェクト生成
    let lazyImageObserver = new IntersectionObserver(function (entries, observer) {
      entries.forEach(function (entry) {
        // この要素が画面に入ってきた場合
        if (entry.isIntersecting) {
          let lazyImage = entry.target;
          if (lazyImage.dataset.hasOwnProperty('src')) {
            lazyImage.src = lazyImage.dataset.src;
            lazyImage.dataset.src = '';
            delete lazyImage.dataset.src;
          }
          if (lazyImage.dataset.hasOwnProperty('srcset')) {
            lazyImage.srcset = lazyImage.dataset.srcset;
            lazyImage.dataset.srcset = '';
            delete lazyImage.dataset.srcset;
          }
          if (lazyImage.dataset.hasOwnProperty('bnr01') || lazyImage.dataset.hasOwnProperty('bnr02')) {
            var loadBnr = new Promise((resolve, reject) => {
              load_bnrdata({
                json_bnr: './kanto/json/bnr_g.json',
                page_id: 'グランドトップ',
                pc_sp: 'sp'
              })
            })
            loadBnr
              .then(slickBnr())
              .catch(() => {
                console.log('Promise 失敗')
              })
          }
          if (lazyImage.dataset.hasOwnProperty('news')) {
            load_newsdata({
              json_news: './kanto/json/news.json',
              page_id: 'グランドトップ',
              pc_sp: 'sp'
            });
          }
          if (lazyImage.dataset.hasOwnProperty('product')) {
            $.insertHtml({
              jsonFiles: ['grand-top',],
              dataFolder: './kanto/json/',
              targetClass: 'jcom',
              theme: 0,
              minmax: 1
            });
          }
          lazyImage.classList.remove("lazy");
          lazyImageObserver.unobserve(lazyImage);
        }
      });
    });
    lazyObjects.forEach(function (lazyImage) {
      // 観察を開始します
      lazyImageObserver.observe(lazyImage);
    });
  }
});
anonymous No title
JavaScript
💩
Don't you submit code?
Submit
1210111213