first commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
(function () {
|
||||
|
||||
window.dd3s = {}; //创建一个自己的对象相当于C#中的命名空间
|
||||
|
||||
const download = function (filepath, filename) {
|
||||
window.open('/platform/base/Common/download?filepath=' + filepath + '&filename=' + filename);
|
||||
};
|
||||
|
||||
dd3s.download = download;
|
||||
|
||||
//这个预览只针对于文档 图片的话用viewer.js
|
||||
const preview = function (filepath, fileid) {
|
||||
window.open('/platform/base/Common/preview?filepath=' + filepath + '&fileid=' + fileid);
|
||||
};
|
||||
|
||||
dd3s.preview = preview;
|
||||
|
||||
const doctype = ['doc', 'docx', 'xls', 'xlsx'];
|
||||
|
||||
const pictype = ['jpg', 'png', 'gif', 'jpeg'];
|
||||
|
||||
const isDoc = function (filepath) {
|
||||
let filetype = filepath.substring(filepath.lastIndexOf('.') + 1, filepath.length);
|
||||
if (doctype.indexOf(filetype) > -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
dd3s.isDoc = isDoc;
|
||||
|
||||
const isPic = function (filepath) {
|
||||
let filetype = filepath.substring(filepath.lastIndexOf('.') + 1, filepath.length);
|
||||
if (pictype.indexOf(filetype) > -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
dd3s.isPic = isPic;
|
||||
|
||||
//获取鼠标选中的位置和值 传入元素
|
||||
const getChecked = function getChecked(obj) {
|
||||
var result = {
|
||||
start: 0,
|
||||
end: 0,
|
||||
val: ''
|
||||
};
|
||||
if (obj.selectionStart || obj.selectionStart == 0) {
|
||||
// another support
|
||||
result.start = obj.selectionStart;
|
||||
result.end = obj.selectionEnd;
|
||||
result.val = obj.value.substring(obj.selectionStart, obj.selectionEnd);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
dd3s.getChecked = getChecked;
|
||||
|
||||
const html2txt = function html2txt(html) {
|
||||
return html.replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi, '').replace(/<[^>]+?>/g, '').replace(/\s+/g, ' ').replace(/ /g, ' ').replace(/>/g, ' ');
|
||||
};
|
||||
dd3s.html2txt = html2txt;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user