upload.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. function idGen() {
  2. var expire = Math.floor(Date.now() / 1000 + $('#expire').val() * 86400);
  3. var random = Math.floor(Math.random() * Math.floor(99));
  4. return expire + '-' + random;
  5. }
  6. $(function () {
  7. // Copy on clipart : https://stackoverflow.com/questions/44888884/copying-to-clipboard-textbox-value-using-jquery-javascript
  8. function copyToClipboard(text) {
  9. var textArea = document.createElement( "textarea" );
  10. textArea.value = text;
  11. document.body.appendChild( textArea );
  12. textArea.select();
  13. try {
  14. var successful = document.execCommand( 'copy' );
  15. var msg = successful ? 'successful' : 'unsuccessful';
  16. } catch (err) {
  17. console.log('Oops, unable to copy');
  18. }
  19. document.body.removeChild( textArea );
  20. }
  21. $( "#similarServices" ).click(function() {
  22. $('.similarHref').hide();
  23. $('.similarLink').show();
  24. });
  25. $(document).on('click', '.copy', function(){
  26. copyToClipboard($(this).val());
  27. $(this).select();
  28. });
  29. $("#passwordCheckbox").on('change',function(){
  30. if( $('#passwordCheckbox').is(':checked') ){
  31. $('#passwordForm').show();
  32. } else {
  33. $('#passwordForm').hide();
  34. }
  35. });
  36. $("#accessCheckbox").on('change',function(){
  37. if( $('#accessCheckbox').is(':checked') ){
  38. $('#accessForm').show();
  39. } else {
  40. $('#accessForm').hide();
  41. }
  42. });
  43. $("#uploadOptionsLinkShow").on('click',function(){
  44. $('#uploadOptions').show();
  45. $('#uploadOptionsLinkShow').hide();
  46. });
  47. $("#uploadOptionsLinkHide").on('click',function(){
  48. $('#uploadOptions').hide();
  49. $('#uploadOptionsLinkShow').show();
  50. });
  51. $("#expire").on('change',function(){
  52. $('#files_id').val(idGen());
  53. });
  54. $("#resize").on('change',function(){
  55. $('#fileupload').fileupload('option', {
  56. imageMaxWidth: $('#resize').val(),
  57. imageMaxHeight: $('#resize').val(),
  58. });
  59. });
  60. $('#ButtonStart').hide();
  61. $('#ButtonReset').hide();
  62. });