DO按钮配置代码=>复制代码后在工具栏自定义后粘贴即可
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label> URI编码/解码</label>
<tip>对下载的文件名乱码进行编码/解码</tip>
<icon1>#pathfield</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>function OnClick(clickData)</instruction>
<instruction>{</instruction>
<instruction />
<instruction> DOpus.ClearOutput();</instruction>
<instruction> // --------------------------------------------------------</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> cmd.deselect = false; // Prevent automatic deselection</instruction>
<instruction> // --------------------------------------------------------</instruction>
<instruction> // cmd.RunCommand("Set VIEW=Details");</instruction>
<instruction> // --------------------------------------------------------</instruction>
<instruction />
<instruction> if (clickData.func.sourcetab.selected.count == 0)</instruction>
<instruction> {</instruction>
<instruction> DOpus.Output(" (none)");</instruction>
<instruction> }</instruction>
<instruction> else</instruction>
<instruction> {</instruction>
<instruction> for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())</instruction>
<instruction> {</instruction>
<instruction> DOpus.Output(" (none)"+eSel.item().name.indexOf("%"));</instruction>
<instruction />
<instruction> if (eSel.item().name.indexOf("%")>-1)</instruction>
<instruction> {</instruction>
<instruction> var coded=decodeURIComponent(eSel.item().name.replace(/\+/g, " "));</instruction>
<instruction> cmd.RunCommand('rename to "'+coded+'"');</instruction>
<instruction> DOpus.Output('解'+coded);</instruction>
<instruction> }</instruction>
<instruction> else</instruction>
<instruction> {</instruction>
<instruction> var coded=encodeURIComponent(eSel.item().name).replace(/'/g,"%27").replace(/"/g,"%22"); </instruction>
<instruction> cmd.RunCommand('rename to "'+coded+'"');</instruction>
<instruction> DOpus.Output('加'+coded);</instruction>
<instruction> }</instruction>
<instruction> }</instruction>
<instruction> }</instruction>
<instruction />
<instruction>}</instruction>
</function>
</button>
功能代码=>JScript
function OnClick(clickData)
{
DOpus.ClearOutput();
// --------------------------------------------------------
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
if (clickData.func.sourcetab.selected.count == 0)
{
DOpus.Output(" (none)");
}
else
{
for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
{
DOpus.Output(" (none)"+eSel.item().name.indexOf("%"));
if (eSel.item().name.indexOf("%")>-1)
{
var coded=decodeURIComponent(eSel.item().name.replace(/\+/g, " "));
cmd.RunCommand('rename to "'+coded+'"');
DOpus.Output('解'+coded);
}
else
{
var coded=encodeURIComponent(eSel.item().name).replace(/'/g,"%27").replace(/"/g,"%22");
cmd.RunCommand('rename to "'+coded+'"');
DOpus.Output('加'+coded);
}
}
}
}
======================
T