changxin commited on
Commit
64ed785
1 Parent(s): 6e76f78

Upload ribbon.js

Browse files
Files changed (1) hide show
  1. wps-test/js/ribbon.js +103 -0
wps-test/js/ribbon.js ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function OnAddinLoad(ribbonUI){
2
+ if (typeof (wps.ribbonUI) != "object"){wps.ribbonUI = ribbonUI}
3
+ if (typeof (wps.Enum) != "object") {wps.Enum = WPS_Enum}
4
+ wps.PluginStorage.setItem("EnableFlag", false)
5
+ return true
6
+ }
7
+
8
+ var WebNotifycount = 0;
9
+ function fx(n){
10
+ var a=1,b=1;
11
+ for(i=2;i<=n;i++){[a,b]=[b,a+b]};
12
+ return a
13
+ }
14
+
15
+ function OnAction(control) {
16
+ const eleId = control.Id
17
+ switch (eleId) {
18
+ case "btnShowMsg":
19
+ {
20
+ const doc = wps.EtApplication().ActiveWorkbook
21
+ alert(`畅心提醒您当前打开的文件名为${doc.Name},当前时间:${Date()}`)
22
+ }
23
+ break;
24
+ case "fbnq":
25
+ {
26
+ const doc = wps.EtApplication().ActiveSheet
27
+ const x=wps.EtApplication().InputBox('请输入需要生成的项序号','测试','5',200,200)
28
+ doc.Cells.Item(1, 1).Formula=fx(Number(x))
29
+ }
30
+ break;
31
+ case "btnIsEnbable":
32
+ {
33
+ let bFlag = wps.PluginStorage.getItem("EnableFlag")
34
+ wps.PluginStorage.setItem("EnableFlag", !bFlag)
35
+ wps.ribbonUI.InvalidateControl("btnIsEnbable")
36
+ wps.ribbonUI.InvalidateControl("btnShowcx")
37
+ break
38
+ }
39
+ case "btnShowcx":
40
+ wps.ShowDialog(GetUrlPath() + "/ui/cx.html", "调用网页对话框", 400 * window.devicePixelRatio, 400 * window.devicePixelRatio, false)
41
+ break
42
+ default:
43
+ break
44
+ }
45
+ return true
46
+ }
47
+
48
+ function GetImage(control) {
49
+ const eleId = control.Id
50
+ switch (eleId) {
51
+ case "btnShowMsg":
52
+ return "images/1.svg"
53
+ case "fbnq":
54
+ return "images/M.svg"
55
+ case "btnShowcx":
56
+ return "images/M.svg"
57
+ default:
58
+ ;
59
+ }
60
+ return "images/newFromTemp.svg"
61
+ }
62
+
63
+ function OnGetEnabled(control) {
64
+ const eleId = control.Id
65
+ switch (eleId) {
66
+ case "btnShowMsg":
67
+ return true
68
+ break
69
+ case "fbnq":
70
+ return true
71
+ break
72
+ case "btnShowcx":
73
+ {
74
+ let bFlag = wps.PluginStorage.getItem("EnableFlag")
75
+ return bFlag
76
+ break
77
+ }
78
+ default:
79
+ break
80
+ }
81
+ return true
82
+ }
83
+
84
+ function OnGetVisible(control){
85
+ return true
86
+ }
87
+
88
+ function OnGetLabel(control){
89
+ const eleId = control.Id
90
+ switch (eleId) {
91
+ case "btnIsEnbable":
92
+ {
93
+ let bFlag = wps.PluginStorage.getItem("EnableFlag")
94
+ return bFlag ? "按钮不可用" : "按钮可用"
95
+ break
96
+ }
97
+ }
98
+ return ""
99
+ }
100
+
101
+ function OnNewDocumentApiEvent(doc){
102
+ alert("新建文件事件响应,取文件名: " + doc.Name)
103
+ }