From 834c5909a75bff6b65b4e8ec00b6300a3d398c1e Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 24 Mar 2022 21:39:05 +0800 Subject: [PATCH] released v2.1.0 (#42) --- dist/notify.common.js | 233 +++++++++++++++++-------------------- dist/notify.common.js.map | 1 + dist/notify.common.min.js | 4 +- dist/notify.esm.js | 235 +++++++++++++++++-------------------- dist/notify.esm.js.map | 1 + dist/notify.js | 239 +++++++++++++++++--------------------- dist/notify.js.map | 1 + dist/notify.min.js | 5 +- dist/notify.min.js.map | 1 + package-lock.json | 4 +- package.json | 2 +- 11 files changed, 327 insertions(+), 399 deletions(-) create mode 100644 dist/notify.common.js.map create mode 100644 dist/notify.esm.js.map create mode 100644 dist/notify.js.map create mode 100644 dist/notify.min.js.map diff --git a/dist/notify.common.js b/dist/notify.common.js index 645f446..7074316 100644 --- a/dist/notify.common.js +++ b/dist/notify.common.js @@ -1,5 +1,5 @@ /*! - * @wcjiang/notify v2.0.12 + * @wcjiang/notify v2.1.0 * JS achieve the browser title flashing , scrolling, voice prompts , chrome notice. * * Copyright (c) 2022 kenny wang @@ -11,57 +11,52 @@ 'use strict'; // 提醒是否添加chrome通知 -if (window.Notification && window.Notification.permission !== "granted") { +if (window.Notification && window.Notification.permission !== 'granted') { window.Notification.requestPermission(); } +let iconURL = ''; +const repeatableEffects = ['flash', 'scroll']; -var iconURL = ""; -var repeatableEffects = ["flash", "scroll"]; -var defaultNotification = { - title: "iNotify !", - body: "You have a new message.", - openurl: "" +const defaultNotification = { + title: 'iNotify !', + body: 'You have a new message.', + openurl: '', }; - function jsonArguments(news, olds) { - for (var a in olds) { + for (const a in olds) { if (news[a]) { olds[a] = news[a]; } } - return olds; } - function isArray(value) { - return Object.prototype.toString.call(value) === "[object Array]"; + return Object.prototype.toString.call(value) === '[object Array]'; } function createAudio(url) { - var audioElm = document.createElement("audio"); - var source; - + const audioElm = document.createElement('audio'); + audioElm.autoplay = true; + audioElm.muted = true; + let source; if (isArray(url) && url.length > 0) { - for (var i = 0; i < url.length; i++) { - source = document.createElement("source"); + for (let i = 0; i < url.length; i++) { + source = document.createElement('source'); source.src = url[i]; - source.type = "audio/".concat(getExtension(url[i])); + source.type = `audio/${getExtension(url[i])}`; audioElm.appendChild(source); } } else { audioElm.src = url; } - return audioElm; } function getFavicon(setting) { - var ic = document.querySelectorAll("link[rel~=shortcut]")[0]; - + let ic = document.querySelectorAll('link[rel~=shortcut]')[0]; if (!ic) { - ic = changeFavicon("O", setting); + ic = changeFavicon('O', setting); } - return ic; } @@ -70,25 +65,28 @@ function getExtension(fileName) { } function changeFavicon(num, settings) { - var canvas = document.createElement("canvas"); - var head = document.getElementsByTagName("head")[0]; - var linkTag = document.createElement("link"); - var ctx = null; + const canvas = document.createElement('canvas'); + const head = document.getElementsByTagName('head')[0]; + const linkTag = document.createElement('link'); + let ctx = null; + canvas.height = 32; canvas.width = 32; - ctx = canvas.getContext("2d"); + ctx = canvas.getContext('2d'); ctx.fillStyle = settings.backgroundColor; ctx.fillRect(0, 0, 32, 32); - ctx.textAlign = "center"; + + ctx.textAlign = 'center'; ctx.font = '22px "helvetica", sans-serif'; ctx.fillStyle = settings.textColor; - num && ctx.fillText(num, 16, 24); // 生成到 - - linkTag.setAttribute("rel", "shortcut icon"); - linkTag.setAttribute("type", "image/x-icon"); - linkTag.setAttribute("id", "new".concat(settings.id)); - linkTag.setAttribute("href", canvas.toDataURL("image/png")); - iconURL = canvas.toDataURL("image/png"); + num && ctx.fillText(num, 16, 24); + + // 生成到 + linkTag.setAttribute('rel', 'shortcut icon'); + linkTag.setAttribute('type', 'image/x-icon'); + linkTag.setAttribute('id', `new${settings.id}`); + linkTag.setAttribute('href', canvas.toDataURL('image/png')); + iconURL = canvas.toDataURL('image/png'); return head.appendChild(linkTag); } @@ -99,49 +97,44 @@ function Notify(config) { } Notify.prototype = { - init: function init(config) { + init(config) { if (!config) { config = {}; } - this.interval = config.interval || 100; // 响应时长 - - this.effect = config.effect || "flash"; // 效果 - + this.effect = config.effect || 'flash'; // 效果 this.title = config.title || document.title; // 标题 - this.message = config.message || this.title; // 原来的标题 - this.onclick = config.onclick || this.onclick; // 点击事件 - this.openurl = config.openurl || this.openurl; // 点击事件 - this.disableFavicon = config.disableFavicon || false; // 禁用favicon 默认开启 - - this.updateFavicon = !this.disableFavicon && (config.updateFavicon || { - id: "favicon", - textColor: "#fff", - backgroundColor: "#2F9A00" - }); - this.audio = config.audio || ""; + this.updateFavicon = !this.disableFavicon + && (config.updateFavicon || { + id: 'favicon', + textColor: '#fff', + backgroundColor: '#2F9A00', + }); + this.audio = config.audio || ''; this.favicon = !this.disableFavicon && getFavicon(this.updateFavicon); this.cloneFavicon = this.favicon && this.favicon.cloneNode(true); - iconURL = config.notification && config.notification.icon ? config.notification.icon : config.icon ? config.icon : this.favicon.href; + iconURL = config.notification && config.notification.icon + ? config.notification.icon + : config.icon + ? config.icon + : this.favicon.href; defaultNotification.icon = iconURL; - this.notification = config.notification || defaultNotification; // 初始化生成声音文件节点 - + this.notification = config.notification || defaultNotification; + // 初始化生成声音文件节点 if (this.audio && this.audio.file) { this.setURL(this.audio.file); } - return this; }, - render: function render() { - if (this.effect === "flash") { + render() { + if (this.effect === 'flash') { document.title = this.title === document.title ? this.message : this.title; - } else if (this.effect === "scroll") { - var title = this.message || document.title; - + } else if (this.effect === 'scroll') { + const title = this.message || document.title; if (!this.scrollTitle || !this.scrollTitle.slice(1)) { document.title = title; this.scrollTitle = title; @@ -150,203 +143,185 @@ Notify.prototype = { document.title = this.scrollTitle; } } - return this; }, // 设置标题 - setTitle: function setTitle(str) { + setTitle(str) { if (str === true) { if (repeatableEffects.indexOf(this.effect) >= 0) { return this.addTimer(); } } else if (str) { this.message = str; - this.scrollTitle = ""; + this.scrollTitle = ''; this.addTimer(); } else { this.clearTimer(); } - return this; }, - setURL: function setURL(url) { + setURL(url) { if (url) { if (this.audioElm) { this.audioElm.remove(); } - this.audioElm = createAudio(url); document.body.appendChild(this.audioElm); } - return this; }, - loopPlay: function loopPlay() { + loopPlay() { this.setURL(); this.audioElm.loop = true; this.player(); return this; }, - stopPlay: function stopPlay() { - this.audioElm && (this.audioElm.loop = false, this.audioElm.pause()); + stopPlay() { + this.audioElm && ((this.audioElm.loop = false), this.audioElm.pause()); return this; }, // 播放声音 - player: function player() { + player() { if (!this.audio || !this.audio.file) { return; } - if (!this.audioElm) { this.audioElm = createAudio(this.audio.file); document.body.appendChild(this.audioElm); } - - this.audioElm.play(); + this.audioElm.muted = false; + const resp = this.audioElm.play(); + if (resp !== undefined) { + resp.then(() => { + // autoplay starts! + }).catch(() => { + // show error + }); + } return this; }, - notify: function notify(json) { - var nt = this.notification; - var url = json.openurl ? json.openurl : this.openurl; - var onclick = json.onclick ? json.onclick : this.onclick; - + notify(json) { + let nt = this.notification; + const url = json.openurl ? json.openurl : this.openurl; + const onclick = json.onclick ? json.onclick : this.onclick; if (window.Notification) { if (json) { nt = jsonArguments(json, nt); } else { nt = defaultNotification; } - - var option = {}; + const option = {}; option.icon = json.icon ? json.icon : iconURL; option.body = nt.body || json.body; if (json.dir) option.dir = json.dir; - var n = new Notification(nt.title || json.title, option); - - n.onclick = function () { - onclick && typeof onclick === "function" && onclick(n); + const n = new Notification(nt.title || json.title, option); + n.onclick = () => { + onclick && typeof onclick === 'function' && onclick(n); url && window.open(url); }; - - n.onshow = function () { - json.onshow && typeof json.onshow === "function" && json.onshow(n); + n.onshow = () => { + json.onshow && typeof json.onshow === 'function' && json.onshow(n); }; - - n.onclose = function () { - json.onclose && typeof json.onclose === "function" && json.onclose(n); + n.onclose = () => { + json.onclose && typeof json.onclose === 'function' && json.onclose(n); }; - - n.onerror = function () { - json.onerror && typeof json.onerror === "function" && json.onerror(n); + n.onerror = () => { + json.onerror && typeof json.onerror === 'function' && json.onerror(n); }; - this.Notifiy = n; } - return this; }, // 是否许可弹框通知 - isPermission: function isPermission() { - return window.Notification && Notification.permission === "granted"; + isPermission() { + return window.Notification && Notification.permission === 'granted'; }, // 设置时间间隔 - setInterval: function setInterval(num) { + setInterval(num) { if (num) { this.interval = num; this.addTimer(); } - return this; }, // 设置网页Icon - setFavicon: function setFavicon(num) { + setFavicon(num) { if (!num && num !== 0) { return this.faviconClear(); } - - var oldicon = document.getElementById("new".concat(this.updateFavicon.id)); - + const oldicon = document.getElementById(`new${this.updateFavicon.id}`); if (this.favicon) { this.favicon.remove(); } - if (oldicon) { oldicon.remove(); } - this.updateFavicon.num = num; changeFavicon(num, this.updateFavicon); return this; }, // 设置 Favicon 文字颜色 - setFaviconColor: function setFaviconColor(color) { + setFaviconColor(color) { if (color) { this.faviconRemove(); this.updateFavicon.textColor = color; changeFavicon(this.updateFavicon.num, this.updateFavicon); } - return this; }, // 设置 Favicon 背景颜色 - setFaviconBackgroundColor: function setFaviconBackgroundColor(color) { + setFaviconBackgroundColor(color) { if (color) { this.faviconRemove(); this.updateFavicon.backgroundColor = color; changeFavicon(this.updateFavicon.num, this.updateFavicon); } - return this; }, - faviconRemove: function faviconRemove() { + faviconRemove() { this.faviconClear(); - var oldicon = document.getElementById("new".concat(this.updateFavicon.id)); - + const oldicon = document.getElementById(`new${this.updateFavicon.id}`); if (this.favicon) { this.favicon.remove(); } - if (oldicon) { oldicon.remove(); } }, // 添加计数器 - addTimer: function addTimer() { + addTimer() { this.clearTimer(); - if (repeatableEffects.indexOf(this.effect) >= 0) { this.timer = setInterval(this.render.bind(this), this.interval); } - return this; }, - close: function close() { + close() { if (this.Notifiy) this.Notifiy.close(); }, // 清除Icon - faviconClear: function faviconClear() { - var newicon = document.getElementById("new".concat(this.updateFavicon.id)); - var head = document.getElementsByTagName("head")[0]; - var ficon = document.querySelectorAll("link[rel~=shortcut]"); + faviconClear() { + const newicon = document.getElementById(`new${this.updateFavicon.id}`); + const head = document.getElementsByTagName('head')[0]; + const ficon = document.querySelectorAll('link[rel~=shortcut]'); newicon && newicon.remove(); - if (ficon.length > 0) { - for (var i = 0; i < ficon.length; i++) { + for (let i = 0; i < ficon.length; i++) { ficon[i].remove(); } } - head.appendChild(this.cloneFavicon); iconURL = this.cloneFavicon.href; this.favicon = this.cloneFavicon; return this; }, // 清除计数器 - clearTimer: function clearTimer() { + clearTimer() { this.timer && clearInterval(this.timer); document.title = this.title; return this; - } + }, }; module.exports = Notify; +//# sourceMappingURL=notify.common.js.map diff --git a/dist/notify.common.js.map b/dist/notify.common.js.map new file mode 100644 index 0000000..de55e4c --- /dev/null +++ b/dist/notify.common.js.map @@ -0,0 +1 @@ +{"version":3,"file":"notify.common.js","sources":["../src/main.js"],"sourcesContent":["// 提醒是否添加chrome通知\nif (window.Notification && window.Notification.permission !== 'granted') {\n window.Notification.requestPermission();\n}\nlet iconURL = '';\nconst repeatableEffects = ['flash', 'scroll'];\n\nconst defaultNotification = {\n title: 'iNotify !',\n body: 'You have a new message.',\n openurl: '',\n};\nfunction jsonArguments(news, olds) {\n for (const a in olds) {\n if (news[a]) {\n olds[a] = news[a];\n }\n }\n return olds;\n}\nfunction isArray(value) {\n return Object.prototype.toString.call(value) === '[object Array]';\n}\n\nfunction createAudio(url) {\n const audioElm = document.createElement('audio');\n audioElm.autoplay = true;\n audioElm.muted = true;\n let source;\n if (isArray(url) && url.length > 0) {\n for (let i = 0; i < url.length; i++) {\n source = document.createElement('source');\n source.src = url[i];\n source.type = `audio/${getExtension(url[i])}`;\n audioElm.appendChild(source);\n }\n } else {\n audioElm.src = url;\n }\n return audioElm;\n}\n\nfunction getFavicon(setting) {\n let ic = document.querySelectorAll('link[rel~=shortcut]')[0];\n if (!ic) {\n ic = changeFavicon('O', setting);\n }\n return ic;\n}\n\nfunction getExtension(fileName) {\n return fileName.match(/\\.([^\\\\.]+)$/)[1];\n}\n\nfunction changeFavicon(num, settings) {\n const canvas = document.createElement('canvas');\n const head = document.getElementsByTagName('head')[0];\n const linkTag = document.createElement('link');\n let ctx = null;\n\n canvas.height = 32;\n canvas.width = 32;\n ctx = canvas.getContext('2d');\n ctx.fillStyle = settings.backgroundColor;\n ctx.fillRect(0, 0, 32, 32);\n\n ctx.textAlign = 'center';\n ctx.font = '22px \"helvetica\", sans-serif';\n ctx.fillStyle = settings.textColor;\n num && ctx.fillText(num, 16, 24);\n\n // 生成到\n linkTag.setAttribute('rel', 'shortcut icon');\n linkTag.setAttribute('type', 'image/x-icon');\n linkTag.setAttribute('id', `new${settings.id}`);\n linkTag.setAttribute('href', canvas.toDataURL('image/png'));\n iconURL = canvas.toDataURL('image/png');\n return head.appendChild(linkTag);\n}\n\nfunction Notify(config) {\n if (config) {\n this.init(config);\n }\n}\n\nNotify.prototype = {\n init(config) {\n if (!config) {\n config = {};\n }\n this.interval = config.interval || 100; // 响应时长\n this.effect = config.effect || 'flash'; // 效果\n this.title = config.title || document.title; // 标题\n this.message = config.message || this.title; // 原来的标题\n this.onclick = config.onclick || this.onclick; // 点击事件\n this.openurl = config.openurl || this.openurl; // 点击事件\n this.disableFavicon = config.disableFavicon || false; // 禁用favicon 默认开启\n this.updateFavicon = !this.disableFavicon\n && (config.updateFavicon || {\n id: 'favicon',\n textColor: '#fff',\n backgroundColor: '#2F9A00',\n });\n this.audio = config.audio || '';\n this.favicon = !this.disableFavicon && getFavicon(this.updateFavicon);\n this.cloneFavicon = this.favicon && this.favicon.cloneNode(true);\n iconURL = config.notification && config.notification.icon\n ? config.notification.icon\n : config.icon\n ? config.icon\n : this.favicon.href;\n defaultNotification.icon = iconURL;\n this.notification = config.notification || defaultNotification;\n // 初始化生成声音文件节点\n if (this.audio && this.audio.file) {\n this.setURL(this.audio.file);\n }\n return this;\n },\n render() {\n if (this.effect === 'flash') {\n document.title = this.title === document.title ? this.message : this.title;\n } else if (this.effect === 'scroll') {\n const title = this.message || document.title;\n if (!this.scrollTitle || !this.scrollTitle.slice(1)) {\n document.title = title;\n this.scrollTitle = title;\n } else {\n this.scrollTitle = this.scrollTitle.slice(1);\n document.title = this.scrollTitle;\n }\n }\n return this;\n },\n // 设置标题\n setTitle(str) {\n if (str === true) {\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n return this.addTimer();\n }\n } else if (str) {\n this.message = str;\n this.scrollTitle = '';\n this.addTimer();\n } else {\n this.clearTimer();\n }\n return this;\n },\n setURL(url) {\n if (url) {\n if (this.audioElm) {\n this.audioElm.remove();\n }\n this.audioElm = createAudio(url);\n document.body.appendChild(this.audioElm);\n }\n return this;\n },\n loopPlay() {\n this.setURL();\n this.audioElm.loop = true;\n this.player();\n return this;\n },\n stopPlay() {\n this.audioElm && ((this.audioElm.loop = false), this.audioElm.pause());\n return this;\n },\n // 播放声音\n player() {\n if (!this.audio || !this.audio.file) {\n return;\n }\n if (!this.audioElm) {\n this.audioElm = createAudio(this.audio.file);\n document.body.appendChild(this.audioElm);\n }\n this.audioElm.muted = false;\n const resp = this.audioElm.play();\n if (resp !== undefined) {\n resp.then(() => {\n // autoplay starts!\n }).catch(() => {\n // show error\n });\n }\n return this;\n },\n notify(json) {\n let nt = this.notification;\n const url = json.openurl ? json.openurl : this.openurl;\n const onclick = json.onclick ? json.onclick : this.onclick;\n if (window.Notification) {\n if (json) {\n nt = jsonArguments(json, nt);\n } else {\n nt = defaultNotification;\n }\n const option = {};\n option.icon = json.icon ? json.icon : iconURL;\n option.body = nt.body || json.body;\n if (json.dir) option.dir = json.dir;\n const n = new Notification(nt.title || json.title, option);\n n.onclick = () => {\n onclick && typeof onclick === 'function' && onclick(n);\n url && window.open(url);\n };\n n.onshow = () => {\n json.onshow && typeof json.onshow === 'function' && json.onshow(n);\n };\n n.onclose = () => {\n json.onclose && typeof json.onclose === 'function' && json.onclose(n);\n };\n n.onerror = () => {\n json.onerror && typeof json.onerror === 'function' && json.onerror(n);\n };\n this.Notifiy = n;\n }\n return this;\n },\n // 是否许可弹框通知\n isPermission() {\n return window.Notification && Notification.permission === 'granted';\n },\n // 设置时间间隔\n setInterval(num) {\n if (num) {\n this.interval = num;\n this.addTimer();\n }\n return this;\n },\n // 设置网页Icon\n setFavicon(num) {\n if (!num && num !== 0) {\n return this.faviconClear();\n }\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n this.updateFavicon.num = num;\n changeFavicon(num, this.updateFavicon);\n return this;\n },\n // 设置 Favicon 文字颜色\n setFaviconColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.textColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n // 设置 Favicon 背景颜色\n setFaviconBackgroundColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.backgroundColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n faviconRemove() {\n this.faviconClear();\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n },\n // 添加计数器\n addTimer() {\n this.clearTimer();\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n this.timer = setInterval(this.render.bind(this), this.interval);\n }\n return this;\n },\n close() {\n if (this.Notifiy) this.Notifiy.close();\n },\n // 清除Icon\n faviconClear() {\n const newicon = document.getElementById(`new${this.updateFavicon.id}`);\n const head = document.getElementsByTagName('head')[0];\n const ficon = document.querySelectorAll('link[rel~=shortcut]');\n newicon && newicon.remove();\n if (ficon.length > 0) {\n for (let i = 0; i < ficon.length; i++) {\n ficon[i].remove();\n }\n }\n head.appendChild(this.cloneFavicon);\n iconURL = this.cloneFavicon.href;\n this.favicon = this.cloneFavicon;\n return this;\n },\n // 清除计数器\n clearTimer() {\n this.timer && clearInterval(this.timer);\n document.title = this.title;\n return this;\n },\n};\n\nexport default Notify;\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AACA,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE;AACzE,EAAE,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC;AAC1C,CAAC;AACD,IAAI,OAAO,G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/dist/notify.common.min.js +++ b/dist/notify.common.min.js @@ -1,2 +1,2 @@ -/*! @wcjiang/notify v2.0.12 | MIT (c) 2018 kenny wang | http://jaywcjlove.github.io/iNotify */ -"use strict";window.Notification&&"granted"!==window.Notification.permission&&window.Notification.requestPermission();var iconURL="",repeatableEffects=["flash","scroll"],defaultNotification={title:"iNotify !",body:"You have a new message.",openurl:""};function jsonArguments(t,i){for(var e in i)t[e]&&(i[e]=t[e]);return i}function isArray(t){return"[object Array]"===Object.prototype.toString.call(t)}function createAudio(t){var i,e=document.createElement("audio");if(isArray(t)&&0 0) { - for (var i = 0; i < url.length; i++) { - source = document.createElement("source"); + for (let i = 0; i < url.length; i++) { + source = document.createElement('source'); source.src = url[i]; - source.type = "audio/".concat(getExtension(url[i])); + source.type = `audio/${getExtension(url[i])}`; audioElm.appendChild(source); } } else { audioElm.src = url; } - return audioElm; } function getFavicon(setting) { - var ic = document.querySelectorAll("link[rel~=shortcut]")[0]; - + let ic = document.querySelectorAll('link[rel~=shortcut]')[0]; if (!ic) { - ic = changeFavicon("O", setting); + ic = changeFavicon('O', setting); } - return ic; } @@ -68,25 +63,28 @@ function getExtension(fileName) { } function changeFavicon(num, settings) { - var canvas = document.createElement("canvas"); - var head = document.getElementsByTagName("head")[0]; - var linkTag = document.createElement("link"); - var ctx = null; + const canvas = document.createElement('canvas'); + const head = document.getElementsByTagName('head')[0]; + const linkTag = document.createElement('link'); + let ctx = null; + canvas.height = 32; canvas.width = 32; - ctx = canvas.getContext("2d"); + ctx = canvas.getContext('2d'); ctx.fillStyle = settings.backgroundColor; ctx.fillRect(0, 0, 32, 32); - ctx.textAlign = "center"; + + ctx.textAlign = 'center'; ctx.font = '22px "helvetica", sans-serif'; ctx.fillStyle = settings.textColor; - num && ctx.fillText(num, 16, 24); // 生成到 - - linkTag.setAttribute("rel", "shortcut icon"); - linkTag.setAttribute("type", "image/x-icon"); - linkTag.setAttribute("id", "new".concat(settings.id)); - linkTag.setAttribute("href", canvas.toDataURL("image/png")); - iconURL = canvas.toDataURL("image/png"); + num && ctx.fillText(num, 16, 24); + + // 生成到 + linkTag.setAttribute('rel', 'shortcut icon'); + linkTag.setAttribute('type', 'image/x-icon'); + linkTag.setAttribute('id', `new${settings.id}`); + linkTag.setAttribute('href', canvas.toDataURL('image/png')); + iconURL = canvas.toDataURL('image/png'); return head.appendChild(linkTag); } @@ -97,49 +95,44 @@ function Notify(config) { } Notify.prototype = { - init: function init(config) { + init(config) { if (!config) { config = {}; } - this.interval = config.interval || 100; // 响应时长 - - this.effect = config.effect || "flash"; // 效果 - + this.effect = config.effect || 'flash'; // 效果 this.title = config.title || document.title; // 标题 - this.message = config.message || this.title; // 原来的标题 - this.onclick = config.onclick || this.onclick; // 点击事件 - this.openurl = config.openurl || this.openurl; // 点击事件 - this.disableFavicon = config.disableFavicon || false; // 禁用favicon 默认开启 - - this.updateFavicon = !this.disableFavicon && (config.updateFavicon || { - id: "favicon", - textColor: "#fff", - backgroundColor: "#2F9A00" - }); - this.audio = config.audio || ""; + this.updateFavicon = !this.disableFavicon + && (config.updateFavicon || { + id: 'favicon', + textColor: '#fff', + backgroundColor: '#2F9A00', + }); + this.audio = config.audio || ''; this.favicon = !this.disableFavicon && getFavicon(this.updateFavicon); this.cloneFavicon = this.favicon && this.favicon.cloneNode(true); - iconURL = config.notification && config.notification.icon ? config.notification.icon : config.icon ? config.icon : this.favicon.href; + iconURL = config.notification && config.notification.icon + ? config.notification.icon + : config.icon + ? config.icon + : this.favicon.href; defaultNotification.icon = iconURL; - this.notification = config.notification || defaultNotification; // 初始化生成声音文件节点 - + this.notification = config.notification || defaultNotification; + // 初始化生成声音文件节点 if (this.audio && this.audio.file) { this.setURL(this.audio.file); } - return this; }, - render: function render() { - if (this.effect === "flash") { + render() { + if (this.effect === 'flash') { document.title = this.title === document.title ? this.message : this.title; - } else if (this.effect === "scroll") { - var title = this.message || document.title; - + } else if (this.effect === 'scroll') { + const title = this.message || document.title; if (!this.scrollTitle || !this.scrollTitle.slice(1)) { document.title = title; this.scrollTitle = title; @@ -148,203 +141,185 @@ Notify.prototype = { document.title = this.scrollTitle; } } - return this; }, // 设置标题 - setTitle: function setTitle(str) { + setTitle(str) { if (str === true) { if (repeatableEffects.indexOf(this.effect) >= 0) { return this.addTimer(); } } else if (str) { this.message = str; - this.scrollTitle = ""; + this.scrollTitle = ''; this.addTimer(); } else { this.clearTimer(); } - return this; }, - setURL: function setURL(url) { + setURL(url) { if (url) { if (this.audioElm) { this.audioElm.remove(); } - this.audioElm = createAudio(url); document.body.appendChild(this.audioElm); } - return this; }, - loopPlay: function loopPlay() { + loopPlay() { this.setURL(); this.audioElm.loop = true; this.player(); return this; }, - stopPlay: function stopPlay() { - this.audioElm && (this.audioElm.loop = false, this.audioElm.pause()); + stopPlay() { + this.audioElm && ((this.audioElm.loop = false), this.audioElm.pause()); return this; }, // 播放声音 - player: function player() { + player() { if (!this.audio || !this.audio.file) { return; } - if (!this.audioElm) { this.audioElm = createAudio(this.audio.file); document.body.appendChild(this.audioElm); } - - this.audioElm.play(); + this.audioElm.muted = false; + const resp = this.audioElm.play(); + if (resp !== undefined) { + resp.then(() => { + // autoplay starts! + }).catch(() => { + // show error + }); + } return this; }, - notify: function notify(json) { - var nt = this.notification; - var url = json.openurl ? json.openurl : this.openurl; - var onclick = json.onclick ? json.onclick : this.onclick; - + notify(json) { + let nt = this.notification; + const url = json.openurl ? json.openurl : this.openurl; + const onclick = json.onclick ? json.onclick : this.onclick; if (window.Notification) { if (json) { nt = jsonArguments(json, nt); } else { nt = defaultNotification; } - - var option = {}; + const option = {}; option.icon = json.icon ? json.icon : iconURL; option.body = nt.body || json.body; if (json.dir) option.dir = json.dir; - var n = new Notification(nt.title || json.title, option); - - n.onclick = function () { - onclick && typeof onclick === "function" && onclick(n); + const n = new Notification(nt.title || json.title, option); + n.onclick = () => { + onclick && typeof onclick === 'function' && onclick(n); url && window.open(url); }; - - n.onshow = function () { - json.onshow && typeof json.onshow === "function" && json.onshow(n); + n.onshow = () => { + json.onshow && typeof json.onshow === 'function' && json.onshow(n); }; - - n.onclose = function () { - json.onclose && typeof json.onclose === "function" && json.onclose(n); + n.onclose = () => { + json.onclose && typeof json.onclose === 'function' && json.onclose(n); }; - - n.onerror = function () { - json.onerror && typeof json.onerror === "function" && json.onerror(n); + n.onerror = () => { + json.onerror && typeof json.onerror === 'function' && json.onerror(n); }; - this.Notifiy = n; } - return this; }, // 是否许可弹框通知 - isPermission: function isPermission() { - return window.Notification && Notification.permission === "granted"; + isPermission() { + return window.Notification && Notification.permission === 'granted'; }, // 设置时间间隔 - setInterval: function setInterval(num) { + setInterval(num) { if (num) { this.interval = num; this.addTimer(); } - return this; }, // 设置网页Icon - setFavicon: function setFavicon(num) { + setFavicon(num) { if (!num && num !== 0) { return this.faviconClear(); } - - var oldicon = document.getElementById("new".concat(this.updateFavicon.id)); - + const oldicon = document.getElementById(`new${this.updateFavicon.id}`); if (this.favicon) { this.favicon.remove(); } - if (oldicon) { oldicon.remove(); } - this.updateFavicon.num = num; changeFavicon(num, this.updateFavicon); return this; }, // 设置 Favicon 文字颜色 - setFaviconColor: function setFaviconColor(color) { + setFaviconColor(color) { if (color) { this.faviconRemove(); this.updateFavicon.textColor = color; changeFavicon(this.updateFavicon.num, this.updateFavicon); } - return this; }, // 设置 Favicon 背景颜色 - setFaviconBackgroundColor: function setFaviconBackgroundColor(color) { + setFaviconBackgroundColor(color) { if (color) { this.faviconRemove(); this.updateFavicon.backgroundColor = color; changeFavicon(this.updateFavicon.num, this.updateFavicon); } - return this; }, - faviconRemove: function faviconRemove() { + faviconRemove() { this.faviconClear(); - var oldicon = document.getElementById("new".concat(this.updateFavicon.id)); - + const oldicon = document.getElementById(`new${this.updateFavicon.id}`); if (this.favicon) { this.favicon.remove(); } - if (oldicon) { oldicon.remove(); } }, // 添加计数器 - addTimer: function addTimer() { + addTimer() { this.clearTimer(); - if (repeatableEffects.indexOf(this.effect) >= 0) { this.timer = setInterval(this.render.bind(this), this.interval); } - return this; }, - close: function close() { + close() { if (this.Notifiy) this.Notifiy.close(); }, // 清除Icon - faviconClear: function faviconClear() { - var newicon = document.getElementById("new".concat(this.updateFavicon.id)); - var head = document.getElementsByTagName("head")[0]; - var ficon = document.querySelectorAll("link[rel~=shortcut]"); + faviconClear() { + const newicon = document.getElementById(`new${this.updateFavicon.id}`); + const head = document.getElementsByTagName('head')[0]; + const ficon = document.querySelectorAll('link[rel~=shortcut]'); newicon && newicon.remove(); - if (ficon.length > 0) { - for (var i = 0; i < ficon.length; i++) { + for (let i = 0; i < ficon.length; i++) { ficon[i].remove(); } } - head.appendChild(this.cloneFavicon); iconURL = this.cloneFavicon.href; this.favicon = this.cloneFavicon; return this; }, // 清除计数器 - clearTimer: function clearTimer() { + clearTimer() { this.timer && clearInterval(this.timer); document.title = this.title; return this; - } + }, }; -export default Notify; +export { Notify as default }; +//# sourceMappingURL=notify.esm.js.map diff --git a/dist/notify.esm.js.map b/dist/notify.esm.js.map new file mode 100644 index 0000000..2059967 --- /dev/null +++ b/dist/notify.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"notify.esm.js","sources":["../src/main.js"],"sourcesContent":["// 提醒是否添加chrome通知\nif (window.Notification && window.Notification.permission !== 'granted') {\n window.Notification.requestPermission();\n}\nlet iconURL = '';\nconst repeatableEffects = ['flash', 'scroll'];\n\nconst defaultNotification = {\n title: 'iNotify !',\n body: 'You have a new message.',\n openurl: '',\n};\nfunction jsonArguments(news, olds) {\n for (const a in olds) {\n if (news[a]) {\n olds[a] = news[a];\n }\n }\n return olds;\n}\nfunction isArray(value) {\n return Object.prototype.toString.call(value) === '[object Array]';\n}\n\nfunction createAudio(url) {\n const audioElm = document.createElement('audio');\n audioElm.autoplay = true;\n audioElm.muted = true;\n let source;\n if (isArray(url) && url.length > 0) {\n for (let i = 0; i < url.length; i++) {\n source = document.createElement('source');\n source.src = url[i];\n source.type = `audio/${getExtension(url[i])}`;\n audioElm.appendChild(source);\n }\n } else {\n audioElm.src = url;\n }\n return audioElm;\n}\n\nfunction getFavicon(setting) {\n let ic = document.querySelectorAll('link[rel~=shortcut]')[0];\n if (!ic) {\n ic = changeFavicon('O', setting);\n }\n return ic;\n}\n\nfunction getExtension(fileName) {\n return fileName.match(/\\.([^\\\\.]+)$/)[1];\n}\n\nfunction changeFavicon(num, settings) {\n const canvas = document.createElement('canvas');\n const head = document.getElementsByTagName('head')[0];\n const linkTag = document.createElement('link');\n let ctx = null;\n\n canvas.height = 32;\n canvas.width = 32;\n ctx = canvas.getContext('2d');\n ctx.fillStyle = settings.backgroundColor;\n ctx.fillRect(0, 0, 32, 32);\n\n ctx.textAlign = 'center';\n ctx.font = '22px \"helvetica\", sans-serif';\n ctx.fillStyle = settings.textColor;\n num && ctx.fillText(num, 16, 24);\n\n // 生成到\n linkTag.setAttribute('rel', 'shortcut icon');\n linkTag.setAttribute('type', 'image/x-icon');\n linkTag.setAttribute('id', `new${settings.id}`);\n linkTag.setAttribute('href', canvas.toDataURL('image/png'));\n iconURL = canvas.toDataURL('image/png');\n return head.appendChild(linkTag);\n}\n\nfunction Notify(config) {\n if (config) {\n this.init(config);\n }\n}\n\nNotify.prototype = {\n init(config) {\n if (!config) {\n config = {};\n }\n this.interval = config.interval || 100; // 响应时长\n this.effect = config.effect || 'flash'; // 效果\n this.title = config.title || document.title; // 标题\n this.message = config.message || this.title; // 原来的标题\n this.onclick = config.onclick || this.onclick; // 点击事件\n this.openurl = config.openurl || this.openurl; // 点击事件\n this.disableFavicon = config.disableFavicon || false; // 禁用favicon 默认开启\n this.updateFavicon = !this.disableFavicon\n && (config.updateFavicon || {\n id: 'favicon',\n textColor: '#fff',\n backgroundColor: '#2F9A00',\n });\n this.audio = config.audio || '';\n this.favicon = !this.disableFavicon && getFavicon(this.updateFavicon);\n this.cloneFavicon = this.favicon && this.favicon.cloneNode(true);\n iconURL = config.notification && config.notification.icon\n ? config.notification.icon\n : config.icon\n ? config.icon\n : this.favicon.href;\n defaultNotification.icon = iconURL;\n this.notification = config.notification || defaultNotification;\n // 初始化生成声音文件节点\n if (this.audio && this.audio.file) {\n this.setURL(this.audio.file);\n }\n return this;\n },\n render() {\n if (this.effect === 'flash') {\n document.title = this.title === document.title ? this.message : this.title;\n } else if (this.effect === 'scroll') {\n const title = this.message || document.title;\n if (!this.scrollTitle || !this.scrollTitle.slice(1)) {\n document.title = title;\n this.scrollTitle = title;\n } else {\n this.scrollTitle = this.scrollTitle.slice(1);\n document.title = this.scrollTitle;\n }\n }\n return this;\n },\n // 设置标题\n setTitle(str) {\n if (str === true) {\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n return this.addTimer();\n }\n } else if (str) {\n this.message = str;\n this.scrollTitle = '';\n this.addTimer();\n } else {\n this.clearTimer();\n }\n return this;\n },\n setURL(url) {\n if (url) {\n if (this.audioElm) {\n this.audioElm.remove();\n }\n this.audioElm = createAudio(url);\n document.body.appendChild(this.audioElm);\n }\n return this;\n },\n loopPlay() {\n this.setURL();\n this.audioElm.loop = true;\n this.player();\n return this;\n },\n stopPlay() {\n this.audioElm && ((this.audioElm.loop = false), this.audioElm.pause());\n return this;\n },\n // 播放声音\n player() {\n if (!this.audio || !this.audio.file) {\n return;\n }\n if (!this.audioElm) {\n this.audioElm = createAudio(this.audio.file);\n document.body.appendChild(this.audioElm);\n }\n this.audioElm.muted = false;\n const resp = this.audioElm.play();\n if (resp !== undefined) {\n resp.then(() => {\n // autoplay starts!\n }).catch(() => {\n // show error\n });\n }\n return this;\n },\n notify(json) {\n let nt = this.notification;\n const url = json.openurl ? json.openurl : this.openurl;\n const onclick = json.onclick ? json.onclick : this.onclick;\n if (window.Notification) {\n if (json) {\n nt = jsonArguments(json, nt);\n } else {\n nt = defaultNotification;\n }\n const option = {};\n option.icon = json.icon ? json.icon : iconURL;\n option.body = nt.body || json.body;\n if (json.dir) option.dir = json.dir;\n const n = new Notification(nt.title || json.title, option);\n n.onclick = () => {\n onclick && typeof onclick === 'function' && onclick(n);\n url && window.open(url);\n };\n n.onshow = () => {\n json.onshow && typeof json.onshow === 'function' && json.onshow(n);\n };\n n.onclose = () => {\n json.onclose && typeof json.onclose === 'function' && json.onclose(n);\n };\n n.onerror = () => {\n json.onerror && typeof json.onerror === 'function' && json.onerror(n);\n };\n this.Notifiy = n;\n }\n return this;\n },\n // 是否许可弹框通知\n isPermission() {\n return window.Notification && Notification.permission === 'granted';\n },\n // 设置时间间隔\n setInterval(num) {\n if (num) {\n this.interval = num;\n this.addTimer();\n }\n return this;\n },\n // 设置网页Icon\n setFavicon(num) {\n if (!num && num !== 0) {\n return this.faviconClear();\n }\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n this.updateFavicon.num = num;\n changeFavicon(num, this.updateFavicon);\n return this;\n },\n // 设置 Favicon 文字颜色\n setFaviconColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.textColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n // 设置 Favicon 背景颜色\n setFaviconBackgroundColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.backgroundColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n faviconRemove() {\n this.faviconClear();\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n },\n // 添加计数器\n addTimer() {\n this.clearTimer();\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n this.timer = setInterval(this.render.bind(this), this.interval);\n }\n return this;\n },\n close() {\n if (this.Notifiy) this.Notifiy.close();\n },\n // 清除Icon\n faviconClear() {\n const newicon = document.getElementById(`new${this.updateFavicon.id}`);\n const head = document.getElementsByTagName('head')[0];\n const ficon = document.querySelectorAll('link[rel~=shortcut]');\n newicon && newicon.remove();\n if (ficon.length > 0) {\n for (let i = 0; i < ficon.length; i++) {\n ficon[i].remove();\n }\n }\n head.appendChild(this.cloneFavicon);\n iconURL = this.cloneFavicon.href;\n this.favicon = this.cloneFavicon;\n return this;\n },\n // 清除计数器\n clearTimer() {\n this.timer && clearInterval(this.timer);\n document.title = this.title;\n return this;\n },\n};\n\nexport default Notify;\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE;AACzE,EAAE,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC;AAC1C,CAAC;AACD,IAAI,OAAO,GAAG,EAAE,CAAC;AACjB,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC9C;AACA,MAAM,mBAAmB,GAAG;AAC5B,EAAE,KAAK,EAAE,WAAW;AACpB,EAAE,IAAI,EAAE,yBAAyB;AACjC,EAAE,OAAO,EAAE,EAAE;AACb,CAAC,CAAC;AACF,SAAS,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE;AACnC,EAAE,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE;AACxB,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE;AACjB,MAAM,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACxB,KAAK;AACL,GAAG;AACH,EAAE,OAAO,IAAI,CAAC;AACd,CAAC;AACD,SAAS,OAAO,CAAC,KAAK,EAAE;AACxB,EAAE,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,gBAAgB,CAAC;AACpE,CAAC;AACD;AACA,SAAS,WAAW,CAAC,GAAG,EAAE;AAC1B,EAAE,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AACnD,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC3B,EAAE,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;AACxB,E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AI,CAAC,YAAY,CAAC;AACrC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH;AACA,EAAE,UAAU,GAAG;AACf,IAAI,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5C,IAAI,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AAChC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,CAAC;;;;"} \ No newline at end of file diff --git a/dist/notify.js b/dist/notify.js index 90b93a3..0e68764 100644 --- a/dist/notify.js +++ b/dist/notify.js @@ -1,5 +1,5 @@ /*! - * @wcjiang/notify v2.0.12 + * @wcjiang/notify v2.1.0 * JS achieve the browser title flashing , scrolling, voice prompts , chrome notice. * * Copyright (c) 2022 kenny wang @@ -11,61 +11,56 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global.notify = factory()); -}(this, (function () { 'use strict'; + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Notify = factory()); +})(this, (function () { 'use strict'; // 提醒是否添加chrome通知 - if (window.Notification && window.Notification.permission !== "granted") { + if (window.Notification && window.Notification.permission !== 'granted') { window.Notification.requestPermission(); } + let iconURL = ''; + const repeatableEffects = ['flash', 'scroll']; - var iconURL = ""; - var repeatableEffects = ["flash", "scroll"]; - var defaultNotification = { - title: "iNotify !", - body: "You have a new message.", - openurl: "" + const defaultNotification = { + title: 'iNotify !', + body: 'You have a new message.', + openurl: '', }; - function jsonArguments(news, olds) { - for (var a in olds) { + for (const a in olds) { if (news[a]) { olds[a] = news[a]; } } - return olds; } - function isArray(value) { - return Object.prototype.toString.call(value) === "[object Array]"; + return Object.prototype.toString.call(value) === '[object Array]'; } function createAudio(url) { - var audioElm = document.createElement("audio"); - var source; - + const audioElm = document.createElement('audio'); + audioElm.autoplay = true; + audioElm.muted = true; + let source; if (isArray(url) && url.length > 0) { - for (var i = 0; i < url.length; i++) { - source = document.createElement("source"); + for (let i = 0; i < url.length; i++) { + source = document.createElement('source'); source.src = url[i]; - source.type = "audio/".concat(getExtension(url[i])); + source.type = `audio/${getExtension(url[i])}`; audioElm.appendChild(source); } } else { audioElm.src = url; } - return audioElm; } function getFavicon(setting) { - var ic = document.querySelectorAll("link[rel~=shortcut]")[0]; - + let ic = document.querySelectorAll('link[rel~=shortcut]')[0]; if (!ic) { - ic = changeFavicon("O", setting); + ic = changeFavicon('O', setting); } - return ic; } @@ -74,25 +69,28 @@ } function changeFavicon(num, settings) { - var canvas = document.createElement("canvas"); - var head = document.getElementsByTagName("head")[0]; - var linkTag = document.createElement("link"); - var ctx = null; + const canvas = document.createElement('canvas'); + const head = document.getElementsByTagName('head')[0]; + const linkTag = document.createElement('link'); + let ctx = null; + canvas.height = 32; canvas.width = 32; - ctx = canvas.getContext("2d"); + ctx = canvas.getContext('2d'); ctx.fillStyle = settings.backgroundColor; ctx.fillRect(0, 0, 32, 32); - ctx.textAlign = "center"; + + ctx.textAlign = 'center'; ctx.font = '22px "helvetica", sans-serif'; ctx.fillStyle = settings.textColor; - num && ctx.fillText(num, 16, 24); // 生成到 - - linkTag.setAttribute("rel", "shortcut icon"); - linkTag.setAttribute("type", "image/x-icon"); - linkTag.setAttribute("id", "new".concat(settings.id)); - linkTag.setAttribute("href", canvas.toDataURL("image/png")); - iconURL = canvas.toDataURL("image/png"); + num && ctx.fillText(num, 16, 24); + + // 生成到 + linkTag.setAttribute('rel', 'shortcut icon'); + linkTag.setAttribute('type', 'image/x-icon'); + linkTag.setAttribute('id', `new${settings.id}`); + linkTag.setAttribute('href', canvas.toDataURL('image/png')); + iconURL = canvas.toDataURL('image/png'); return head.appendChild(linkTag); } @@ -103,49 +101,44 @@ } Notify.prototype = { - init: function init(config) { + init(config) { if (!config) { config = {}; } - this.interval = config.interval || 100; // 响应时长 - - this.effect = config.effect || "flash"; // 效果 - + this.effect = config.effect || 'flash'; // 效果 this.title = config.title || document.title; // 标题 - this.message = config.message || this.title; // 原来的标题 - this.onclick = config.onclick || this.onclick; // 点击事件 - this.openurl = config.openurl || this.openurl; // 点击事件 - this.disableFavicon = config.disableFavicon || false; // 禁用favicon 默认开启 - - this.updateFavicon = !this.disableFavicon && (config.updateFavicon || { - id: "favicon", - textColor: "#fff", - backgroundColor: "#2F9A00" - }); - this.audio = config.audio || ""; + this.updateFavicon = !this.disableFavicon + && (config.updateFavicon || { + id: 'favicon', + textColor: '#fff', + backgroundColor: '#2F9A00', + }); + this.audio = config.audio || ''; this.favicon = !this.disableFavicon && getFavicon(this.updateFavicon); this.cloneFavicon = this.favicon && this.favicon.cloneNode(true); - iconURL = config.notification && config.notification.icon ? config.notification.icon : config.icon ? config.icon : this.favicon.href; + iconURL = config.notification && config.notification.icon + ? config.notification.icon + : config.icon + ? config.icon + : this.favicon.href; defaultNotification.icon = iconURL; - this.notification = config.notification || defaultNotification; // 初始化生成声音文件节点 - + this.notification = config.notification || defaultNotification; + // 初始化生成声音文件节点 if (this.audio && this.audio.file) { this.setURL(this.audio.file); } - return this; }, - render: function render() { - if (this.effect === "flash") { + render() { + if (this.effect === 'flash') { document.title = this.title === document.title ? this.message : this.title; - } else if (this.effect === "scroll") { - var title = this.message || document.title; - + } else if (this.effect === 'scroll') { + const title = this.message || document.title; if (!this.scrollTitle || !this.scrollTitle.slice(1)) { document.title = title; this.scrollTitle = title; @@ -154,205 +147,187 @@ document.title = this.scrollTitle; } } - return this; }, // 设置标题 - setTitle: function setTitle(str) { + setTitle(str) { if (str === true) { if (repeatableEffects.indexOf(this.effect) >= 0) { return this.addTimer(); } } else if (str) { this.message = str; - this.scrollTitle = ""; + this.scrollTitle = ''; this.addTimer(); } else { this.clearTimer(); } - return this; }, - setURL: function setURL(url) { + setURL(url) { if (url) { if (this.audioElm) { this.audioElm.remove(); } - this.audioElm = createAudio(url); document.body.appendChild(this.audioElm); } - return this; }, - loopPlay: function loopPlay() { + loopPlay() { this.setURL(); this.audioElm.loop = true; this.player(); return this; }, - stopPlay: function stopPlay() { - this.audioElm && (this.audioElm.loop = false, this.audioElm.pause()); + stopPlay() { + this.audioElm && ((this.audioElm.loop = false), this.audioElm.pause()); return this; }, // 播放声音 - player: function player() { + player() { if (!this.audio || !this.audio.file) { return; } - if (!this.audioElm) { this.audioElm = createAudio(this.audio.file); document.body.appendChild(this.audioElm); } - - this.audioElm.play(); + this.audioElm.muted = false; + const resp = this.audioElm.play(); + if (resp !== undefined) { + resp.then(() => { + // autoplay starts! + }).catch(() => { + // show error + }); + } return this; }, - notify: function notify(json) { - var nt = this.notification; - var url = json.openurl ? json.openurl : this.openurl; - var onclick = json.onclick ? json.onclick : this.onclick; - + notify(json) { + let nt = this.notification; + const url = json.openurl ? json.openurl : this.openurl; + const onclick = json.onclick ? json.onclick : this.onclick; if (window.Notification) { if (json) { nt = jsonArguments(json, nt); } else { nt = defaultNotification; } - - var option = {}; + const option = {}; option.icon = json.icon ? json.icon : iconURL; option.body = nt.body || json.body; if (json.dir) option.dir = json.dir; - var n = new Notification(nt.title || json.title, option); - - n.onclick = function () { - onclick && typeof onclick === "function" && onclick(n); + const n = new Notification(nt.title || json.title, option); + n.onclick = () => { + onclick && typeof onclick === 'function' && onclick(n); url && window.open(url); }; - - n.onshow = function () { - json.onshow && typeof json.onshow === "function" && json.onshow(n); + n.onshow = () => { + json.onshow && typeof json.onshow === 'function' && json.onshow(n); }; - - n.onclose = function () { - json.onclose && typeof json.onclose === "function" && json.onclose(n); + n.onclose = () => { + json.onclose && typeof json.onclose === 'function' && json.onclose(n); }; - - n.onerror = function () { - json.onerror && typeof json.onerror === "function" && json.onerror(n); + n.onerror = () => { + json.onerror && typeof json.onerror === 'function' && json.onerror(n); }; - this.Notifiy = n; } - return this; }, // 是否许可弹框通知 - isPermission: function isPermission() { - return window.Notification && Notification.permission === "granted"; + isPermission() { + return window.Notification && Notification.permission === 'granted'; }, // 设置时间间隔 - setInterval: function setInterval(num) { + setInterval(num) { if (num) { this.interval = num; this.addTimer(); } - return this; }, // 设置网页Icon - setFavicon: function setFavicon(num) { + setFavicon(num) { if (!num && num !== 0) { return this.faviconClear(); } - - var oldicon = document.getElementById("new".concat(this.updateFavicon.id)); - + const oldicon = document.getElementById(`new${this.updateFavicon.id}`); if (this.favicon) { this.favicon.remove(); } - if (oldicon) { oldicon.remove(); } - this.updateFavicon.num = num; changeFavicon(num, this.updateFavicon); return this; }, // 设置 Favicon 文字颜色 - setFaviconColor: function setFaviconColor(color) { + setFaviconColor(color) { if (color) { this.faviconRemove(); this.updateFavicon.textColor = color; changeFavicon(this.updateFavicon.num, this.updateFavicon); } - return this; }, // 设置 Favicon 背景颜色 - setFaviconBackgroundColor: function setFaviconBackgroundColor(color) { + setFaviconBackgroundColor(color) { if (color) { this.faviconRemove(); this.updateFavicon.backgroundColor = color; changeFavicon(this.updateFavicon.num, this.updateFavicon); } - return this; }, - faviconRemove: function faviconRemove() { + faviconRemove() { this.faviconClear(); - var oldicon = document.getElementById("new".concat(this.updateFavicon.id)); - + const oldicon = document.getElementById(`new${this.updateFavicon.id}`); if (this.favicon) { this.favicon.remove(); } - if (oldicon) { oldicon.remove(); } }, // 添加计数器 - addTimer: function addTimer() { + addTimer() { this.clearTimer(); - if (repeatableEffects.indexOf(this.effect) >= 0) { this.timer = setInterval(this.render.bind(this), this.interval); } - return this; }, - close: function close() { + close() { if (this.Notifiy) this.Notifiy.close(); }, // 清除Icon - faviconClear: function faviconClear() { - var newicon = document.getElementById("new".concat(this.updateFavicon.id)); - var head = document.getElementsByTagName("head")[0]; - var ficon = document.querySelectorAll("link[rel~=shortcut]"); + faviconClear() { + const newicon = document.getElementById(`new${this.updateFavicon.id}`); + const head = document.getElementsByTagName('head')[0]; + const ficon = document.querySelectorAll('link[rel~=shortcut]'); newicon && newicon.remove(); - if (ficon.length > 0) { - for (var i = 0; i < ficon.length; i++) { + for (let i = 0; i < ficon.length; i++) { ficon[i].remove(); } } - head.appendChild(this.cloneFavicon); iconURL = this.cloneFavicon.href; this.favicon = this.cloneFavicon; return this; }, // 清除计数器 - clearTimer: function clearTimer() { + clearTimer() { this.timer && clearInterval(this.timer); document.title = this.title; return this; - } + }, }; return Notify; -}))); +})); +//# sourceMappingURL=notify.js.map diff --git a/dist/notify.js.map b/dist/notify.js.map new file mode 100644 index 0000000..0f2f8b7 --- /dev/null +++ b/dist/notify.js.map @@ -0,0 +1 @@ +{"version":3,"file":"notify.js","sources":["../src/main.js"],"sourcesContent":["// 提醒是否添加chrome通知\nif (window.Notification && window.Notification.permission !== 'granted') {\n window.Notification.requestPermission();\n}\nlet iconURL = '';\nconst repeatableEffects = ['flash', 'scroll'];\n\nconst defaultNotification = {\n title: 'iNotify !',\n body: 'You have a new message.',\n openurl: '',\n};\nfunction jsonArguments(news, olds) {\n for (const a in olds) {\n if (news[a]) {\n olds[a] = news[a];\n }\n }\n return olds;\n}\nfunction isArray(value) {\n return Object.prototype.toString.call(value) === '[object Array]';\n}\n\nfunction createAudio(url) {\n const audioElm = document.createElement('audio');\n audioElm.autoplay = true;\n audioElm.muted = true;\n let source;\n if (isArray(url) && url.length > 0) {\n for (let i = 0; i < url.length; i++) {\n source = document.createElement('source');\n source.src = url[i];\n source.type = `audio/${getExtension(url[i])}`;\n audioElm.appendChild(source);\n }\n } else {\n audioElm.src = url;\n }\n return audioElm;\n}\n\nfunction getFavicon(setting) {\n let ic = document.querySelectorAll('link[rel~=shortcut]')[0];\n if (!ic) {\n ic = changeFavicon('O', setting);\n }\n return ic;\n}\n\nfunction getExtension(fileName) {\n return fileName.match(/\\.([^\\\\.]+)$/)[1];\n}\n\nfunction changeFavicon(num, settings) {\n const canvas = document.createElement('canvas');\n const head = document.getElementsByTagName('head')[0];\n const linkTag = document.createElement('link');\n let ctx = null;\n\n canvas.height = 32;\n canvas.width = 32;\n ctx = canvas.getContext('2d');\n ctx.fillStyle = settings.backgroundColor;\n ctx.fillRect(0, 0, 32, 32);\n\n ctx.textAlign = 'center';\n ctx.font = '22px \"helvetica\", sans-serif';\n ctx.fillStyle = settings.textColor;\n num && ctx.fillText(num, 16, 24);\n\n // 生成到\n linkTag.setAttribute('rel', 'shortcut icon');\n linkTag.setAttribute('type', 'image/x-icon');\n linkTag.setAttribute('id', `new${settings.id}`);\n linkTag.setAttribute('href', canvas.toDataURL('image/png'));\n iconURL = canvas.toDataURL('image/png');\n return head.appendChild(linkTag);\n}\n\nfunction Notify(config) {\n if (config) {\n this.init(config);\n }\n}\n\nNotify.prototype = {\n init(config) {\n if (!config) {\n config = {};\n }\n this.interval = config.interval || 100; // 响应时长\n this.effect = config.effect || 'flash'; // 效果\n this.title = config.title || document.title; // 标题\n this.message = config.message || this.title; // 原来的标题\n this.onclick = config.onclick || this.onclick; // 点击事件\n this.openurl = config.openurl || this.openurl; // 点击事件\n this.disableFavicon = config.disableFavicon || false; // 禁用favicon 默认开启\n this.updateFavicon = !this.disableFavicon\n && (config.updateFavicon || {\n id: 'favicon',\n textColor: '#fff',\n backgroundColor: '#2F9A00',\n });\n this.audio = config.audio || '';\n this.favicon = !this.disableFavicon && getFavicon(this.updateFavicon);\n this.cloneFavicon = this.favicon && this.favicon.cloneNode(true);\n iconURL = config.notification && config.notification.icon\n ? config.notification.icon\n : config.icon\n ? config.icon\n : this.favicon.href;\n defaultNotification.icon = iconURL;\n this.notification = config.notification || defaultNotification;\n // 初始化生成声音文件节点\n if (this.audio && this.audio.file) {\n this.setURL(this.audio.file);\n }\n return this;\n },\n render() {\n if (this.effect === 'flash') {\n document.title = this.title === document.title ? this.message : this.title;\n } else if (this.effect === 'scroll') {\n const title = this.message || document.title;\n if (!this.scrollTitle || !this.scrollTitle.slice(1)) {\n document.title = title;\n this.scrollTitle = title;\n } else {\n this.scrollTitle = this.scrollTitle.slice(1);\n document.title = this.scrollTitle;\n }\n }\n return this;\n },\n // 设置标题\n setTitle(str) {\n if (str === true) {\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n return this.addTimer();\n }\n } else if (str) {\n this.message = str;\n this.scrollTitle = '';\n this.addTimer();\n } else {\n this.clearTimer();\n }\n return this;\n },\n setURL(url) {\n if (url) {\n if (this.audioElm) {\n this.audioElm.remove();\n }\n this.audioElm = createAudio(url);\n document.body.appendChild(this.audioElm);\n }\n return this;\n },\n loopPlay() {\n this.setURL();\n this.audioElm.loop = true;\n this.player();\n return this;\n },\n stopPlay() {\n this.audioElm && ((this.audioElm.loop = false), this.audioElm.pause());\n return this;\n },\n // 播放声音\n player() {\n if (!this.audio || !this.audio.file) {\n return;\n }\n if (!this.audioElm) {\n this.audioElm = createAudio(this.audio.file);\n document.body.appendChild(this.audioElm);\n }\n this.audioElm.muted = false;\n const resp = this.audioElm.play();\n if (resp !== undefined) {\n resp.then(() => {\n // autoplay starts!\n }).catch(() => {\n // show error\n });\n }\n return this;\n },\n notify(json) {\n let nt = this.notification;\n const url = json.openurl ? json.openurl : this.openurl;\n const onclick = json.onclick ? json.onclick : this.onclick;\n if (window.Notification) {\n if (json) {\n nt = jsonArguments(json, nt);\n } else {\n nt = defaultNotification;\n }\n const option = {};\n option.icon = json.icon ? json.icon : iconURL;\n option.body = nt.body || json.body;\n if (json.dir) option.dir = json.dir;\n const n = new Notification(nt.title || json.title, option);\n n.onclick = () => {\n onclick && typeof onclick === 'function' && onclick(n);\n url && window.open(url);\n };\n n.onshow = () => {\n json.onshow && typeof json.onshow === 'function' && json.onshow(n);\n };\n n.onclose = () => {\n json.onclose && typeof json.onclose === 'function' && json.onclose(n);\n };\n n.onerror = () => {\n json.onerror && typeof json.onerror === 'function' && json.onerror(n);\n };\n this.Notifiy = n;\n }\n return this;\n },\n // 是否许可弹框通知\n isPermission() {\n return window.Notification && Notification.permission === 'granted';\n },\n // 设置时间间隔\n setInterval(num) {\n if (num) {\n this.interval = num;\n this.addTimer();\n }\n return this;\n },\n // 设置网页Icon\n setFavicon(num) {\n if (!num && num !== 0) {\n return this.faviconClear();\n }\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n this.updateFavicon.num = num;\n changeFavicon(num, this.updateFavicon);\n return this;\n },\n // 设置 Favicon 文字颜色\n setFaviconColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.textColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n // 设置 Favicon 背景颜色\n setFaviconBackgroundColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.backgroundColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n faviconRemove() {\n this.faviconClear();\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n },\n // 添加计数器\n addTimer() {\n this.clearTimer();\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n this.timer = setInterval(this.render.bind(this), this.interval);\n }\n return this;\n },\n close() {\n if (this.Notifiy) this.Notifiy.close();\n },\n // 清除Icon\n faviconClear() {\n const newicon = document.getElementById(`new${this.updateFavicon.id}`);\n const head = document.getElementsByTagName('head')[0];\n const ficon = document.querySelectorAll('link[rel~=shortcut]');\n newicon && newicon.remove();\n if (ficon.length > 0) {\n for (let i = 0; i < ficon.length; i++) {\n ficon[i].remove();\n }\n }\n head.appendChild(this.cloneFavicon);\n iconURL = this.cloneFavicon.href;\n this.favicon = this.cloneFavicon;\n return this;\n },\n // 清除计数器\n clearTimer() {\n this.timer && clearInterval(this.timer);\n document.title = this.title;\n return this;\n },\n};\n\nexport default Notify;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;EAAA;EACA,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE;EACzE,EAAE,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC;EAC1C,CAAC;EACD,IAAI,OAAO,GAAG,EAAE,CAAC;EACjB,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,Q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AAC;EAC3C,GAAG;EACH;EACA,EAAE,YAAY,GAAG;EACjB,IAAI,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;EAC3E,IAAI,MAAM,IAAI,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;EAC1D,IAAI,MAAM,KAAK,GAAG,QAAQ,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;EACnE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;EAChC,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;EAC1B,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;EAC7C,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;EAC1B,OAAO;EACP,KAAK;EACL,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;EACxC,IAAI,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;EACrC,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;EACrC,IAAI,OAAO,IAAI,CAAC;EAChB,GAAG;EACH;EACA,EAAE,UAAU,GAAG;EACf,IAAI,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5C,IAAI,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;EAChC,IAAI,OAAO,IAAI,CAAC;EAChB,GAAG;EACH,CAAC;;;;;;;;"} \ No newline at end of file diff --git a/dist/notify.min.js b/dist/notify.min.js index 6325974..87504e7 100644 --- a/dist/notify.min.js +++ b/dist/notify.min.js @@ -1,2 +1,3 @@ -/*! @wcjiang/notify v2.0.12 | MIT (c) 2018 kenny wang | http://jaywcjlove.github.io/iNotify */ -!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.Notify=i()}(this,function(){"use strict";window.Notification&&"granted"!==window.Notification.permission&&window.Notification.requestPermission();var s="",i=["flash","scroll"],r={title:"iNotify !",body:"You have a new message.",openurl:""};function e(t){var i,e=document.createElement("audio");if("[object Array]"===Object.prototype.toString.call(t)&&00)for(let n=0;n=0)return this.addTimer()}else t?(this.message=t,this.scrollTitle="",this.addTimer()):this.clearTimer();return this},setURL(t){return t&&(this.audioElm&&this.audioElm.remove(),this.audioElm=o(t),document.body.appendChild(this.audioElm)),this},loopPlay(){return this.setURL(),this.audioElm.loop=!0,this.player(),this},stopPlay(){return this.audioElm&&(this.audioElm.loop=!1,this.audioElm.pause()),this},player(){if(!this.audio||!this.audio.file)return;this.audioElm||(this.audioElm=o(this.audio.file),document.body.appendChild(this.audioElm)),this.audioElm.muted=!1;const t=this.audioElm.play();return void 0!==t&&t.then((()=>{})).catch((()=>{})),this},notify(i){let o=this.notification;const n=i.openurl?i.openurl:this.openurl,s=i.onclick?i.onclick:this.onclick;if(window.Notification){o=i?function(t,i){for(const e in i)t[e]&&(i[e]=t[e]);return i}(i,o):e;const l={};l.icon=i.icon?i.icon:t,l.body=o.body||i.body,i.dir&&(l.dir=i.dir);const c=new Notification(o.title||i.title,l);c.onclick=()=>{s&&"function"==typeof s&&s(c),n&&window.open(n)},c.onshow=()=>{i.onshow&&"function"==typeof i.onshow&&i.onshow(c)},c.onclose=()=>{i.onclose&&"function"==typeof i.onclose&&i.onclose(c)},c.onerror=()=>{i.onerror&&"function"==typeof i.onerror&&i.onerror(c)},this.Notifiy=c}return this},isPermission:()=>window.Notification&&"granted"===Notification.permission,setInterval(t){return t&&(this.interval=t,this.addTimer()),this},setFavicon(t){if(!t&&0!==t)return this.faviconClear();const i=document.getElementById(`new${this.updateFavicon.id}`);return this.favicon&&this.favicon.remove(),i&&i.remove(),this.updateFavicon.num=t,n(t,this.updateFavicon),this},setFaviconColor(t){return t&&(this.faviconRemove(),this.updateFavicon.textColor=t,n(this.updateFavicon.num,this.updateFavicon)),this},setFaviconBackgroundColor(t){return t&&(this.faviconRemove(),this.updateFavicon.backgroundColor=t,n(this.updateFavicon.num,this.updateFavicon)),this},faviconRemove(){this.faviconClear();const t=document.getElementById(`new${this.updateFavicon.id}`);this.favicon&&this.favicon.remove(),t&&t.remove()},addTimer(){return this.clearTimer(),i.indexOf(this.effect)>=0&&(this.timer=setInterval(this.render.bind(this),this.interval)),this},close(){this.Notifiy&&this.Notifiy.close()},faviconClear(){const i=document.getElementById(`new${this.updateFavicon.id}`),e=document.getElementsByTagName("head")[0],o=document.querySelectorAll("link[rel~=shortcut]");if(i&&i.remove(),o.length>0)for(let t=0;t 0) {\n for (let i = 0; i < url.length; i++) {\n source = document.createElement('source');\n source.src = url[i];\n source.type = `audio/${getExtension(url[i])}`;\n audioElm.appendChild(source);\n }\n } else {\n audioElm.src = url;\n }\n return audioElm;\n}\n\nfunction getFavicon(setting) {\n let ic = document.querySelectorAll('link[rel~=shortcut]')[0];\n if (!ic) {\n ic = changeFavicon('O', setting);\n }\n return ic;\n}\n\nfunction getExtension(fileName) {\n return fileName.match(/\\.([^\\\\.]+)$/)[1];\n}\n\nfunction changeFavicon(num, settings) {\n const canvas = document.createElement('canvas');\n const head = document.getElementsByTagName('head')[0];\n const linkTag = document.createElement('link');\n let ctx = null;\n\n canvas.height = 32;\n canvas.width = 32;\n ctx = canvas.getContext('2d');\n ctx.fillStyle = settings.backgroundColor;\n ctx.fillRect(0, 0, 32, 32);\n\n ctx.textAlign = 'center';\n ctx.font = '22px \"helvetica\", sans-serif';\n ctx.fillStyle = settings.textColor;\n num && ctx.fillText(num, 16, 24);\n\n // 生成到\n linkTag.setAttribute('rel', 'shortcut icon');\n linkTag.setAttribute('type', 'image/x-icon');\n linkTag.setAttribute('id', `new${settings.id}`);\n linkTag.setAttribute('href', canvas.toDataURL('image/png'));\n iconURL = canvas.toDataURL('image/png');\n return head.appendChild(linkTag);\n}\n\nfunction Notify(config) {\n if (config) {\n this.init(config);\n }\n}\n\nNotify.prototype = {\n init(config) {\n if (!config) {\n config = {};\n }\n this.interval = config.interval || 100; // 响应时长\n this.effect = config.effect || 'flash'; // 效果\n this.title = config.title || document.title; // 标题\n this.message = config.message || this.title; // 原来的标题\n this.onclick = config.onclick || this.onclick; // 点击事件\n this.openurl = config.openurl || this.openurl; // 点击事件\n this.disableFavicon = config.disableFavicon || false; // 禁用favicon 默认开启\n this.updateFavicon = !this.disableFavicon\n && (config.updateFavicon || {\n id: 'favicon',\n textColor: '#fff',\n backgroundColor: '#2F9A00',\n });\n this.audio = config.audio || '';\n this.favicon = !this.disableFavicon && getFavicon(this.updateFavicon);\n this.cloneFavicon = this.favicon && this.favicon.cloneNode(true);\n iconURL = config.notification && config.notification.icon\n ? config.notification.icon\n : config.icon\n ? config.icon\n : this.favicon.href;\n defaultNotification.icon = iconURL;\n this.notification = config.notification || defaultNotification;\n // 初始化生成声音文件节点\n if (this.audio && this.audio.file) {\n this.setURL(this.audio.file);\n }\n return this;\n },\n render() {\n if (this.effect === 'flash') {\n document.title = this.title === document.title ? this.message : this.title;\n } else if (this.effect === 'scroll') {\n const title = this.message || document.title;\n if (!this.scrollTitle || !this.scrollTitle.slice(1)) {\n document.title = title;\n this.scrollTitle = title;\n } else {\n this.scrollTitle = this.scrollTitle.slice(1);\n document.title = this.scrollTitle;\n }\n }\n return this;\n },\n // 设置标题\n setTitle(str) {\n if (str === true) {\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n return this.addTimer();\n }\n } else if (str) {\n this.message = str;\n this.scrollTitle = '';\n this.addTimer();\n } else {\n this.clearTimer();\n }\n return this;\n },\n setURL(url) {\n if (url) {\n if (this.audioElm) {\n this.audioElm.remove();\n }\n this.audioElm = createAudio(url);\n document.body.appendChild(this.audioElm);\n }\n return this;\n },\n loopPlay() {\n this.setURL();\n this.audioElm.loop = true;\n this.player();\n return this;\n },\n stopPlay() {\n this.audioElm && ((this.audioElm.loop = false), this.audioElm.pause());\n return this;\n },\n // 播放声音\n player() {\n if (!this.audio || !this.audio.file) {\n return;\n }\n if (!this.audioElm) {\n this.audioElm = createAudio(this.audio.file);\n document.body.appendChild(this.audioElm);\n }\n this.audioElm.muted = false;\n const resp = this.audioElm.play();\n if (resp !== undefined) {\n resp.then(() => {\n // autoplay starts!\n }).catch(() => {\n // show error\n });\n }\n return this;\n },\n notify(json) {\n let nt = this.notification;\n const url = json.openurl ? json.openurl : this.openurl;\n const onclick = json.onclick ? json.onclick : this.onclick;\n if (window.Notification) {\n if (json) {\n nt = jsonArguments(json, nt);\n } else {\n nt = defaultNotification;\n }\n const option = {};\n option.icon = json.icon ? json.icon : iconURL;\n option.body = nt.body || json.body;\n if (json.dir) option.dir = json.dir;\n const n = new Notification(nt.title || json.title, option);\n n.onclick = () => {\n onclick && typeof onclick === 'function' && onclick(n);\n url && window.open(url);\n };\n n.onshow = () => {\n json.onshow && typeof json.onshow === 'function' && json.onshow(n);\n };\n n.onclose = () => {\n json.onclose && typeof json.onclose === 'function' && json.onclose(n);\n };\n n.onerror = () => {\n json.onerror && typeof json.onerror === 'function' && json.onerror(n);\n };\n this.Notifiy = n;\n }\n return this;\n },\n // 是否许可弹框通知\n isPermission() {\n return window.Notification && Notification.permission === 'granted';\n },\n // 设置时间间隔\n setInterval(num) {\n if (num) {\n this.interval = num;\n this.addTimer();\n }\n return this;\n },\n // 设置网页Icon\n setFavicon(num) {\n if (!num && num !== 0) {\n return this.faviconClear();\n }\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n this.updateFavicon.num = num;\n changeFavicon(num, this.updateFavicon);\n return this;\n },\n // 设置 Favicon 文字颜色\n setFaviconColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.textColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n // 设置 Favicon 背景颜色\n setFaviconBackgroundColor(color) {\n if (color) {\n this.faviconRemove();\n this.updateFavicon.backgroundColor = color;\n changeFavicon(this.updateFavicon.num, this.updateFavicon);\n }\n return this;\n },\n faviconRemove() {\n this.faviconClear();\n const oldicon = document.getElementById(`new${this.updateFavicon.id}`);\n if (this.favicon) {\n this.favicon.remove();\n }\n if (oldicon) {\n oldicon.remove();\n }\n },\n // 添加计数器\n addTimer() {\n this.clearTimer();\n if (repeatableEffects.indexOf(this.effect) >= 0) {\n this.timer = setInterval(this.render.bind(this), this.interval);\n }\n return this;\n },\n close() {\n if (this.Notifiy) this.Notifiy.close();\n },\n // 清除Icon\n faviconClear() {\n const newicon = document.getElementById(`new${this.updateFavicon.id}`);\n const head = document.getElementsByTagName('head')[0];\n const ficon = document.querySelectorAll('link[rel~=shortcut]');\n newicon && newicon.remove();\n if (ficon.length > 0) {\n for (let i = 0; i < ficon.length; i++) {\n ficon[i].remove();\n }\n }\n head.appendChild(this.cloneFavicon);\n iconURL = this.cloneFavicon.href;\n this.favicon = this.cloneFavicon;\n return this;\n },\n // 清除计数器\n clearTimer() {\n this.timer && clearInterval(this.timer);\n document.title = this.title;\n return this;\n },\n};\n\nexport default Notify;\n"],"names":["window","Notification","permission","requestPermission","iconURL","repeatableEffects","defaultNotification","title","body","openurl","createAudio","url","audioElm","document","createElement","source","autoplay","muted","value","Object","prototype","toString","call","length","i","src","type","fileName","match","appendChild","changeFavicon","num","settings","canvas","head","getElementsByTagName","linkTag","ctx","height","width","getContext","fillStyle","backgroundColor","fillRect","textAlign","font","textColor","fillText","setAttribute","id","toDataURL","Notify","config","this","init","interval","effect","message","onclick","disableFavicon","updateFavicon","audio","favicon","setting","ic","querySelectorAll","getFavicon","cloneFavicon","cloneNode","notification","icon","href","file","setURL","render","scrollTitle","slice","setTitle","str","indexOf","addTimer","clearTimer","remove","loopPlay","loop","player","stopPlay","pause","resp","play","undefined","then","catch","notify","json","nt","news","olds","a","jsonArguments","option","dir","n","open","onshow","onclose","onerror","Notifiy","isPermission","setInterval","setFavicon","faviconClear","oldicon","getElementById","setFaviconColor","color","faviconRemove","setFaviconBackgroundColor","timer","bind","close","newicon","ficon","clearInterval"],"mappings":";uOACIA,OAAOC,cAAmD,YAAnCD,OAAOC,aAAaC,YAC7CF,OAAOC,aAAaE,oBAEtB,IAAIC,EAAU,GACd,MAAMC,EAAoB,CAAC,QAAS,UAE9BC,EAAsB,CAC1BC,MAAO,YACPC,KAAM,0BACNC,QAAS,IAcX,SAASC,EAAYC,GACnB,MAAMC,EAAWC,SAASC,cAAc,SAGxC,IAAIC,EACJ,GAHAH,EAASI,UAAW,EACpBJ,EAASK,OAAQ,EAPFC,EASHP,EARqC,mBAA1CQ,OAAOC,UAAUC,SAASC,KAAKJ,IAQlBP,EAAIY,OAAS,EAC/B,IAAK,IAAIC,EAAI,EAAGA,EAAIb,EAAIY,OAAQC,IAC9BT,EAASF,SAASC,cAAc,UAChCC,EAAOU,IAAMd,EAAIa,GACjBT,EAAOW,KAAO,SAiBEC,EAjBoBhB,EAAIa,GAkBrCG,EAASC,MAAM,gBAAgB,KAjBlChB,EAASiB,YAAYd,QAGvBH,EAASa,IAAMd,EAanB,IAAsBgB,EA9BLT,EAmBf,OAAON,EAeT,SAASkB,EAAcC,EAAKC,GAC1B,MAAMC,EAASpB,SAASC,cAAc,UAChCoB,EAAOrB,SAASsB,qBAAqB,QAAQ,GAC7CC,EAAUvB,SAASC,cAAc,QACvC,IAAIuB,EAAM,KAmBV,OAjBAJ,EAAOK,OAAS,GAChBL,EAAOM,MAAQ,GACfF,EAAMJ,EAAOO,WAAW,MACxBH,EAAII,UAAYT,EAASU,gBACzBL,EAAIM,SAAS,EAAG,EAAG,GAAI,IAEvBN,EAAIO,UAAY,SAChBP,EAAIQ,KAAO,+BACXR,EAAII,UAAYT,EAASc,UACzBf,GAAOM,EAAIU,SAAShB,EAAK,GAAI,IAG7B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package-lock.json index e2af864..1920db9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,6 @@ "eslint-plugin-jsx-a11y": "^6.1.0", "eslint-plugin-react": "^7.10.0", "kkt": "~7.1.5", - "maxmin": "~4.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "rollup": "~2.70.0", @@ -29502,8 +29501,7 @@ "dev": true }, "maxmin": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-4.0.0.tgz", + "version": "https://registry.npmjs.org/maxmin/-/maxmin-4.0.0.tgz", "integrity": "sha512-+PBstm8/IM6AFVGpOBqk7ddJHZu6KSGWDHQzncOQKAY6AlMgZC7dWS2Y2MrJll4rJZqWcF76g+zWCQn9lIsfEQ==", "dev": true, "requires": { diff --git a/package.json b/package.json index b3d18b6..19595e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wcjiang/notify", - "version": "2.0.12", + "version": "2.1.0", "description": "JS achieve the browser title flashing , scrolling, voice prompts , chrome notice.", "main": "index.js", "module": "dist/notify.esm.js",