highcharts / wps-test /js /ribbon.js
changxin's picture
Upload ribbon.js
64ed785
raw
history blame
2.79 kB
function OnAddinLoad(ribbonUI){
if (typeof (wps.ribbonUI) != "object"){wps.ribbonUI = ribbonUI}
if (typeof (wps.Enum) != "object") {wps.Enum = WPS_Enum}
wps.PluginStorage.setItem("EnableFlag", false)
return true
}
var WebNotifycount = 0;
function fx(n){
var a=1,b=1;
for(i=2;i<=n;i++){[a,b]=[b,a+b]};
return a
}
function OnAction(control) {
const eleId = control.Id
switch (eleId) {
case "btnShowMsg":
{
const doc = wps.EtApplication().ActiveWorkbook
alert(`畅心提醒您当前打开的文件名为${doc.Name},当前时间:${Date()}`)
}
break;
case "fbnq":
{
const doc = wps.EtApplication().ActiveSheet
const x=wps.EtApplication().InputBox('请输入需要生成的项序号','测试','5',200,200)
doc.Cells.Item(1, 1).Formula=fx(Number(x))
}
break;
case "btnIsEnbable":
{
let bFlag = wps.PluginStorage.getItem("EnableFlag")
wps.PluginStorage.setItem("EnableFlag", !bFlag)
wps.ribbonUI.InvalidateControl("btnIsEnbable")
wps.ribbonUI.InvalidateControl("btnShowcx")
break
}
case "btnShowcx":
wps.ShowDialog(GetUrlPath() + "/ui/cx.html", "调用网页对话框", 400 * window.devicePixelRatio, 400 * window.devicePixelRatio, false)
break
default:
break
}
return true
}
function GetImage(control) {
const eleId = control.Id
switch (eleId) {
case "btnShowMsg":
return "images/1.svg"
case "fbnq":
return "images/M.svg"
case "btnShowcx":
return "images/M.svg"
default:
;
}
return "images/newFromTemp.svg"
}
function OnGetEnabled(control) {
const eleId = control.Id
switch (eleId) {
case "btnShowMsg":
return true
break
case "fbnq":
return true
break
case "btnShowcx":
{
let bFlag = wps.PluginStorage.getItem("EnableFlag")
return bFlag
break
}
default:
break
}
return true
}
function OnGetVisible(control){
return true
}
function OnGetLabel(control){
const eleId = control.Id
switch (eleId) {
case "btnIsEnbable":
{
let bFlag = wps.PluginStorage.getItem("EnableFlag")
return bFlag ? "按钮不可用" : "按钮可用"
break
}
}
return ""
}
function OnNewDocumentApiEvent(doc){
alert("新建文件事件响应,取文件名: " + doc.Name)
}