define('jForumUtils', ['require','jquery', 'jquery-confirm', ], function (require, $, jconfirm) {
    'use strict';

    var jForumUtils = (function () {
        var tools = {};
        //弹出消息窗口
        tools.tipDialog = function (config) {
            var option = {
                content: '',
                type: 'blue',
                ico: 'fa-question',
                reloaded: true
            };
            if (config.level === 'acc') {
                option.type = 'green'; option.ico = 'mdi-check';
            }
            if (config.level === 'err') {
                option.type = 'red'; option.ico = 'mdi-close';
            }
            if (config.level === 'ibb') {
                option.type = 'orange'; option.ico = 'mdi-alert-circle-o';
            }
            if (config.message) {
                option.content = config.message;
            }
            if (!this.isBlank(config.content)) {
                option.content = config.content;
            }
            if (config.hasOwnProperty('refresh')) {
                option.reloaded = config.refresh;
            }
            $.dialog({
                icon: 'ico-lg mdi ' + option.ico,
                title: '',
                theme: 'modern',
                type: option.type,
                closeIcon: false,
                content: '' + option.content,
                onOpen: function () {
                    var jc = this;
                    setTimeout(function () { jc.close(); }, 3000);
                },
                onClose: function () {
                    if (option.reloaded) {
                        location.reload(true);
                    }
                }
            });
        };
        tools.errorMessage = function (message) {
            return this.tipDialog({ "message": message, "level": "err", "refresh": false });
        };
        tools.isBlank = function (strParameter) {
            return (!strParameter || strParameter === undefined || strParameter === "" || strParameter.length === 0);
        };
        tools.randomAlphaNumeric = function (strlen) {
            if (!strlen || parseInt(strlen) <= 6) {
                return;
            }
            var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
            var randomstring = '';
            for (var i = 0; i < strlen; i++) {
                var rnum = Math.floor(Math.random() * chars.length);
                randomstring += chars.substring(rnum, rnum + 1);
            }
            return randomstring;
        };
        //data-params改用data-query
        tools.parseQueryJson = function (dataQueryVal) {
            var data = {};
            if (this.isBlank(dataQueryVal)) {
                return data;
            }
            $.each(dataQueryVal.split(','), function (index, item) {
                var tmp = item.split(':');
                data[tmp[0].trim()] = tmp[1].trim();
            });
            return data;
        };
        tools.getUnixStamp = function () {
            return Math.round(new Date().getTime() / 1000);
        };
        return tools;
    })();
    return jForumUtils;
});