请懂js的帮我改个按钮

这个运行后会跳出个窗口有两个按钮选项,“Source”和“Destination”
我想改直接就是“Source”选项运行,不跳出任何窗口

function OnClick(clickData) {
	var cmd = clickData.func.command;
	var tab = clickData.func.sourcetab;
	var isDual = clickData.func.command.IsSet("DUAL=on");
	var fsu = DOpus.FSUtil();
	var Dlg = DOpus.Dlg;
	var selWarning = false;
	var isTargetSet = false;
	var canceled = false;
	cmd.deselect = false;
	cmd.SetDestTab(tab);

	// cmd.RunCommand('Set UTILITY=otherlog');
	DOpus.ClearOutput();
	DOpus.Output("SMART EXTRACT STARTS\n");
	DOpus.Output("is dual : " + isDual);

	// Check if files are selected and warn user if not
	if (tab.selstats.selfiles == 0) {
		DOpus.Output("No file selected");

		Dlg.window = tab;
		Dlg.icon = "error";
		Dlg.top = true;
		Dlg.template = "error1";
		Dlg.Show;

		// Process selected files
	} else {
		DOpus.Output("Enumerating...\n");

		for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
			var item = e.item();

			if (!canceled) {
				// Skips selected item if it’s not an archive and warns user later.
				if (!item.InGroup("Archives")) {
					DOpus.Output("Error (not an archive file) : '" + item.name + "'");
					selWarning = true;
					continue;
				}

				// If it’s dual display, ask user where to extract
				if (isDual && !isTargetSet) {
					isTargetSet = true;
					Dlg.window = tab;
					Dlg.icon = "question";
					Dlg.top = true;
					Dlg.template = "destination";
					var retVal = Dlg.Show();
					// DOpus.Output("pressed button : "+retVal);

					switch (retVal) {
						case 1: // source
							// instruction
							DOpus.Output("pressed button : source");
							break;

						case 2: // destination
							DOpus.Output("pressed button : destination");
							cmd.SetDestTab(clickData.func.desttab);
							break;

						default:
							// cancel
							DOpus.Output("pressed button : cancel");
							canceled = true;
							DOpus.Output("\nSMART EXTRACT END\n");
							continue;
							break;
					}
				}

				var folderEnum = fsu.ReadDir(item);
				var folderItem = folderEnum.Next();
				if (folderItem.is_dir && folderEnum.complete) {
					var cmdLine = 'Copy FILE="' + item + '" WHENEXISTS=rename EXTRACT';
				} else {
					var cmdLine = 'Copy FILE="' + item + '" WHENEXISTS=rename EXTRACT=sub';
				}
				DOpus.Output(cmdLine);
				cmd.RunCommand(cmdLine);
			}

			if (selWarning) {
				Dlg.window = tab;
				Dlg.icon = "warning";
				Dlg.top = true;
				Dlg.template = "warning";
				Dlg.Show;
			}
			DOpus.Output("\nSMART EXTRACT END\n");
		}
	}
}

Dlg.Show() 改成 1

// var retVal = Dlg.Show();
var retVal = 1;
1 个赞

谢谢啊,可用!

请记得在解决问题后,加心以及勾选问题的答案为解决方案,可以在帖子下方的 … 菜单中找到。