📄 upload-image.js
字号:
/*
* Copyright 2001-2007 Hippo (www.hippo.nl)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
HTMLArea = window.opener.HTMLArea;
//allow second popup to get styling from parent without errors
opener.Dialog = {'_arguments':null, '_return': function(){}}
window.resizeTo(240, 180);
function i18n(str) {
return (HTMLArea._lc(str, 'HTMLArea'));
}
function Init() {
__dlg_translate('HTMLArea');
__dlg_init();
}
function simplify(str) {
str = ""+str;
var local = " áéíóúàèìòùäëïöüâêîôûñ";
var global = "-aeiouaeiouaeiouaeioun";
var nstr = str.toLowerCase();
for(var c = 0; c<nstr.length; c++) {
if (local.indexOf(nstr.charAt(c))!=-1)
nstr = nstr.substring(0, c)+global.charAt(local.indexOf(nstr.charAt(c)))+nstr.substring(c+1);
}
return nstr;
}
function onUpload() {
var documentUrl = opener.opener.top.window.frames['topframe'].Application.sm.lookup('cms.workbench').perspectiveManager.getPerspectiveById('editing').getDocument();
document.getElementById("documentUrlId").value = documentUrl;
var uploadForm = document.getElementById("uploadForm");
var imageUrl = documentUrl.replace(/\/content/, "/binaries");
imageUrl = imageUrl.substring(0, imageUrl.lastIndexOf('.'));
imageUrl = imageUrl.toLowerCase();
var filename = document.getElementById("f_imagefile").value;
if (filename==null || filename.length==0) {
alert("The filename is empty");
return false;
}
filename = filename.substring(filename.lastIndexOf('/')+1);
filename = filename.substring(filename.lastIndexOf('\\')+1);
filename = simplify(filename);
imageUrl += '/'+filename;
document.getElementById("imageUrlId").value = imageUrl;
uploadForm.submit();
return true;
}
function onSelect() {
var imageUrl = document.getElementById("f_alreadyuploaded").value;
imageUrl = imageUrl.substring(imageUrl.indexOf("/binaries"));
window.opener.document.getElementById("f_url").value = imageUrl;
window.close();
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -