<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one or more | |
contributor license agreements. See the NOTICE file distributed with | |
this work for additional information regarding copyright ownership. | |
The ASF licenses this file to You 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. | |
--> | |
<!-- $Id: image.xsl 56062 2004-10-30 19:20:06Z gregor $ --> | |
<script xmlns:i18n="http://apache.org/cocoon/i18n/2.1" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
/* check files to be uploaded against a list of valid extensions, required title and no whitespace in filenames */ | |
function check_upload(fileinput, ext) { | |
var i = 0; | |
var delimiter = ' '; | |
var thefile = fileinput["properties.asset.data"].value; | |
var title = fileinput["properties.asset.title"].value; | |
if (title == "") { | |
alert("<i18n:translate><i18n:text key="upload-with-missing-title"/></i18n:translate>"); | |
return false; | |
} | |
var _tempArray = new Array(); | |
_tempArray = ext.split(delimiter); | |
for(i in _tempArray) { | |
if(thefile.indexOf('.' + _tempArray[i]) != -1) { // file has one of the accepted extensions. | |
return true; | |
} | |
} // file does not have one of the accepted extensions. | |
alert("<i18n:translate><i18n:text key="upload-with-invalid-extension"/><i18n:param>:\n\n"+ext+"\n</i18n:param></i18n:translate>"); | |
return false; | |
} | |
function validRequired(formField,fieldLabel) | |
{ | |
var result = true; | |
if (formField.value == "") | |
{ | |
alert('<i18n:text key="failmessage.createdoc.required"/>'); | |
formField.focus(); | |
result = false; | |
} | |
return result; | |
} | |
function validContent(formField,fieldLabel) | |
{ | |
var result = true; | |
if (formField.value.match("[^a-zA-Z0-9\\-]+")) | |
{ | |
alert('<i18n:text key="failmessage.createdoc.invalidformat"/>'); | |
formField.focus(); | |
result = false; | |
} | |
return result; | |
} | |
function check_num(obj) { | |
var value = parseInt(obj.value); | |
if (value && 0 <= value && value <= 255) { | |
obj.value = "" + parseInt(obj.value); | |
} | |
else { | |
obj.value = "0"; | |
} | |
} | |
</script> |