Файл: adultscript-2.0.3-pro/files/mobile/templates/default/video_upload.tpl.php
Строк: 155
<?php defined('_VALID') or die('Restricted Access!'); ?>
<script type="text/javascript">
var ext = '';
var extensions = /<?php echo '(',implode('|', VF::cfg_item('module.video.video_allowed_ext')),')'; ?>/i;
function fileSelected() {
document.getElementById('details').innerHTML = "";
var file = document.getElementById('fileToUpload').files[0];
var filename = file.name;
ext = filename.slice(filename.indexOf(".")).toLowerCase();
if (!ext.match(extensions)) {
$("#errors").html("<h3>Invalid file extension! Allowed extensions: <?php echo implode(', ', VF::cfg_item('module.video.video_allowed_ext')); ?></h3>");
$("#errors").show();
return;
}
if (file.size > <?php echo VF::cfg_item('module.video.video_max_size')*1024*1024; ?>) {
$("#errors").html("<h3>File exceeds the maximum allowed filesize limit of <?php echo VF::cfg_item('module.video.video_max_size'); ?>MB!</h3>");
$("#errors").show();
return;
}
var fileSize = 0;
if (file.size > 1024 * 1024) {
fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
} else {
fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
}
document.getElementById('details').innerHTML += 'Name: ' + file.name + '<br>Size: ' + fileSize + '<br>Type: ' + file.type;
document.getElementById('details').innerHTML += '<p>';
$("input[name='ext']").val(ext);
}
function uploadFile() {
var fd = new FormData();
var file = document.getElementById('fileToUpload').files[0];
fd.append('myFile', file);
var xhr = new XMLHttpRequest()
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", "<?php echo MOBILE_REL; ?>/ajax.php?s=upload&d=mobile&unique=<?php echo $this->unique; ?>&ext=" + ext);
xhr.send(fd);
}
function uploadProgress(evt) {
if (evt.lengthComputable) {
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
$("#progress").show();
$("#slider").val(percentComplete.toString());
$("#slider").slider('refresh');
} else {
document.getElementById('progress').innerHTML = 'unable to compute';
}
}
function uploadComplete(evt) {
$("#video-upload-form").submit();
}
function uploadFailed(evt) {
alert("There was an error attempting to upload the file.");
}
function uploadCanceled(evt) {
alert("The upload has been canceled by the user or the browser dropped the connection.");
}
</script>
<div data-role="content">
<br>
<ul data-role="listview">
<li data-role="list-divider"><?php echo __('upload-video'); ?></li>
</ul>
<br>
<br>
<form id="video-upload-form" method="post" enctype="multipart/form-data" action="<?php echo MOBILE_REL; ?>/upload/">
<input name="upload_id" type="hidden" value="<?php echo $this->unique; ?>">
<input name="ext" type="hidden" value="">
<input name="upload-submitted" type="hidden" value="1">
<label for="guidelines"><strong><?php echo __('guidelines'); ?></strong>:</label>
<p><?php echo __('upload-guidelines-text'); ?></p>
<label for="title"><?php echo __('title'); ?>: </label>
<input name="title" type="text" id="title" value="<?php echo e($this->video['title']); ?>">
<label for="description"><?php echo __('description'); ?>: </label>
<textarea name="description" id="description"><?php echo e($this->video['description']); ?></textarea>
<?php $categories = (is_string($this->video['category'])) ? explode(',', $this->video['category']) : (array) $this->video['category']; ?>
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend>Categories:</legend>
<?php foreach ($this->categories as $index => $category): $checked = (in_array($category['cat_id'], $categories)) ? ' checked="checked"': ''; ?>
<input type="checkbox" name="category[]" id="category-<?php echo $category['cat_id'],'" value="',$category['cat_id'],'"',$checked; ?>>
<label for="category-<?php echo $category['cat_id'],'">',e($category['name']); ?></label>
<?php endforeach; ?>
</fieldset>
<label for="tags"><?php echo __('tags'); ?>: </label>
<textarea name="tags" id="tags"><?php echo e($this->video['tags']); ?></textarea>
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend><?php echo __('type'); ?>:</legend>
<input type="radio" name="type" id="type-public" value="public"<?php if ($this->video['type'] == 'public'): echo ' checked="checked"'; endif; ?>>
<label for="type-public">Public</label>
<input type="radio" name="type" id="type-private" value="private"<?php if ($this->video['type'] == 'private'): echo ' checked="checked"'; endif; ?>>
<label for="type-private">Private</label>
</fieldset>
<label for="fileToUpload"><?php echo __('file'); ?>:</label>
<input type="file" name="fileToUpload" id="fileToUpload" onchange="fileSelected();" accept="video/*;capture=camcorder">
<div id="errors" class="ui-bar ui-bar-d red" style="display: none;"></div>
<div id="details"></div>
<div id="progress" style="display: none;">
<input type="range" name="slider" id="slider" data-highlight="true" min="0" max="100" value="0">
</div>
<button type="button" data-theme="b" name="submit-upload" onclick="uploadFile();"><?php echo __('upload-video'); ?></button>
</form>
</div>