app.js
2.5 KB
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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React from 'react';
import ReactDOM from 'react-dom';
import {createBrowserHistory,createHashHistory,createMemoryHistory,createHistory} from 'history';
import { syncHistoryWithStore} from 'react-router-redux';
import { useRouterHistory } from 'react-router';
import Root from './containers/Root';
import configureStore from './redux/configureStore';
const history = useRouterHistory(createHashHistory)();
const store = configureStore(window.__INITIAL_STATE__);
const myHistory = syncHistoryWithStore(history, store,{
selectLocationState: (state) => state.router
})
//默认oss配置
window.oss={
app_url : "https://oss.workai.com.cn",
bucket : "hro",
end_point : "oss-cn-beijing.aliyuncs.com",
public_bucket : "hropublic",
isDefault:true
}
/*禁止backspace*/
function banBackSpace(e){
var ev = e || window.event;
//各种浏览器下获取事件对象
var obj = ev.relatedTarget || ev.srcElement || ev.target ||ev.currentTarget;
//按下Backspace键
if(ev.keyCode == 8){
var tagName = obj.nodeName //标签名称
//如果标签类名为medium-editor-element,则为劳动合同模板编辑器,允许backspace删除内容。
if(obj.className&&obj.className.indexOf('medium-editor-element')!=-1){
return true;
}
//如果标签不是input或者textarea则阻止Backspace
if(tagName!='INPUT' && tagName!='TEXTAREA'){
return stopIt(ev);
}
var tagType = obj.type.toUpperCase();//标签类型
//input标签除了下面几种类型,全部阻止Backspace
if(tagName=='INPUT' && (tagType!='TEXT' && tagType!='TEXTAREA' && tagType!='PASSWORD'&& tagType!='EMAIL')){
return stopIt(ev);
}
//input或者textarea输入框如果不可编辑则阻止Backspace
if((tagName=='INPUT' || tagName=='TEXTAREA') && (obj.readOnly==true || obj.disabled ==true)){
return stopIt(ev);
}
}
}
function stopIt(ev){
if(ev.preventDefault ){
//preventDefault()方法阻止元素发生默认的行为
ev.preventDefault();
}
if(ev.returnValue){
//IE浏览器下用window.event.returnValue = false;实现阻止元素发生默认的行为
ev.returnValue = false;
}
return false;
}
//实现对字符码的截获,keypress中屏蔽了这些功能按键
document.onkeypress = banBackSpace;
//对功能按键的获取
document.onkeydown = banBackSpace;
//trim
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, '');
};
// Render the React application to the DOM
ReactDOM.render(
<Root history={myHistory} store={store} />,
document.getElementById('root')
)