//reconnect-websocket
;(function (global, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory)
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = factory()
} else {
global.ReconnectingWebSocket = factory()
}
})(this || window, function () {
if (!('WebSocket' in window)) {
console.warn('此浏览器不支持WebSocket')
return
}
if ('ReconnectingWebSocket' in window) {
return
}
function ReconnectingWebSocket(url, protocols, options) {
// Default settings
var settings = {
/** Whether this instance should log debug messages. */
debug: false,
/** Whether or not the websocket should attempt to connect immediately upon instantiation. */
automaticOpen: true,
/** The number of milliseconds to delay before attempting to reconnect. */
reconnectInterval: 1000,
/** The maximum number of milliseconds to delay a reconnection attempt. */
maxReconnectInterval: 30000,
/** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
reconnectDecay: 1.5,
/** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
timeoutInterval: 2000,
/** The maximum number of reconnection attempts to make. Unlimited if null. */
maxReconnectAttempts: null,
/** The binary type, possible values 'blob' or 'arraybuffer', default 'blob'. */
binaryType: 'blob',
}
if (!options) {
options = {}
}
// Overwrite and define settings with options if they exist.
for (var key in settings) {
if (typeof options[key] !== 'undefined') {
this[key] = options[key]
} else {
this[key] = settings[key]
}
}
// These should be treated as read-only properties
/** The URL as resolved by the constructor. This is always an absolute URL. Read only. */
this.url = url
/** The number of attempted reconnects since starting, or the last successful connection. Read only. */
this.reconnectAttempts = 0
/**
* The current state of the connection.
* Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED
* Read only.
*/
this.readyState = WebSocket.CONNECTING
/**
* A string indicating the name of the sub-protocol the server selected; this will be one of
* the strings specified in the protocols parameter when creating the WebSocket object.
* Read only.
*/
this.protocol = null
// Private state variables
var self = this
var ws
var forcedClose = false
var timedOut = false
var eventTarget = document.createElement('div')
// Wire up "on*" properties as event handlers
eventTarget.addEventListener('open', function (event) {
self.onopen(event)
})
eventTarget.addEventListener('close', function (event) {
self.onclose(event)
})
eventTarget.addEventListener('connecting', function (event) {
self.onconnecting(event)
})
eventTarget.addEventListener('message', function (event) {
self.onmessage(event)
})
eventTarget.addEventListener('error', function (event) {
self.onerror(event)
})
// Expose the API required by EventTarget
this.addEventListener = eventTarget.addEventListener.bind(eventTarget)
this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget)
this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget)
/**
* This function generates an event that is compatible with standard
* compliant browsers and IE9 - IE11
*
* This will prevent the error:
* Object doesn't support this action
*
* http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563
* @param s String The name that the event should use
* @param args Object an optional object that the event will use
*/
function generateEvent(s, args) {
var evt = document.createEvent('CustomEvent')
evt.initCustomEvent(s, false, false, args)
return evt
}
this.open = function (reconnectAttempt) {
ws = new WebSocket(self.url, protocols || [])
ws.binaryType = this.binaryType
if (reconnectAttempt) {
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
return
}
} else {
eventTarget.dispatchEvent(generateEvent('connecting'))
this.reconnectAttempts = 0
}
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'attempt-connect', self.url)
}
var localWs = ws
var timeout = setTimeout(function () {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'connection-timeout', self.url)
}
timedOut = true
localWs.close()
timedOut = false
}, self.timeoutInterval)
ws.onopen = function (event) {
clearTimeout(timeout)
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onopen', self.url)
}
self.protocol = ws.protocol
self.readyState = WebSocket.OPEN
self.reconnectAttempts = 0
var e = generateEvent('open')
e.isReconnect = reconnectAttempt
reconnectAttempt = false
eventTarget.dispatchEvent(e)
}
ws.onclose = function (event) {
clearTimeout(timeout)
ws = null
if (forcedClose) {
self.readyState = WebSocket.CLOSED
eventTarget.dispatchEvent(generateEvent('close'))
} else {
self.readyState = WebSocket.CONNECTING
var e = generateEvent('connecting')
e.code = event.code
e.reason = event.reason
e.wasClean = event.wasClean
eventTarget.dispatchEvent(e)
if (!reconnectAttempt && !timedOut) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onclose', self.url)
}
eventTarget.dispatchEvent(generateEvent('close'))
}
var timeout =
self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts)
setTimeout(
function () {
self.reconnectAttempts++
self.open(true)
},
timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout
)
}
}
ws.onmessage = function (event) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data)
}
var e = generateEvent('message')
e.data = event.data
eventTarget.dispatchEvent(e)
}
ws.onerror = function (event) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onerror', self.url, event)
}
eventTarget.dispatchEvent(generateEvent('error'))
}
}
// Whether or not to create a websocket upon instantiation
if (this.automaticOpen == true) {
this.open(false)
}
/**
* Transmits data to the server over the WebSocket connection.
*
* @param data a text string, ArrayBuffer or Blob to send to the server.
*/
this.send = function (data) {
if (ws) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'send', self.url, data)
}
return ws.send(data)
} else {
throw 'INVALID_STATE_ERR : Pausing to reconnect websocket'
}
}
/**
* Closes the WebSocket connection or connection attempt, if any.
* If the connection is already CLOSED, this method does nothing.
*/
this.close = function (code, reason) {
// Default CLOSE_NORMAL code
if (typeof code == 'undefined') {
code = 1000
}
forcedClose = true
if (ws) {
ws.close(code, reason)
}
}
/**
* Additional public API method to refresh the connection if still open (close, re-open).
* For example, if the app suspects bad data / missed heart beats, it can try to refresh.
*/
this.refresh = function () {
if (ws) {
ws.close()
}
}
}
/**
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
* this indicates that the connection is ready to send and receive data.
*/
ReconnectingWebSocket.prototype.onopen = function (event) {}
/** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */
ReconnectingWebSocket.prototype.onclose = function (event) {}
/** An event listener to be called when a connection begins being attempted. */
ReconnectingWebSocket.prototype.onconnecting = function (event) {}
/** An event listener to be called when a message is received from the server. */
ReconnectingWebSocket.prototype.onmessage = function (event) {}
/** An event listener to be called when an error occurs. */
ReconnectingWebSocket.prototype.onerror = function (event) {}
/**
* Whether all instances of ReconnectingWebSocket should log debug messages.
* Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.
*/
ReconnectingWebSocket.debugAll = false
ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING
ReconnectingWebSocket.OPEN = WebSocket.OPEN
ReconnectingWebSocket.CLOSING = WebSocket.CLOSING
ReconnectingWebSocket.CLOSED = WebSocket.CLOSED
return ReconnectingWebSocket
})
let indidocxModule = {
version: '2023.0412.01',
createInstance(options) {
let indidocxobj = {
//对象属性
slCtl: {
id: 0, //slctl的唯一id
forWindowID: CreateRandomId(),
$$idx: {},
Activation: '',
initPortID: 0,
domain: '127.0.0.1',
curFileType: 'default',
strNeedSaveMark: 'false',
strPageNumUrl: '',
strPageNum: '',
strWaterMarkUrl: '',
strWaterMark: '',
strWaterMarkParam: '',
strPageHeader: '',
strPageHeaderUrl: '',
strSpace: '',
uploadCompentInfoUrl: 'api/framework/v1/indidocx/saveIndidocxMessage',
doTime: new Date(),
isV6PluginInstall: false,
isFileOpen: false,
curPromise: {},
checkInstall: function (argsobj, froceUpdate = false) {
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
if (window.idxProcessCheck && !froceUpdate) {
return window.idxProcessCheck
}
if (window.sessionStorage && sessionStorage.getItem('isV6PluginInstall') !== null) {
indidocxobj.slCtl.isV6PluginInstall = JSON.parse(sessionStorage.getItem('isV6PluginInstall'))
return Promise.resolve(indidocxobj.slCtl.isV6PluginInstall)
}
window.idxProcessCheck = indidocxobj.slCtl.Content.Control._initHttpServer(6000)
return window.idxProcessCheck
},
getRef: function (str, start, substr, seperator) {
var pos
var endpos
pos = str.indexOf(substr, start)
if (pos == -1) return ''
endpos = str.indexOf(seperator, pos + 1)
if (endpos == -1) return str.substring(pos + substr.length, str.length)
else return str.substring(pos + substr.length, endpos)
},
getFileType: function (strFileName) {
var arrtmp = strFileName.split('.')
return '.' + arrtmp.pop().toLowerCase()
},
htmldecode: function (s) {
return s
// var div = document.createElement('div')
// div.innerHTML = s
// return div.textContent
},
setFileList: function (data) {
var strlist = new Array()
for (var i = 0; i < data.length; i++) {
strlist.push(
data[i].properties +
'' +
fnGetFileLink(data[i].code) +
''
)
}
if (strlist != null && strlist != undefined) {
indidocxobj.slCtl.Content.Files._FileInfoString = strlist
indidocxobj.slCtl.Content.Files.FileList = indidocxobj.slCtl.analyzeFileList() //解析filelist
}
},
analyzeFileList: function () {
var arrFileMap = indidocxobj.slCtl.Content.Files._FileInfoString.map(function (
onefile,
index
) {
var filelink = ''
if (typeof fnGetFileLink === 'function') {
filelink = fnGetFileLink(
indidocxobj.slCtl.getRef(onefile, 0, '', '')
)
}
return {
FileName: indidocxobj.slCtl.htmldecode(
indidocxobj.slCtl.getRef(onefile, 0, '', '')
),
Unid: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
CatNum: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
Size: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
FileType: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
Completed: parseInt(
indidocxobj.slCtl.getRef(onefile, 0, '', '')
),
doAdd:
indidocxobj.slCtl.getRef(onefile, 0, '', '') == 'True'
? true
: false,
Type: indidocxobj.slCtl.getFileType(
indidocxobj.slCtl.getRef(onefile, 0, '', '')
),
CreateInfo: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
UpdateInfo: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
TaodaInfo: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
NeedUpdate: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
AllowPrint: false,
DocUnid: indidocxobj.slCtl.getRef(onefile, 0, '', ''),
Uploading:
parseInt(indidocxobj.slCtl.getRef(onefile, 0, '', '')) ==
0 && indidocxobj.slCtl.getRef(onefile, 0, '', '') == 'False'
? true
: false,
Link: filelink,
}
})
return arrFileMap
},
socketSend: function (url, opts) {
if ('function' == typeof opts) {
fn = opts
opts = {}
}
if (!opts) opts = {}
var prefix = opts.prefix || '__jp'
// use the callback name that was passed if one was provided.
// otherwise generate a unique name by incrementing our counter.
var id = opts.name || prefix + this.count++
var param = opts.param || 'callback'
// add qs component
var action = url.substr(url.lastIndexOf('/') + 1)
action += (~action.indexOf('?') ? '&' : '?') + param + '=' + encodeURIComponent(id)
action = action.replace('?&', '?')
this.socketSendSafe(action, 5)
},
socketSendSafe(msg, times = 5) {
if (times <= 0) {
console.warn('通信中断')
var start = msg.indexOf('callback') + 16
var callback = msg.substr(start, msg.indexOf('&', start) - start)
window[callback] && window[callback]({ Update: false })
return
}
var curconn = window.IndidocxShareSocket || indidocxobj.slCtl.socket
if (curconn.readyState == WebSocket.CONNECTING) {
console.log('连接中')
setTimeout(function () {
indidocxobj.slCtl.socketSendSafe(msg, times - 1)
}, 500)
} else if (
curconn.readyState == WebSocket.CLOSED ||
curconn.readyState == WebSocket.CLOSING
) {
curconn.open()
console.log('重新启动socket')
setTimeout(function () {
indidocxobj.slCtl.socketSendSafe(msg, times - 1)
}, 500)
} else {
//OPEN
curconn.send(msg)
}
},
receiveMsg: function (msg) {
// console.log('get message ' + msg.data)
eval(msg.data)
},
//控件传输层 V6控件发送请求 以后控件更换逻辑只需修改此函数即可
sendRequest: function (action, contentJson, timeout, method) {
contentJson.sid = indidocxobj.slCtl.id
contentJson.Activation = indidocxobj.slCtl.Activation
contentJson.base_host = location.origin
contentJson.cookie = indidocxobj.slCtl.$$idx.httpserver.cookie
contentJson.refresh_token = indidocxobj.slCtl.$$idx.httpserver.refresh_token
contentJson.getActivationUrl = indidocxobj.slCtl.$$idx.httpserver.getActivationUrl
contentJson.action = action
contentJson.doTime = Date.now()
var queryString = ''
for (var key in contentJson) {
queryString += key + '=' + encodeURIComponent(contentJson[key]) + '&'
}
indidocxobj.slCtl.socketSend(action, { param: queryString, timeout })
},
formatParams: function (argsobj) {
var $$idxtemp = {}
$$idxtemp.httpserver = {}
$$idxtemp.httpserver.sid = argsobj.sid == undefined ? 'testuser' : argsobj.sid
$$idxtemp.httpserver.Activation =
argsobj.Activation == undefined ? '' : argsobj.Activation
$$idxtemp.httpserver.UserName = argsobj.UserName == undefined ? 'admin' : argsobj.UserName
$$idxtemp.httpserver.MaxFileSize =
argsobj.MaxFileSize == undefined ? '20' : argsobj.MaxFileSize
$$idxtemp.httpserver.SetTakeLogConfig =
argsobj.SetTakeLogConfig == undefined ? 'true' : argsobj.SetTakeLogConfig
$$idxtemp.httpserver.RefuseFileType =
argsobj.RefuseFileType == undefined ? '' : argsobj.RefuseFileType
$$idxtemp.httpserver.AcceptFileType =
argsobj.AcceptFileType == undefined ? '' : argsobj.AcceptFileType
$$idxtemp.httpserver.UseMark = argsobj.UseMark == undefined ? 'true' : argsobj.UseMark
$$idxtemp.httpserver.ContentNeedFormate =
argsobj.ContentNeedFormate == undefined ? '' : argsobj.ContentNeedFormate
$$idxtemp.httpserver.TaoDaType = argsobj.TaoDaType == undefined ? '' : argsobj.TaoDaType
$$idxtemp.httpserver.DirDeleteTime =
argsobj.DirDeleteTime == undefined ? '' : argsobj.DirDeleteTime
$$idxtemp.httpserver.FileFilter =
argsobj.FileFilter == undefined ? '' : argsobj.FileFilter
$$idxtemp.httpserver.MultiText = argsobj.MultiText == undefined ? '' : argsobj.MultiText
$$idxtemp.httpserver.MaxAttachCount =
argsobj.MaxAttachCount == undefined ? '' : argsobj.MaxAttachCount
$$idxtemp.httpserver.UseRevise = argsobj.UseRevise == undefined ? '' : argsobj.UseRevise
$$idxtemp.httpserver.UploadParam =
argsobj.UploadParam == undefined ? '' : argsobj.UploadParam
$$idxtemp.httpserver.UploadUrl = argsobj.UploadUrl == undefined ? '' : argsobj.UploadUrl
$$idxtemp.httpserver.ServerUpdateUrl =
argsobj.ServerUpdateUrl == undefined ? '' : argsobj.ServerUpdateUrl
$$idxtemp.httpserver.cookie =
argsobj.cookie == undefined ? '' : this.Base64.encode(argsobj.cookie)
$$idxtemp.httpserver.refresh_token =
argsobj.refresh_token == undefined ? '' : this.Base64.encode(argsobj.refresh_token)
$$idxtemp.httpserver.getActivationUrl =
argsobj.getActivationUrl == undefined ? '' : argsobj.getActivationUrl
$$idxtemp.idxV6version = argsobj.idxV6version == undefined ? '' : argsobj.idxV6version
indidocxobj.slCtl.id = $$idxtemp.httpserver.sid
indidocxobj.slCtl.Activation = $$idxtemp.httpserver.Activation
return $$idxtemp
},
// V6控件打开附件
fnV6OpenFile: function (fname, fileparam) {
indidocxobj.slCtl.isFileOpen = true
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_OpenFileCompleted_', resolve, false)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/openfile'
if (fileparam.NeedUpdate === undefined)
fileparam.NeedUpdate = [1, 3, 2].indexOf(Number(fileparam.Status)) == -1
var contentJson = {
fileunid: userfile.Unid,
fileinfo: usefileinfostring,
fileparam: JSON.stringify(fileparam),
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 // 60 * 5000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
indidocxobj.slCtl.isFileOpen = false
return Promise.reject(reason)
})
return promise
},
CreateTrackFileName: function (sourcename) {
var count = 1
var tmp = null
var files = indidocxobj.slCtl.Content.Files
for (var i = 0; i < files.FileList.length; i++) {
var userFile = files.FileList[i]
var filename = userFile.FileName
if (filename.indexOf('痕迹稿') != -1 && filename.indexOf('_' + sourcename) != -1) {
count++
}
}
tmp = '痕迹稿' + count + '_' + sourcename //痕迹1_正文.doc
return tmp
},
getV8IDXAddress: function () {
if (window.location.protocol == 'http:') {
return 'ws://' + indidocxobj.slCtl.domain + ':15880/indidocx'
} else {
return 'wss://' + indidocxobj.slCtl.domain + ':15881/indidocx'
}
},
/**
* 注册回调事件
* @param {string} eventType 事件类型
* @param {function} resolve
* @param {boolean} isfileopen 标识打开文件
* @returns {string} 事件名称
*/
registerEvent(eventType, resolve, isfileopen) {
let eventName = eventType + CreateRandomId() + '_' + indidocxobj.slCtl.forWindowID
indidocxobj.slCtl.curPromise[eventName] = resolve
window[eventName] = function (o) {
if (isfileopen !== undefined) indidocxobj.slCtl.isFileOpen = isfileopen
if (typeof fnRefreshFileList === 'function') {
fnRefreshFileList()
}
if (o == undefined) {
indidocxobj.slCtl.curPromise[eventName](false)
return
}
//此处需要返回操作回调的参数
indidocxobj.slCtl.curPromise[eventName](o)
}
return eventName
},
launchBrowser: function (url, type) {
var action = '/launchie'
var contentJson = {
starturl: url,
browser: type,
}
this.sendRequest(action, contentJson)
},
Content: {
Files: {
FileList: [],
_FileInfoString: [],
FileUploadDoing: function () {},
AllFilePost: function () {},
ErrorOccurred: function () {},
SingleFileUploadFinished: function () {},
FileDeleted: function () {},
DupNameFile: function () {},
_anylaze: function () {},
_syncFileInfo: function () {},
},
Control: {
ReadHTML: function () {},
getHTMLed: function () {},
getLablesed: function () {},
FileConvertPDFed: function () {},
FileAdded: function () {},
ActionEnd: function () {},
EventRegioned: function () {},
SingleFileDownloaded: function () {},
SilentDownloaded: function () {},
ErrorMessage: function () {},
OnFileSelected: function () {},
getPrintListed: function () {},
SaveFileCompleted: function () {},
_getversionCompleted: function (o) {
console.log(o.message)
},
_getFileStatued: function () {},
_inithttpCompleted: function () {},
_initHttpServer: function (timeout, tresolve, treject) {
var promise = new Promise((resolve, reject) => {
let eventName = '_inithttpCompleted_' + indidocxobj.slCtl.forWindowID
window[eventName] = function (o) {
var returnValue = false
if (indidocxobj.slCtl.isV6PluginInstall != false) {
//已经初始化成功
returnValue = indidocxobj.slCtl.isV6PluginInstall
resolve(returnValue)
tresolve && tresolve(returnValue)
return
}
if (o == undefined) {
//伪成功事件
indidocxobj.slCtl.isV6PluginInstall = false
returnValue = indidocxobj.slCtl.isV6PluginInstall
return
}
if (o.Update != '' && o.querystring != undefined) {
indidocxobj.slCtl.isV6PluginInstall = o
//this.Content.Control._synMessage();
returnValue = o
if (window.sessionStorage) {
sessionStorage.setItem('isV6PluginInstall', JSON.stringify(o))
}
if (o.querystring.indexOf('授权') > -1) {
returnValue = o.querystring
}
if (!!indidocxobj.slCtl.uploadCompentInfoUrl)
indidocxobj.slCtl.Content.Control._uploadCompentInfo(o)
}
resolve(returnValue) //是否安装控件
tresolve && tresolve(returnValue)
}
var baseUrl = '/inithttpserver'
var contentJson = {
idxversion: indidocxobj.slCtl.$$idx.idxV6version,
ServerUpdateUrl: indidocxobj.slCtl.$$idx.httpserver.ServerUpdateUrl,
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
indidocxobj.slCtl.sendRequest(baseUrl, contentJson, 30000, 'get')
if (timeout == undefined) {
timeout = 8000
}
setTimeout(window[eventName], timeout)
}).catch(function (reason) {
return Promise.reject(reason)
})
return promise
},
_uploadCompentInfo: function (serverinfo) {
var state = JSON.parse(sessionStorage.getItem('vuex'))
var userinfo = state?.sd?.common?.userInfo?.default || {}
var data = {
userId: userinfo.id,
userAccount: userinfo.account,
userName: userinfo.name,
updateDate: Date.now(), //当前日期的毫秒值
controlType: 'IndidocX',
// browsername: navigator.userAgent,
equipmentName: serverinfo.HostName,
indidocxVersion: serverinfo.Update, //inididoc版本
}
var ajax = indidocxobj.slCtl.createXHR()
ajax.open('POST', indidocxobj.slCtl.uploadCompentInfoUrl)
ajax.onreadystatechange = function () {
if (ajax.readyState == 4 && ajax.status == 200) {
console.log('上传组件信息成功')
}
}
ajax.setRequestHeader('Cache-Control', 'no-cache')
ajax.setRequestHeader('Content-type', 'application/json;charset=utf-8')
ajax.setRequestHeader('Authorization', state?.sd?.login?.tokens?.access_token)
ajax.send(JSON.stringify(data))
},
_getServerMessage: function (o) {
if (typeof handleIdxMessage === 'function') {
handleIdxMessage(o)
}
indidocxobj.slCtl.Content.Control._synMessage()
},
_synMessage: function () {
let eventName = '_getServerMessage_' + indidocxobj.slCtl.forWindowID
var baseUrl = '/synmessage'
var contentJson = {
sid: indidocxobj.slCtl.id,
callback: 'window.' + eventName,
}
indidocxobj.slCtl.sendRequest(baseUrl, contentJson, 3000000, 'get')
},
_getVersion: function () {
let eventName = '_getversionCompleted_' + indidocxobj.slCtl.forWindowID
var baseUrl = '/getversion'
var contentJson = {
sid: indidocxobj.slCtl.id,
callback: 'window.' + eventName,
}
indidocxobj.slCtl.sendRequest(baseUrl, contentJson, 30000, 'get')
},
_getTerminalInfo: function () {
let eventName = '_geTerminalInfoCompleted_' + indidocxobj.slCtl.forWindowID
var baseUrl = '/getterminalinfo'
var contentJson = {
sid: indidocxobj.slCtl.id,
callback: 'window.' + eventName,
}
indidocxobj.slCtl.sendRequest(baseUrl, contentJson, 30000, 'get')
},
getFileByName: function (fname) {
var userfile = null
indidocxobj.slCtl.Content.Files.FileList.map(function (onefile, index) {
if (onefile.Unid == fname || onefile.FileName == fname) {
userfile = onefile
}
})
return userfile
},
_getFileInfoByName: function (fname) {
var usefileinfostring = null
indidocxobj.slCtl.Content.Files._FileInfoString.map(function (onefile, index) {
if (
indidocxobj.slCtl.getRef(onefile, 0, '', '') == fname ||
indidocxobj.slCtl.htmldecode(
indidocxobj.slCtl.getRef(onefile, 0, '', '')
) == fname
) {
usefileinfostring = onefile
}
})
return usefileinfostring
},
//编辑
EditFile: function (fname, fileparam, argsobj) {
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
return indidocxobj.slCtl.fnV6OpenFile(fname, fileparam)
},
//打开本地文件夹
OpenLoaclDir: function (openpath, argsobj) {
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_OpenLoaclDirCompleted_', resolve)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var action = '/openloacldir'
var contentJson = {
openfiledir: openpath,
callback: 'window.' + eventName,
}
var timeout = 60 * 5000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
return Promise.reject(reason)
})
return promise
},
//下载附件
SaveFileToLocal: function (fname, fileparam, argsobj) {
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_SaveFileCompleted_', resolve)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/downloadfile'
if (fileparam == undefined) fileparam = ''
var contentJson = {
fileunid: userfile.Unid,
fileparam: JSON.stringify(fileparam),
fileinfo: usefileinfostring,
callback: 'window.' + eventName,
}
var timeout = 60 * 5000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
return Promise.reject(reason)
})
return promise
},
//批量下载
SaveMultiFiles: function (strFiles, fileparam, argsobj) {
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_SaveFileCompleted_', resolve)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
if (fileparam == undefined) fileparam = ''
var arrFileNames = strFiles.split('|')
var strFilesInfo = ''
for (var j = 0, len = arrFileNames.length; j < len; j++) {
if (arrFileNames[j] != '') {
for (
var i = 0, ten = indidocxobj.slCtl.Content.Files.FileList.length;
i < ten;
i++
) {
if (arrFileNames[j] == indidocxobj.slCtl.Content.Files.FileList[i].FileName) {
if (
indidocxobj.slCtl.Content.Files.FileList[i].Link.indexOf('fileName') > 0
) {
strFilesInfo += '|' + indidocxobj.slCtl.Content.Files.FileList[i].Link
} else {
strFilesInfo +=
'|' +
indidocxobj.slCtl.Content.Files.FileList[i].Link +
'?fileName=' +
arrFileNames[j]
}
}
}
}
}
var action = '/downloadmultifile'
var contentJson = {
fileparam: JSON.stringify(fileparam),
files: strFilesInfo,
callback: 'window.' + eventName,
}
var timeout = 60 * 5000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
return Promise.reject(reason)
})
return promise
},
//清稿
QingGao: function (fname, fileparam, argsobj) {
indidocxobj.slCtl.isFileOpen = true
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent(
'_OpenFileCompleted_',
resolve,
false
)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var _files = ''
for (
var j = 0, len = indidocxobj.slCtl.Content.Files.FileList.length;
j < len;
j++
) {
_files += '|' + indidocxobj.slCtl.Content.Files.FileList[j].FileName
}
var action = '/qinggao'
var contentJson = {
fileunid: userfile.Unid,
fileinfo: usefileinfostring,
fileparam: JSON.stringify(fileparam),
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
trackFileName: indidocxobj.slCtl.CreateTrackFileName(fname),
callback: 'window.' + eventName,
}
var timeout = 0 //60 * 2000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
indidocxobj.slCtl.isFileOpen = false
return Promise.reject(reason)
})
return promise
},
//套打
TaoDa: function (
ModelUrl,
ContentFieldName,
fname,
fileparam,
OldDocName,
values,
taodainfo,
argsobj
) {
var replacename = ''
if (checkFileExt(ModelUrl, '.docx')) {
replacename = CreateRandomId() + '.docx'
} else if (checkFileExt(ModelUrl, '.doc')) {
replacename = CreateRandomId() + '.doc'
}
ModelUrl = changeURLArg(ModelUrl, 'fileName', replacename)
indidocxobj.slCtl.isFileOpen = true
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent(
'_OpenFileCompleted_',
resolve,
false
)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
} else {
var infoarr = usefileinfostring.split('')
usefileinfostring =
infoarr[0] +
'' +
taodainfo +
'' +
infoarr[1].split('')[1]
//更新taodainfo
for (var i = 0; i < indidocxobj.slCtl.Content.Files._FileInfoString.length; i++) {
if (
indidocxobj.slCtl.getRef(
indidocxobj.slCtl.Content.Files._FileInfoString[i],
0,
'',
''
) == fname ||
indidocxobj.slCtl.getRef(
indidocxobj.slCtl.Content.Files._FileInfoString[i],
0,
'',
''
) == fname
) {
indidocxobj.slCtl.Content.Files._FileInfoString.splice(
i,
1,
usefileinfostring
)
}
}
}
var _files = ''
for (
var j = 0, len = indidocxobj.slCtl.Content.Files.FileList.length;
j < len;
j++
) {
_files += '|' + indidocxobj.slCtl.Content.Files.FileList[j].FileName
}
var action = '/taoda'
var contentJson = {
fileunid: userfile.Unid,
olddocname: OldDocName,
model_url: ModelUrl,
contentfieldname: ContentFieldName,
fieldvalues: JSON.stringify(values),
fileparam: JSON.stringify(fileparam),
fileinfo: usefileinfostring,
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 // 60 * 2000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
indidocxobj.slCtl.isFileOpen = false
return Promise.reject(reason)
})
return promise
},
//盖章
GaiZhang: function (
ModelUrl,
ContentFieldName,
fname,
fileparam,
OldDocName,
values,
argsobj
) {
var replacename = ''
if (checkFileExt(ModelUrl, '.docx')) {
replacename = CreateRandomId() + '.docx'
} else if (checkFileExt(ModelUrl, '.doc')) {
replacename = CreateRandomId() + '.doc'
}
ModelUrl = changeURLArg(ModelUrl, 'fileName', replacename)
indidocxobj.slCtl.isFileOpen = true
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent(
'_OpenFileCompleted_',
resolve,
false
)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/gaizhang'
var contentJson = {
fileunid: userfile.Unid,
model_url: ModelUrl,
contentfieldname: ContentFieldName,
fileparam: JSON.stringify(fileparam),
fieldvalues: JSON.stringify(values),
fileinfo: usefileinfostring,
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 // 60 * 2000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
indidocxobj.slCtl.isFileOpen = false
return Promise.reject(reason)
})
return promise
},
//更新正文
UpdateRegion: function (fname, values, picvalues, fileparam, argsobj) {
indidocxobj.slCtl.isFileOpen = true
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent(
'_OpenFileCompleted_',
resolve,
false
)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/updateregion'
var contentJson = {
fieldvalues: JSON.stringify(values),
picvalues: picvalues,
fileunid: userfile.Unid,
fileparam: JSON.stringify(fileparam),
fileinfo: usefileinfostring,
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 // 60 * 2000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
indidocxobj.slCtl.isFileOpen = false
return Promise.reject(reason)
})
return promise
},
//文档打印
PrintDocument: function (fname, fileparam, values, argsobj) {
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_OpenFileCompleted_', resolve)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/printdocument'
var contentJson = {
fieldvalues: JSON.stringify(values),
fileunid: userfile.Unid,
fileparam: JSON.stringify(fileparam),
fileinfo: usefileinfostring,
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 // 60 * 2000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
return Promise.reject(reason)
})
return promise
},
//转换pdf
DOCConvertToPDF: function (fname, fileparam, argsobj) {
indidocxobj.slCtl.isFileOpen = true
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_OpenFileCompleted_', resolve)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/convertdoctopdf'
var contentJson = {
fileunid: userfile.Unid,
fileinfo: usefileinfostring,
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 // 60 * 5000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
indidocxobj.slCtl.isFileOpen = false
return Promise.reject(reason)
})
return promise
},
DOCConvertToOFD: function (fname, fileparam, argsobj) {
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_OpenFileCompleted_', resolve)
indidocxobj.slCtl.$$idx = indidocxobj.slCtl.formatParams(argsobj)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
;(userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/convertdoctoofd'
var contentJson = {
fileunid: userfile.Unid,
fileinfo: usefileinfostring,
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 //60 * 5000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
return Promise.reject(reason)
})
return promise
},
//图片章
TuPianZhang: function (fname, fileparam, argsobj) {
var promise = new Promise((resolve, reject) => {
let eventName = indidocxobj.slCtl.registerEvent('_TuPianZhangCompleted_', resolve, false)
var userfile = indidocxobj.slCtl.Content.Control.getFileByName(fname)
var usefileinfostring = indidocxobj.slCtl.Content.Control._getFileInfoByName(fname)
if (userfile == null) {
userfile = {}
; (userfile.Unid = CreateRandomId()), (usefileinfostring = fname)
}
var action = '/tupianzhang'
var contentJson = {
fileunid: userfile.Unid,
fileinfo: usefileinfostring,
fileparam: JSON.stringify(fileparam),
UserName: indidocxobj.slCtl.$$idx.httpserver.UserName,
UploadParam: indidocxobj.slCtl.$$idx.httpserver.UploadParam,
UploadUrl: indidocxobj.slCtl.$$idx.httpserver.UploadUrl,
callback: 'window.' + eventName,
}
var timeout = 0 // 60 * 5000
indidocxobj.slCtl.sendRequest(action, contentJson, timeout, 'get')
}).catch(function (reason) {
return Promise.reject(reason)
})
return promise
},
},
},
createXHR: function () {
if (typeof XMLHttpRequest != 'undefined') {
//兼容高版本浏览器
return new XMLHttpRequest()
} else if (typeof ActiveXObject != 'undefined') {
//IE6 采用 ActiveXObject, 兼容IE6
var versions = [
//由于MSXML库有3个版本,因此都要考虑
'MSXML2.XMLHttp.6.0',
'MSXML2.XMLHttp.3.0',
'MSXML2.XMLHttp',
]
for (var i = 0; i < versions.length; i++) {
try {
return new ActiveXObject(versions[i])
} catch (e) {
//跳过
}
}
} else {
throw new Error('您的浏览器不支持XHR对象')
}
},
Base64: {
base64EncodeChars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
base64DecodeChars: new Array(
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
62,
-1,
-1,
-1,
63,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
-1,
-1,
-1,
-1,
-1,
-1,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
-1,
-1,
-1,
-1,
-1
),
base64encode: function (str) {
var out, i, len
var c1, c2, c3
len = str.length
i = 0
out = ''
while (i < len) {
c1 = str.charCodeAt(i++) & 0xff
if (i == len) {
out += this.base64EncodeChars.charAt(c1 >> 2)
out += this.base64EncodeChars.charAt((c1 & 0x3) << 4)
out += '=='
break
}
c2 = str.charCodeAt(i++)
if (i == len) {
out += this.base64EncodeChars.charAt(c1 >> 2)
out += this.base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4))
out += this.base64EncodeChars.charAt((c2 & 0xf) << 2)
out += '='
break
}
c3 = str.charCodeAt(i++)
out += this.base64EncodeChars.charAt(c1 >> 2)
out += this.base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4))
out += this.base64EncodeChars.charAt(((c2 & 0xf) << 2) | ((c3 & 0xc0) >> 6))
out += this.base64EncodeChars.charAt(c3 & 0x3f)
}
return out
},
base64decode: function (str) {
var c1, c2, c3, c4
var i, len, out
len = str.length
i = 0
out = ''
while (i < len) {
do {
c1 = this.base64DecodeChars[str.charCodeAt(i++) & 0xff]
} while (i < len && c1 == -1)
if (c1 == -1) break
do {
c2 = this.base64DecodeChars[str.charCodeAt(i++) & 0xff]
} while (i < len && c2 == -1)
if (c2 == -1) break
out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4))
do {
c3 = str.charCodeAt(i++) & 0xff
if (c3 == 61) return out
c3 = this.base64DecodeChars[c3]
} while (i < len && c3 == -1)
if (c3 == -1) break
out += String.fromCharCode(((c2 & 0xf) << 4) | ((c3 & 0x3c) >> 2))
do {
c4 = str.charCodeAt(i++) & 0xff
if (c4 == 61) return out
c4 = this.base64DecodeChars[c4]
} while (i < len && c4 == -1)
if (c4 == -1) break
out += String.fromCharCode(((c3 & 0x03) << 6) | c4)
}
return out
},
utf16to8: function (str) {
var out, i, len, c
out = ''
len = str.length
for (i = 0; i < len; i++) {
c = str.charCodeAt(i)
if (c >= 0x0001 && c <= 0x007f) {
out += str.charAt(i)
} else if (c > 0x07ff) {
out += String.fromCharCode(0xe0 | ((c >> 12) & 0x0f))
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3f))
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f))
} else {
out += String.fromCharCode(0xc0 | ((c >> 6) & 0x1f))
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f))
}
}
return out
},
utf8to16: function (str) {
var out, i, len, c
var char2, char3
out = ''
len = str.length
i = 0
while (i < len) {
c = str.charCodeAt(i++)
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
// 0xxxxxxx
out += str.charAt(i - 1)
break
case 12:
case 13:
// 110x xxxx 10xx xxxx
char2 = str.charCodeAt(i++)
out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))
break
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = str.charCodeAt(i++)
char3 = str.charCodeAt(i++)
out += String.fromCharCode(
((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0)
)
break
}
}
return out
}, //end
encode: function (input) {
return this.base64encode(this.utf16to8(input))
},
decode: function (str) {
return this.utf8to16(this.base64decode(str))
},
},
},
}
/**
* 获取随机ID
* @returns string
*/
function CreateRandomId() {
return Number(Math.random().toString().substr(3, 3) + Date.now()).toString(36)
}
/**
* 修改url参数
*/
function changeURLArg(url, arg, arg_val) {
var pattern = arg + '=([^&]*)'
var replaceText = arg + '=' + arg_val
if (url.match(pattern)) {
var tmp = '/(' + arg + '=)([^&]*)/gi'
tmp = url.replace(eval(tmp), replaceText)
return tmp
} else {
if (url.match('[?]')) {
return url + '&' + replaceText
} else {
return url + '?' + replaceText
}
}
}
/**
* 判断后缀
*/
function checkFileExt(filename, ext) {
var index = filename.lastIndexOf('.')
filename = filename.substring(index)
if (filename.toLowerCase() == ext) {
return true
} else {
return false
}
}
if (!window.slCtlList) {
window.slCtlList = []
}
window.slCtlList.push(indidocxobj)
//初始化socket
var conn = window.IndidocxShareSocket || indidocxobj.slCtl.socket
if (conn == undefined) {
conn = new ReconnectingWebSocket(indidocxobj.slCtl.getV8IDXAddress())
conn.onmessage = indidocxobj.slCtl.receiveMsg
window.IndidocxShareSocket = conn
indidocxobj.slCtl.socket = conn
}
return indidocxobj
},
}
export default indidocxModule