diff --git a/sub/subService.go b/sub/subService.go index 332f8150..ddf9692b 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -20,6 +20,7 @@ type SubService struct { address string showInfo bool remarkModel string + datepicker string inboundService service.InboundService settingService service.SettingService } @@ -39,6 +40,10 @@ func (s *SubService) GetSubs(subId string, host string, showInfo bool) ([]string if err != nil { s.remarkModel = "-ieo" } + s.datepicker, err = s.settingService.GetDatepicker() + if err != nil { + s.datepicker = "gregorian" + } for _, inbound := range inbounds { clients, err := s.inboundService.GetClients(inbound) if err != nil { diff --git a/web/assets/js/model/setting.js b/web/assets/js/model/setting.js index 86bea983..3ddddb18 100644 --- a/web/assets/js/model/setting.js +++ b/web/assets/js/model/setting.js @@ -12,6 +12,7 @@ class AllSetting { this.expireDiff = ""; this.trafficDiff = ""; this.remarkModel = "-ieo"; + this.datepicker = "gregorian"; this.tgBotEnable = false; this.tgBotToken = ""; this.tgBotChatId = ""; diff --git a/web/assets/moment/moment-jalali.min.js b/web/assets/moment/moment-jalali.min.js new file mode 100644 index 00000000..a5947644 --- /dev/null +++ b/web/assets/moment/moment-jalali.min.js @@ -0,0 +1,1252 @@ + +;(function(){ + + /** + * Require the module at `name`. + * + * @param {String} name + * @return {Object} exports + * @api public + */ + + function require(name) { + var module = require.modules[name]; + if (!module) throw new Error('failed to require "' + name + '"'); + + if (!('exports' in module) && typeof module.definition === 'function') { + module.client = module.component = true; + module.definition.call(this, module.exports = {}, module); + delete module.definition; + } + + return module.exports; + } + + /** + * Registered modules. + */ + + require.modules = { + moment: { exports: moment } + }; + + /** + * Register module at `name` with callback `definition`. + * + * @param {String} name + * @param {Function} definition + * @api private + */ + + require.register = function (name, definition) { + require.modules[name] = { + definition: definition + }; + }; + + /** + * Define a module's exports immediately with `exports`. + * + * @param {String} name + * @param {Generic} exports + * @api private + */ + + require.define = function (name, exports) { + require.modules[name] = { + exports: exports + }; + }; + + require.register("jalaali-js", function (exports, module) { + /* + Expose functions. + */ + module.exports = + { toJalaali: toJalaali + , toGregorian: toGregorian + , isValidJalaaliDate: isValidJalaaliDate + , isLeapJalaaliYear: isLeapJalaaliYear + , jalaaliMonthLength: jalaaliMonthLength + , jalCal: jalCal + , j2d: j2d + , d2j: d2j + , g2d: g2d + , d2g: d2g + } + + /* + Converts a Gregorian date to Jalaali. + */ + function toJalaali(gy, gm, gd) { + if (Object.prototype.toString.call(gy) === '[object Date]') { + gd = gy.getDate() + gm = gy.getMonth() + 1 + gy = gy.getFullYear() + } + return d2j(g2d(gy, gm, gd)) + } + + /* + Converts a Jalaali date to Gregorian. + */ + function toGregorian(jy, jm, jd) { + return d2g(j2d(jy, jm, jd)) + } + + /* + Checks whether a Jalaali date is valid or not. + */ + function isValidJalaaliDate(jy, jm, jd) { + return jy >= -61 && jy <= 3177 && + jm >= 1 && jm <= 12 && + jd >= 1 && jd <= jalaaliMonthLength(jy, jm) + } + + /* + Is this a leap year or not? + */ + function isLeapJalaaliYear(jy) { + return jalCal(jy).leap === 0 + } + + /* + Number of days in a given month in a Jalaali year. + */ + function jalaaliMonthLength(jy, jm) { + if (jm <= 6) return 31 + if (jm <= 11) return 30 + if (isLeapJalaaliYear(jy)) return 30 + return 29 + } + + /* + This function determines if the Jalaali (Persian) year is + leap (366-day long) or is the common year (365 days), and + finds the day in March (Gregorian calendar) of the first + day of the Jalaali year (jy). + + @param jy Jalaali calendar year (-61 to 3177) + @return + leap: number of years since the last leap year (0 to 4) + gy: Gregorian year of the beginning of Jalaali year + march: the March day of Farvardin the 1st (1st day of jy) + @see: http://www.astro.uni.torun.pl/~kb/Papers/EMP/PersianC-EMP.htm + @see: http://www.fourmilab.ch/documents/calendar/ + */ + function jalCal(jy) { + // Jalaali years starting the 33-year rule. + var breaks = [ -61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210 + , 1635, 2060, 2097, 2192, 2262, 2324, 2394, 2456, 3178 + ] + , bl = breaks.length + , gy = jy + 621 + , leapJ = -14 + , jp = breaks[0] + , jm + , jump + , leap + , leapG + , march + , n + , i + + if (jy < jp || jy >= breaks[bl - 1]) + throw new Error('Invalid Jalaali year ' + jy) + + // Find the limiting years for the Jalaali year jy. + for (i = 1; i < bl; i += 1) { + jm = breaks[i] + jump = jm - jp + if (jy < jm) + break + leapJ = leapJ + div(jump, 33) * 8 + div(mod(jump, 33), 4) + jp = jm + } + n = jy - jp + + // Find the number of leap years from AD 621 to the beginning + // of the current Jalaali year in the Persian calendar. + leapJ = leapJ + div(n, 33) * 8 + div(mod(n, 33) + 3, 4) + if (mod(jump, 33) === 4 && jump - n === 4) + leapJ += 1 + + // And the same in the Gregorian calendar (until the year gy). + leapG = div(gy, 4) - div((div(gy, 100) + 1) * 3, 4) - 150 + + // Determine the Gregorian date of Farvardin the 1st. + march = 20 + leapJ - leapG + + // Find how many years have passed since the last leap year. + if (jump - n < 6) + n = n - jump + div(jump + 4, 33) * 33 + leap = mod(mod(n + 1, 33) - 1, 4) + if (leap === -1) { + leap = 4 + } + + return { leap: leap + , gy: gy + , march: march + } + } + + /* + Converts a date of the Jalaali calendar to the Julian Day number. + + @param jy Jalaali year (1 to 3100) + @param jm Jalaali month (1 to 12) + @param jd Jalaali day (1 to 29/31) + @return Julian Day number + */ + function j2d(jy, jm, jd) { + var r = jalCal(jy) + return g2d(r.gy, 3, r.march) + (jm - 1) * 31 - div(jm, 7) * (jm - 7) + jd - 1 + } + + /* + Converts the Julian Day number to a date in the Jalaali calendar. + + @param jdn Julian Day number + @return + jy: Jalaali year (1 to 3100) + jm: Jalaali month (1 to 12) + jd: Jalaali day (1 to 29/31) + */ + function d2j(jdn) { + var gy = d2g(jdn).gy // Calculate Gregorian year (gy). + , jy = gy - 621 + , r = jalCal(jy) + , jdn1f = g2d(gy, 3, r.march) + , jd + , jm + , k + + // Find number of days that passed since 1 Farvardin. + k = jdn - jdn1f + if (k >= 0) { + if (k <= 185) { + // The first 6 months. + jm = 1 + div(k, 31) + jd = mod(k, 31) + 1 + return { jy: jy + , jm: jm + , jd: jd + } + } else { + // The remaining months. + k -= 186 + } + } else { + // Previous Jalaali year. + jy -= 1 + k += 179 + if (r.leap === 1) + k += 1 + } + jm = 7 + div(k, 30) + jd = mod(k, 30) + 1 + return { jy: jy + , jm: jm + , jd: jd + } + } + + /* + Calculates the Julian Day number from Gregorian or Julian + calendar dates. This integer number corresponds to the noon of + the date (i.e. 12 hours of Universal Time). + The procedure was tested to be good since 1 March, -100100 (of both + calendars) up to a few million years into the future. + + @param gy Calendar year (years BC numbered 0, -1, -2, ...) + @param gm Calendar month (1 to 12) + @param gd Calendar day of the month (1 to 28/29/30/31) + @return Julian Day number + */ + function g2d(gy, gm, gd) { + var d = div((gy + div(gm - 8, 6) + 100100) * 1461, 4) + + div(153 * mod(gm + 9, 12) + 2, 5) + + gd - 34840408 + d = d - div(div(gy + 100100 + div(gm - 8, 6), 100) * 3, 4) + 752 + return d + } + + /* + Calculates Gregorian and Julian calendar dates from the Julian Day number + (jdn) for the period since jdn=-34839655 (i.e. the year -100100 of both + calendars) to some millions years ahead of the present. + + @param jdn Julian Day number + @return + gy: Calendar year (years BC numbered 0, -1, -2, ...) + gm: Calendar month (1 to 12) + gd: Calendar day of the month M (1 to 28/29/30/31) + */ + function d2g(jdn) { + var j + , i + , gd + , gm + , gy + j = 4 * jdn + 139361631 + j = j + div(div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908 + i = div(mod(j, 1461), 4) * 5 + 308 + gd = div(mod(i, 153), 5) + 1 + gm = mod(div(i, 153), 12) + 1 + gy = div(j, 1461) - 100100 + div(8 - gm, 6) + return { gy: gy + , gm: gm + , gd: gd + } + } + + /* + Utility helper functions. + */ + + function div(a, b) { + return ~~(a / b) + } + + function mod(a, b) { + return a - ~~(a / b) * b + } + }) + require.register("moment-jalaali", function (exports, module) { + + module.exports = jMoment + + var moment = require('moment') + , jalaali = require('jalaali-js') + + /************************************ + Constants + ************************************/ + + var formattingTokens = /(\[[^\[]*\])|(\\)?j(Mo|MM?M?M?|Do|DDDo|DD?D?D?|w[o|w]?|YYYYY|YYYY|YY|gg(ggg?)?|)|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g + , localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS?|LL?L?L?|l{1,4})/g + + , parseTokenOneOrTwoDigits = /\d\d?/ + , parseTokenOneToThreeDigits = /\d{1,3}/ + , parseTokenThreeDigits = /\d{3}/ + , parseTokenFourDigits = /\d{1,4}/ + , parseTokenSixDigits = /[+\-]?\d{1,6}/ + , parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i + , parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i + , parseTokenT = /T/i + , parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/ + , symbolMap = { + '1': '۱', + '2': '۲', + '3': '۳', + '4': '۴', + '5': '۵', + '6': '۶', + '7': '۷', + '8': '۸', + '9': '۹', + '0': '۰' + } + , numberMap = { + '۱': '1', + '۲': '2', + '۳': '3', + '۴': '4', + '۵': '5', + '۶': '6', + '۷': '7', + '۸': '8', + '۹': '9', + '۰': '0' + } + + + , unitAliases = + { jm: 'jmonth' + , jmonths: 'jmonth' + , jy: 'jyear' + , jyears: 'jyear' + } + + , formatFunctions = {} + + , ordinalizeTokens = 'DDD w M D'.split(' ') + , paddedTokens = 'M D w'.split(' ') + + , formatTokenFunctions = + { jM: function () { + return this.jMonth() + 1 + } + , jMMM: function (format) { + return this.localeData().jMonthsShort(this, format) + } + , jMMMM: function (format) { + return this.localeData().jMonths(this, format) + } + , jD: function () { + return this.jDate() + } + , jDDD: function () { + return this.jDayOfYear() + } + , jw: function () { + return this.jWeek() + } + , jYY: function () { + return leftZeroFill(this.jYear() % 100, 2) + } + , jYYYY: function () { + return leftZeroFill(this.jYear(), 4) + } + , jYYYYY: function () { + return leftZeroFill(this.jYear(), 5) + } + , jgg: function () { + return leftZeroFill(this.jWeekYear() % 100, 2) + } + , jgggg: function () { + return this.jWeekYear() + } + , jggggg: function () { + return leftZeroFill(this.jWeekYear(), 5) + } + } + + function padToken(func, count) { + return function (a) { + return leftZeroFill(func.call(this, a), count) + } + } + function ordinalizeToken(func, period) { + return function (a) { + return this.localeData().ordinal(func.call(this, a), period) + } + } + + (function () { + var i + while (ordinalizeTokens.length) { + i = ordinalizeTokens.pop() + formatTokenFunctions['j' + i + 'o'] = ordinalizeToken(formatTokenFunctions['j' + i], i) + } + while (paddedTokens.length) { + i = paddedTokens.pop() + formatTokenFunctions['j' + i + i] = padToken(formatTokenFunctions['j' + i], 2) + } + formatTokenFunctions.jDDDD = padToken(formatTokenFunctions.jDDD, 3) + }()) + + /************************************ + Helpers + ************************************/ + + function extend(a, b) { + var key + for (key in b) + if (b.hasOwnProperty(key)) + a[key] = b[key] + return a + } + + function leftZeroFill(number, targetLength) { + var output = number + '' + while (output.length < targetLength) + output = '0' + output + return output + } + + function isArray(input) { + return Object.prototype.toString.call(input) === '[object Array]' + } + +// function compareArrays(array1, array2) { +// var len = Math.min(array1.length, array2.length) +// , lengthDiff = Math.abs(array1.length - array2.length) +// , diffs = 0 +// , i +// for (i = 0; i < len; i += 1) +// if (~~array1[i] !== ~~array2[i]) +// diffs += 1 +// return diffs + lengthDiff +// } + + function normalizeUnits(units) { + if (units) { + var lowered = units.toLowerCase() + units = unitAliases[lowered] || lowered + } + return units + } + + function setDate(m, year, month, date) { + var d = m._d + if (isNaN(year)) { + m._isValid = false + } + if (m._isUTC) { + /*eslint-disable new-cap*/ + m._d = new Date(Date.UTC(year, month, date, + d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds())) + /*eslint-enable new-cap*/ + } else { + m._d = new Date(year, month, date, + d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()) + } + } + + function objectCreate(parent) { + function F() {} + F.prototype = parent + return new F() + } + + function getPrototypeOf(object) { + if (Object.getPrototypeOf) + return Object.getPrototypeOf(object) + else if (''.__proto__) + return object.__proto__ + else + return object.constructor.prototype + } + + /************************************ + Languages + ************************************/ + extend(getPrototypeOf(moment.localeData()), + { _jMonths: [ 'Farvardin' + , 'Ordibehesht' + , 'Khordaad' + , 'Tir' + , 'Amordaad' + , 'Shahrivar' + , 'Mehr' + , 'Aabaan' + , 'Aazar' + , 'Dey' + , 'Bahman' + , 'Esfand' + ] + , jMonths: function (m) { + return this._jMonths[m.jMonth()] + } + + , _jMonthsShort: [ 'Far' + , 'Ord' + , 'Kho' + , 'Tir' + , 'Amo' + , 'Sha' + , 'Meh' + , 'Aab' + , 'Aaz' + , 'Dey' + , 'Bah' + , 'Esf' + ] + , jMonthsShort: function (m) { + return this._jMonthsShort[m.jMonth()] + } + + , jMonthsParse: function (monthName) { + var i + , mom + , regex + if (!this._jMonthsParse) + this._jMonthsParse = [] + for (i = 0; i < 12; i += 1) { + // Make the regex if we don't have it already. + if (!this._jMonthsParse[i]) { + mom = jMoment([2000, (2 + i) % 12, 25]) + regex = '^' + this.jMonths(mom, '') + '|^' + this.jMonthsShort(mom, '') + this._jMonthsParse[i] = new RegExp(regex.replace('.', ''), 'i') + } + // Test the regex. + if (this._jMonthsParse[i].test(monthName)) + return i + } + } + } + ) + + /************************************ + Formatting + ************************************/ + + function makeFormatFunction(format) { + var array = format.match(formattingTokens) + , length = array.length + , i + + for (i = 0; i < length; i += 1) + if (formatTokenFunctions[array[i]]) + array[i] = formatTokenFunctions[array[i]] + + return function (mom) { + var output = '' + for (i = 0; i < length; i += 1) + output += array[i] instanceof Function ? '[' + array[i].call(mom, format) + ']' : array[i] + return output + } + } + + /************************************ + Parsing + ************************************/ + + function getParseRegexForToken(token, config) { + switch (token) { + case 'jDDDD': + return parseTokenThreeDigits + case 'jYYYY': + return parseTokenFourDigits + case 'jYYYYY': + return parseTokenSixDigits + case 'jDDD': + return parseTokenOneToThreeDigits + case 'jMMM': + case 'jMMMM': + return parseTokenWord + case 'jMM': + case 'jDD': + case 'jYY': + case 'jM': + case 'jD': + return parseTokenOneOrTwoDigits + case 'DDDD': + return parseTokenThreeDigits + case 'YYYY': + return parseTokenFourDigits + case 'YYYYY': + return parseTokenSixDigits + case 'S': + case 'SS': + case 'SSS': + case 'DDD': + return parseTokenOneToThreeDigits + case 'MMM': + case 'MMMM': + case 'dd': + case 'ddd': + case 'dddd': + return parseTokenWord + case 'a': + case 'A': + return moment.localeData(config._l)._meridiemParse + case 'X': + return parseTokenTimestampMs + case 'Z': + case 'ZZ': + return parseTokenTimezone + case 'T': + return parseTokenT + case 'MM': + case 'DD': + case 'YY': + case 'HH': + case 'hh': + case 'mm': + case 'ss': + case 'M': + case 'D': + case 'd': + case 'H': + case 'h': + case 'm': + case 's': + return parseTokenOneOrTwoDigits + default: + return new RegExp(token.replace('\\', '')) + } + } + + function addTimeToArrayFromToken(token, input, config) { + var a + , datePartArray = config._a + + switch (token) { + case 'jM': + case 'jMM': + datePartArray[1] = input == null ? 0 : ~~input - 1 + break + case 'jMMM': + case 'jMMMM': + a = moment.localeData(config._l).jMonthsParse(input) + if (a != null) + datePartArray[1] = a + else + config._isValid = false + break + case 'jD': + case 'jDD': + case 'jDDD': + case 'jDDDD': + if (input != null) + datePartArray[2] = ~~input + break + case 'jYY': + datePartArray[0] = ~~input + (~~input > 47 ? 1300 : 1400) + break + case 'jYYYY': + case 'jYYYYY': + datePartArray[0] = ~~input + } + if (input == null) + config._isValid = false + } + + function dateFromArray(config) { + var g + , j + , jy = config._a[0] + , jm = config._a[1] + , jd = config._a[2] + + if ((jy == null) && (jm == null) && (jd == null)) + return [0, 0, 1] + jy = jy != null ? jy : 0 + jm = jm != null ? jm : 0 + jd = jd != null ? jd : 1 + if (jd < 1 || jd > jMoment.jDaysInMonth(jy, jm) || jm < 0 || jm > 11) + config._isValid = false + g = toGregorian(jy, jm, jd) + j = toJalaali(g.gy, g.gm, g.gd) + if (isNaN(g.gy)) + config._isValid = false + config._jDiff = 0 + if (~~j.jy !== jy) + config._jDiff += 1 + if (~~j.jm !== jm) + config._jDiff += 1 + if (~~j.jd !== jd) + config._jDiff += 1 + return [g.gy, g.gm, g.gd] + } + + function makeDateFromStringAndFormat(config) { + var tokens = config._f.match(formattingTokens) + , string = config._i + '' + , len = tokens.length + , i + , token + , parsedInput + + config._a = [] + + for (i = 0; i < len; i += 1) { + token = tokens[i] + parsedInput = (getParseRegexForToken(token, config).exec(string) || [])[0] + if (parsedInput) + string = string.slice(string.indexOf(parsedInput) + parsedInput.length) + if (formatTokenFunctions[token]) + addTimeToArrayFromToken(token, parsedInput, config) + } + if (string) + config._il = string + return dateFromArray(config) + } + + function makeDateFromStringAndArray(config, utc) { + var len = config._f.length + , i + , format + , tempMoment + , bestMoment + , currentScore + , scoreToBeat + + if (len === 0) { + return makeMoment(new Date(NaN)) + } + + for (i = 0; i < len; i += 1) { + format = config._f[i] + currentScore = 0 + tempMoment = makeMoment(config._i, format, config._l, config._strict, utc) + + if (!tempMoment.isValid()) continue + + // currentScore = compareArrays(tempMoment._a, tempMoment.toArray()) + currentScore += tempMoment._jDiff + if (tempMoment._il) + currentScore += tempMoment._il.length + if (scoreToBeat == null || currentScore < scoreToBeat) { + scoreToBeat = currentScore + bestMoment = tempMoment + } + } + + return bestMoment + } + + function removeParsedTokens(config) { + var string = config._i + '' + , input = '' + , format = '' + , array = config._f.match(formattingTokens) + , len = array.length + , i + , match + , parsed + + for (i = 0; i < len; i += 1) { + match = array[i] + parsed = (getParseRegexForToken(match, config).exec(string) || [])[0] + if (parsed) + string = string.slice(string.indexOf(parsed) + parsed.length) + if (!(formatTokenFunctions[match] instanceof Function)) { + format += match + if (parsed) + input += parsed + } + } + config._i = input + config._f = format + } + + /************************************ + Week of Year + ************************************/ + + function jWeekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) { + var end = firstDayOfWeekOfYear - firstDayOfWeek + , daysToDayOfWeek = firstDayOfWeekOfYear - mom.day() + , adjustedMoment + + if (daysToDayOfWeek > end) { + daysToDayOfWeek -= 7 + } + if (daysToDayOfWeek < end - 7) { + daysToDayOfWeek += 7 + } + adjustedMoment = jMoment(mom).add(daysToDayOfWeek, 'd') + return { week: Math.ceil(adjustedMoment.jDayOfYear() / 7) + , year: adjustedMoment.jYear() + } + } + + /************************************ + Top Level Functions + ************************************/ + var maxTimestamp = 57724432199999 + + function makeMoment(input, format, lang, strict, utc) { + if (typeof lang === 'boolean') { + strict = lang + lang = undefined + } + + if (format && typeof format === 'string') + format = fixFormat(format, moment) + + var config = + { _i: input + , _f: format + , _l: lang + , _strict: strict + , _isUTC: utc + } + , date + , m + , jm + , origInput = input + , origFormat = format + if (format) { + if (isArray(format)) { + return makeDateFromStringAndArray(config, utc) + } else { + date = makeDateFromStringAndFormat(config) + removeParsedTokens(config) + format = 'YYYY-MM-DD-' + config._f + input = leftZeroFill(date[0], 4) + '-' + + leftZeroFill(date[1] + 1, 2) + '-' + + leftZeroFill(date[2], 2) + '-' + + config._i + } + } + if (utc) + m = moment.utc(input, format, lang, strict) + else + m = moment(input, format, lang, strict) + if (config._isValid === false) + m._isValid = false + m._jDiff = config._jDiff || 0 + jm = objectCreate(jMoment.fn) + extend(jm, m) + if (strict && format && jm.isValid()) { + jm._isValid = jm.format(origFormat) === origInput + } + if (m._d.getTime() > maxTimestamp) { + jm._isValid = false + } + return jm + } + + function jMoment(input, format, lang, strict) { + return makeMoment(input, format, lang, strict, false) + } + + extend(jMoment, moment) + jMoment.fn = objectCreate(moment.fn) + + jMoment.utc = function (input, format, lang, strict) { + return makeMoment(input, format, lang, strict, true) + } + + jMoment.unix = function (input) { + return makeMoment(input * 1000) + } + + /************************************ + jMoment Prototype + ************************************/ + + function fixFormat(format, _moment) { + var i = 5 + var replace = function (input) { + return _moment.localeData().longDateFormat(input) || input + } + while (i > 0 && localFormattingTokens.test(format)) { + i -= 1 + format = format.replace(localFormattingTokens, replace) + } + return format + } + + jMoment.fn.format = function (format) { + + if (format) { + format = fixFormat(format, this) + + if (!formatFunctions[format]) { + formatFunctions[format] = makeFormatFunction(format) + } + format = formatFunctions[format](this) + } + return moment.fn.format.call(this, format) + } + + jMoment.fn.jYear = function (input) { + var lastDay + , j + , g + if (typeof input === 'number') { + j = toJalaali(this.year(), this.month(), this.date()) + lastDay = Math.min(j.jd, jMoment.jDaysInMonth(input, j.jm)) + g = toGregorian(input, j.jm, lastDay) + setDate(this, g.gy, g.gm, g.gd) + moment.updateOffset(this) + return this + } else { + return toJalaali(this.year(), this.month(), this.date()).jy + } + } + + jMoment.fn.jMonth = function (input) { + var lastDay + , j + , g + if (input != null) { + if (typeof input === 'string') { + input = this.localeData().jMonthsParse(input) + if (typeof input !== 'number') + return this + } + j = toJalaali(this.year(), this.month(), this.date()) + lastDay = Math.min(j.jd, jMoment.jDaysInMonth(j.jy, input)) + this.jYear(j.jy + div(input, 12)) + input = mod(input, 12) + if (input < 0) { + input += 12 + this.jYear(this.jYear() - 1) + } + g = toGregorian(this.jYear(), input, lastDay) + setDate(this, g.gy, g.gm, g.gd) + moment.updateOffset(this) + return this + } else { + return toJalaali(this.year(), this.month(), this.date()).jm + } + } + + jMoment.fn.jDate = function (input) { + var j + , g + if (typeof input === 'number') { + j = toJalaali(this.year(), this.month(), this.date()) + g = toGregorian(j.jy, j.jm, input) + setDate(this, g.gy, g.gm, g.gd) + moment.updateOffset(this) + return this + } else { + return toJalaali(this.year(), this.month(), this.date()).jd + } + } + + jMoment.fn.jDayOfYear = function (input) { + var dayOfYear = Math.round((jMoment(this).startOf('day') - jMoment(this).startOf('jYear')) / 864e5) + 1 + return input == null ? dayOfYear : this.add(input - dayOfYear, 'd') + } + + jMoment.fn.jWeek = function (input) { + var week = jWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).week + return input == null ? week : this.add((input - week) * 7, 'd') + } + + jMoment.fn.jWeekYear = function (input) { + var year = jWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year + return input == null ? year : this.add(input - year, 'y') + } + + jMoment.fn.add = function (val, units) { + var temp + if (units !== null && !isNaN(+units)) { + temp = val + val = units + units = temp + } + units = normalizeUnits(units) + if (units === 'jyear') { + this.jYear(this.jYear() + val) + } else if (units === 'jmonth') { + this.jMonth(this.jMonth() + val) + } else { + moment.fn.add.call(this, val, units) + if (isNaN(this.jYear())) { + this._isValid = false + } + } + return this + } + + jMoment.fn.subtract = function (val, units) { + var temp + if (units !== null && !isNaN(+units)) { + temp = val + val = units + units = temp + } + units = normalizeUnits(units) + if (units === 'jyear') { + this.jYear(this.jYear() - val) + } else if (units === 'jmonth') { + this.jMonth(this.jMonth() - val) + } else { + moment.fn.subtract.call(this, val, units) + } + return this + } + + jMoment.fn.startOf = function (units) { + units = normalizeUnits(units) + if (units === 'jyear' || units === 'jmonth') { + if (units === 'jyear') { + this.jMonth(0) + } + this.jDate(1) + this.hours(0) + this.minutes(0) + this.seconds(0) + this.milliseconds(0) + return this + } else { + return moment.fn.startOf.call(this, units) + } + } + + jMoment.fn.endOf = function (units) { + units = normalizeUnits(units) + if (units === undefined || units === 'milisecond') { + return this + } + return this.startOf(units).add(1, (units === 'isoweek' ? 'week' : units)).subtract(1, 'ms') + } + + jMoment.fn.isSame = function (other, units) { + units = normalizeUnits(units) + if (units === 'jyear' || units === 'jmonth') { + return moment.fn.isSame.call(this.startOf(units), other.startOf(units)) + } + return moment.fn.isSame.call(this, other, units) + } + + jMoment.fn.clone = function () { + return jMoment(this) + } + + jMoment.fn.jYears = jMoment.fn.jYear + jMoment.fn.jMonths = jMoment.fn.jMonth + jMoment.fn.jDates = jMoment.fn.jDate + jMoment.fn.jWeeks = jMoment.fn.jWeek + + /************************************ + jMoment Statics + ************************************/ + + jMoment.jDaysInMonth = function (year, month) { + year += div(month, 12) + month = mod(month, 12) + if (month < 0) { + month += 12 + year -= 1 + } + if (month < 6) { + return 31 + } else if (month < 11) { + return 30 + } else if (jMoment.jIsLeapYear(year)) { + return 30 + } else { + return 29 + } + } + + jMoment.jIsLeapYear = jalaali.isLeapJalaaliYear + + jMoment.loadPersian = function (args) { + var usePersianDigits = args !== undefined && args.hasOwnProperty('usePersianDigits') ? args.usePersianDigits : false + var dialect = args !== undefined && args.hasOwnProperty('dialect') ? args.dialect : 'persian' + moment.locale('fa') + moment.updateLocale('fa' + , { months: ('ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر').split('_') + , monthsShort: ('ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر').split('_') + , weekdays: + { + 'persian': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'), + 'persian-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_') + }[dialect] + , weekdaysShort: + { + 'persian': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_آدینه_شنبه').split('_'), + 'persian-modern': ('یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه').split('_') + }[dialect] + , weekdaysMin: + { + 'persian': 'ی_د_س_چ_پ_آ_ش'.split('_'), + 'persian-modern': 'ی_د_س_چ_پ_ج_ش'.split('_') + }[dialect] + , longDateFormat: + { LT: 'HH:mm' + , L: 'jYYYY/jMM/jDD' + , LL: 'jD jMMMM jYYYY' + , LLL: 'jD jMMMM jYYYY LT' + , LLLL: 'dddd، jD jMMMM jYYYY LT' + } + , calendar: + { sameDay: '[امروز ساعت] LT' + , nextDay: '[فردا ساعت] LT' + , nextWeek: 'dddd [ساعت] LT' + , lastDay: '[دیروز ساعت] LT' + , lastWeek: 'dddd [ی پیش ساعت] LT' + , sameElse: 'L' + } + , relativeTime: + { future: 'در %s' + , past: '%s پیش' + , s: 'چند ثانیه' + , m: '1 دقیقه' + , mm: '%d دقیقه' + , h: '1 ساعت' + , hh: '%d ساعت' + , d: '1 روز' + , dd: '%d روز' + , M: '1 ماه' + , MM: '%d ماه' + , y: '1 سال' + , yy: '%d سال' + } + , preparse: function (string) { + if (usePersianDigits) { + return string.replace(/[۰-۹]/g, function (match) { + return numberMap[match] + }).replace(/،/g, ',') + } + return string + } + , postformat: function (string) { + if (usePersianDigits) { + return string.replace(/\d/g, function (match) { + return symbolMap[match] + }).replace(/,/g, '،') + } + return string + } + , ordinal: '%dم' + , week: + { dow: 6 // Saturday is the first day of the week. + , doy: 12 // The week that contains Jan 1st is the first week of the year. + } + , meridiem: function (hour) { + return hour < 12 ? 'ق.ظ' : 'ب.ظ' + } + , jMonths: + { + 'persian': ('فروردین_اردیبهشت_خرداد_تیر_امرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند').split('_'), + 'persian-modern': ('فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند').split('_') + }[dialect] + , jMonthsShort: + { + 'persian': 'فرو_ارد_خرد_تیر_امر_شهر_مهر_آبا_آذر_دی_بهم_اسف'.split('_'), + 'persian-modern': 'فرو_ارد_خرد_تیر_مرد_شهر_مهر_آبا_آذر_دی_بهم_اسف'.split('_') + }[dialect] + } + ) + } + + jMoment.jConvert = { toJalaali: toJalaali + , toGregorian: toGregorian + } + + /************************************ + Jalaali Conversion + ************************************/ + + function toJalaali(gy, gm, gd) { + try { + var j = jalaali.toJalaali(gy, gm + 1, gd) + j.jm -= 1 + return j + } catch (e) { + return { + jy: NaN + , jm: NaN + , jd: NaN + } + } + } + + function toGregorian(jy, jm, jd) { + try { + var g = jalaali.toGregorian(jy, jm + 1, jd) + g.gm -= 1 + return g + } catch (e) { + return { + gy: NaN + , gm: NaN + , gd: NaN + } + } + } + + /* + Utility helper functions. + */ + + function div(a, b) { + return ~~(a / b) + } + + function mod(a, b) { + return a - ~~(a / b) * b + } + }); + + if (typeof exports == "object") { + module.exports = require("moment-jalaali"); + } else if (typeof define == "function" && define.amd) { + define([], function(){ return require("moment-jalaali"); }); + } else { + this["moment"] = require("moment-jalaali"); + } +})(); \ No newline at end of file diff --git a/web/assets/persian-datepicker/persian-datepicker.min.css b/web/assets/persian-datepicker/persian-datepicker.min.css new file mode 100644 index 00000000..bbbef736 --- /dev/null +++ b/web/assets/persian-datepicker/persian-datepicker.min.css @@ -0,0 +1 @@ +jdp-overlay{height:0;width:0}jdp-container{-moz-animation:.3s cubic-bezier(.23,1,.32,1) jdpOpenAnimation;-webkit-animation:.3s cubic-bezier(.23,1,.32,1) jdpOpenAnimation;animation:.3s cubic-bezier(.23,1,.32,1) jdpOpenAnimation;background:#fff;border-radius:4px;box-shadow:0 1px 6px rgba(0,0,0,.12),0 1px 4px rgba(0,0,0,.24);direction:rtl;display:none;max-width:307.875px;min-width:307.875px;overflow:hidden;padding:.5rem 0;position:absolute;-ms-touch-action:manipulation;touch-action:manipulation;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}jdp-container,jdp-container *,jdp-container :after,jdp-container :before{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}jdp-container .jdp-icon-minus,jdp-container .jdp-icon-plus{border:1px solid #e6e6e6;border-radius:4px;cursor:pointer;display:inline-block;flex:none;overflow:hidden;text-align:center;text-decoration:none;vertical-align:middle}jdp-container .jdp-icon-minus svg,jdp-container .jdp-icon-plus svg{height:1.5rem;padding:.25rem;vertical-align:middle;width:1.5rem}jdp-container .jdp-icon-minus.not-in-range,jdp-container .jdp-icon-plus.not-in-range{cursor:not-allowed}jdp-container .jdp-icon-minus.not-in-range svg,jdp-container .jdp-icon-plus.not-in-range svg{opacity:.3}jdp-container .jdp-months,jdp-container .jdp-years{fill:rgba(0,0,0,.9);color:rgba(0,0,0,.9);display:-webkit-inline-box;display:-webkit-flex;display:-ms-inline-flexbox;display:inline-flex;font-size:120%;margin:0 2.5%}jdp-container .jdp-months{width:50%}jdp-container .jdp-years{width:40%}jdp-container .jdp-month,jdp-container .jdp-month input,jdp-container .jdp-month select,jdp-container .jdp-time,jdp-container .jdp-time input,jdp-container .jdp-time select,jdp-container .jdp-year,jdp-container .jdp-year input,jdp-container .jdp-year select{background:#fff;border:none;border-radius:0;color:inherit;display:inline-block;font-family:inherit;font-size:inherit;font-weight:300;height:auto;line-height:inherit;margin:0;outline:0;padding:0;text-align:center;vertical-align:initial;width:100%}jdp-container .jdp-month input:active,jdp-container .jdp-month input:focus,jdp-container .jdp-month select:active,jdp-container .jdp-month select:focus,jdp-container .jdp-month:active,jdp-container .jdp-month:focus,jdp-container .jdp-time input:active,jdp-container .jdp-time input:focus,jdp-container .jdp-time select:active,jdp-container .jdp-time select:focus,jdp-container .jdp-time:active,jdp-container .jdp-time:focus,jdp-container .jdp-year input:active,jdp-container .jdp-year input:focus,jdp-container .jdp-year select:active,jdp-container .jdp-year select:focus,jdp-container .jdp-year:active,jdp-container .jdp-year:focus{outline:0}jdp-container .jdp-month input option,jdp-container .jdp-month option,jdp-container .jdp-month select option,jdp-container .jdp-time input option,jdp-container .jdp-time option,jdp-container .jdp-time select option,jdp-container .jdp-year input option,jdp-container .jdp-year option,jdp-container .jdp-year select option{font-size:95%;min-height:1.3rem;outline:0;padding:0}jdp-container .jdp-month:hover,jdp-container .jdp-time:hover,jdp-container .jdp-year:hover{filter:brightness(.9)}jdp-container .jdp-month input,jdp-container .jdp-time input,jdp-container .jdp-year input{-webkit-appearance:none;-moz-appearance:textfield;cursor:text}jdp-container .jdp-month input::-webkit-inner-spin-button,jdp-container .jdp-month input::-webkit-outer-spin-button,jdp-container .jdp-time input::-webkit-inner-spin-button,jdp-container .jdp-time input::-webkit-outer-spin-button,jdp-container .jdp-year input::-webkit-inner-spin-button,jdp-container .jdp-year input::-webkit-outer-spin-button{-webkit-appearance:none}jdp-container .jdp-month select,jdp-container .jdp-time select,jdp-container .jdp-year select{-webkit-appearance:menulist;-moz-appearance:menulist;cursor:pointer;position:relative}jdp-container .jdp-days{-ms-flex-pack:justify;display:inline-block;display:-ms-flexbox;display:flex;flex-wrap:wrap;-ms-flex-wrap:wrap;justify-content:space-around;outline:0;padding:.5rem 0 0;text-align:left;width:100%}jdp-container .jdp-day,jdp-container .jdp-day-name{background:0 0;border:1px solid transparent;color:rgba(0,0,0,.9);display:inline-block;flex-basis:14.2857143%;font-weight:400;height:31px;justify-content:center;line-height:31px;margin:2px 0;position:relative;text-align:center;width:14.2857143%}jdp-container .jdp-day-name.today,jdp-container .jdp-day.today{border-color:rgba(0,0,0,.3)}.dark jdp-container .jdp-day-name.selected,.dark jdp-container .jdp-day.selected,jdp-container .jdp-day-name.selected,jdp-container .jdp-day.selected{background-color:#008771!important;color:#fff!important;opacity:1!important}.dark jdp-container .jdp-day-name.holly-day,.dark jdp-container .jdp-day-name.last-week,.dark jdp-container .jdp-day.holly-day,.dark jdp-container .jdp-day.last-week,jdp-container .jdp-day-name.holly-day,jdp-container .jdp-day-name.last-week,jdp-container .jdp-day.holly-day,jdp-container .jdp-day.last-week{color:#f44336}.dark jdp-container .jdp-day.not-in-month,jdp-container .jdp-day.not-in-month{opacity:.4}jdp-container .jdp-day.disabled-day{cursor:not-allowed;opacity:.15}jdp-container .jdp-day:not(.disabled-day){border-radius:4px;cursor:pointer;transition:.1s linear}jdp-container .jdp-day:not(.disabled-day):hover{background:rgba(0,0,0,.1);transform:scale(1.15);z-index:1}jdp-container .jdp-day-name{background-color:rgba(0,0,0,.1);border-radius:0;cursor:default;font-size:90%;font-weight:900}jdp-container .jdp-footer{-ms-flex-pack:justify;display:inline-block;display:-ms-flexbox;display:flex;flex-wrap:nowrap;-ms-flex-wrap:nowrap;justify-content:space-between;outline:0;padding:.5rem .5rem 0;width:100%}jdp-container .jdp-btn-close,jdp-container .jdp-btn-empty,jdp-container .jdp-btn-today{background:#008771;border-radius:5px;color:#fff;cursor:pointer;display:inline-block;font-size:90%;font-weight:400;padding:.3em .6em;text-align:center}jdp-container .jdp-btn-close.disabled-btn,jdp-container .jdp-btn-empty.disabled-btn,jdp-container .jdp-btn-today.disabled-btn{cursor:not-allowed;opacity:.2}@media only screen and (max-width:481px){jdp-overlay{backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);background-color:rgba(0,0,0,.3);display:none;height:100%;left:0;position:fixed;top:0;width:100%}jdp-container{-moz-animation:.3s cubic-bezier(.23,1,.32,1) jdpOpenAnimationMobile;-webkit-animation:.3s cubic-bezier(.23,1,.32,1) jdpOpenAnimationMobile;animation:.3s cubic-bezier(.23,1,.32,1) jdpOpenAnimationMobile;border-radius:4px 4px 0 0;bottom:0!important;left:50%!important;max-width:100%;min-width:280px;top:unset!important;transform:translateX(-50%)!important;width:100%}jdp-container .jdp-footer{margin:.5rem 0}jdp-container .jdp-btn-close,jdp-container .jdp-btn-empty,jdp-container .jdp-btn-today{font-size:100%;padding:.5em .8em}jdp-container .jdp-btn-today~.jdp-btn-empty{margin-left:auto;margin-right:1em}}jdp-container .jdp-time-container{display:flex;padding:0}jdp-container .jdp-time-container .jdp-time{flex:auto;margin:0 .5rem;position:relative}jdp-container .jdp-time-container .jdp-time select{background:rgba(0,0,0,.03);border-radius:5px;padding:.5rem 1rem .5rem 7px}jdp-container .jdp-time-container .jdp-time:after{content:":";font-size:1.5rem;height:100%;position:absolute;right:-.7rem;top:50%;transform:translateY(-50%)}jdp-container .jdp-time-container .jdp-time:first-child:after{display:none}jdp-container .jdp-time-container.jdp-only-time .jdp-time select{font-size:1.5rem;padding:.8rem 1rem .8rem 7px}jdp-container .jdp-time-container.jdp-only-time .jdp-time:after{font-size:2.3rem;position:absolute;right:-.8rem}@-webkit-keyframes jdpOpenAnimation{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes jdpOpenAnimation{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@-webkit-keyframes jdpOpenAnimationMobile{0%{bottom:-10%;opacity:0}to{bottom:0;opacity:1}}@keyframes jdpOpenAnimationMobile{0%{margin-bottom:-20%;opacity:0}to{margin-bottom:0;opacity:1}}.dark jdp-overlay{background-color:#181f2c}.dark jdp-container{background:#181f2c;border-color:#2c3950;box-shadow:0 1px 6px rgba(255,255,255,.12),0 1px 4px rgba(255,255,255,.24);color:#fff}.dark jdp-container .jdp-icon-minus,.dark jdp-container .jdp-icon-plus{border:1px solid #ccc}.dark jdp-container .jdp-months,.dark jdp-container .jdp-years{fill:rgba(255,255,255,0.9);color:rgba(255,255,255,.9)}.dark jdp-container .jdp-month,.dark jdp-container .jdp-month input,.dark jdp-container .jdp-month select,.dark jdp-container .jdp-time,.dark jdp-container .jdp-time input,.dark jdp-container .jdp-time select,.dark jdp-container .jdp-year,.dark jdp-container .jdp-year input,.dark jdp-container .jdp-year select{background:#222d42;color:#fff}.dark jdp-container .jdp-day,.dark jdp-container .jdp-day-name{border:1px solid transparent;color:rgba(255,255,255,.9)}.dark jdp-container .jdp-day-name.today,.dark jdp-container .jdp-day.today{border-color:rgba(255,255,255,.3)}.dark jdp-container .jdp-day.disabled-day{opacity:.15}.dark jdp-container .jdp-day:not(.disabled-day):hover{background:rgba(255,255,255,.1);transform:scale(1.15);z-index:1}.dark jdp-container .jdp-day-name{background-color:#222d42}.dark jdp-container .jdp-footer{background:#181f2c}.dark jdp-container .jdp-btn-close,.dark jdp-container .jdp-btn-empty,.dark jdp-container .jdp-btn-today{background:#008771;color:#fff}.dark jdp-container .jdp-btn-close.disabled-btn,.dark jdp-container .jdp-btn-empty.disabled-btn,.dark jdp-container .jdp-btn-today.disabled-btn{opacity:.2} \ No newline at end of file diff --git a/web/assets/persian-datepicker/persian-datepicker.min.js b/web/assets/persian-datepicker/persian-datepicker.min.js new file mode 100644 index 00000000..bff7bfae --- /dev/null +++ b/web/assets/persian-datepicker/persian-datepicker.min.js @@ -0,0 +1 @@ +!function(){"use strict";!function(){var t=void 0;function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var e=function(t){return void 0===t},i=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},a=function(t){return JSON.parse(JSON.stringify(t))},r=function(t){if(!t||!t.constructor||t.nodeType)return!1;try{return"{}"===JSON.stringify(t)}catch(t){return!0}},s=function o(){for(var a,s,u,h,d,c=arguments.length,p=new Array(c),m=0;m1&&void 0!==arguments[1]?arguments[1]:2,e=String(Math.abs(t)),i=e.length,o="";for(t<0&&(o+="-");i1999?u=o.year:ua.year&&(u=a.year),isNaN(h)||h<1||h>12?h=o.month:u<=r.year&&h=a.year&&h>a.month&&(h=a.month),isNaN(d)||d<1?d=o.day:h<=r.month&&d=a.month&&d>a.day&&(d=a.day),{year:parseInt(u),month:parseInt(h),day:parseInt(d)}},c=function(t,n,e){var i=s(n,e),o=t.initTime,a=t.options.maxTime,r=t.options.minTime,u=i.hour,h=i.minute,d=i.second;return isNaN(u)||u<0||u>23?u=o.hour:ua.hour&&(u=a.hour),isNaN(h)||h<0||h>59?h=o.minute:u<=r.hour&&h=a.hour&&h>a.minute&&(h=a.minute),isNaN(d)||d<0||d>59?d=o.second:u<=r.hour&&h<=r.minute&&d=a.hour&&h>=a.minute&&d>a.second&&(d=a.second),{hour:parseInt(u),minute:parseInt(h),second:parseInt(d)}},p=function(t,n,e,i){var o=t.options.minDate,a=t.options.maxDate,s=l(t,{year:n,month:e,day:i});return o=r(o)?s:l(t,{year:o.year,month:o.month,day:o.day}),s<=(a=r(a)?s:l(t,{year:a.year,month:a.month,day:a.day}))&&s>=o},m=function(t,n){var e=t.options.separatorChars,i=n.split(e.between),o=t.options.date?i[0].split(e.date):{},a=t.options.date?t.options.time&&i[1]?i[1].split(e.time):{}:i[0].split(e.time);return{year:parseInt(o[0]),month:parseInt(o[1]),day:parseInt(o[2]),hour:parseInt(a[0]),minute:parseInt(a[1]),second:parseInt(a[2])}},l=function(t,n){var e=t.options.separatorChars;return"".concat(n.year).concat(e.date).concat(h(n.month)).concat(e.date).concat(h(n.day))},y=function(t,n){if(!n)return!1;var e=n.substr(0,10).split(t.options.separatorChars.date);return 3===e.length&&4===e[0].length&&2===e[1].length&&2===e[2].length},f=function(t,n){if(!n)return!1;var e=n.substr(t.options.date?11:0,8).split(t.options.separatorChars.time);return e.length===(t.options.hasSecond?3:2)&&!e.find((function(t){return 2!==t.toString().length}))},v="jdp",g="".concat(v,"-container"),D="".concat(v,"-overlay"),w="div.".concat(v,"-years"),_="div.".concat(v,"-year"),b="div.".concat(v,"-months"),C="div.".concat(v,"-month"),T="div.".concat(v,"-days"),x="div.".concat(v,"-day"),I="div.".concat(v,"-day.not-in-month"),M="div.".concat(v,"-day.disabled-day"),S="".concat(I,".disabled-day"),A="div.".concat(v,"-day-name"),E="div.".concat(v,"-icon-plus"),O="div.".concat(v,"-icon-minus"),j="div.".concat(v,"-footer"),N="div.".concat(v,"-btn-today"),P="div.".concat(v,"-btn-empty"),V="div.".concat(v,"-btn-close"),B="div.".concat(v,"-time-container"),H="div.".concat(v,"-time"),Y="not-in-range",L="holly-day",k="".concat(v,":change"),z="click",R="focusin",J="today",W="attr",q="data-jdp-only-date",F="data-jdp-only-time",X=("data-".concat(v),"visible"),G="block",K="none",Q=function t(n){if(["html","body","#document"].indexOf((n.nodeName||"").toLowerCase())>=0)return window;if(n instanceof HTMLElement){var e=window.getComputedStyle(n),i=e.overflow,o=e.overflowX,a=e.overflowY;if(/auto|scroll|overlay/.test(i+a+o))return n}return t(n.parentNode)},U=function(t){var n=document.createEvent("Event");return n.initEvent(t,!0,!0),n},Z=function(t,n){t&&(t.dispatchEvent(U(n)),n===k&&(t.dispatchEvent(U("change")),t.dispatchEvent(U("input"))))},$=function(t,n,i,a,r){var s=t.split(".");t=s.shift()||"div";var u=s,h=window.document.createElement(t);return o(n)?window.document.querySelector(n).appendChild(h):n.appendChild(h),u.length&&(h.className=u.join(" ")),i&&a&&function(t,n,e){for(var i=n.split(" "),o=0,a=i.length;o2e3||t.yearChange(n.target.value)}));if(i)for(var a=function(t){function n(t){return 100*Math.round(t/100)}var e=t.initDate.year;return{min:t.options.minDate.year||n(e-200),max:t.options.maxDate.year||n(e+200)}}(t),r=a.min;r<=a.max;r++){var s=$("option",o);s.value=r,s.text=nt(r,t.options.persianDigits),s.selected=r===t.initDate.year}else o.tabIndex=-1,o.value=t.initDate.year,o.type="number"},mt=function(t){pt(t),function(t){var n=$(b,t.dpContainer);dt(t,n,!1);var e=$(C,n);ct(t,n,!1);var i=$("select",e,"change",(function(n){t.monthChange(n.target.value)}));i.tabIndex=-1;for(var o=function(t){var n=t.initDate.year,e=t.options.minDate,i=t.options.maxDate,o=[],a=1,r=12;n===e.year?(a=e.month,n===i.year&&(r=i.month)):n===i.year&&(a=1,r=i.month);for(var s=a;s<=r;s++)o.push(s);return o}(t),a=t.options.months,r=0;r=r+f,(a.inBeforeMonth||a.inAfterMonth)&&(a.inBeforeMonth?(v++,a.day=v,a.year=m,a.month=d):(g++,a.day=g,a.year=l,a.month=c)),a.isValid=p(t,a.year,a.month,a.day),a.className=ht(it(a.year,a.month,a.day)),t.inputValue.day===a.day&&t.inputValue.year===a.year&&t.inputValue.month===a.month&&(a.className+=".".concat("selected")),t.today.day===a.day&&t.today.year===a.year&&t.today.month===a.month&&(a.className+=".".concat("today")),i(t.options.dayRendering)&&s(a,t.options.dayRendering(a,t.input)),a.isHollyDay&&(a.className+=".".concat(L));var u=a.isValid?x:M;(a.inBeforeMonth||a.inAfterMonth)&&(u=I,a.isValid||(u=S));var h=$(u+a.className,n,null,null,nt(a.day,t.options.persianDigits));h.day=a.day,h.month=a.month,h.year=a.year,a.isValid&&h.addEventListener(z,(function(){t.setValue({year:h.year,month:h.month,day:h.day})})),o(a)},w=0;w<=h;w++)D(w)}(t)},lt=function(t){var n,e=$(j,t.dpContainer);if(t.options.showTodayBtn&&t.options.date){var i=function(t){return p(t,t.today.year,t.today.month,t.today.day)}(t);$(N+(i?"":".disabled-btn"),e,z,(function(){i&&t.setValue(t.today)}),"امروز")}t.options.date||!t.options.time||null!==(n=t.input)&&void 0!==n&&n.value||$(N,e,z,(function(){t.setValue(t.initTime),t.hide()}),"انتخاب"),t.options.showEmptyBtn&&$(P,e,z,(function(){t.input.value="",Z(t.input,k),t.options.hideAfterChange&&t.hide()}),"خالی"),t.options.showCloseBtn&&$(V,e,z,(function(){t.hide()}),"بستن")},yt=function(t){tt(t.dpContainer,""),t.options.date&&mt(t),t.options.time&&function(t){var n=B+(t.options.time&&!t.options.date?".jdp-only-time":""),e=$(n,t.dpContainer);t.options.hasSecond&&ut(t,e,"second"),ut(t,e,"minute"),ut(t,e,"hour")}(t),lt(t)};var ft=/iphone|ipod|android|ie|blackberry|fennec/.test(null===(at=window.navigator)||void 0===at||null===(rt=at.userAgent)||void 0===rt?void 0:rt.toLowerCase()),vt={init:function(t){var n;this.updateOptions(t),Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector,window.addEventListener("resize",(function(){vt.setPosition()})),this.options.autoHide&&document.body.addEventListener("click",(function(t){var n,e,o;vt.isShow&&(n=vt.dpContainer,!((o=(e=t).path||e.composedPath&&e.composedPath()||!1)?-1!==o.indexOf(n):n.outerHTML.indexOf(e.target.outerHTML)>-1))&&function(t){try{return i(t.composedPath)?t.composedPath()[0]:t.target}catch(n){return t.target}}(t)!==vt.input&&vt.hide()})),this.options.autoShow&&(n=this.options.selector,document.body.addEventListener(R,(function(t){t.target&&t.target.matches(n)&&vt.show(t.target)})))},updateOptions:function(t){this.options=Dt(t)},options:a({days:["ش","ی","د","س","چ","پ","ج"],months:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],initDate:null,today:null,initTime:null,hasSecond:!0,time:!1,date:!0,minDate:{},maxDate:{},minTime:{},maxTime:{},separatorChars:{date:"/",between:" ",time:":"},persianDigits:!1,zIndex:1e3,container:"body",selector:"input[data-jdp]",autoShow:!0,autoHide:!0,hideAfterChange:!0,plusHtml:'',minusHtml:'',changeMonthRotateYear:!1,showTodayBtn:!0,showEmptyBtn:!0,showCloseBtn:ft,autoReadOnlyInput:ft,useDropDownYears:!0,topSpace:0,bottomSpace:0}),input:null,get dpContainer(){return this._dpContainer||(this._dpContainer=$(g,this.options.container),this.overlayElm=$(D,this.options.container),this.dpContainer.style.zIndex=this.options.zIndex,this.overlayElm.style.zIndex=this.options.zIndex-1),this._dpContainer},get today(){return this._today=this._today||this.options.today||function(){var t,n,e=new Date,i=parseInt(e.getFullYear()),o=parseInt(e.getMonth())+1,a=parseInt(e.getDate());i>1600?(t=979,i-=1600):(t=0,i-=621);var r=o>2?i+1:i;return n=365*i+parseInt((r+3)/4)-parseInt((r+99)/100)+parseInt((r+399)/400)-80+a+[0,31,59,90,120,151,181,212,243,273,304,334][o-1],t+=33*parseInt(n/12053),n%=12053,t+=4*parseInt(n/1461),(n%=1461)>365&&(t+=parseInt((n-1)/365),n=(n-1)%365),{year:t,month:n<186?1+parseInt(n/31):7+parseInt((n-186)/30),day:1+(n<186?n%31:(n-186)%30)}}(),this._today},get inputValue(){var t=a(this.input.value);return t=function(t,n){if(!n)return!1;var e=t.options.separatorChars,i=t.options.date?"\\d{4}".concat(e.date,"\\d{2}").concat(e.date,"\\d{2}"):"",o=t.options.time?"\\d{2}".concat(e.time,"\\d{2}")+(t.options.hasSecond?"".concat(e.time,"\\d{2}"):""):"";return new RegExp(i+(i&&o?e.between:"")+o).test(n,"g")}(this,t)||o(t)&&y(this,t)?m(this,t):{}},get initDate(){return this.options.initDate?this.options.initDate:(this._initDate||(this._initDate=a(this.input.value)||{},r(this._initDate)?this._initDate=this.options.initDate||a(this.today):o(this._initDate)&&y(this,this._initDate)?this._initDate=m(this,this._initDate):this._initDate=a(this.today),this._initDate=d(this,this._initDate)),this._initDate)},get initTime(){if(this._initTime)return this._initTime;var t=new Date,n={hour:t.getHours(),minute:t.getMinutes(),second:0};return this._initTime=a(this.input.value)||this.options.initTime||n,o(this._initTime)&&(f(this,this._initTime)?this._initTime=m(this,this._initTime):this._initTime=n),this._initTime=c(this,this._initTime),this._initTime},_draw:function(){yt(this)},show:function(t){var n=this;this._initDate=null,this._initTime=null,this._value=null,this.input=t,this._draw(),function(t,n){n.autoReadOnlyInput&&!t.readOnly&&(t.setAttribute("readonly","readonly"),t.readOnly=!0)}(t,this.options),this.dpContainer.style.visibility=X,this.dpContainer.style.display=G,this.overlayElm.style.display=G,setTimeout((function(){n.dpContainer.style.visibility=X,n.dpContainer.style.display=G,n.overlayElm.style.display=G,n.isShow=!0}),300),this.setPosition(),function(t){Q(t).addEventListener("scroll",(function(){vt.setPosition()}),{passive:!0})}(t)},hide:function(){this.dpContainer.style.visibility="hidden",this.dpContainer.style.display=K,this.overlayElm.style.display=K,this.isShow=!1},setPosition:function(){if(this.dpContainer.style.visibility===X){var t=this.input.getBoundingClientRect(),n=t.height,e=t.left,i=t.top+n;i+=this.options.topSpace;var o=window.document.body.offsetWidth,a=this.dpContainer.offsetWidth,r=this.dpContainer.offsetHeight;e+a>=o&&(e-=e+a-(o+10)),i-n>=r&&i+r>=window.innerHeight&&(i-=r+n+this.options.bottomSpace+this.options.topSpace),this.dpContainer.style.position="fixed",this.dpContainer.style.left=e+"px",this.dpContainer.style.top=i+"px"}},get getValue(){return this._value=this._value||this.inputValue||{},this._value},setValue:function(t){var n,e,i,o,a;this._value=s({year:this.today.year,month:this.today.month,day:this.today.day,hour:this.initTime.hour,minute:this.initTime.minute,second:this.initTime.second},s(this._value,t)),this._initTime=null,this.input.value=(n=this,e=this._value,i=n.options.separatorChars,o=n.options.date?"".concat(e.year).concat(i.date).concat(h(e.month)).concat(i.date).concat(h(e.day)):"",a=n.options.time?"".concat(h(e.hour)).concat(i.time).concat(h(e.minute))+(n.options.hasSecond?i.time+h(e.second):""):"",o+(o&&a?i.between:"")+a),Z(this.input,k),!this.options.time&&this.options.hideAfterChange?this.hide():this._draw()},increaseMonth:function(){var t=12===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.increaseYear(),this.monthChange(t?1:this._initDate.month+1)},decreaseMonth:function(){var t=1===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.decreaseYear(),this.monthChange(t?12:this._initDate.month-1)},monthChange:function(t){this._initDate=d(this,this._initDate,{month:t}),this._draw()},increaseYear:function(){this.yearChange(this._initDate.year+1)},decreaseYear:function(){this.yearChange(this._initDate.year-1)},yearChange:function(t){this._initDate=d(this,this._initDate,{year:t}),this._draw()}},gt=function(t,n){var e,i=null===(e=vt.input)||void 0===e?void 0:e.getAttribute(t);if(!n&&i===J)return a(vt.today);if(!o(i))return{};try{i=document.querySelector(i).value}catch(t){}return i=n?f(vt,i)?m(vt,i):{}:y(vt,i)?m(vt,i):{}},Dt=function(t){return!e(vt.options._date)&&e(t.date)&&(t.date=vt.options._date),!e(vt.options._time)&&e(t.time)&&(t.time=vt.options._time),t.separatorChars=s(vt.options.separatorChars,t.separatorChars),(t=s({},vt.options,t)).minDate===J&&(t.minDate=a(vt.today)),t.maxDate===J&&(t.maxDate=a(vt.today)),(t.initDate===W||t._initDateIsAttr)&&(delete t.initDate,t._initDateIsAttr=!0,window.Object.defineProperty(t,"initDate",{get:function(){return gt("data-jdp-init-date")},enumerable:!0})),(t.minDate===W||t._minDateIsAttr)&&(delete t.minDate,t._minDateIsAttr=!0,window.Object.defineProperty(t,"minDate",{get:function(){return gt("data-jdp-min-date")},enumerable:!0})),(t.maxDate===W||t._maxDateIsAttr)&&(delete t.maxDate,t._maxDateIsAttr=!0,window.Object.defineProperty(t,"maxDate",{get:function(){return gt("data-jdp-max-date")},enumerable:!0})),(t.minTime===W||t._minTimeIsAttr)&&(delete t.minTime,t._minTimeIsAttr=!0,window.Object.defineProperty(t,"minTime",{get:function(){return gt("data-jdp-min-time",!0)},enumerable:!0})),(t.maxTime===W||t._maxTimeIsAttr)&&(delete t.maxTime,t._maxTimeIsAttr=!0,window.Object.defineProperty(t,"maxTime",{get:function(){return gt("data-jdp-max-time",!0)},enumerable:!0})),t._date=t.date,delete t.date,window.Object.defineProperty(t,"date",{get:function(){var n,e;return!(null!==(n=vt.input)&&void 0!==n&&n.hasAttribute(F))&&(t._date||(null===(e=vt.input)||void 0===e?void 0:e.hasAttribute(q)))},enumerable:!0}),t._time=t.time,delete t.time,window.Object.defineProperty(t,"time",{get:function(){var n,e;return!(null!==(n=vt.input)&&void 0!==n&&n.hasAttribute(q))&&(t._time||(null===(e=vt.input)||void 0===e?void 0:e.hasAttribute(F)))},enumerable:!0}),t};window.jalaliDatepicker={startWatch:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};vt.init(t)},show:function(t){vt.show(t)},hide:function(){vt.hide()},updateOptions:function(t){vt.updateOptions(t)}}}()}(); \ No newline at end of file diff --git a/web/entity/entity.go b/web/entity/entity.go index 69e5b2d4..5b09400c 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -47,6 +47,7 @@ type AllSetting struct { SubEncrypt bool `json:"subEncrypt" form:"subEncrypt"` SubShowInfo bool `json:"subShowInfo" form:"subShowInfo"` SubURI string `json:"subURI" form:"subURI"` + Datepicker string `json:"datepicker" form:"datepicker"` } func (s *AllSetting) CheckValid() error { diff --git a/web/html/xui/client_bulk_modal.html b/web/html/xui/client_bulk_modal.html index 75e9bf6b..c951bc8d 100644 --- a/web/html/xui/client_bulk_modal.html +++ b/web/html/xui/client_bulk_modal.html @@ -104,8 +104,10 @@ - + - + Expired diff --git a/web/html/xui/form/inbound.html b/web/html/xui/form/inbound.html index 6f0480c3..5da8ec56 100644 --- a/web/html/xui/form/inbound.html +++ b/web/html/xui/form/inbound.html @@ -54,9 +54,11 @@ - + diff --git a/web/html/xui/inbound_modal.html b/web/html/xui/inbound_modal.html index f7f9d727..ab42e09c 100644 --- a/web/html/xui/inbound_modal.html +++ b/web/html/xui/inbound_modal.html @@ -63,6 +63,9 @@ get client() { return inModal.inbound.clients[0]; }, + get datepicker() { + return app.datepicker; + }, get delayedExpireDays() { return this.client && this.client.expiryTime < 0 ? this.client.expiryTime / -86400000 : 0; }, diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 2be031e5..8d1da2f4 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -446,6 +446,7 @@ {{template "component/themeSwitcher" .}} +{{template "component/persianDatepicker" .}}