Fix JavaScript problems on channels where you are not allowed to upload photos.

Add some try...catch blocks around JavaScript that throws errors.
This commit should fix the current problems that were introduced by an
earlier commit.
This commit is contained in:
Klaus Weidenbach 2015-03-12 22:57:00 +01:00
parent d11bec6f58
commit c6162c4c88

View File

@ -1,6 +1,6 @@
<script language="javascript" type="text/javascript">
var editor=false;
var editor = false;
var textlen = 0;
var plaintext = '{{$editselect}}';
@ -22,7 +22,7 @@ function initEditor(cb){
$(".jothidden").show();
if (typeof cb!="undefined") cb();
return;
}
}
tinyMCE.init({
theme : "advanced",
mode : "specific_textareas",
@ -74,8 +74,7 @@ function initEditor(cb){
}
else {
$('#profile-jot-desc').html('&nbsp;');
}
}
});
ed.onInit.add(function(ed) {
@ -89,7 +88,6 @@ function initEditor(cb){
});
editor = true;
} else {
if (typeof cb!="undefined") cb();
}
@ -100,22 +98,19 @@ function enableOnUser(){
$(this).val("");
initEditor();
}
</script>
<script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js" ></script>
<script>
var ispublic = '{{$ispublic}}';
$(document).ready(function() {
/* enable tinymce on focus and click */
$("#profile-jot-text").focus(enableOnUser);
$("#profile-jot-text").click(enableOnUser);
var upload_title = $('#wall-image-upload').attr('title');
var attach_title = $('#wall-file-upload').attr('title');
var uploader = new window.AjaxUpload(
'wall-image-upload',
try {
var uploader = new window.AjaxUpload('wall-image-upload',
{ action: '{{$baseurl}}/wall_upload/{{$nickname}}',
name: 'userfile',
title: upload_title,
@ -124,11 +119,12 @@ function enableOnUser(){
addeditortext(response);
$('#jot-media').val($('#jot-media').val() + response);
$('#profile-rotator').spin(false);
}
}
);
var uploader_sub = new window.AjaxUpload(
'wall-image-upload-sub',
}
});
} catch (e) {
}
try {
var uploader_sub = new window.AjaxUpload('wall-image-upload-sub',
{ action: '{{$baseurl}}/wall_upload/{{$nickname}}',
name: 'userfile',
title: upload_title,
@ -137,12 +133,12 @@ function enableOnUser(){
addeditortext(response);
$('#jot-media').val($('#jot-media').val() + response);
$('#profile-rotator').spin(false);
}
}
);
var file_uploader = new window.AjaxUpload(
'wall-file-upload',
}
});
} catch(e) {
}
try {
var file_uploader = new window.AjaxUpload('wall-file-upload',
{ action: '{{$baseurl}}/wall_attach/{{$nickname}}',
name: 'userfile',
title: attach_title,
@ -152,10 +148,11 @@ function enableOnUser(){
$('#jot-media').val($('#jot-media').val() + response);
$('#profile-rotator').spin(false);
}
}
);
var file_uploader_sub = new window.AjaxUpload(
'wall-file-upload-sub',
});
} catch(e) {
}
try {
var file_uploader_sub = new window.AjaxUpload('wall-file-upload-sub',
{ action: '{{$baseurl}}/wall_attach/{{$nickname}}',
name: 'userfile',
title: attach_title,
@ -165,10 +162,9 @@ function enableOnUser(){
$('#jot-media').val($('#jot-media').val() + response);
$('#profile-rotator').spin(false);
}
}
);
});
} catch(e) {
}
});
function deleteCheckedItems() {
@ -182,7 +178,7 @@ function enableOnUser(){
else {
checkedstr = $(this).val();
}
}
}
});
$.post('item', { dropitems: checkedstr }, function(data) {
window.location.reload();
@ -226,14 +222,12 @@ function enableOnUser(){
//reply = prompt("{{$expirewhen}}", $('#jot-expire').val());
$('#expiryModal').modal();
$('#expiry-modal-OKButton').on('click', function() {
reply=$('#expiration-date').val();
if(reply && reply.length) {
$('#jot-expire').val(reply);
$('#expiryModal').modal('hide');
}
})
reply=$('#expiration-date').val();
if(reply && reply.length) {
$('#jot-expire').val(reply);
$('#expiryModal').modal('hide');
}
})
}
function jotShare(id) {
@ -247,7 +241,6 @@ function enableOnUser(){
$('#like-rotator-' + id).spin(false);
$(window).scrollTop(0);
});
});
}
@ -292,9 +285,9 @@ function enableOnUser(){
}
function itemFiler(id) {
var bordercolor = $("input").css("border-color");
$.get('filer/', function(data){
$.colorbox({html:data});
$("#id_term").keypress(function(){
@ -303,7 +296,7 @@ function enableOnUser(){
$("#select_term").change(function(){
$("#id_term").css("border-color",bordercolor);
})
$("#filer_save").click(function(e){
e.preventDefault();
reply = $("#id_term").val();
@ -352,8 +345,6 @@ function enableOnUser(){
$('#profile-nolocation-wrapper').attr('disabled', true);
}
{{$geotag}}
</script>
@ -362,16 +353,15 @@ function enableOnUser(){
$( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-delete-link,.block-delete-link", function(e) {
var link = $(this).attr("href"); // "get" the intended link in a var
if (typeof(eval($.fn.modal)) === 'function'){
e.preventDefault();
bootbox.confirm("<h4>{{$confirmdelete}}</h4>",function(result) {
if (result) {
document.location.href = link;}
});}
else {
return confirm("{{$confirmdelete}}");
}
});
if (typeof(eval($.fn.modal)) === 'function'){
e.preventDefault();
bootbox.confirm("<h4>{{$confirmdelete}}</h4>",function(result) {
if (result) {
document.location.href = link;
}
});
} else {
return confirm("{{$confirmdelete}}");
}
});
</script>