% # vim:set sw=4 ts=4 sts=4 ft=html.epl expandtab:
% if (config('always_encrypt')) {

<%=l 'always_encrypt' %>

% } % if (defined(stash('short'))) {
% if (defined(stash('short'))) { <%= stash('filename') %> thumbnail % }
% # Display image informations % my $url = index_url(1).stash('short'); <%= stash('filename') %>    <%=l 'tweet_it' %>
    % my $delete_url = url_for('delete', {short => stash('real_short'), token => stash('token')})->to_abs();
  • <%= link_to $url => begin %> <%= $url %> <%= end %>
  • <%= link_to $url.'?dl' => begin %> <%= $url.'?dl' %> <%= end %>
  • <%= link_to $url.'?t' => begin %> <%= $url.'?t' %> <%= end %>
  • <%= link_to $delete_url => begin %> <%= $delete_url %> <%= end %>
% # Delay modification form % my $modify_url = url_for('modify', {short => stash('real_short'), token => stash('token')})->to_abs();
<%= submit_button l('go'), class => 'btn btn-sm btn-default btn-primary', id => 'submitbutton' %>
% } % if (defined(flash('success'))) {

<%== flash('success') %>

% } % if (defined(flash('msg'))) {
<%=l 'some-bad' %>
<%= flash('filename') %> <%= flash('msg') %>
% }
<%=l 'drag-n-drop' %>
<%=l 'or' %>

<%=l 'image-only' %>

<%=l 'go' %>
%= javascript begin function link(url, dl, token, modify) { if (token !== undefined) { if (modify !== undefined && modify === true) { return '<%== index_url(1) %>m/'+url+'/'+token; } else { url = 'd/'+url+'/'+token; } } else if (dl !== '') { url = url+'?'+dl; } return '<%== index_url(1) %>'+url+''; } function share(url) { console.log(url); new MozActivity({ name: "share", data: { type: "url", number: 1, url: url } }); } function tw_url(url) { var btn = '   <%=l 'tweet_it' %>'; if (navigator.mozSetMessageHandler !== undefined) { btn = btn+'   <%=l 'share_it' %>'; } return btn } function modify(url, short) { $.ajax({ url : url, type : "POST", data : { 'image_url' : '<%== index_url(1) %>'+short, 'format' : 'json', 'first-view' : ($("#first-view-"+short).prop('checked')) ? 1 : 0, 'delete-day' : $("#day-"+short).val() }, success: function(data) { alert(data.msg); }, error: function() { alert('<%=l 'modify_image_error' %>'); } }); } function build_message(success, msg) { if(success) { var thumb = (msg.thumb !== null) ? ''+msg.filename+' thumbnail' : '' return '
' +thumb +'
' +msg.filename +'' +tw_url(msg.short) +'
 
' +'
 ' +'<%=l 'go' %>
' +'
'; } else { return '
<%=l 'some-bad' %>
' +msg.filename +"
" +msg.msg +'
'; } } function bindddz(firstview, deleteday) { $('#drag-and-drop-zone').dmUploader({ url: '<%== index_url %>', dataType: 'json', allowedTypes: 'image/*', maxFileSize: <%= $max_file_size %>, onNewFile: function(id, file){ $(".messages").append('
'+file.name+'
0%
'); }, onUploadProgress: function(id, percent){ var percentStr = ' '+percent+'%'; $('#'+id).prop('aria-valuenow', percent); $('#'+id).prop('style', 'width: '+percent+'%;'); $('#'+id+'-text').html(percentStr); }, onUploadSuccess: function(id, data){ $('#'+id+'-div').remove(); $(".messages").append(build_message(data.success, data.msg)); }, onUploadError: function(id, message){ $(".messages").append(build_message(false, '')); }, onFileSizeError: function(file){ $(".messages").append(build_message(false, { filename: file.name, msg: '<%= l('file_too_big', $max_file_size) %>'})); } }); } function upload_url() { var val = $("#lutim-file-url").val(); if (val !== undefined && val !== "") { $("#lutim-file-url").prop('disabled', 'disabled'); $(".hidden-spin").css('display', 'block'); console.log(val); $.ajax({ url : '<%== index_url %>', type : "POST", data : { 'lutim-file-url' : val, 'format' : 'json', 'first-view' : ($("#first-view").prop('checked')) ? 1 : 0, 'crypt' : ($("#crypt").prop('checked')) ? 1 : 0, 'delete-day' : $("#delete-day").val() }, success: function(data) { $(".messages").append(build_message(data.success, data.msg)); if (data.success) { $("#lutim-file-url").val(''); } }, error: function() { $(".messages").append(build_message(false, '')); }, complete: function() { $("#lutim-file-url").prop('disabled', ''); $(".hidden-spin").css('display', 'none'); } }); } else { console.log("fhdsjnf"); } } function fileUpload(file) { var fd = new FormData(); fd.append('file', file); fd.append('format', 'json'); fd.append('first-view', ($("#first-view").prop('checked')) ? 1 : 0); fd.append('crypt', ($("#crypt").prop('checked')) ? 1 : 0); fd.append('delete-day', ($("#delete-day").val())); $(".messages").append('
'+file.name+'
0%
'); // Ajax Submit $.ajax({ url: '<%== index_url %>', type: 'POST', dataType: 'json', data: fd, cache: false, contentType: false, processData: false, forceSync: false, xhr: function(){ var xhrobj = $.ajaxSettings.xhr(); if(xhrobj.upload){ xhrobj.upload.addEventListener('progress', function(event) { var percent = 0; var position = event.loaded || event.position; var total = event.total || e.totalSize; if(event.lengthComputable){ percent = Math.ceil(position / total * 100); } var percentStr = ' '+percent+'%'; $('#1').prop('aria-valuenow', percent); $('#1').prop('style', 'width: '+percent+'%;'); $('#1-text').html(percentStr); }, false); } return xhrobj; }, success: function (data, message, xhr){ $('#1-div').remove(); $(".messages").append(build_message(data.success, data.msg)); }, error: function (xhr, status, errMsg){ $(".messages").append(build_message(false, '')); }, }); } window.onload = function() { if (navigator.mozSetMessageHandler !== undefined) { navigator.mozSetMessageHandler('activity', function handler(activityRequest) { var activityName = activityRequest.source.name; if (activityName == 'share') { activity = activityRequest; blob = activity.source.data.blobs[0]; fileUpload(blob); } }); } }; $('document').ready(function() { var firstview = ($("#first-view").prop('checked')) ? 1 : 0; var deleteday = ($("#delete-day").prop('checked')) ? 1 : 0; bindddz(firstview, deleteday); $("#file-url-button").on("click", upload_url); $('#lutim-file-url').keydown( function(e) { var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; if(key == 13) { e.preventDefault(); upload_url(); } }); }); % end