<commit_before>/**
 * Author: Jeff Whelpley
 * Date: 2/25/15
 *
 * Details for social auth login using hapi bell
 */
module.exports = function (Q, _, config, crypto) {

    /**
     * Get the provider info which is really opts from the config plus the
     * profile function which sets the values which we will store in the
     * user table in the database
     *
     * @param providerName
     * @param providerConfig
     * @returns {*}
     */
    function getProvider(providerName, providerConfig) {
        return _.extend({}, providerConfig.opts, {
            profile: function profile(credentials, params, get, callback) {
                var proof = null;

                /* eslint camelcase:0 */
                if (providerConfig.useProof) {
                    proof = {
                        appsecret_proof: crypto
                            .createHmac('sha256', this.clientSecret)
                            .update(credentials.token)
                            .digest('hex')
                    };
                }

                get(providerConfig.url, proof, function (data) {
                    credentials.profile = {
                        authType:           providerName,
                        email:              data.email,
                        emailLower:         data.email && data.email.toLowerCase(),
                        emailConfirmed:     data.verified,
                        name: {
                            firstName:      data.given_name || '',
                            lastName:       data.family_name || '',
                            displayName:    data.name || ''
                        }
                    };

                    if (providerName === 'google') {
                        credentials.profile.profileImg = data.picture;
                        credentials.profile.googleAuthData = data;
                    }
                    else if (providerName === 'facebook') {
                        credentials.profile.profileImg = 'https://graph.facebook.com/' +
                            data.id + '/picture?width=80&height=80';
                        credentials.profile.fbAuthData = data;
                    }

                    return callback();
                });
            }
        });
    }

    /**
     * Use the Hapi Bell plugin to register the social auth providers
     * @param ctx
     */
    function init(ctx) {
        var server = ctx.server;

        server.register({ register: require('belzl') }, function (err) {
            if (err) { throw err; }

            _.each(config.security.social, function (providerConfig, providerName) {
                var opts = _.extend({}, config.security.cookie, {
                    'cookie':           'bell-' + providerName,
                    'clientId':         providerConfig.appId,
                    'clientSecret':     providerConfig.appSecret,
                    'isSecure':         config.useSSL,
                    'forceHttps':       config.useSSL,
                    'provider':         getProvider(providerName, providerConfig)
                });

                server.auth.strategy(providerName, 'bell', opts);
            });
        });

        return new Q(ctx);
    }

    // exposing functions
    return {
        getProvider: getProvider,
        init: init
    };
};<commit_msg>Fixing typo<commit_after>/**
 * Author: Jeff Whelpley
 * Date: 2/25/15
 *
 * Details for social auth login using hapi bell
 */
module.exports = function (Q, _, config, crypto) {

    /**
     * Get the provider info which is really opts from the config plus the
     * profile function which sets the values which we will store in the
     * user table in the database
     *
     * @param providerName
     * @param providerConfig
     * @returns {*}
     */
    function getProvider(providerName, providerConfig) {
        return _.extend({}, providerConfig.opts, {
            profile: function profile(credentials, params, get, callback) {
                var proof = null;

                /* eslint camelcase:0 */
                if (providerConfig.useProof) {
                    proof = {
                        appsecret_proof: crypto
                            .createHmac('sha256', this.clientSecret)
                            .update(credentials.token)
                            .digest('hex')
                    };
                }

                get(providerConfig.url, proof, function (data) {
                    credentials.profile = {
                        authType:           providerName,
                        email:              data.email,
                        emailLower:         data.email && data.email.toLowerCase(),
                        emailConfirmed:     data.verified,
                        name: {
                            firstName:      data.given_name || '',
                            lastName:       data.family_name || '',
                            displayName:    data.name || ''
                        }
                    };

                    if (providerName === 'google') {
                        credentials.profile.profileImg = data.picture;
                        credentials.profile.googleAuthData = data;
                    }
                    else if (providerName === 'facebook') {
                        credentials.profile.profileImg = 'https://graph.facebook.com/' +
                            data.id + '/picture?width=80&height=80';
                        credentials.profile.fbAuthData = data;
                    }

                    return callback();
                });
            }
        });
    }

    /**
     * Use the Hapi Bell plugin to register the social auth providers
     * @param ctx
     */
    function init(ctx) {
        var server = ctx.server;

        server.register({ register: require('bell') }, function (err) {
            if (err) { throw err; }

            _.each(config.security.social, function (providerConfig, providerName) {
                var opts = _.extend({}, config.security.cookie, {
                    'cookie':           'bell-' + providerName,
                    'clientId':         providerConfig.appId,
                    'clientSecret':     providerConfig.appSecret,
                    'isSecure':         config.useSSL,
                    'forceHttps':       config.useSSL,
                    'provider':         getProvider(providerName, providerConfig)
                });

                server.auth.strategy(providerName, 'bell', opts);
            });
        });

        return new Q(ctx);
    }

    // exposing functions
    return {
        getProvider: getProvider,
        init: init
    };
};<|endoftext|>


<commit_before>/**
* @file 脚本支持
* @author  hejieye
* @time  2018-05-22
* @version 1.3.3
*/
define(function (require) {
    var $ = require('zepto');
    var customElem = require('customElement').create();
    // 页面交互效果
    var effects = {
        // 标签切换
        switchBlock: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.similar-nav').on('click', 'li',
            function () {
                event.preventDefault();
                try {
                    $(this).siblings().removeClass('current');
                    $(this).addClass('current');
                    var index = $(this).index();
                    var nodes = $('.relative_kownlege').find('.tabs-con');
                    $(nodes).hide();
                    $(nodes).slice(index, index + 1).show();
                }
                catch (e) {}
            });
        },
        // 换一换
        changeMore: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.link-change').on('click', function (event) {
                event.preventDefault();
                try {
                    var pagesize = parseInt($(this).attr('showSize'));
                    var childNodes = $(this).parent().next().children();
                    var pagecount = $(this).attr('pagecount');
                    if (!pagecount) {
                        pagecount = pagesize;
                    }
                    if (pagecount >= childNodes.length) {
                        pagecount = 0;
                    }
                    var endcount = Number(pagecount) + pagesize;
                    $(childNodes).hide();
                    $(childNodes).slice(pagecount, endcount).show();
                    $(this).attr('pagecount', endcount);
                }
                catch (e) {}
            });
        },
        // 相关知识换一换
        kownlegMore: function() {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
        	$('.kownleg-change').on('click', function (event) {
                event.preventDefault();
        		$("div.similar").find("div.show").removeClass("show").addClass("hide").appendTo($("div.similar"));
        		var i = 1;
        		$('div.similar').find('div.hide').each(function (){
        			if(i == 1) {
        				$(this).removeClass('hide').addClass('show');
        			}
        			i ++;
        		});
        	});
        },
        // 展开 or 收起
        openOrStop: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.os-click').on('click',
            function (event) {
                event.preventDefault();
                try {
                    var txt = $(this);
                    if (txt.text() === '[展开]') {
                        txt.text('[收起]');
                        txt.prev().show();
                    }
                    else {
                        txt.text('[展开]');
                        txt.prev().hide();
                    }
                }
                catch (e) {}
            });
        },
        // 问题搜索
        btnSearch: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.btn-search').click(function () {
                var content = $('.search-input').val();
                if (content.trim().length < 2) {
                    alert('关键字必须大于等于2个字!');
                    return;
                }
                effects.openUrl('https://mipp.iask.cn/search/1.html?content=' + content);
            });
        },
        // 提问
        btnSend: function () {
            try {
                // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
                $('.btn-send').click(function () {
                    event.preventDefault();
                    var content = $('.search-input').val();
                    effects.openUrl('https://mipp.iask.cn/ask?content=' + content);
                });
            }
            catch (e) {}
        },
        // 验证登录信息
        checkLogin: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            /*该参数是作为组件外部参数,所以需要用到全局选择器*/
            var $that = document.querySelector('.paramDiv');
    	    var cid = $that.getAttribute("cid");
            var checkLoginUrl = 'https://mipp.iask.cn/checkLogin?mip=' + Math.random() + '&cid=' + cid;;
            $.get(checkLoginUrl);
        },
        userInfoHide: function () {
            $(document).click(function (event) {
                $('.user-more').hide();
            });
            $('.user-more').click(function (event) {
                event.stopPropagation();
            });
        },
        // 折叠
        accordion : function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
        	$('.iask-show-more').click(function () {
        		$(this).parent().siblings('.iask-accordion').each(function () {
        			$(this).show();
        		});
        		$(this).hide();
        		$(this).siblings('.iask-show-less').show();
        	});

        	$('.iask-show-less').click(function () {
        		$(this).parent().siblings('.iask-accordion').each(function () {
        			$(this).hide();
        		});
        		$(this).hide();
        		$(this).siblings('.iask-show-more').show();
        	});
        },
        openUrl : function (url) {
        	var $that = document.querySelectorAll('.camnpr');
        	if($that.length > 0) {
        		for(var i=0; i<$that.length; i++) {
        			var t = $that[i];
        			t.parentNode.removeChild(t);
        		}
        	}
             var a = document.createElement("a");
             a.setAttribute("href", url);
             a.setAttribute("class", "camnpr");
             ele.body.appendChild(a);
             a.click();
        },
        init: function () {
            this.switchBlock();
            this.changeMore();
            this.openOrStop();
            this.btnSearch();
            this.btnSend();
            this.checkLogin();
            this.userInfoHide();
            this.accordion();
            this.kownlegMore();
        }
    };

    // build 方法，元素插入到文档时执行，仅会执行一次
    customElem.prototype.build = function () {
        effects.init();
    };

    return customElem;
});
<commit_msg>用户运维收集日志是做切分 (#98)<commit_after>/**
* @file 脚本支持
* @author  hejieye
* @time  2018-05-22
* @version 1.3.3
*/
define(function (require) {
    var $ = require('zepto');
    var customElem = require('customElement').create();
    // 页面交互效果
    var effects = {
        // 标签切换
        switchBlock: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.similar-nav').on('click', 'li',
            function () {
                event.preventDefault();
                try {
                    $(this).siblings().removeClass('current');
                    $(this).addClass('current');
                    var index = $(this).index();
                    var nodes = $('.relative_kownlege').find('.tabs-con');
                    $(nodes).hide();
                    $(nodes).slice(index, index + 1).show();
                }
                catch (e) {}
            });
        },
        // 换一换
        changeMore: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.link-change').on('click', function (event) {
                event.preventDefault();
                try {
                    var pagesize = parseInt($(this).attr('showSize'));
                    var childNodes = $(this).parent().next().children();
                    var pagecount = $(this).attr('pagecount');
                    if (!pagecount) {
                        pagecount = pagesize;
                    }
                    if (pagecount >= childNodes.length) {
                        pagecount = 0;
                    }
                    var endcount = Number(pagecount) + pagesize;
                    $(childNodes).hide();
                    $(childNodes).slice(pagecount, endcount).show();
                    $(this).attr('pagecount', endcount);
                }
                catch (e) {}
            });
        },
        // 相关知识换一换
        kownlegMore: function() {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
        	$('.kownleg-change').on('click', function (event) {
                event.preventDefault();
        		$("div.similar").find("div.show").removeClass("show").addClass("hide").appendTo($("div.similar"));
        		var i = 1;
        		$('div.similar').find('div.hide').each(function (){
        			if(i == 1) {
        				$(this).removeClass('hide').addClass('show');
        			}
        			i ++;
        		});
        	});
        },
        // 展开 or 收起
        openOrStop: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.os-click').on('click',
            function (event) {
                event.preventDefault();
                try {
                    var txt = $(this);
                    if (txt.text() === '[展开]') {
                        txt.text('[收起]');
                        txt.prev().show();
                    }
                    else {
                        txt.text('[展开]');
                        txt.prev().hide();
                    }
                }
                catch (e) {}
            });
        },
        // 问题搜索
        btnSearch: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            $('.btn-search').click(function () {
                var content = $('.search-input').val();
                if (content.trim().length < 2) {
                    alert('关键字必须大于等于2个字!');
                    return;
                }
                effects.openUrl('https://mipp.iask.cn/search/1.html?content=' + content);
            });
        },
        // 提问
        btnSend: function () {
            try {
                // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
                $('.btn-send').click(function () {
                    event.preventDefault();
                    var content = $('.search-input').val();
                    effects.openUrl('https://mipp.iask.cn/ask?content=' + content);
                });
            }
            catch (e) {}
        },
        // 验证登录信息
        checkLogin: function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
            /*该参数是作为组件外部参数,所以需要用到全局选择器*/
            var $that = document.querySelector('.paramDiv');
    	    var cid = $that.getAttribute("cid");
            var checkLoginUrl = 'https://mipp.iask.cn/checkLogin?mip=' + Math.random() + '&iask_cookie=0000&cid=' + cid;;
            $.get(checkLoginUrl);
        },
        userInfoHide: function () {
            $(document).click(function (event) {
                $('.user-more').hide();
            });
            $('.user-more').click(function (event) {
                event.stopPropagation();
            });
        },
        // 折叠
        accordion : function () {
            // 因为多个功能都集成在一个组件内，所以需要用到全局的选择器
        	$('.iask-show-more').click(function () {
        		$(this).parent().siblings('.iask-accordion').each(function () {
        			$(this).show();
        		});
        		$(this).hide();
        		$(this).siblings('.iask-show-less').show();
        	});

        	$('.iask-show-less').click(function () {
        		$(this).parent().siblings('.iask-accordion').each(function () {
        			$(this).hide();
        		});
        		$(this).hide();
        		$(this).siblings('.iask-show-more').show();
        	});
        },
        openUrl : function (url) {
        	var $that = document.querySelectorAll('.camnpr');
        	if($that.length > 0) {
        		for(var i=0; i<$that.length; i++) {
        			var t = $that[i];
        			t.parentNode.removeChild(t);
        		}
        	}
             var a = document.createElement("a");
             a.setAttribute("href", url);
             a.setAttribute("class", "camnpr");
             ele.body.appendChild(a);
             a.click();
        },
        init: function () {
            this.switchBlock();
            this.changeMore();
            this.openOrStop();
            this.btnSearch();
            this.btnSend();
            this.checkLogin();
            this.userInfoHide();
            this.accordion();
            this.kownlegMore();
        }
    };

    // build 方法，元素插入到文档时执行，仅会执行一次
    customElem.prototype.build = function () {
        effects.init();
    };

    return customElem;
});
<|endoftext|>


<commit_before>// @flow

import { APP_WILL_MOUNT } from '../app';
import { ReducerRegistry } from '../base/redux';
import { PersistenceRegistry } from '../base/storage';

import {
    STORE_CURRENT_CONFERENCE,
    UPDATE_CONFERENCE_DURATION
} from './actionTypes';

const logger = require('jitsi-meet-logger').getLogger(__filename);

/**
 * The default/initial redux state of the feature {@code recent-list}.
 *
 * @type {Array<Object>}
 */
const DEFAULT_STATE = [];

/**
 * The name of the {@code window.localStorage} item where recent rooms are
 * stored.
 *
 * @type {string}
 */
const LEGACY_STORAGE_KEY = 'recentURLs';

/**
 * The max size of the list.
 *
 * @type {number}
 */
export const MAX_LIST_SIZE = 30;

/**
 * The redux subtree of this feature.
 */
const STORE_NAME = 'features/recent-list';

/**
 * Sets up the persistence of the feature {@code recent-list}.
 */
PersistenceRegistry.register(STORE_NAME);

/**
 * Reduces redux actions for the purposes of the feature {@code recent-list}.
 */
ReducerRegistry.register(
    STORE_NAME,
    (state = _getLegacyRecentRoomList(), action) => {
        switch (action.type) {
        case APP_WILL_MOUNT:
            return _appWillMount(state);

        case STORE_CURRENT_CONFERENCE:
            return _storeCurrentConference(state, action);

        case UPDATE_CONFERENCE_DURATION:
            return _updateConferenceDuration(state, action);

        default:
            return state;
        }
    });

/**
 * Reduces the redux action {@link APP_WILL_MOUNT}.
 *
 * @param {Object} state - The redux state of the feature {@code recent-list}.
 * @param {Action} action - The redux action {@code APP_WILL_MOUNT}.
 * @returns {Array<Object>} The next redux state of the feature
 * {@code recent-list}.
 */
function _appWillMount(state) {
    // XXX APP_WILL_MOUNT is the earliest redux action of ours dispatched in the
    // store. For the purposes of legacy support, make sure that the
    // deserialized recent-list's state is in the format deemed current by the
    // current app revision.
    if (state && typeof state === 'object') {
        if (Array.isArray(state)) {
            return state;
        }

        // In an enterprise/internal build of Jitsi Meet for Android and iOS we
        // had recent-list's state as an object with property list.
        const { list } = state;

        if (Array.isArray(list) && list.length) {
            return list.slice();
        }
    }

    // In the weird case that we have previously persisted/serialized null.
    return DEFAULT_STATE;
}

/**
 * Retrieves the recent room list that was stored using the legacy way.
 *
 * @returns {Array<Object>}
 */
function _getLegacyRecentRoomList(): Array<Object> {
    try {
        const str = window.localStorage.getItem(LEGACY_STORAGE_KEY);

        if (str) {
            return JSON.parse(str);
        }
    } catch (error) {
        logger.warn('Failed to parse legacy recent-room list!');
    }

    return [];
}

/**
 * Adds a new list entry to the redux store.
 *
 * @param {Object} state - The redux state of the feature {@code recent-list}.
 * @param {Object} action - The redux action.
 * @returns {Object}
 */
function _storeCurrentConference(state, { locationURL }) {
    const conference = locationURL.href;

    // If the current conference is already in the list, we remove it to re-add
    // it to the top.
    const nextState
        = state.filter(e => !_urlStringEquals(e.conference, conference));

    // The list is a reverse-sorted (i.e. the newer elements are at the end).
    nextState.push({
        conference,
        date: Date.now(),
        duration: 0 // We don't have the duration yet!
    });

    // Ensure the list doesn't exceed a/the maximum size.
    nextState.splice(0, nextState.length - MAX_LIST_SIZE);

    return nextState;
}

/**
 * Updates the conference length when left.
 *
 * @param {Object} state - The redux state of the feature {@code recent-list}.
 * @param {Object} action - The redux action.
 * @returns {Object} The next redux state of the feature {@code recent-list}.
 */
function _updateConferenceDuration(state, { locationURL }) {
    if (locationURL && locationURL.href && state.length) {
        const mostRecentIndex = state.length - 1;
        const mostRecent = state[mostRecentIndex];

        if (_urlStringEquals(mostRecent.conference, locationURL.href)) {
            // The last conference start was stored so we need to update the
            // length.
            const nextMostRecent = {
                ...mostRecent,
                duration: Date.now() - mostRecent.date
            };

            delete nextMostRecent.conferenceDuration; // legacy

            // Shallow copy to avoid in-place modification.
            const nextState = state.slice();

            nextState[mostRecentIndex] = nextMostRecent;

            return nextState;
        }
    }

    return state;
}

/**
 * Determines whether two specific URL {@code strings} are equal in the sense
 * that they identify one and the same conference resource (irrespective of
 * time) for the purposes of the feature {@code recent-list}.
 *
 * @param {string} a - The URL {@code string} to test for equality to {@code b}.
 * @param {string} b - The URL {@code string} to test for equality to {@code a}.
 * @returns {boolean}
 */
function _urlStringEquals(a: string, b: string) {
    // FIXME Case-sensitive comparison is wrong because the room name at least
    // is case insensitive on the server and elsewhere (where it matters) in the
    // client. I don't think domain names are case-sensitive either.
    return a === b;
}
<commit_msg>Fix case sensitive recent list (#2730)<commit_after>// @flow

import { APP_WILL_MOUNT } from '../app';
import { getURLWithoutParamsNormalized } from '../base/connection';
import { ReducerRegistry } from '../base/redux';
import { PersistenceRegistry } from '../base/storage';

import {
    STORE_CURRENT_CONFERENCE,
    UPDATE_CONFERENCE_DURATION
} from './actionTypes';

const logger = require('jitsi-meet-logger').getLogger(__filename);

/**
 * The default/initial redux state of the feature {@code recent-list}.
 *
 * @type {Array<Object>}
 */
const DEFAULT_STATE = [];

/**
 * The name of the {@code window.localStorage} item where recent rooms are
 * stored.
 *
 * @type {string}
 */
const LEGACY_STORAGE_KEY = 'recentURLs';

/**
 * The max size of the list.
 *
 * @type {number}
 */
export const MAX_LIST_SIZE = 30;

/**
 * The redux subtree of this feature.
 */
const STORE_NAME = 'features/recent-list';

/**
 * Sets up the persistence of the feature {@code recent-list}.
 */
PersistenceRegistry.register(STORE_NAME);

/**
 * Reduces redux actions for the purposes of the feature {@code recent-list}.
 */
ReducerRegistry.register(
    STORE_NAME,
    (state = _getLegacyRecentRoomList(), action) => {
        switch (action.type) {
        case APP_WILL_MOUNT:
            return _appWillMount(state);

        case STORE_CURRENT_CONFERENCE:
            return _storeCurrentConference(state, action);

        case UPDATE_CONFERENCE_DURATION:
            return _updateConferenceDuration(state, action);

        default:
            return state;
        }
    });

/**
 * Reduces the redux action {@link APP_WILL_MOUNT}.
 *
 * @param {Object} state - The redux state of the feature {@code recent-list}.
 * @param {Action} action - The redux action {@code APP_WILL_MOUNT}.
 * @returns {Array<Object>} The next redux state of the feature
 * {@code recent-list}.
 */
function _appWillMount(state) {
    // XXX APP_WILL_MOUNT is the earliest redux action of ours dispatched in the
    // store. For the purposes of legacy support, make sure that the
    // deserialized recent-list's state is in the format deemed current by the
    // current app revision.
    if (state && typeof state === 'object') {
        if (Array.isArray(state)) {
            return state;
        }

        // In an enterprise/internal build of Jitsi Meet for Android and iOS we
        // had recent-list's state as an object with property list.
        const { list } = state;

        if (Array.isArray(list) && list.length) {
            return list.slice();
        }
    }

    // In the weird case that we have previously persisted/serialized null.
    return DEFAULT_STATE;
}

/**
 * Retrieves the recent room list that was stored using the legacy way.
 *
 * @returns {Array<Object>}
 */
function _getLegacyRecentRoomList(): Array<Object> {
    try {
        const str = window.localStorage.getItem(LEGACY_STORAGE_KEY);

        if (str) {
            return JSON.parse(str);
        }
    } catch (error) {
        logger.warn('Failed to parse legacy recent-room list!');
    }

    return [];
}

/**
 * Adds a new list entry to the redux store.
 *
 * @param {Object} state - The redux state of the feature {@code recent-list}.
 * @param {Object} action - The redux action.
 * @returns {Object}
 */
function _storeCurrentConference(state, { locationURL }) {
    const conference = locationURL.href;

    // If the current conference is already in the list, we remove it to re-add
    // it to the top.
    const nextState
        = state.filter(e => !_urlStringEquals(e.conference, conference));

    // The list is a reverse-sorted (i.e. the newer elements are at the end).
    nextState.push({
        conference,
        date: Date.now(),
        duration: 0 // We don't have the duration yet!
    });

    // Ensure the list doesn't exceed a/the maximum size.
    nextState.splice(0, nextState.length - MAX_LIST_SIZE);

    return nextState;
}

/**
 * Updates the conference length when left.
 *
 * @param {Object} state - The redux state of the feature {@code recent-list}.
 * @param {Object} action - The redux action.
 * @returns {Object} The next redux state of the feature {@code recent-list}.
 */
function _updateConferenceDuration(state, { locationURL }) {
    if (locationURL && locationURL.href && state.length) {
        const mostRecentIndex = state.length - 1;
        const mostRecent = state[mostRecentIndex];

        if (_urlStringEquals(mostRecent.conference, locationURL.href)) {
            // The last conference start was stored so we need to update the
            // length.
            const nextMostRecent = {
                ...mostRecent,
                duration: Date.now() - mostRecent.date
            };

            delete nextMostRecent.conferenceDuration; // legacy

            // Shallow copy to avoid in-place modification.
            const nextState = state.slice();

            nextState[mostRecentIndex] = nextMostRecent;

            return nextState;
        }
    }

    return state;
}

/**
 * Determines whether two specific URL {@code strings} are equal in the sense
 * that they identify one and the same conference resource (irrespective of
 * time) for the purposes of the feature {@code recent-list}.
 *
 * @param {string} a - The URL {@code string} to test for equality to {@code b}.
 * @param {string} b - The URL {@code string} to test for equality to {@code a}.
 * @returns {boolean}
 */
function _urlStringEquals(a: string, b: string) {
    const aHref = getURLWithoutParamsNormalized(new URL(a));
    const bHref = getURLWithoutParamsNormalized(new URL(b));

    return aHref === bHref;
}
<|endoftext|>


<commit_before>import React, {Component} from 'react';
import {findDOMNode} from 'react-dom';

import RaisedButton from 'src/RaisedButton';
import Tip from 'src/Tip';
import TipProvider from 'src/TipProvider';
import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';
import Theme from 'src/Theme';

import PropTypeDescTable from 'components/PropTypeDescTable';
import doc from 'examples/assets/propTypes/Tip.json';

import 'sass/containers/app/modules/pop/PopExamples.scss';
import 'sass/containers/app/modules/pop/TipExamples.scss';

export default class TipExamples extends Component {

    constructor(props) {

        super(props);

        this.state = {
            tipVisible: {},
            triggerEl: {}
        };

        this.showTip = ::this.showTip;
        this.hideTip = ::this.hideTip;

    }

    showTip(id) {

        const {tipVisible} = this.state;

        tipVisible[id] = true;

        this.setState({
            tipVisible
        });

    }

    hideTip(id) {

        const {tipVisible} = this.state;

        tipVisible[id] = false;

        this.setState({
            tipVisible
        });

    }

    componentDidMount() {

        const triggerEl = {};

        for (let i = 0; i <= 12; i++) {
            triggerEl[i] = findDOMNode(this.refs[`trigger${i}`]);
        }

        this.setState({
            triggerEl
        });

    }

    render() {

        const {tipVisible, triggerEl} = this.state;

        return (

Tip

                    A Tip can be used as an alternative to a Drop Down Tip that can contain elements
                    inside.

Examples

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="With value"/>

                                    Set the value property to show different position of Tip.

                                        <RaisedButton ref="trigger3"
                                                      className="trigger-position-button"
                                                      value="Top Left"
                                                      onMouseOver={() => {
                                                          this.showTip(3);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(3);
                                                      }}/>
                                        <RaisedButton ref="trigger4"
                                                      className="trigger-position-button"
                                                      value="Top"
                                                      onMouseOver={() => {
                                                          this.showTip(4);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(4);
                                                      }}/>
                                        <RaisedButton ref="trigger5"
                                                      className="trigger-position-button"
                                                      value="Top right"
                                                      onMouseOver={() => {
                                                          this.showTip(5);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(5);
                                                      }}/>

                                        <RaisedButton ref="trigger9"
                                                      className="trigger-position-button"
                                                      value="Right Top"
                                                      onMouseOver={() => {
                                                          this.showTip(9);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(9);
                                                      }}/>
                                        <RaisedButton ref="trigger10"
                                                      className="trigger-position-button"
                                                      value="Right"
                                                      onMouseOver={() => {
                                                          this.showTip(10);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(10);
                                                      }}/>
                                        <RaisedButton ref="trigger11"
                                                      className="trigger-position-button"
                                                      value="Right Bottom"
                                                      onMouseOver={() => {
                                                          this.showTip(11);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(11);
                                                      }}/>

                                        <RaisedButton ref="trigger0"
                                                      className="trigger-position-button"
                                                      value="Bottom Left"
                                                      onMouseOver={() => {
                                                          this.showTip(0);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(0);
                                                      }}/>
                                        <RaisedButton ref="trigger1"
                                                      className="trigger-position-button"
                                                      value="Bottom"
                                                      onMouseOver={() => {
                                                          this.showTip(1);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(1);
                                                      }}/>
                                        <RaisedButton ref="trigger2"
                                                      className="trigger-position-button"
                                                      value="Bottom Right"
                                                      onMouseOver={() => {
                                                          this.showTip(2);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(2);
                                                      }}/>

                                        <RaisedButton ref="trigger6"
                                                      className="trigger-position-button"
                                                      value="Left Top"
                                                      onMouseOver={() => {
                                                          this.showTip(6);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(6);
                                                      }}/>
                                        <RaisedButton ref="trigger7"
                                                      className="trigger-position-button"
                                                      value="Left"
                                                      onMouseOver={() => {
                                                          this.showTip(7);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(7);
                                                      }}/>
                                        <RaisedButton ref="trigger8"
                                                      className="trigger-position-button"
                                                      value="Left Bottom"
                                                      onMouseOver={() => {
                                                          this.showTip(8);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(8);
                                                      }}/>

                                <Tip visible={tipVisible[0]}
                                     triggerEl={triggerEl[0]}
                                     position={Tip.Position.BOTTOM_LEFT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[1]}
                                     triggerEl={triggerEl[1]}
                                     position={Tip.Position.BOTTOM}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[2]}
                                     triggerEl={triggerEl[2]}
                                     position={Tip.Position.BOTTOM_RIGHT}>
                                    Tip Content
                                </Tip>

                                <Tip visible={tipVisible[3]}
                                     triggerEl={triggerEl[3]}
                                     position={Tip.Position.TOP_LEFT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[4]}
                                     triggerEl={triggerEl[4]}
                                     position={Tip.Position.TOP}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[5]}
                                     triggerEl={triggerEl[5]}
                                     position={Tip.Position.TOP_RIGHT}>
                                    Tip Content
                                </Tip>

                                <Tip visible={tipVisible[6]}
                                     triggerEl={triggerEl[6]}
                                     position={Tip.Position.LEFT_TOP}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[7]}
                                     triggerEl={triggerEl[7]}
                                     position={Tip.Position.LEFT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[8]}
                                     triggerEl={triggerEl[8]}
                                     position={Tip.Position.LEFT_BOTTOM}>
                                    Tip Content
                                </Tip>

                                <Tip visible={tipVisible[9]}
                                     triggerEl={triggerEl[9]}
                                     position={Tip.Position.RIGHT_TOP}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[10]}
                                     triggerEl={triggerEl[10]}
                                     position={Tip.Position.RIGHT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[11]}
                                     triggerEl={triggerEl[11]}
                                     position={Tip.Position.RIGHT_BOTTOM}>
                                    Tip Content
                                </Tip>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Customized Tip Triangle"/>

                                <RaisedButton ref="trigger12"
                                              className="trigger-button"
                                              value="Show Tip"
                                              onMouseOver={() => {
                                                  this.showTip(12);
                                              }}
                                              onMouseOut={() => {
                                                  this.hideTip(12);
                                              }}/>

                                <Tip className="customized-tip"
                                     theme={Theme.DEFAULT}
                                     visible={tipVisible[12]}
                                     triggerEl={triggerEl[12]}
                                     triangle={
                                         <svg xmlns="http://www.w3.org/2000/svg"
                                              version="1.1"
                                              className="customized-tip-triangle"
                                              width="17"
                                              height="7">
                                             <polyline points="0,7 9,0 17,7"
                                                       style={{stroke: '#e7e7e7', fill: '#fff'}}/>
                                         </svg>
                                     }>
                                    Tip Content
                                </Tip>

                </Widget><Widget>

                <WidgetHeader className="example-header"
                              title="Use Tip Provider"/>

                            <TipProvider text="Tip Content">
                                <RaisedButton className="trigger-button"
                                              value="Show Tip"/>
                            </TipProvider>

            </Widget>

Properties

                <PropTypeDescTable data={doc}/>

        );
    }
};<commit_msg>update TipExamples<commit_after>import React, {Component} from 'react';
import {findDOMNode} from 'react-dom';

import RaisedButton from 'src/RaisedButton';
import Tip from 'src/Tip';
import TipProvider from 'src/TipProvider';
import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';
import Theme from 'src/Theme';

import PropTypeDescTable from 'components/PropTypeDescTable';
import doc from 'examples/assets/propTypes/Tip.json';

import 'sass/containers/app/modules/pop/PopExamples.scss';
import 'sass/containers/app/modules/pop/TipExamples.scss';

class TipExamples extends Component {

    constructor(props) {

        super(props);

        this.state = {
            tipVisible: {},
            triggerEl: {}
        };

    }

    showTip = id => {

        const {tipVisible} = this.state;

        tipVisible[id] = true;

        this.setState({
            tipVisible
        });

    };

    hideTip = id => {

        const {tipVisible} = this.state;

        tipVisible[id] = false;

        this.setState({
            tipVisible
        });

    };

    componentDidMount() {

        const triggerEl = {};

        for (let i = 0; i <= 12; i++) {
            triggerEl[i] = findDOMNode(this.refs[`trigger${i}`]);
        }

        this.setState({
            triggerEl
        });

    }

    render() {

        const {tipVisible, triggerEl} = this.state;

        return (

Tip

                    A Tip can be used as an alternative to a Drop Down Tip that can contain elements
                    inside.

Examples

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="With value"/>

                                    Set the value property to show different position of Tip.

                                        <RaisedButton ref="trigger3"
                                                      className="trigger-position-button"
                                                      value="Top Left"
                                                      onMouseOver={() => {
                                                          this.showTip(3);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(3);
                                                      }}/>
                                        <RaisedButton ref="trigger4"
                                                      className="trigger-position-button"
                                                      value="Top"
                                                      onMouseOver={() => {
                                                          this.showTip(4);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(4);
                                                      }}/>
                                        <RaisedButton ref="trigger5"
                                                      className="trigger-position-button"
                                                      value="Top right"
                                                      onMouseOver={() => {
                                                          this.showTip(5);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(5);
                                                      }}/>

                                        <RaisedButton ref="trigger9"
                                                      className="trigger-position-button"
                                                      value="Right Top"
                                                      onMouseOver={() => {
                                                          this.showTip(9);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(9);
                                                      }}/>
                                        <RaisedButton ref="trigger10"
                                                      className="trigger-position-button"
                                                      value="Right"
                                                      onMouseOver={() => {
                                                          this.showTip(10);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(10);
                                                      }}/>
                                        <RaisedButton ref="trigger11"
                                                      className="trigger-position-button"
                                                      value="Right Bottom"
                                                      onMouseOver={() => {
                                                          this.showTip(11);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(11);
                                                      }}/>

                                        <RaisedButton ref="trigger0"
                                                      className="trigger-position-button"
                                                      value="Bottom Left"
                                                      onMouseOver={() => {
                                                          this.showTip(0);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(0);
                                                      }}/>
                                        <RaisedButton ref="trigger1"
                                                      className="trigger-position-button"
                                                      value="Bottom"
                                                      onMouseOver={() => {
                                                          this.showTip(1);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(1);
                                                      }}/>
                                        <RaisedButton ref="trigger2"
                                                      className="trigger-position-button"
                                                      value="Bottom Right"
                                                      onMouseOver={() => {
                                                          this.showTip(2);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(2);
                                                      }}/>

                                        <RaisedButton ref="trigger6"
                                                      className="trigger-position-button"
                                                      value="Left Top"
                                                      onMouseOver={() => {
                                                          this.showTip(6);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(6);
                                                      }}/>
                                        <RaisedButton ref="trigger7"
                                                      className="trigger-position-button"
                                                      value="Left"
                                                      onMouseOver={() => {
                                                          this.showTip(7);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(7);
                                                      }}/>
                                        <RaisedButton ref="trigger8"
                                                      className="trigger-position-button"
                                                      value="Left Bottom"
                                                      onMouseOver={() => {
                                                          this.showTip(8);
                                                      }}
                                                      onMouseOut={() => {
                                                          this.hideTip(8);
                                                      }}/>

                                <Tip visible={tipVisible[0]}
                                     triggerEl={triggerEl[0]}
                                     position={Tip.Position.BOTTOM_LEFT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[1]}
                                     triggerEl={triggerEl[1]}
                                     position={Tip.Position.BOTTOM}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[2]}
                                     triggerEl={triggerEl[2]}
                                     position={Tip.Position.BOTTOM_RIGHT}>
                                    Tip Content
                                </Tip>

                                <Tip visible={tipVisible[3]}
                                     triggerEl={triggerEl[3]}
                                     position={Tip.Position.TOP_LEFT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[4]}
                                     triggerEl={triggerEl[4]}
                                     position={Tip.Position.TOP}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[5]}
                                     triggerEl={triggerEl[5]}
                                     position={Tip.Position.TOP_RIGHT}>
                                    Tip Content
                                </Tip>

                                <Tip visible={tipVisible[6]}
                                     triggerEl={triggerEl[6]}
                                     position={Tip.Position.LEFT_TOP}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[7]}
                                     triggerEl={triggerEl[7]}
                                     position={Tip.Position.LEFT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[8]}
                                     triggerEl={triggerEl[8]}
                                     position={Tip.Position.LEFT_BOTTOM}>
                                    Tip Content
                                </Tip>

                                <Tip visible={tipVisible[9]}
                                     triggerEl={triggerEl[9]}
                                     position={Tip.Position.RIGHT_TOP}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[10]}
                                     triggerEl={triggerEl[10]}
                                     position={Tip.Position.RIGHT}>
                                    Tip Content
                                </Tip>
                                <Tip visible={tipVisible[11]}
                                     triggerEl={triggerEl[11]}
                                     position={Tip.Position.RIGHT_BOTTOM}>
                                    Tip Content
                                </Tip>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Customized Tip Triangle"/>

                                <RaisedButton ref="trigger12"
                                              className="trigger-button"
                                              value="Show Tip"
                                              onMouseOver={() => {
                                                  this.showTip(12);
                                              }}
                                              onMouseOut={() => {
                                                  this.hideTip(12);
                                              }}/>

                                <Tip className="customized-tip"
                                     theme={Theme.DEFAULT}
                                     visible={tipVisible[12]}
                                     triggerEl={triggerEl[12]}
                                     triangle={
                                         <svg xmlns="http://www.w3.org/2000/svg"
                                              version="1.1"
                                              className="customized-tip-triangle"
                                              width="17"
                                              height="7">
                                             <polyline points="0,7 9,0 17,7"
                                                       style={{stroke: '#e7e7e7', fill: '#fff'}}/>
                                         </svg>
                                     }>
                                    Tip Content
                                </Tip>

                </Widget><Widget>

                <WidgetHeader className="example-header"
                              title="Use Tip Provider"/>

                            <TipProvider text="Tip Content">
                                <RaisedButton className="trigger-button"
                                              value="Show Tip"/>
                            </TipProvider>

            </Widget>

Properties

                <PropTypeDescTable data={doc}/>

        );
    }
};

export default TipExamples;<|endoftext|>


<commit_before>//dojo.require("dojo.has");

var registry;
var lang;

require([
	"dijit/registry",  // registry.byId
	"dojo/_base/lang",
	"doh/runner"	//doh functions
], function(dijit, dojoLang){
	registry = dijit;
	lang = dojoLang;
});

function fireOnInput(obj){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(dojo.isIE<9){
		anchorNode.fireEvent( "onpropertychange" );
	}else{
		var e = document.createEvent('Events');
		e.initEvent('input', true, true);
		anchorNode.dispatchEvent(e);
	}
}

function fireOnClick(obj, eventMixin){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(dojo.isIE<9){
		anchorNode.fireEvent( "onclick" );
	}else{
		var e = document.createEvent('Events');
		e.initEvent('click', true, true);
		anchorNode.dispatchEvent(lang.mixin(e, eventMixin));
	}
}

function fireOnMouseDown(obj, eventMixin){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(dojo.isIE<9){
		anchorNode.fireEvent( "onmousedown" );
	}else{
		var eventName = "mousedown";
		if (dojo.isIE >= 10){
			eventName = "MSPointerDown";
		}
		var e = document.createEvent('Events');
		e.initEvent(eventName, true, true);
		anchorNode.dispatchEvent(lang.mixin(e, eventMixin));
	}
}
function fireOnMouseUp(obj, eventMixin){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(dojo.isIE<9){
		anchorNode.fireEvent( "onmouseup" );
	}else{
		var eventName = "mouseup";
		if (dojo.isIE >= 10){
			eventName = "MSPointerUp";
		}
		var e = document.createEvent('Events');
		e.initEvent(eventName, true, true);
		anchorNode.dispatchEvent(lang.mixin(e, eventMixin));
	}
}

function fireTouchEvent(eventtype, node, x, y){
	var e;
	if(dojo.isIE<9){
		e = document.createEventObject(window.event);
		e.button = 1;
		e.pageX = x;
		e.pageY = y;
		node.fireEvent( "on" + eventtype[1], e );
	}else{
		e = document.createEvent('Events');
		e.initEvent( dojo.has('touch') ? eventtype[0] : eventtype[1], true, true);
		e.touches = [ { pageX: x, pageY: y } ];
		e.pageX = x;
		e.pageY = y;
		e.changedTouches = e.touches;
		node.dispatchEvent(e);
	}
}

/*
function fireTouchStart(node, x, y){
	fireTouchEvent(["touchstart", "mousedown"], node, x, y);
}

function fireTouchEnd(node, x, y){
	fireTouchEvent(["touchend", "mouseup"], node, x, y);
}

function fireTouchMove(node, x, y){
	fireTouchEvent(["touchmove", "mousemove"], node, x, y);
}
*/

function verifyListItem(id, text, rightText, domButtonType, hasIcon, hasRightIcon, hasIcon2, hasVariableHeight, regExp, hasSelected, isSprite){
	var demoWidget = registry.byId(id);
	doh.assertNotEqual(null, demoWidget, "ListItem: Did not instantiate. id=" + id);
	doh.assertEqual('mblListItem' + (hasVariableHeight ?" mblVariableHeight":"") + (hasSelected ?" mblListItemSelected":""), demoWidget.domNode.className, "id=" + id);
	var childNodes = demoWidget.domNode.children;
//	doh.assertEqual('mblListItemAnchor' + (hasIcon?'':' mblListItemAnchorNoIcon'), childNodes[0].className);

//	doh.assertEqual('A', childNodes[0].tagName);

//	childNodes = childNodes[0].childNodes;

	var i=0;
	if(hasIcon){
		if(!dojo.isIE && regExp){
			if(isSprite){
				doh.assertTrue(childNodes[i].childNodes[0].src.search(regExp) != -1, "search " + regExp.toString());
			}else{
				doh.assertTrue(childNodes[i].src.search(regExp) != -1, "search " + regExp.toString());
			}
		}
		doh.assertTrue(dojo.hasClass(childNodes[i], 'mblListItemIcon'), 'mblListItemIcon id=' + id + " got: " + childNodes[i].className);
		i++;
	}

	if(hasRightIcon){
		if(domButtonType){
			doh.assertEqual(domButtonType + ' mblDomButton', childNodes[i].childNodes[0].className, "id=" + id);
		}
		doh.assertTrue(dojo.hasClass(childNodes[i], 'mblListItemRightIcon'), 'mblListItemRightIcon id=' + id + " got: " + childNodes[i].className);
		i++;
	}

	if(hasIcon2){
		doh.assertTrue(dojo.hasClass(childNodes[i], 'mblListItemRightIcon2'), 'mblListItemRightIcon2 id=' + id + " got: " + childNodes[i].className);
		i++;
	}

	if(rightText){
		doh.assertEqual(rightText, dojo.isFF ==3.6 ? childNodes[i].childNodes[0].innerHTML : childNodes[i].innerHTML, "id=" + id); //2 0r 3
		doh.assertEqual('mblListItemRightText', childNodes[i++].className, "id=" + id);
	}
	if(!hasVariableHeight){
		doh.assertEqual('mblListItemLabel', childNodes[i].className, "id=" + id);
		doh.assertEqual('DIV', childNodes[i].tagName, "id=" + id);
	}else{
		doh.assertEqual('mblListItemLabel', childNodes[i+1].className, "id=" + id);
		doh.assertEqual('DIV', childNodes[i+1].tagName, "id=" + id);
	}

	try{
		doh.assertEqual(text, dojo.trim(childNodes[i].innerHTML.replace(/\r\n|\n|\t/g,"")), "id=" + id);
	} catch (e) {
		if(dojo.isFF ==3.6){
			doh.assertEqual(text, dojo.trim(childNodes[i].childNodes[0].innerHTML.replace(/\r\n|\n|\t/g,"")), "id=" + id);
		}else{
			throw e;
		}
	}

}

function verifyListItemPos(id, rTop, rRight, rBottom, rLeft, sTop, sLeft, isSprite) {
	var demoWidget = registry.byId(id);
	var node;
	if(isSprite){
		node = demoWidget.domNode.childNodes[0].childNodes[0];
	}else{
		node = demoWidget.domNode.childNodes[0].childNodes[0].childNodes[0];
	}
	verifyRect(node, rTop, rRight, rBottom, rLeft);

	doh.assertEqual(sTop, node.style.top);
	doh.assertEqual(sLeft, node.style.left);
}

function verifyRect(node, rTop, rRight, rBottom, rLeft) {
	var rectArray = node.style.clip.split(/[, ]+/);
	doh.assertEqual("rect("+rTop, rectArray[0]);
	doh.assertEqual(rRight, rectArray[1]);
	doh.assertEqual(rBottom, rectArray[2]);
	doh.assertEqual(rLeft+")", rectArray[3]);
}

function verifyIconItem(id, text, display, regExp, isSprite){
	var demoWidget = registry.byId(id);
	if(!dojo.isIE && !dojo.isFF) {
		if(isSprite){
			doh.assertTrue(demoWidget.domNode.childNodes[0].childNodes[0].childNodes[0].childNodes[0].src.search(regExp) != -1, "search " + regExp.toString() + " id=" +id);
		}else{
			doh.assertTrue(demoWidget.domNode.childNodes[0].childNodes[0].childNodes[0].src.search(regExp) != -1, "search " + regExp.toString() + " id=" +id);
		}
	}
	doh.assertEqual(text, demoWidget.domNode.childNodes[0].childNodes[1].childNodes[0].nodeValue, "id=" +id);
	doh.assertEqual(display, demoWidget.paneWidget.domNode.style.display, "id=" +id);
	doh.assertEqual('mblIconItemPaneHeading', demoWidget.paneWidget.domNode.childNodes[0].className, "id=" +id);
	doh.assertEqual('mblDomButtonBlueMinus mblDomButton', demoWidget.paneWidget.domNode.childNodes[0].childNodes[0].childNodes[0].className, "id=" +id);
	doh.assertEqual(text, demoWidget.paneWidget.domNode.childNodes[0].childNodes[1].childNodes[0].nodeValue, "id=" +id);
}

function verifyTabBarButton(id, text, classNames, visibility1, visibility2, regExp1, regExp2, isSprite){
	var demoWidget = registry.byId(id);
	for(var i = 0; i < classNames.length;i++){
		doh.assertTrue(dojo.hasClass(demoWidget.domNode, classNames[i]), classNames[i] + " id=" +id + " className:"+demoWidget.domNode.className);
	}
	doh.assertEqual('mblTabBarButtonIconArea', demoWidget.domNode.childNodes[0].className, "id=" +id);
	doh.assertEqual('mblTabBarButtonLabel', demoWidget.domNode.childNodes[1].className, "id=" +id);
	if(demoWidget.iconNode1){
		if(!dojo.isIE) {
			if(isSprite){
				doh.assertTrue(demoWidget.iconNode1.childNodes[0].src.search(regExp1) != -1, "search " + regExp1.toString() + " id=" +id);
			}else{
				doh.assertTrue(demoWidget.iconNode1.src.search(regExp1) != -1, "search " + regExp1.toString() + " id=" +id);
			}
		}
//		doh.assertEqual(visibility1, demoWidget.iconNode1.style.visibility, "id=" +id);
	}else{
		console.log("There is no iconNode1. id=" + id);
	}
	if(demoWidget.iconNode2){
		if(!dojo.isIE){
			if(isSprite){
				doh.assertTrue(demoWidget.iconNode2.childNodes[0].src.search(regExp2) != -1, "search " + regExp2.toString() + " id=" +id);
			}else{
				doh.assertTrue(demoWidget.iconNode2.src.search(regExp2) != -1, "search " + regExp2.toString() + " id=" +id);
			}
		}
		doh.assertEqual(visibility2, demoWidget.iconNode2.style.visibility, "id=" +id);
	}else{
		console.log("There is no iconNode2. id=" + id);
	}
	doh.assertEqual(text, dojo.trim(demoWidget.labelNode.innerHTML), "id=" +id);
}
<commit_msg>Replace deprecated dojo.isIE test with has('ie').<commit_after>//dojo.require("dojo.has");

var registry;
var lang;
var has;

require([
	"dijit/registry",  // registry.byId
	"dojo/_base/lang",
	"dojo/has",
	"doh/runner"	//doh functions
], function(dijit, dojoLang, dojoHas){
	registry = dijit;
	lang = dojoLang;
	has = dojoHas;
});

function fireOnInput(obj){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(has('ie')<9){
		anchorNode.fireEvent( "onpropertychange" );
	}else{
		var e = document.createEvent('Events');
		e.initEvent('input', true, true);
		anchorNode.dispatchEvent(e);
	}
}

function fireOnClick(obj, eventMixin){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(has('ie')<9){
		anchorNode.fireEvent( "onclick" );
	}else{
		var e = document.createEvent('Events');
		e.initEvent('click', true, true);
		anchorNode.dispatchEvent(lang.mixin(e, eventMixin));
	}
}

function fireOnMouseDown(obj, eventMixin){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(has('ie')<9){
		anchorNode.fireEvent( "onmousedown" );
	}else{
		var eventName = "mousedown";
		if (has('ie') >= 10){
			eventName = "MSPointerDown";
		}
		var e = document.createEvent('Events');
		e.initEvent(eventName, true, true);
		anchorNode.dispatchEvent(lang.mixin(e, eventMixin));
	}
}
function fireOnMouseUp(obj, eventMixin){
	var anchorNode;
	if(typeof obj === "string"){
		var demoWidget = registry.byId(obj);
		anchorNode = demoWidget.domNode;
	}else{
		anchorNode = obj;
	}
	if(has('ie')<9){
		anchorNode.fireEvent( "onmouseup" );
	}else{
		var eventName = "mouseup";
		if (has('ie') >= 10){
			eventName = "MSPointerUp";
		}
		var e = document.createEvent('Events');
		e.initEvent(eventName, true, true);
		anchorNode.dispatchEvent(lang.mixin(e, eventMixin));
	}
}

function fireTouchEvent(eventtype, node, x, y){
	var e;
	if(has('ie')<9){
		e = document.createEventObject(window.event);
		e.button = 1;
		e.pageX = x;
		e.pageY = y;
		node.fireEvent( "on" + eventtype[1], e );
	}else{
		e = document.createEvent('Events');
		e.initEvent( dojo.has('touch') ? eventtype[0] : eventtype[1], true, true);
		e.touches = [ { pageX: x, pageY: y } ];
		e.pageX = x;
		e.pageY = y;
		e.changedTouches = e.touches;
		node.dispatchEvent(e);
	}
}

/*
function fireTouchStart(node, x, y){
	fireTouchEvent(["touchstart", "mousedown"], node, x, y);
}

function fireTouchEnd(node, x, y){
	fireTouchEvent(["touchend", "mouseup"], node, x, y);
}

function fireTouchMove(node, x, y){
	fireTouchEvent(["touchmove", "mousemove"], node, x, y);
}
*/

function verifyListItem(id, text, rightText, domButtonType, hasIcon, hasRightIcon, hasIcon2, hasVariableHeight, regExp, hasSelected, isSprite){
	var demoWidget = registry.byId(id);
	doh.assertNotEqual(null, demoWidget, "ListItem: Did not instantiate. id=" + id);
	doh.assertEqual('mblListItem' + (hasVariableHeight ?" mblVariableHeight":"") + (hasSelected ?" mblListItemSelected":""), demoWidget.domNode.className, "id=" + id);
	var childNodes = demoWidget.domNode.children;
//	doh.assertEqual('mblListItemAnchor' + (hasIcon?'':' mblListItemAnchorNoIcon'), childNodes[0].className);

//	doh.assertEqual('A', childNodes[0].tagName);

//	childNodes = childNodes[0].childNodes;

	var i=0;
	if(hasIcon){
		if(!has('ie') && regExp){
			if(isSprite){
				doh.assertTrue(childNodes[i].childNodes[0].src.search(regExp) != -1, "search " + regExp.toString());
			}else{
				doh.assertTrue(childNodes[i].src.search(regExp) != -1, "search " + regExp.toString());
			}
		}
		doh.assertTrue(dojo.hasClass(childNodes[i], 'mblListItemIcon'), 'mblListItemIcon id=' + id + " got: " + childNodes[i].className);
		i++;
	}

	if(hasRightIcon){
		if(domButtonType){
			doh.assertEqual(domButtonType + ' mblDomButton', childNodes[i].childNodes[0].className, "id=" + id);
		}
		doh.assertTrue(dojo.hasClass(childNodes[i], 'mblListItemRightIcon'), 'mblListItemRightIcon id=' + id + " got: " + childNodes[i].className);
		i++;
	}

	if(hasIcon2){
		doh.assertTrue(dojo.hasClass(childNodes[i], 'mblListItemRightIcon2'), 'mblListItemRightIcon2 id=' + id + " got: " + childNodes[i].className);
		i++;
	}

	if(rightText){
		doh.assertEqual(rightText, dojo.isFF ==3.6 ? childNodes[i].childNodes[0].innerHTML : childNodes[i].innerHTML, "id=" + id); //2 0r 3
		doh.assertEqual('mblListItemRightText', childNodes[i++].className, "id=" + id);
	}
	if(!hasVariableHeight){
		doh.assertEqual('mblListItemLabel', childNodes[i].className, "id=" + id);
		doh.assertEqual('DIV', childNodes[i].tagName, "id=" + id);
	}else{
		doh.assertEqual('mblListItemLabel', childNodes[i+1].className, "id=" + id);
		doh.assertEqual('DIV', childNodes[i+1].tagName, "id=" + id);
	}

	try{
		doh.assertEqual(text, dojo.trim(childNodes[i].innerHTML.replace(/\r\n|\n|\t/g,"")), "id=" + id);
	} catch (e) {
		if(dojo.isFF ==3.6){
			doh.assertEqual(text, dojo.trim(childNodes[i].childNodes[0].innerHTML.replace(/\r\n|\n|\t/g,"")), "id=" + id);
		}else{
			throw e;
		}
	}

}

function verifyListItemPos(id, rTop, rRight, rBottom, rLeft, sTop, sLeft, isSprite) {
	var demoWidget = registry.byId(id);
	var node;
	if(isSprite){
		node = demoWidget.domNode.childNodes[0].childNodes[0];
	}else{
		node = demoWidget.domNode.childNodes[0].childNodes[0].childNodes[0];
	}
	verifyRect(node, rTop, rRight, rBottom, rLeft);

	doh.assertEqual(sTop, node.style.top);
	doh.assertEqual(sLeft, node.style.left);
}

function verifyRect(node, rTop, rRight, rBottom, rLeft) {
	var rectArray = node.style.clip.split(/[, ]+/);
	doh.assertEqual("rect("+rTop, rectArray[0]);
	doh.assertEqual(rRight, rectArray[1]);
	doh.assertEqual(rBottom, rectArray[2]);
	doh.assertEqual(rLeft+")", rectArray[3]);
}

function verifyIconItem(id, text, display, regExp, isSprite){
	var demoWidget = registry.byId(id);
	if(!has('ie') && !dojo.isFF) {
		if(isSprite){
			doh.assertTrue(demoWidget.domNode.childNodes[0].childNodes[0].childNodes[0].childNodes[0].src.search(regExp) != -1, "search " + regExp.toString() + " id=" +id);
		}else{
			doh.assertTrue(demoWidget.domNode.childNodes[0].childNodes[0].childNodes[0].src.search(regExp) != -1, "search " + regExp.toString() + " id=" +id);
		}
	}
	doh.assertEqual(text, demoWidget.domNode.childNodes[0].childNodes[1].childNodes[0].nodeValue, "id=" +id);
	doh.assertEqual(display, demoWidget.paneWidget.domNode.style.display, "id=" +id);
	doh.assertEqual('mblIconItemPaneHeading', demoWidget.paneWidget.domNode.childNodes[0].className, "id=" +id);
	doh.assertEqual('mblDomButtonBlueMinus mblDomButton', demoWidget.paneWidget.domNode.childNodes[0].childNodes[0].childNodes[0].className, "id=" +id);
	doh.assertEqual(text, demoWidget.paneWidget.domNode.childNodes[0].childNodes[1].childNodes[0].nodeValue, "id=" +id);
}

function verifyTabBarButton(id, text, classNames, visibility1, visibility2, regExp1, regExp2, isSprite){
	var demoWidget = registry.byId(id);
	for(var i = 0; i < classNames.length;i++){
		doh.assertTrue(dojo.hasClass(demoWidget.domNode, classNames[i]), classNames[i] + " id=" +id + " className:"+demoWidget.domNode.className);
	}
	doh.assertEqual('mblTabBarButtonIconArea', demoWidget.domNode.childNodes[0].className, "id=" +id);
	doh.assertEqual('mblTabBarButtonLabel', demoWidget.domNode.childNodes[1].className, "id=" +id);
	if(demoWidget.iconNode1){
		if(!has('ie')) {
			if(isSprite){
				doh.assertTrue(demoWidget.iconNode1.childNodes[0].src.search(regExp1) != -1, "search " + regExp1.toString() + " id=" +id);
			}else{
				doh.assertTrue(demoWidget.iconNode1.src.search(regExp1) != -1, "search " + regExp1.toString() + " id=" +id);
			}
		}
//		doh.assertEqual(visibility1, demoWidget.iconNode1.style.visibility, "id=" +id);
	}else{
		console.log("There is no iconNode1. id=" + id);
	}
	if(demoWidget.iconNode2){
		if(!has('ie')){
			if(isSprite){
				doh.assertTrue(demoWidget.iconNode2.childNodes[0].src.search(regExp2) != -1, "search " + regExp2.toString() + " id=" +id);
			}else{
				doh.assertTrue(demoWidget.iconNode2.src.search(regExp2) != -1, "search " + regExp2.toString() + " id=" +id);
			}
		}
		doh.assertEqual(visibility2, demoWidget.iconNode2.style.visibility, "id=" +id);
	}else{
		console.log("There is no iconNode2. id=" + id);
	}
	doh.assertEqual(text, dojo.trim(demoWidget.labelNode.innerHTML), "id=" +id);
}
<|endoftext|>


<commit_before>var searchBox = Ti.UI.createTextField({
	hintText: "キーワードで検索",
	width: "60%",
	color: "black"
});
searchBox.addEventListener("return", function(e){
	var keyword = this.value;
	var getKeywordSearchResultClient = Ti.Network.createHTTPClient({
		onload: function(e){
			var searchWin = Alloy.createController('searchBooks', {
				data: this.responseText,
				searchCondition: keyword
			}).getView();
			searchWin.open();
		}
	});
	getKeywordSearchResultClient.open("POST", Alloy.Globals.ajaxUrl);
	getKeywordSearchResultClient.send({
		action: "echo_posts_data_json",
		keyword: this.value
	});
});

var getCategoriesTreeClient = Ti.Network.createHTTPClient({
	onload: function(e){
		// Get categoris data, and create a categories table.
		var categoriesTree = JSON.parse(this.responseText);
		var header = Ti.UI.createTableViewSection({headerTitle: "カテゴリから検索"});
		var categoriesData = [header];

		for(var i=0;i<categoriesTree.length;i++){
			var mainCategory = categoriesTree[i];
			var mainSection = Ti.UI.createTableViewSection({headerTitle: mainCategory.cat_name});
			var subCategories = mainCategory.subcategories;
			for(var elm in subCategories){
				var subCategory = subCategories[elm];
				mainSection.add(createRow(subCategory.cat_name, subCategory.cat_ID));
			}
			categoriesData.push(mainSection);
		}
		var categoriesTable = Ti.UI.createTableView({data:categoriesData});
		categoriesTable.top = 70;

		$.searchMenuWin.add(categoriesTable);
	}
});

getCategoriesTreeClient.open("POST", Alloy.Globals.ajaxUrl);
getCategoriesTreeClient.send({
	action: "echo_categories_tree_json"
});

$.searchMenuWin.add(Alloy.Globals.createCommonHeader([searchBox]));

function createRow(title, catId){
	var row = Ti.UI.createTableViewRow({
		title: title,
		catId: catId,
		color: "black"
	});
	row.addEventListener("click", function(e){
		var getSearchResultClient = Ti.Network.createHTTPClient({
			onload: function(e){
				var searchWin = Alloy.createController('searchBooks', {
					data: this.responseText,
					searchCondition: title
				}).getView();
				searchWin.open();
			}
		});
		getSearchResultClient.open("POST", Alloy.Globals.ajaxUrl);
		getSearchResultClient.send({
			action: "echo_posts_data_json",
			category: this.catId
		});
	});
	return row;
}
<commit_msg>Fixed bug with null search keyword<commit_after>var searchBox = Ti.UI.createTextField({
	hintText: "キーワードで検索",
	width: "60%",
	color: "black"
});
searchBox.addEventListener("return", function(e){
	var keyword = this.value;
	if(!keyword){
		return;
	}
	var getKeywordSearchResultClient = Ti.Network.createHTTPClient({
		onload: function(e){
			var searchWin = Alloy.createController('searchBooks', {
				data: this.responseText,
				searchCondition: keyword
			}).getView();
			searchWin.open();
		}
	});
	getKeywordSearchResultClient.open("POST", Alloy.Globals.ajaxUrl);
	getKeywordSearchResultClient.send({
		action: "echo_posts_data_json",
		keyword: this.value
	});
});

var getCategoriesTreeClient = Ti.Network.createHTTPClient({
	onload: function(e){
		// Get categoris data, and create a categories table.
		var categoriesTree = JSON.parse(this.responseText);
		var header = Ti.UI.createTableViewSection({headerTitle: "カテゴリから検索"});
		var categoriesData = [header];

		for(var i=0;i<categoriesTree.length;i++){
			var mainCategory = categoriesTree[i];
			var mainSection = Ti.UI.createTableViewSection({headerTitle: mainCategory.cat_name});
			var subCategories = mainCategory.subcategories;
			for(var elm in subCategories){
				var subCategory = subCategories[elm];
				mainSection.add(createRow(subCategory.cat_name, subCategory.cat_ID));
			}
			categoriesData.push(mainSection);
		}
		var categoriesTable = Ti.UI.createTableView({data:categoriesData});
		categoriesTable.top = 70;

		$.searchMenuWin.add(categoriesTable);
	}
});

getCategoriesTreeClient.open("POST", Alloy.Globals.ajaxUrl);
getCategoriesTreeClient.send({
	action: "echo_categories_tree_json"
});

$.searchMenuWin.add(Alloy.Globals.createCommonHeader([searchBox]));

function createRow(title, catId){
	var row = Ti.UI.createTableViewRow({
		title: title,
		catId: catId,
		color: "black"
	});
	row.addEventListener("click", function(e){
		var getSearchResultClient = Ti.Network.createHTTPClient({
			onload: function(e){
				var searchWin = Alloy.createController('searchBooks', {
					data: this.responseText,
					searchCondition: title
				}).getView();
				searchWin.open();
			}
		});
		getSearchResultClient.open("POST", Alloy.Globals.ajaxUrl);
		getSearchResultClient.send({
			action: "echo_posts_data_json",
			category: this.catId
		});
	});
	return row;
}
<|endoftext|>


<commit_before>import { permissionsModel } from './permissions.model.js';
import { userModel } from './user.model.js';

export const pageSecurityModel = [
    { field: '@href', name: 'href' },
    {
        field: [ 'grants', 'grant' ],
        name: 'grants',
        isArray: true,
        transform: [
            { field: 'date.modified', name: 'dateModified', transform: 'date' },
            { field: 'permissions', transform: permissionsModel },
            { field: 'user', transform: userModel },
            { field: 'user.modifiedby', name: 'userModifiedBy', transform: userModel }
        ]
    },
    { field: 'permissions.effective', name: 'effectivePermissions', transform: permissionsModel },
    { field: 'permissions.page', name: 'pagePermissions', transform: permissionsModel },
    { field: 'permissions.revoked', name: 'revokedPermissions', transform: permissionsModel }
];
<commit_msg>Fix for missing  field in pageSecurity.model<commit_after>import { permissionsModel } from './permissions.model.js';
import { userModel } from './user.model.js';
import { groupModel } from './group.model.js';

export const pageSecurityModel = [
    { field: '@href', name: 'href' },
    {
        field: [ 'grants', 'grant' ],
        name: 'grants',
        isArray: true,
        transform: [
            { field: 'date.modified', name: 'dateModified', transform: 'date' },
            { field: 'permissions', transform: permissionsModel },
            { field: 'user', transform: userModel },
            { field: 'user.modifiedby', name: 'userModifiedBy', transform: userModel },
            { field: 'group', transform: groupModel }
        ]
    },
    { field: 'permissions.effective', name: 'effectivePermissions', transform: permissionsModel },
    { field: 'permissions.page', name: 'pagePermissions', transform: permissionsModel },
    { field: 'permissions.revoked', name: 'revokedPermissions', transform: permissionsModel }
];
<|endoftext|>


<commit_before>var app;
var dialog;
var dialogVue;

(function () {
	// 画面ロード時に初期化処理を呼び出す
	window.addEventListener('load', function _initEvent() {
		init();
		window.removeEventListener('load', _initEvent);
	});

	// 共通で使用するもの(予定を含む)
	let common = {
		zpdic: {
			alphabetOrder: "abcdefghijklmnopqrstuvwxyz"
		},
		createSetting: {
			setSimple: {
				letters: "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u,v,w,x,y,z",
				patterns: "5",
			},
			setSimpleCv: {
				consonants: "b,c,d,f,g,h,j,k,l,m,n,p,r,s,t,v,w,x,z",
				vowels: "a,e,i,o,u,y",
				patterns: "CVCCV",
			}
		},
	};

	// 初期化用関数
	function init() {
		// 設定ダイアログの初期化
		dialog = new NtDialog("設定画面", {
			top: 100, left:500,
			width: 500, height: 200,
			style: 'flat', //'default',
			draggable: true,
			dialog: document.getElementById('dialogs'),
		});

		// メインのVMの初期化
		let id = 1;
		app = new Vue({
			el: '#app',
			data: {
				words: [
				],
				zpdic: common.zpdic,
			},
			methods: {
				showDialog: function _showDialog() {
					dialog.show();
				},
				create: function _create() {
					let form = "";
					switch(dialogVue.mode.value) {
						case WordGenerator.simple_symbol:
							form = WordGenerator.simple(common.createSetting.setSimple);
							break;
						case WordGenerator.simplecv_symbol:
							form = WordGenerator.simplecv(common.createSetting.setSimpleCv);
							break;
						default:
							break;
					}

					this.words.push(new OtmWord(0, form));
				},
				outputJson: function _outputJson() {
					this.words.forEach(function(x) { x.entry.id = id++; });
					id = 1;

					let blob = new Blob([ JSON.stringify(this.$data, undefined, 2) ], { type: "application/json" });

					if(window.navigator.msSaveBlob) {
						window.navigator.msSaveBlob(blob, "data.json");
					}
					else {
						let a = document.createElement("a");
						a.download = "data.json";

						a.href = window.URL.createObjectURL(blob);
						document.body.appendChild(a);
						a.click();
						document.body.removeChild(a);
					}
				},
				remove: function _remove(index) {
					this.words.splice(index, 1);
				},
			},
		});

		// 設定ダイアログのVMの初期化
		dialogVue = new Vue({
			el: '#dialogVue',
			data: {
				mode: {
					value: 'simple',
					options: [
						{ text: '単純文字列生成', value: WordGenerator.simple_symbol },
						{ text: '母子音別定義単純文字列生成', value: WordGenerator.simplecv_symbol },
						//{ text: '多定義文字列生成', value: 'manytype' },
					],
				},
				createSetting: common.createSetting,
			},
			computed: {
				isSimple: function _isSimple() {
					return this.mode.value === WordGenerator.simple_symbol;
				},
				isSimpleCv: function _isSimpleCv() {
					return this.mode.value === WordGenerator.simplecv_symbol;
				},
			},
			methods: {
				inputSetting: function _inputSetting(ev) {
					let reader = new FileReader();
					reader.readAsText(ev.target.files[0]);

					let this_ = this;
					reader.onload = function _reader_onload(loadEv) {
						let arr = reader.result.replace('\r\n', '\n').replace('\r', '\n').split('\n');
						arr = arr.filter(function(el) {
							return el !== "" && !el.startsWith("#");
						});

						switch(this_.mode.value) {
							case WordGenerator.simple_symbol:
								let letters = [];
								for(let i = 0; i < arr.length; i++) {
									letters = letters.concat(arr[i].split(","));
								}

								this_.createSetting.setSimple.letters = letters.join(",");
								break;
							case WordGenerator.simplecv_symbol:
								let consonants = "";
								let vowels = "";

								for(let i = 0; i < arr.length; i++) {
									let split = arr[i].split(/\s*=\s*/);
									switch(split[0].trim()) {
										case "consonants":
											consonants = split[1];
											break;
										case "vowels":
											vowels = split[1];
											break;
										case "patterns":
											patterns = split[1];
											break;
									}
								}

								this_.createSetting.setSimpleCv.consonants = consonants;
								this_.createSetting.setSimpleCv.vowels = vowels;
								this_.createSetting.setSimpleCv.patterns = patterns;
								break;
							default:
								break;
						}
					}
				}
			}
		});
	}
})();
<commit_msg>idの設定をJSON化する時に行うように変更<commit_after>var app;
var dialog;
var dialogVue;

(function () {
	// 画面ロード時に初期化処理を呼び出す
	window.addEventListener('load', function _initEvent() {
		init();
		window.removeEventListener('load', _initEvent);
	});

	// 共通で使用するもの(予定を含む)
	let common = {
		zpdic: {
			alphabetOrder: "abcdefghijklmnopqrstuvwxyz"
		},
		createSetting: {
			setSimple: {
				letters: "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u,v,w,x,y,z",
				patterns: "5",
			},
			setSimpleCv: {
				consonants: "b,c,d,f,g,h,j,k,l,m,n,p,r,s,t,v,w,x,z",
				vowels: "a,e,i,o,u,y",
				patterns: "CVCCV",
			}
		},
	};

	// 初期化用関数
	function init() {
		// 設定ダイアログの初期化
		dialog = new NtDialog("設定画面", {
			top: 100, left:500,
			width: 500, height: 200,
			style: 'flat', //'default',
			draggable: true,
			dialog: document.getElementById('dialogs'),
		});

		// メインのVMの初期化
		let id = 1;
		app = new Vue({
			el: '#app',
			data: {
				words: [
				],
				zpdic: common.zpdic,
			},
			methods: {
				showDialog: function _showDialog() {
					dialog.show();
				},
				create: function _create() {
					let form = "";
					switch(dialogVue.mode.value) {
						case WordGenerator.simple_symbol:
							form = WordGenerator.simple(common.createSetting.setSimple);
							break;
						case WordGenerator.simplecv_symbol:
							form = WordGenerator.simplecv(common.createSetting.setSimpleCv);
							break;
						default:
							break;
					}

					this.words.push(new OtmWord(0, form));
				},
				outputJson: function _outputJson() {
					this.words.forEach(function(x) { x.entry.id = id++; });
					id = 1;

					let blob = new Blob([ JSON.stringify(this.$data, undefined, 2) ], { type: "application/json" });

					if(window.navigator.msSaveBlob) {
						window.navigator.msSaveBlob(blob, "data.json");
					}
					else {
						let a = document.createElement("a");
						a.download = "data.json";

						a.href = window.URL.createObjectURL(blob);
						document.body.appendChild(a);
						a.click();
						document.body.removeChild(a);
					}
				},
				remove: function _remove(index) {
					this.words.splice(index, 1);
				},
			},
		});

		// 設定ダイアログのVMの初期化
		dialogVue = new Vue({
			el: '#dialogVue',
			data: {
				mode: {
					value: 'simple',
					options: [
						{ text: '単純文字列生成', value: WordGenerator.simple_symbol },
						{ text: '母子音別定義単純文字列生成', value: WordGenerator.simplecv_symbol },
						//{ text: '多定義文字列生成', value: 'manytype' },
					],
				},
				createSetting: common.createSetting,
			},
			computed: {
				isSimple: function _isSimple() {
					return this.mode.value === WordGenerator.simple_symbol;
				},
				isSimpleCv: function _isSimpleCv() {
					return this.mode.value === WordGenerator.simplecv_symbol;
				},
			},
			methods: {
				inputSetting: function _inputSetting(ev) {
					let reader = new FileReader();
					reader.readAsText(ev.target.files[0]);

					let this_ = this;
					reader.onload = function _reader_onload(loadEv) {
						let arr = reader.result.replace('\r\n', '\n').replace('\r', '\n').split('\n');
						arr = arr.filter(function(el) {
							return el !== "" && !el.startsWith("#");
						});

						switch(this_.mode.value) {
							case WordGenerator.simple_symbol:
								let letters = [];
								for(let i = 0; i < arr.length; i++) {
									letters = letters.concat(arr[i].split(","));
								}

								common.createSetting.setSimple.letters = letters.join(",");
								break;
							case WordGenerator.simplecv_symbol:
								let consonants = "";
								let vowels = "";

								for(let i = 0; i < arr.length; i++) {
									let split = arr[i].split(/\s*=\s*/);
									switch(split[0].trim()) {
										case "consonants":
											consonants = split[1];
											break;
										case "vowels":
											vowels = split[1];
											break;
										case "patterns":
											patterns = split[1];
											break;
									}
								}

								common.createSetting.setSimpleCv.consonants = consonants;
								common.createSetting.setSimpleCv.vowels = vowels;
								common.createSetting.setSimpleCv.patterns = patterns;
								break;
							default:
								break;
						}
					}
				}
			}
		});
	}
})();
<|endoftext|>


<commit_before><commit_msg>Update blToolBar.js<commit_after><|endoftext|>


<commit_before>/*
Game

>> gameID
>> time
>> location
>> userIDs

*/

var mongoose = require('mongoose');

var gameSchema = mongoose.Schema({
    gameSession: {
        gameCreatedAt:  Date;
        gameLocation: Array;
        gamePlayers: Array ;

    }
});

// Makes the model for the schema useful
module.exports = mongoose.model('game', gameSchema);
<commit_msg>Game Callback<commit_after>/*
Game

>> gameID
>> time
>> location
>> userIDs

*/

var mongoose = require('mongoose');

var gameSchema = mongoose.Schema({
    gameSession: {
        createdAt:  Date  ;
        location:   Array ;
        players:    Array ;

    }
});

// Makes the model for the schema useful
module.exports = mongoose.model('game', gameSchema);

//game players, game location, error
gameSession.save(function(gameSession, err ){
  if (err) return console.error(err);
  gameSession.save();

});
<|endoftext|>