[Frontend][系統監控] 調整為卡片式呈現

This commit is contained in:
dev01 2022-11-21 18:47:47 +08:00
parent bcb07e0054
commit 36e64f8eac
17 changed files with 52996 additions and 357 deletions

View File

@ -14,15 +14,15 @@
<div class="col-sm-12 col-xl-5">
<div class="d-flex mb-4" style="gap:15px">
<div class="row m-0 align-items-center">
<span id="sysNorLight" class="circle-light mr-2"></span>
<span id="sysNorLight" class="circle-light mr-2 " data-light-type="normal"></span>
<label class="mb-0">正常</label>
</div>
<div class="row m-0 align-items-center">
<span id="sysCloLight" class="circle-light mr-2"></span>
<span id="sysCloLight" class="circle-light mr-2" data-light-type="close"></span>
<label class="mb-0">關機</label>
</div>
<div class="row m-0 align-items-center">
<span id="sysErrLight" class="circle-light mr-2"></span>
<span id="sysErrLight" class="circle-light mr-2" data-light-type="error"></span>
<label class="mb-0">異常</label>
</div>
</div>
@ -49,25 +49,44 @@
$(function () {
getFloDevList();
loadStaLight();
setLightColor();
})
function loadStaLight() {
if (pageAct.sysSubObj.device_normal_color) {
$("#sysNorLight").css("background-color", pageAct.sysSubObj.device_normal_color);
} else {
$("#sysNorLight").addClass("bg-success");
}
if (pageAct.sysSubObj.device_close_color) {
$("#sysCloLight").css("background-color", pageAct.sysSubObj.device_close_color);
} else {
$("#sysCloLight").addClass("bg-secondary");
}
if (pageAct.sysSubObj.device_error_color) {
$("#sysErrLight").css("background-color", pageAct.sysSubObj.device_error_color);
} else {
$("#sysErrLight").addClass("bg-danger");
}
//function loadStaLight() {
// if (pageAct.sysSubObj.device_normal_color) {
// $("#sysNorLight").css("background-color", pageAct.sysSubObj.device_normal_color);
// } else {
// $("#sysNorLight").addClass("bg-success");
// }
// if (pageAct.sysSubObj.device_close_color) {
// $("#sysCloLight").css("background-color", pageAct.sysSubObj.device_close_color);
// } else {
// $("#sysCloLight").addClass("bg-secondary");
// }
// if (pageAct.sysSubObj.device_error_color) {
// $("#sysErrLight").css("background-color", pageAct.sysSubObj.device_error_color);
// } else {
// $("#sysErrLight").addClass("bg-danger");
// }
//}
function setLightColor() {
$("[data-light-type]").each((index, ele) => {
let type = $(ele).data("light-type");
let color = "#000";
switch (type) {
case "normal":
color = pageAct.sysSubObj.device_normal_color ?? "var(--theme-success)";
break;
case "close":
color = pageAct.sysSubObj.device_close_color ?? "var(--theme-secondary)";
break;
case "error":
color = pageAct.sysSubObj.device_error_color ?? "var(--theme-danger)";
break;
}
$(ele).css("background-color", color);
})
}
function getFloDevList() {
@ -84,15 +103,28 @@
} else {
let strHtml = ``;
$.each(res.data, (index, floObj) => {
strHtml += `<div class='d-flex justify-content-start mb-5' style="height:60px">`
strHtml += `<div class='d-flex justify-content-start mb-5' style="">`
strHtml += `<button id="floItemBtn${floObj.full_name}" type="button" class="btn btn-primary waves-effect waves-themed mr-5 align-self-center" >${floObj.full_name}</button>`
$.each(floObj.device_list, (index2, devObj) => {
console.log(">>>> url: " + baseImgUrl + " , img: " + varPathImg + ", icon: " + devObj.device_master_icon);
strHtml += `<div name="devItem" data-id="${devObj.device_guid}" data-number="${devObj.device_number}" data-name="${devObj.full_name}" class="mr-5 cur-poi">
<span class="status status-success d-inline-block">
<img src="${baseImgUrl + varPathImg + devObj.device_master_icon}" class="profile-image rounded-circle" onerror="defDev(this)" alt="...">
</span> ${devObj.full_name}
strHtml += `<div class="card m-1 border device-wrap" style="width:300px">
<div class="card-body p-2">
<div class="d-flex mb-2">
<div class="mr-5 cur-poi">
<span class="d-inline-block mr-3">
<img src="${baseImgUrl + varPathImg + devObj.device_master_icon}" class="profile-image rounded-circle" onerror="defDev(this)" alt="...">
</span>
<a href="javascript:;">${devObj.full_name}</a>
</div>
</div>
<div class="d-flex mb-0 mt-2 align-items-center">
<span id="${devObj.device_number}_status" class="circle-light" data-light-type="normal"></span>
<span class="d-none">即時功率:</span>
<a href="javascript:;" name="devItem" data-id="${devObj.device_guid}" data-number="${devObj.device_number}" data-name="${devObj.full_name}" class=" ml-2 mb-0 ">詳細資料</a>
</div>
</div>
</div>`;
})
strHtml += "</div>"
@ -163,7 +195,11 @@
let devName = $(ele).data("name"); //full_name
$(ele).YTTooltip({
html: `<div class="card m-1 border device-wrap">
<div class="col-12 p-0 row justify-content-end m-0">
<button class="btn p-2"><i class="fas fa-times fs-1 text-white-50" data-close="yttooltip"></i></button>
</div>
<div class="card-header p-2 px-3">
<div class="position-absolute w-50" style="word-break: break-all;">
<label class="m-0 mt-2">${devName}</label>
</div>
@ -267,7 +303,7 @@
{
"title": "異常ID",
"data": "uuid",
},
{
"title": "異常原因",

View File

@ -1,4 +1,4 @@
/*
/*
* FileSaver.js
* A saveAs() FileSaver implementation.
*
@ -11,59 +11,59 @@
// The one and only way of getting global scope in all environments
// https://stackoverflow.com/q/3277182/1008999
var _global = typeof window === 'object' && window.window === window
? window : typeof self === 'object' && self.self === self
? self : typeof global === 'object' && global.global === global
? global
: this
? window : typeof self === 'object' && self.self === self
? self : typeof global === 'object' && global.global === global
? global
: this
function bom(blob, opts) {
if (typeof opts === 'undefined') opts = { autoBom: false }
else if (typeof opts !== 'object') {
console.warn('Deprecated: Expected third argument to be a object')
opts = { autoBom: !opts }
}
function bom (blob, opts) {
if (typeof opts === 'undefined') opts = { autoBom: false }
else if (typeof opts !== 'object') {
console.warn('Deprecated: Expected third argument to be a object')
opts = { autoBom: !opts }
}
// prepend BOM for UTF-8 XML and text/* types (including HTML)
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(0xFEFF), blob], { type: blob.type })
}
return blob
// prepend BOM for UTF-8 XML and text/* types (including HTML)
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(0xFEFF), blob], { type: blob.type })
}
return blob
}
function download(url, name, opts) {
var xhr = new XMLHttpRequest()
xhr.open('GET', url)
xhr.responseType = 'blob'
xhr.onload = function () {
saveAs(xhr.response, name, opts)
}
xhr.onerror = function () {
console.error('could not download file')
}
function download (url, name, opts) {
var xhr = new XMLHttpRequest()
xhr.open('GET', url)
xhr.responseType = 'blob'
xhr.onload = function () {
saveAs(xhr.response, name, opts)
}
xhr.onerror = function () {
console.error('could not download file')
}
xhr.send()
}
function corsEnabled (url) {
var xhr = new XMLHttpRequest()
// use sync to avoid popup blocker
xhr.open('HEAD', url, false)
try {
xhr.send()
}
function corsEnabled(url) {
var xhr = new XMLHttpRequest()
// use sync to avoid popup blocker
xhr.open('HEAD', url, false)
try {
xhr.send()
} catch (e) { }
return xhr.status >= 200 && xhr.status <= 299
} catch (e) {}
return xhr.status >= 200 && xhr.status <= 299
}
// `a.click()` doesn't work for all browsers (#465)
function click(node) {
try {
node.dispatchEvent(new MouseEvent('click'))
} catch (e) {
var evt = document.createEvent('MouseEvents')
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80,
20, false, false, false, false, 0, null)
node.dispatchEvent(evt)
}
function click (node) {
try {
node.dispatchEvent(new MouseEvent('click'))
} catch (e) {
var evt = document.createEvent('MouseEvents')
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80,
20, false, false, false, false, 0, null)
node.dispatchEvent(evt)
}
}
// Detect WebView inside a native macOS app by ruling out all browsers
@ -72,100 +72,100 @@ function click(node) {
var isMacOSWebView = _global.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent)
var saveAs = _global.saveAs || (
// probably in some web worker
(typeof window !== 'object' || window !== _global)
? function saveAs() { /* noop */ }
// probably in some web worker
(typeof window !== 'object' || window !== _global)
? function saveAs () { /* noop */ }
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
: ('download' in HTMLAnchorElement.prototype && !isMacOSWebView)
? function saveAs(blob, name, opts) {
var URL = _global.URL || _global.webkitURL
var a = document.createElement('a')
name = name || blob.name || 'download'
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
: ('download' in HTMLAnchorElement.prototype && !isMacOSWebView)
? function saveAs (blob, name, opts) {
var URL = _global.URL || _global.webkitURL
var a = document.createElement('a')
name = name || blob.name || 'download'
a.download = name
a.rel = 'noopener' // tabnabbing
a.download = name
a.rel = 'noopener' // tabnabbing
// TODO: detect chrome extensions & packaged apps
// a.target = '_blank'
// TODO: detect chrome extensions & packaged apps
// a.target = '_blank'
if (typeof blob === 'string') {
// Support regular links
a.href = blob
if (a.origin !== location.origin) {
corsEnabled(a.href)
? download(blob, name, opts)
: click(a, a.target = '_blank')
} else {
click(a)
}
} else {
// Support blobs
a.href = URL.createObjectURL(blob)
setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s
setTimeout(function () { click(a) }, 0)
}
}
if (typeof blob === 'string') {
// Support regular links
a.href = blob
if (a.origin !== location.origin) {
corsEnabled(a.href)
? download(blob, name, opts)
: click(a, a.target = '_blank')
} else {
click(a)
}
} else {
// Support blobs
a.href = URL.createObjectURL(blob)
setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s
setTimeout(function () { click(a) }, 0)
}
}
// Use msSaveOrOpenBlob as a second approach
: 'msSaveOrOpenBlob' in navigator
? function saveAs(blob, name, opts) {
name = name || blob.name || 'download'
// Use msSaveOrOpenBlob as a second approach
: 'msSaveOrOpenBlob' in navigator
? function saveAs (blob, name, opts) {
name = name || blob.name || 'download'
if (typeof blob === 'string') {
if (corsEnabled(blob)) {
download(blob, name, opts)
} else {
var a = document.createElement('a')
a.href = blob
a.target = '_blank'
setTimeout(function () { click(a) })
}
} else {
navigator.msSaveOrOpenBlob(bom(blob, opts), name)
}
}
if (typeof blob === 'string') {
if (corsEnabled(blob)) {
download(blob, name, opts)
} else {
var a = document.createElement('a')
a.href = blob
a.target = '_blank'
setTimeout(function () { click(a) })
}
} else {
navigator.msSaveOrOpenBlob(bom(blob, opts), name)
}
}
// Fallback to using FileReader and a popup
: function saveAs(blob, name, opts, popup) {
// Open a popup immediately do go around popup blocker
// Mostly only available on user interaction and the fileReader is async so...
popup = popup || open('', '_blank')
if (popup) {
popup.document.title =
popup.document.body.innerText = 'downloading...'
}
// Fallback to using FileReader and a popup
: function saveAs (blob, name, opts, popup) {
// Open a popup immediately do go around popup blocker
// Mostly only available on user interaction and the fileReader is async so...
popup = popup || open('', '_blank')
if (popup) {
popup.document.title =
popup.document.body.innerText = 'downloading...'
}
if (typeof blob === 'string') return download(blob, name, opts)
if (typeof blob === 'string') return download(blob, name, opts)
var force = blob.type === 'application/octet-stream'
var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent)
var force = blob.type === 'application/octet-stream'
var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent)
if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && typeof FileReader !== 'undefined') {
// Safari doesn't allow downloading of blob URLs
var reader = new FileReader()
reader.onloadend = function () {
var url = reader.result
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;')
if (popup) popup.location.href = url
else location = url
popup = null // reverse-tabnabbing #460
}
reader.readAsDataURL(blob)
} else {
var URL = _global.URL || _global.webkitURL
var url = URL.createObjectURL(blob)
if (popup) popup.location = url
else location.href = url
popup = null // reverse-tabnabbing #460
setTimeout(function () { URL.revokeObjectURL(url) }, 4E4) // 40s
}
}
if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && typeof FileReader !== 'undefined') {
// Safari doesn't allow downloading of blob URLs
var reader = new FileReader()
reader.onloadend = function () {
var url = reader.result
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;')
if (popup) popup.location.href = url
else location = url
popup = null // reverse-tabnabbing #460
}
reader.readAsDataURL(blob)
} else {
var URL = _global.URL || _global.webkitURL
var url = URL.createObjectURL(blob)
if (popup) popup.location = url
else location.href = url
popup = null // reverse-tabnabbing #460
setTimeout(function () { URL.revokeObjectURL(url) }, 4E4) // 40s
}
}
)
_global.saveAs = saveAs.saveAs = saveAs
if (typeof module !== 'undefined') {
module.exports = saveAs;
module.exports = saveAs;
}

View File

@ -1,4 +1,4 @@
/** vim: et:ts=4:sw=4:sts=4
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.3.3 Copyright jQuery Foundation and other contributors.
* Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
*/
@ -26,7 +26,7 @@ var requirejs, require, define;
// then 'complete'. The UA check is unfortunate, but not sure how
//to feature test w/o causing perf issues.
readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
/^complete$/ : /^(complete|loaded)$/,
/^complete$/ : /^(complete|loaded)$/,
defContextName = '_',
//Oh the tragedy, detecting opera. See the usage of isOpera for reason.
isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
@ -359,7 +359,7 @@ var requirejs, require, define;
if (isBrowser) {
each(scripts(), function (scriptNode) {
if (scriptNode.getAttribute('data-requiremodule') === name &&
scriptNode.getAttribute('data-requirecontext') === context.contextName) {
scriptNode.getAttribute('data-requirecontext') === context.contextName) {
scriptNode.parentNode.removeChild(scriptNode);
return true;
}
@ -456,8 +456,8 @@ var requirejs, require, define;
// loading of a loader plugin. But for now, fixes the
// common uses. Details in #1131
normalizedName = name.indexOf('!') === -1 ?
normalize(name, parentName, applyMap) :
name;
normalize(name, parentName, applyMap) :
name;
}
} else {
//A regular module.
@ -479,8 +479,8 @@ var requirejs, require, define;
//normalization, stamp it with a unique ID so two matching relative
//ids that may conflict can be separate.
suffix = prefix && !pluginModule && !isNormalized ?
'_unnormalized' + (unnormalizedCounter += 1) :
'';
'_unnormalized' + (unnormalizedCounter += 1) :
'';
return {
prefix: prefix,
@ -491,8 +491,8 @@ var requirejs, require, define;
originalName: originalName,
isDefine: isDefine,
id: (prefix ?
prefix + '!' + normalizedName :
normalizedName) + suffix
prefix + '!' + normalizedName :
normalizedName) + suffix
};
}
@ -512,7 +512,7 @@ var requirejs, require, define;
mod = getOwn(registry, id);
if (hasProp(defined, id) &&
(!mod || mod.defineEmitComplete)) {
(!mod || mod.defineEmitComplete)) {
if (name === 'defined') {
fn(defined[id]);
}
@ -558,7 +558,7 @@ var requirejs, require, define;
function takeGlobalQueue() {
//Push all the globalDefQueue items into the context's defQueue
if (globalDefQueue.length) {
each(globalDefQueue, function (queueItem) {
each(globalDefQueue, function(queueItem) {
var id = queueItem[0];
if (typeof id === 'string') {
context.defQueueMap[id] = true;
@ -974,8 +974,8 @@ var requirejs, require, define;
//prefix and name should already be normalized, no need
//for applying map config again either.
normalizedMap = makeModuleMap(map.prefix + '!' + name,
this.map.parentMap,
true);
this.map.parentMap,
true);
on(normalizedMap,
'defined', bind(this, function (value) {
this.map.normalizedMap = normalizedMap;
@ -1067,10 +1067,10 @@ var requirejs, require, define;
req.exec(text);
} catch (e) {
return onError(makeError('fromtexteval',
'fromText eval for ' + id +
' failed: ' + e,
e,
[id]));
'fromText eval for ' + id +
' failed: ' + e,
e,
[id]));
}
if (hasInteractive) {
@ -1117,9 +1117,9 @@ var requirejs, require, define;
//Dependency needs to be converted to a depMap
//and wired up to this module.
depMap = makeModuleMap(depMap,
(this.map.isDefine ? this.map : this.map.parentMap),
false,
!this.skipMap);
(this.map.isDefine ? this.map : this.map.parentMap),
false,
!this.skipMap);
this.depMaps[i] = depMap;
handler = getOwn(handlers, depMap.id);
@ -1145,7 +1145,7 @@ var requirejs, require, define;
// No direct errback on this module, but something
// else is listening for errors, so be sure to
// propagate the error correctly.
on(depMap, 'error', bind(this, function (err) {
on(depMap, 'error', bind(this, function(err) {
this.emit('error', err);
}));
}
@ -1290,7 +1290,7 @@ var requirejs, require, define;
// Convert old style urlArgs string to a function.
if (typeof cfg.urlArgs === 'string') {
var urlArgs = cfg.urlArgs;
cfg.urlArgs = function (id, url) {
cfg.urlArgs = function(id, url) {
return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
};
}
@ -1349,7 +1349,7 @@ var requirejs, require, define;
each(cfg.packages, function (pkgObj) {
var location, name;
pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
name = pkgObj.name;
location = pkgObj.location;
@ -1363,8 +1363,8 @@ var requirejs, require, define;
//envs have different conventions: some use a module name,
//some use a file name.
config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
.replace(currDirRegExp, '')
.replace(jsSuffixRegExp, '');
.replace(currDirRegExp, '')
.replace(jsSuffixRegExp, '');
});
}
@ -1434,10 +1434,10 @@ var requirejs, require, define;
if (!hasProp(defined, id)) {
return onError(makeError('notloaded', 'Module name "' +
id +
'" has not been loaded yet for context: ' +
contextName +
(relMap ? '' : '. Use require([])')));
id +
'" has not been loaded yet for context: ' +
contextName +
(relMap ? '' : '. Use require([])')));
}
return defined[id];
}
@ -1489,7 +1489,7 @@ var requirejs, require, define;
}
return context.nameToUrl(normalize(moduleNamePlusExt,
relMap && relMap.id, true), ext, true);
relMap && relMap.id, true), ext, true);
},
defined: function (id) {
@ -1522,7 +1522,7 @@ var requirejs, require, define;
//Clean queued defines too. Go backwards
//in array so that the splices do not
//mess up the iteration.
eachReverse(defQueue, function (args, i) {
eachReverse(defQueue, function(args, i) {
if (args[0] === id) {
defQueue.splice(i, 1);
}
@ -1601,9 +1601,9 @@ var requirejs, require, define;
return;
} else {
return onError(makeError('nodefine',
'No define call for ' + moduleName,
null,
[moduleName]));
'No define call for ' + moduleName,
null,
[moduleName]));
}
} else {
//A script that does not call define(), so just simulate
@ -1676,7 +1676,7 @@ var requirejs, require, define;
}
return config.urlArgs && !/^blob\:/.test(url) ?
url + config.urlArgs(moduleName, url) : url;
url + config.urlArgs(moduleName, url) : url;
},
//Delegates to req.load. Broken out as a separate function to
@ -1707,7 +1707,7 @@ var requirejs, require, define;
//all old browsers will be supported, but this one was easy enough
//to support and still makes sense.
if (evt.type === 'load' ||
(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
//Reset interactive script so a script node is not held onto for
//to long.
interactiveScript = null;
@ -1725,9 +1725,9 @@ var requirejs, require, define;
var data = getScriptData(evt);
if (!hasPathFallback(data.id)) {
var parents = [];
eachProp(registry, function (value, key) {
eachProp(registry, function(value, key) {
if (key.indexOf('_@r') !== 0) {
each(value.depMaps, function (depMap) {
each(value.depMaps, function(depMap) {
if (depMap.id === data.id) {
parents.push(key);
return true;
@ -1736,9 +1736,9 @@ var requirejs, require, define;
}
});
return onError(makeError('scripterror', 'Script error for "' + data.id +
(parents.length ?
'", needed by: ' + parents.join(', ') :
'"'), evt, [data.id]));
(parents.length ?
'", needed by: ' + parents.join(', ') :
'"'), evt, [data.id]));
}
}
};
@ -1874,8 +1874,8 @@ var requirejs, require, define;
*/
req.createNode = function (config, moduleName, url) {
var node = config.xhtml ?
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
document.createElement('script');
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
document.createElement('script');
node.type = config.scriptType || 'text/javascript';
node.charset = 'utf-8';
node.async = true;
@ -1910,15 +1910,15 @@ var requirejs, require, define;
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
//script execution mode.
if (node.attachEvent &&
//Check if node.attachEvent is artificially added by custom script or
//natively supported by browser
//read https://github.com/requirejs/requirejs/issues/187
//if we can NOT find [native code] then it must NOT natively supported.
//in IE8, node.attachEvent does not have toString()
//Note the test for "[native code" with no closing brace, see:
//https://github.com/requirejs/requirejs/issues/273
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
!isOpera) {
//Check if node.attachEvent is artificially added by custom script or
//natively supported by browser
//read https://github.com/requirejs/requirejs/issues/187
//if we can NOT find [native code] then it must NOT natively supported.
//in IE8, node.attachEvent does not have toString()
//Note the test for "[native code" with no closing brace, see:
//https://github.com/requirejs/requirejs/issues/273
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
!isOpera) {
//Probably IE. IE (at least 6-8) do not fire
//script onload right after executing the script, so
//we cannot tie the anonymous define call to a name.
@ -1975,17 +1975,17 @@ var requirejs, require, define;
// Post a task to the event loop to work around a bug in WebKit
// where the worker gets garbage-collected after calling
// importScripts(): https://webkit.org/b/153317
setTimeout(function () { }, 0);
setTimeout(function() {}, 0);
importScripts(url);
//Account for anonymous modules
context.completeLoad(moduleName);
} catch (e) {
context.onError(makeError('importscripts',
'importScripts failed for ' +
moduleName + ' at ' + url,
e,
[moduleName]));
'importScripts failed for ' +
moduleName + ' at ' + url,
e,
[moduleName]));
}
}
};
@ -2029,7 +2029,7 @@ var requirejs, require, define;
//baseUrl.
src = mainScript.split('/');
mainScript = src.pop();
subPath = src.length ? src.join('/') + '/' : './';
subPath = src.length ? src.join('/') + '/' : './';
cfg.baseUrl = subPath;
}

View File

@ -1,69 +1,70 @@
var require = typeof require === 'undefined' ? {} : require;
var require = typeof require === 'undefined' ? {} : require;
require.urlArgs = require.urlArgs || 'version=1496767636459';
require.waitSeconds = 0;
require.config = require.config || {};
require.config.ord = require.config.ord || {};
require.config.ord.useLocalWbRc = false;
require.config.baja = require.config.baja || {};
require.config.baja.webdev = false;
require.config.baja.offline = false;
require.config.lex = require.config.lex || {};
require.config.lex.webdev = false;
require.hbs = require.hbs || {};
require.hbs.i18n = require.hbs.i18n === undefined ? false : require.hbs.i18n;
require.hbs.helpers = require.hbs.helpers === undefined ? false : require.hbs.helpers;
require.urlArgs=require.urlArgs || 'version=1496767636459';
require.waitSeconds=0;
require.config=require.config || {};
require.config.ord=require.config.ord || {};
require.config.ord.useLocalWbRc=false;
require.config.baja=require.config.baja || {};
require.config.baja.webdev=false;
require.config.baja.offline=false;
require.config.lex=require.config.lex || {};
require.config.lex.webdev=false;
require.hbs=require.hbs || {};
require.hbs.i18n=require.hbs.i18n===undefined?false:require.hbs.i18n;
require.hbs.helpers=require.hbs.helpers===undefined?false:require.hbs.helpers;
require.hbs.fetchText = function (uri, callback) {
function unmodularize(href) {
var res;
if (href) {
res = /^module:\/\/(.+)$/.exec(href);
if (res && res[1]) {
href = '/module/' + res[1];
}
}
return href;
function unmodularize(href) {
var res;
if (href) {
res = /^module:\/\/(.+)$/.exec(href);
if (res && res[1]) {
href = '/module/' + res[1];
}
}
require(['baja!', 'jquery'], function (baja, $) {
if (baja.isOffline()) {
uri = /([^?]*)\??.*/.exec(uri)[1];
uri = uri.replace('https://workbench/module/', 'module://');
baja.rpc('type:web:FileRpc', 'readTextFile', uri)
.then(function (text) {
callback(text, uri);
});
}
else {
$.ajax(unmodularize(uri)).then(function (text) {
callback(text, uri);
});
}
});
return href;
}
require(['baja!', 'jquery'], function (baja, $) {
if (baja.isOffline()) {
uri = /([^?]*)\??.*/.exec(uri)[1];
uri = uri.replace('https://workbench/module/', 'module://');
baja.rpc('type:web:FileRpc', 'readTextFile', uri)
.then(function (text) {
callback(text, uri);
});
}
else {
$.ajax(unmodularize(uri)).then(function (text) {
callback(text, uri);
});
}
});
};
require.config['nmodule/js/rc/lex/lex'] = { storageId: '1496767636459', lang: 'en-US' };
require.paths = require.paths || {};
require.paths.nmodule = require.paths.nmodule || '/module';
require.paths.Promise = require.paths.Promise || '/module/js/rc/bluebird/bluebird.min';
require.paths.bajaScript = require.paths.bajaScript || '/module/bajaScript/rc';
require.paths.bajaux = require.paths.bajaux || '/module/bajaux/rc';
require.paths.jquery = require.paths.jquery || '/module/js/rc/jquery/jquery-3.1.1.min';
require.config['nmodule/js/rc/lex/lex']={storageId:'1496767636459',lang:'en-US'};
require.paths=require.paths || {};
//require.paths.jquery=require.paths.jquery || '/module/js/rc/jquery/jquery-3.1.1.min'; //add
require.paths.nmodule=require.paths.nmodule || '/module';
require.paths.Promise=require.paths.Promise || '/module/js/rc/bluebird/bluebird.min';
require.paths.bajaScript=require.paths.bajaScript || '/module/bajaScript/rc';
require.paths.bajaux=require.paths.bajaux || '/module/bajaux/rc';
//require.paths.jquery=require.paths.jquery || '/module/js/rc/jquery/jquery-3.1.1.min';
//require.paths.jqueryUI=require.paths.jqueryUI || 'file:^html/js/jquery-ui.min';
require.paths.dialogs = require.paths.dialogs || '/module/js/rc/dialogs/dialogs.built.min';
require.paths.ord = require.paths.ord || '/module/js/com/tridium/js/require/ord';
require.paths.lex = require.paths.lex || '/module/js/rc/lex/lexplugin';
require.paths.css = require.paths.css || '/module/js/com/tridium/js/ext/require/css';
require.paths.baja = require.paths.baja || '/module/bajaScript/rc/plugin/baja';
require.paths.obix = require.paths.obix || '/module/obixjs/rc/obix.built.min';
require.paths.Handlebars = require.paths.Handlebars || '/module/js/rc/handlebars/handlebars.min-v2.0.0';
require.paths.underscore = require.paths.underscore || '/module/js/rc/underscore/underscore.min';
require.paths.hbs = require.paths.hbs || '/module/js/rc/require-handlebars-plugin/hbs.built.min';
require.paths.moment = require.paths.moment || '/module/js/rc/moment/moment.min';
require.paths.d3 = require.paths.d3 || '/module/js/rc/d3/d3.min';
require.paths.hx = require.paths.hx || '/module/hx/javax/baja/hx/hx';
require.paths.jqueryContextMenu = require.paths.jqueryContextMenu || '/module/js/rc/jquery/contextMenu/jquery.contextMenu';
require.paths.ace = require.paths.ace || '/module/js/rc/ace';
require.shim = require.shim || {};
require.shim.d3 = require.shim.d3 || {};
require.shim.d3.exports = require.shim.d3.exports || 'd3';
require.shim.jqueryContextMenu = require.shim.jqueryContextMenu || { deps: ['jquery'], exports: 'jQuery' };
require.paths.dialogs=require.paths.dialogs || '/module/js/rc/dialogs/dialogs.built.min';
require.paths.ord=require.paths.ord || '/module/js/com/tridium/js/require/ord';
require.paths.lex=require.paths.lex || '/module/js/rc/lex/lexplugin';
require.paths.css=require.paths.css || '/module/js/com/tridium/js/ext/require/css';
require.paths.baja=require.paths.baja || '/module/bajaScript/rc/plugin/baja';
require.paths.obix=require.paths.obix || '/module/obixjs/rc/obix.built.min';
require.paths.Handlebars=require.paths.Handlebars || '/module/js/rc/handlebars/handlebars.min-v2.0.0';
require.paths.underscore=require.paths.underscore || '/module/js/rc/underscore/underscore.min';
require.paths.hbs=require.paths.hbs || '/module/js/rc/require-handlebars-plugin/hbs.built.min';
require.paths.moment=require.paths.moment || '/module/js/rc/moment/moment.min';
require.paths.d3=require.paths.d3 || '/module/js/rc/d3/d3.min';
require.paths.hx=require.paths.hx || '/module/hx/javax/baja/hx/hx';
require.paths.jqueryContextMenu=require.paths.jqueryContextMenu || '/module/js/rc/jquery/contextMenu/jquery.contextMenu';
require.paths.ace=require.paths.ace || '/module/js/rc/ace';
require.shim=require.shim || {};
require.shim.d3=require.shim.d3 || {};
require.shim.d3.exports=require.shim.d3.exports || 'd3';
//require.shim.jqueryContextMenu=require.shim.jqueryContextMenu || {deps:['jquery'],exports:'jQuery'};

View File

@ -1,12 +1,12 @@
require.config({
require.config({
baseUrl: 'js',
"paths": {
"jquery-ui": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui",
"jquery-ui-min": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min",
"d3": "https://d3js.org/d3.v4.min"
"jquery-ui": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui",
"jquery-ui-min": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min",
"d3" : "https://d3js.org/d3.v4.min"
},
shim: {
"d3": {
exports: "d3"

View File

@ -6,15 +6,6 @@ var varApiUrl = "/api/"; //API路徑
var varPathImg = "/Upload/Images/";
var varPathFile = "/Upload/Files/";
var statusArr = { 1: "啟用", 0: "未啟用", 9: "刪除" };
var common = {
AddSuc:"新增成功",
EditSuc:"編輯成功",
DelSuc:"刪除成功",
AddErr:"新增失敗,",
EditErr:"編輯失敗,",
DelErr: "刪除失敗,",
SysErr: "系統內部發生錯誤,請聯繫系統管理員"
}
var objSendData = { Data: null };
//重新轉址 for Niagara4

10872
Frontend/js/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,4 @@

function addzero(num) {
return num < 10 ? '0' + num : num;
}
/**
* 取得異常資料 by baja
* @param {any} startDate_millisecond
@ -19,7 +15,7 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
var _bfName = "";
var _sourceName = "";
var _index = 0;
var _recoverState = isRecover ? "!= null" : "= null"
var _recoverState = isRecover ? "!= null" : "= null";
var _ackState = isAck ? "= 1" : "!= 1";
require(['baja!'], function (baja) {
@ -54,8 +50,6 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
var _result = "";
var _ss = "";
var _occurrenceTime = "";
var _normalTime = "";
var _index = 0;
//{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
require(['baja!'], function (baja) {
@ -63,29 +57,16 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
.then(function (table) {
return table.cursor({
each: function (record) {
_occurrenceTime = "";
_normalTime = "";
var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60
var _timestampTemp = new Date(record.get('timestamp').toString());
_occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
//var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
var _normaltime = new Date(record.get('normalTime').toString());
_normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
var _msgText = record.get('alarmData').get('msgText') == 1 ? _occurrenceTime : "未確認";
if (_index == 0)
_ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
_ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
else
_ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
_ss += ',{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index + ', "data":[';
_result += '{' + '"count": ' + _index +', data:[';
_result += _ss + ']';
_result += _ss+']';
_result += '}';
if (typeof callback === 'function') {
callback(_result);

30430
Frontend/js/r.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -19,30 +19,6 @@ $.fn.outerHtml = function () {
return $(this).prop("outerHTML");
}
/**
* jquery validate 初始設定 | 輸出含原元素 html
*/
$.validator.setDefaults({
onkeyup: function (element, event) {
$(element).valid();
},
//errorPlacement: function (error, element) {
// if (element.hasClass("removedTitle"))
// error.insertAfter(element.next("img"));
// else
// error.insertAfter(element);
//}
});
jQuery.validator.addMethod("phone", function (phoneNumber, element) {
phoneNumber = phoneNumber.replace(/\s+/g, "");
return phoneNumber.match(/^[0-9]{9,10}$/);
}, "請輸入正確電話號碼格式");
jQuery.validator.addMethod("dbLimit", function (value, element,param) {
return value.length > param;
}, "超出輸入限制");
/**
* 設置 bootstrap dropdown 為下拉選單
* @param {any} menuEle .dropdown-menu element
@ -65,10 +41,6 @@ function setDropdownItem(menuEle) {
})
}
onEvent("click", "[e-prevent]", function (e) {
e.preventDefault();
})
/**
* 預設設備圖像
* @param {any} obj
@ -83,7 +55,6 @@ function dtAjaxResetSendData(table,sendData) {
d = sendData;
return JSON.stringify(d)
}
table.ajax.reload();
}
/**
@ -131,6 +102,6 @@ function creSelect(id = null, cls = [], name = null, data = {}, attr = {}, text
}
function creOption(text = null, value = null, data = {}, attr = {}, cls = [], name = null, id = null) {
value != null ? attr.value = value : "";
attr = value != null ? attr.value = value : attr;
return creEle("option", text, id, name, cls, data, attr);
}

View File

@ -95,6 +95,8 @@ $.fn.YTTooltip = function (option) {
} else if (obj.direction == "top" || obj.direction == "bottom"){
$(clone).css({ left: offset.left, top: top});
}
event();
} else {
obj.hideTooltipEvent(tooId);
}
@ -108,6 +110,8 @@ $.fn.YTTooltip = function (option) {
obj.hideTooltipEvent(tooId);
})
}
})
if (obj.toggle == "hover") {
@ -130,7 +134,15 @@ $.fn.YTTooltip = function (option) {
//}, 100)
}
function event() {
let tooId = $(obj.ele).data("yttooltipid");
$("#yt_tooltip_" + tooId).off("click", "[data-close='yttooltip']");
$("#yt_tooltip_" + tooId).on("click", "[data-close='yttooltip']", function () {
hideTooltipEvent(tooId);
})
}
eleArr.push(obj);
})
@ -139,6 +151,8 @@ $.fn.YTTooltip = function (option) {
return result;
}
function resetYTTooltip() {
$("[id^=yt_tooltip_]").remove();
}

10872
Frontend/lib/jquery/dist/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,476 @@
/*
* Toastr
* Copyright 2012-2015
* Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
* All Rights Reserved.
* Use, reproduction, distribution, and modification of this code is subject to the terms and
* conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
*
* ARIA Support: Greta Krafsig
*
* Project: https://github.com/CodeSeven/toastr
*/
/* global define */
(function (define) {
define(['jquery'], function ($) {
return (function () {
var $container;
var listener;
var toastId = 0;
var toastType = {
error: 'error',
info: 'info',
success: 'success',
warning: 'warning'
};
var toastr = {
clear: clear,
remove: remove,
error: error,
getContainer: getContainer,
info: info,
options: {},
subscribe: subscribe,
success: success,
version: '2.1.4',
warning: warning
};
var previousToast;
return toastr;
////////////////
function error(message, title, optionsOverride) {
return notify({
type: toastType.error,
iconClass: getOptions().iconClasses.error,
message: message,
optionsOverride: optionsOverride,
title: title
});
}
function getContainer(options, create) {
if (!options) { options = getOptions(); }
$container = $('#' + options.containerId);
if ($container.length) {
return $container;
}
if (create) {
$container = createContainer(options);
}
return $container;
}
function info(message, title, optionsOverride) {
return notify({
type: toastType.info,
iconClass: getOptions().iconClasses.info,
message: message,
optionsOverride: optionsOverride,
title: title
});
}
function subscribe(callback) {
listener = callback;
}
function success(message, title, optionsOverride) {
return notify({
type: toastType.success,
iconClass: getOptions().iconClasses.success,
message: message,
optionsOverride: optionsOverride,
title: title
});
}
function warning(message, title, optionsOverride) {
return notify({
type: toastType.warning,
iconClass: getOptions().iconClasses.warning,
message: message,
optionsOverride: optionsOverride,
title: title
});
}
function clear($toastElement, clearOptions) {
var options = getOptions();
if (!$container) { getContainer(options); }
if (!clearToast($toastElement, options, clearOptions)) {
clearContainer(options);
}
}
function remove($toastElement) {
var options = getOptions();
if (!$container) { getContainer(options); }
if ($toastElement && $(':focus', $toastElement).length === 0) {
removeToast($toastElement);
return;
}
if ($container.children().length) {
$container.remove();
}
}
// internal functions
function clearContainer (options) {
var toastsToClear = $container.children();
for (var i = toastsToClear.length - 1; i >= 0; i--) {
clearToast($(toastsToClear[i]), options);
}
}
function clearToast ($toastElement, options, clearOptions) {
var force = clearOptions && clearOptions.force ? clearOptions.force : false;
if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
$toastElement[options.hideMethod]({
duration: options.hideDuration,
easing: options.hideEasing,
complete: function () { removeToast($toastElement); }
});
return true;
}
return false;
}
function createContainer(options) {
$container = $('<div/>')
.attr('id', options.containerId)
.addClass(options.positionClass);
$container.appendTo($(options.target));
return $container;
}
function getDefaults() {
return {
tapToDismiss: true,
toastClass: 'toast',
containerId: 'toast-container',
debug: false,
showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
showDuration: 300,
showEasing: 'swing', //swing and linear are built into jQuery
onShown: undefined,
hideMethod: 'fadeOut',
hideDuration: 1000,
hideEasing: 'swing',
onHidden: undefined,
closeMethod: false,
closeDuration: false,
closeEasing: false,
closeOnHover: true,
extendedTimeOut: 1000,
iconClasses: {
error: 'toast-error',
info: 'toast-info',
success: 'toast-success',
warning: 'toast-warning'
},
iconClass: 'toast-info',
positionClass: 'toast-top-right',
timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
titleClass: 'toast-title',
messageClass: 'toast-message',
escapeHtml: false,
target: 'body',
closeHtml: '<button type="button">&times;</button>',
closeClass: 'toast-close-button',
newestOnTop: true,
preventDuplicates: false,
progressBar: false,
progressClass: 'toast-progress',
rtl: false
};
}
function publish(args) {
if (!listener) { return; }
listener(args);
}
function notify(map) {
var options = getOptions();
var iconClass = map.iconClass || options.iconClass;
if (typeof (map.optionsOverride) !== 'undefined') {
options = $.extend(options, map.optionsOverride);
iconClass = map.optionsOverride.iconClass || iconClass;
}
if (shouldExit(options, map)) { return; }
toastId++;
$container = getContainer(options, true);
var intervalId = null;
var $toastElement = $('<div/>');
var $titleElement = $('<div/>');
var $messageElement = $('<div/>');
var $progressElement = $('<div/>');
var $closeElement = $(options.closeHtml);
var progressBar = {
intervalId: null,
hideEta: null,
maxHideTime: null
};
var response = {
toastId: toastId,
state: 'visible',
startTime: new Date(),
options: options,
map: map
};
personalizeToast();
displayToast();
handleEvents();
publish(response);
if (options.debug && console) {
console.log(response);
}
return $toastElement;
function escapeHtml(source) {
if (source == null) {
source = '';
}
return source
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
function personalizeToast() {
setIcon();
setTitle();
setMessage();
setCloseButton();
setProgressBar();
setRTL();
setSequence();
setAria();
}
function setAria() {
var ariaValue = '';
switch (map.iconClass) {
case 'toast-success':
case 'toast-info':
ariaValue = 'polite';
break;
default:
ariaValue = 'assertive';
}
$toastElement.attr('aria-live', ariaValue);
}
function handleEvents() {
if (options.closeOnHover) {
$toastElement.hover(stickAround, delayedHideToast);
}
if (!options.onclick && options.tapToDismiss) {
$toastElement.click(hideToast);
}
if (options.closeButton && $closeElement) {
$closeElement.click(function (event) {
if (event.stopPropagation) {
event.stopPropagation();
} else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
event.cancelBubble = true;
}
if (options.onCloseClick) {
options.onCloseClick(event);
}
hideToast(true);
});
}
if (options.onclick) {
$toastElement.click(function (event) {
options.onclick(event);
hideToast();
});
}
}
function displayToast() {
$toastElement.hide();
$toastElement[options.showMethod](
{duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
);
if (options.timeOut > 0) {
intervalId = setTimeout(hideToast, options.timeOut);
progressBar.maxHideTime = parseFloat(options.timeOut);
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
if (options.progressBar) {
progressBar.intervalId = setInterval(updateProgress, 10);
}
}
}
function setIcon() {
if (map.iconClass) {
$toastElement.addClass(options.toastClass).addClass(iconClass);
}
}
function setSequence() {
if (options.newestOnTop) {
$container.prepend($toastElement);
} else {
$container.append($toastElement);
}
}
function setTitle() {
if (map.title) {
var suffix = map.title;
if (options.escapeHtml) {
suffix = escapeHtml(map.title);
}
$titleElement.append(suffix).addClass(options.titleClass);
$toastElement.append($titleElement);
}
}
function setMessage() {
if (map.message) {
var suffix = map.message;
if (options.escapeHtml) {
suffix = escapeHtml(map.message);
}
$messageElement.append(suffix).addClass(options.messageClass);
$toastElement.append($messageElement);
}
}
function setCloseButton() {
if (options.closeButton) {
$closeElement.addClass(options.closeClass).attr('role', 'button');
$toastElement.prepend($closeElement);
}
}
function setProgressBar() {
if (options.progressBar) {
$progressElement.addClass(options.progressClass);
$toastElement.prepend($progressElement);
}
}
function setRTL() {
if (options.rtl) {
$toastElement.addClass('rtl');
}
}
function shouldExit(options, map) {
if (options.preventDuplicates) {
if (map.message === previousToast) {
return true;
} else {
previousToast = map.message;
}
}
return false;
}
function hideToast(override) {
var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
var duration = override && options.closeDuration !== false ?
options.closeDuration : options.hideDuration;
var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
if ($(':focus', $toastElement).length && !override) {
return;
}
clearTimeout(progressBar.intervalId);
return $toastElement[method]({
duration: duration,
easing: easing,
complete: function () {
removeToast($toastElement);
clearTimeout(intervalId);
if (options.onHidden && response.state !== 'hidden') {
options.onHidden();
}
response.state = 'hidden';
response.endTime = new Date();
publish(response);
}
});
}
function delayedHideToast() {
if (options.timeOut > 0 || options.extendedTimeOut > 0) {
intervalId = setTimeout(hideToast, options.extendedTimeOut);
progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
}
}
function stickAround() {
clearTimeout(intervalId);
progressBar.hideEta = 0;
$toastElement.stop(true, true)[options.showMethod](
{duration: options.showDuration, easing: options.showEasing}
);
}
function updateProgress() {
var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
$progressElement.width(percentage + '%');
}
}
function getOptions() {
return $.extend({}, getDefaults(), toastr.options);
}
function removeToast($toastElement) {
if (!$container) { $container = getContainer(); }
if ($toastElement.is(':visible')) {
return;
}
$toastElement.remove();
$toastElement = null;
if ($container.children().length === 0) {
$container.remove();
previousToast = undefined;
}
}
})();
});
}(typeof define === 'function' && define.amd ? define : function (deps, factory) {
if (typeof module !== 'undefined' && module.exports) { //Node
module.exports = factory(require('jquery'));
} else {
window.toastr = factory(window.jQuery);
}
}));