pictures.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. function constructSharingPath() {
  2. return document.location.protocol + '//' + document.location.host + OC.linkTo('', 'public.php') + '?service=gallery&token=' + Albums.token;
  3. }
  4. function shareGallery() {
  5. var existing_token = '';
  6. //if (Albums.token)
  7. // existing_token = constructSharingPath();
  8. var form_fields = [{text: 'Share', name: 'share', type: 'checkbox', value: false},
  9. {text: 'Share recursive', name: 'recursive', type: 'checkbox', value: false},
  10. {text: 'Shared gallery address', name: 'address', type: 'text', value: ''}];
  11. OC.dialogs.form(form_fields, t('gallery', 'Share gallery'), function(values){
  12. var p = '';
  13. for (var i in paths) p += paths[i]+'/';
  14. if (p == '') p = '/';
  15. alert(p);
  16. $.getJSON(OC.filePath('gallery', 'ajax', 'galleryOp.php'), {operation: 'share', path: p, share: values[0].value, recursive: values[1].value}, function(r) {
  17. if (r.status == 'success') {
  18. Albums.shared = r.sharing;
  19. if (Albums.shared) {
  20. Albums.token = r.token;
  21. Albums.recursive = r.recursive;
  22. } else {
  23. Albums.token = '';
  24. Albums.recursive = false;
  25. }
  26. var actual_addr = '';
  27. if (Albums.token)
  28. actual_addr = constructSharingPath();
  29. $('input[name="address"]').val(actual_addr);
  30. } else {
  31. OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
  32. }
  33. });
  34. });
  35. }