[Frontend] baja使用的js檔
This commit is contained in:
parent
d625ffb16a
commit
280caecb6e
171
Frontend/js/FileSaver.js
Normal file
171
Frontend/js/FileSaver.js
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* FileSaver.js
|
||||||
|
* A saveAs() FileSaver implementation.
|
||||||
|
*
|
||||||
|
* By Eli Grey, http://eligrey.com
|
||||||
|
*
|
||||||
|
* License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)
|
||||||
|
* source : http://purl.eligrey.com/github/FileSaver.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
} 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect WebView inside a native macOS app by ruling out all browsers
|
||||||
|
// We just need to check for 'Safari' because all other browsers (besides Firefox) include that too
|
||||||
|
// https://www.whatismybrowser.com/guides/the-latest-user-agent/macos
|
||||||
|
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 */ }
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
_global.saveAs = saveAs.saveAs = saveAs
|
||||||
|
|
||||||
|
if (typeof module !== 'undefined') {
|
||||||
|
module.exports = saveAs;
|
||||||
|
}
|
2145
Frontend/js/Require.js
Normal file
2145
Frontend/js/Require.js
Normal file
File diff suppressed because it is too large
Load Diff
2145
Frontend/js/bajascript/Require.js
Normal file
2145
Frontend/js/bajascript/Require.js
Normal file
File diff suppressed because it is too large
Load Diff
69
Frontend/js/bajascript/bscriptReq.js
Normal file
69
Frontend/js/bajascript/bscriptReq.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
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.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.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' };
|
15
Frontend/js/bajascript/require.config.js
Normal file
15
Frontend/js/bajascript/require.config.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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"
|
||||||
|
},
|
||||||
|
|
||||||
|
shim: {
|
||||||
|
"d3": {
|
||||||
|
exports: "d3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
4
Frontend/js/jquery-3.1.1.min.js
vendored
Normal file
4
Frontend/js/jquery-3.1.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Frontend/js/jquery.keyframes.min.js
vendored
Normal file
1
Frontend/js/jquery.keyframes.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
Frontend/js/jquery.min.js
vendored
Normal file
12
Frontend/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
function addzero(num) {
|
||||||
|
return num < 10 ? '0' + num : num;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得異常資料 by baja
|
* 取得異常資料 by baja
|
||||||
* @param {any} startDate_millisecond
|
* @param {any} startDate_millisecond
|
||||||
@ -50,6 +54,8 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
|||||||
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||||
var _result = "";
|
var _result = "";
|
||||||
var _ss = "";
|
var _ss = "";
|
||||||
|
var _occurrenceTime = "";
|
||||||
|
var _normalTime = "";
|
||||||
var _index = 0;
|
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": "燈泡故障" }]}
|
//{ "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) {
|
require(['baja!'], function (baja) {
|
||||||
@ -57,14 +63,27 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
|||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
return table.cursor({
|
return table.cursor({
|
||||||
each: function (record) {
|
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)
|
if (_index == 0)
|
||||||
_ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
|
_ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
||||||
else
|
else
|
||||||
_ss += ',{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
|
_ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
||||||
_index++;
|
_index++;
|
||||||
},
|
},
|
||||||
after: function () {
|
after: function () {
|
||||||
_result += '{' + '"count": ' + _index +', data:[';
|
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||||
|
|
||||||
_result += _ss + ']';
|
_result += _ss + ']';
|
||||||
_result += '}';
|
_result += '}';
|
||||||
|
Loading…
Reference in New Issue
Block a user