Hi Patrick,

First: using hard-coded integer indices is dangerous. What happens if in
the future there are other lists that are added ? What if some apps are
creating their own additional file lists, presenting the files in yet a
different filter/order ?

Your app should not need to distinguish between the lists or even know
they exist.
The best way is to make your app work only with context.dir + '/' +
fileName from the action handler.
I'm not clear yet why you want to distinguish the lists in the first place.

I guess you probably just want to add some status update into the
original list ?
If yes, then the following should work with a Javascript closure:

// this is the function you pass to OCA.Files.fileActions.register()
function actionHandler(fileName, context) {
    // do something
    // ...
    // do ajax call
    $.ajax({
        url: OC.filePath('files_w2g','ajax','workin2gether.php'),
        type: "post",
        data: {
            path: context.dir + '/' + fileName,
            safe: _safe
        },
        success: function(data){
            // from here you still have access to the "context" variable
because
            // it is inside an inner function, so you could just pass
the instance of the
            // FileList class to your postmode() function
            postmode(filename, data, context.fileList)},
        });
}

Hope this helps :-)

Cheers,

Vincent

On 06/17/2014 02:07 PM, Hoffmann, Patrick wrote:
> Hello Vincent,
>
> I use ajax for grabbing the return values from my php scripts like this:
>
> $.ajax({
>         url: OC.filePath('files_w2g','ajax','workin2gether.php'),
>         type: "post",
>         data: { path: oc_path, safe: _safe},
>         success: function(data){postmode(filename,data)},
>     });
>
> I'd like to give the number of my filelist in a form like an integer 0-4, 
> that my script knows what kind of function it has to use to determinate
> the orginal source of the file (for shared files). Currently my script finds 
> only files, owned by oneself. So my php script needs to know what it should 
> look for
> Shared by me, Shared with me, Shared by link.
>
> It should look like this then:
>
> $.ajax({
>         url: OC.filePath('files_w2g','ajax','workin2gether.php'),
>         type: "post",
>         data: { path: oc_path, safe: _safe, filelist: 
> <thegloryfilelistnumberfromsomewhere> },
>         success: function(data){ postmode(filename,data) },
>     });
>
> Or do you know a better way?
> Maybe the last option would be separate php scripts for each filelist, but 
> I'd like to reduce the code not increase.
>
>
> Cheers
>
> Patrick
>
> Von: [email protected] [mailto:[email protected]] Im 
> Auftrag von Vincent Petry
> Gesendet: Dienstag, 17. Juni 2014 13:43
> An: List for Developers of ownCloud
> Betreff: Re: [owncloud-devel] OC7a JS context object
>
> Hi Patrick,
>
> Glad to see that your project is progressing forward :-D
>
> I guess what you want is the DOM element of the file list ?
>
> You can reach the container with context.fileList.$el
> If you want the "table" element, it should be context.fileList.$table
> And the "tbody", the one that had the "fileList" id can be reached under 
> context.fileList.$fileList.
>
> Ok, I re-read your comment and I don't quite understand how your PHP can 
> access a live DOM node ? Are you injecting Javascript code from PHP ?
>
> Let me know how it goes.
>
> Cheers,
>
> Vincent
> On 06/17/2014 12:35 PM, Hoffmann, Patrick wrote:
>
>
>
> Gesch?ftsf?hrer: Werner Magin, Winfried Schmuck | HRB 2704 Bad Kreuznach | 
> Gesellschafter: Fritz Bittmann Holding GmbH | USt-ID: DE 811 202 181
>
>
> BITO-Lagertechnik
> Bittmann GmbH
> Obertor 29
> D-55590 Meisenheim      Telefon:
> Telefax:
> E-Mail:
> Internet:       +49 (0) 6753 122 0
> +49 (0) 6753 122 399
> [email protected]
> www.bito.de
>
>
>
> Dieses E-Mail ist nur f?r den Empf?nger bestimmt, an den es gerichtet ist und 
> kann vertrauliches bzw. unter das Berufsgeheimnis fallendes Material 
> enthalten. Jegliche darin enthaltene Ansicht oder Meinungs?u?erung ist die 
> des Autors und stellt nicht notwendigerweise die Ansicht oder Meinung von 
> BITO-Lagertechnik Bittmann GmbH dar.
> Sind Sie nicht der Empf?nger und haben diese E-Mail irrt?mlich erhalten, sind 
> jegliche Verwendung, Ver?ffentlichung, Weiterleitung, Abschrift oder 
> jeglicher Druck dieser E-Mail strengstens untersagt.
> Jede ausgehende E-Mail wird von uns mit h?chster Sorgfalt auf Viren gepr?ft. 
> Jedoch ?bernehmen weder BITO-Lagertechnik Bittmann GmbH noch der Absender 
> (Patrick Hoffmann) die Haftung f?r Viren; es obliegt Ihrer Verantwortung, die 
> E-Mail und deren Anh?nge auf Viren zu pr?fen.
>
> This email is exclusively meant for the addressee and may contain 
> confidential information or information which can be classified as 
> professional secret. Any view or opinion stated in this email is that of the 
> author and does not necessarily represent the view or the opinion of 
> BITO-Lagertechnik Bittmann GmbH. If you are not the addressee and if this 
> email has been transmitted to you by mistake, you may not make use of, 
> publish, transmit, reproduce or print the information contained therein for 
> whatever purpose. We take every reasonable care to check all out-bound emails 
> for viruses. However, neither BITO-Lagertechnik Bittmann GmbH nor the sender 
> (Patrick Hoffmann) can be held liable for the occurrence of viruses and any 
> consequential damages. It is therefore the addressee's sole responsibility to 
> check incoming emails and attachments for viruses.
>
> Anh?nge - :
> Versand am 17.06.2014 14:07 von Patrick Hoffmann
>
>
>
>
> Hello Vincent,
>
>
>
> is there a smart way to determinate from which Filelist the FileAction is 
> called?
>
> context.fileList is useful for javascript, but I need a useful value for my 
> php script.
>
> Something like Filelist number 0 - 3. Sadly all filelists have the id 
> (#)Filelist.
>
>
>
> Everything so far is working now :), but I stuck on this tricky thing.
>
>
>
> Cheers,
>
>
>
> Patrick
>
>
>
>
>
>
>
>
>
> Gesch?ftsf?hrer: Werner Magin, Winfried Schmuck | HRB 2704 Bad Kreuznach | 
> Gesellschafter: Fritz Bittmann Holding GmbH | USt-ID: DE 811 202 181
>
>
>
>
>
> BITO-Lagertechnik
>
> Bittmann GmbH
>
> Obertor 29
>
> D-55590 Meisenheim      Telefon:
>
> Telefax:
>
> E-Mail:
>
> Internet:       +49 (0) 6753 122 0
>
> +49 (0) 6753 122 399
>
> [email protected]<mailto:[email protected]>
>
> www.bito.de<http://www.bito.de>
>
>
>
>
>
>
>
> Dieses E-Mail ist nur f?r den Empf?nger bestimmt, an den es gerichtet ist und 
> kann vertrauliches bzw. unter das Berufsgeheimnis fallendes Material 
> enthalten. Jegliche darin enthaltene Ansicht oder Meinungs?u?erung ist die 
> des Autors und stellt nicht notwendigerweise die Ansicht oder Meinung von 
> BITO-Lagertechnik Bittmann GmbH dar.
>
> Sind Sie nicht der Empf?nger und haben diese E-Mail irrt?mlich erhalten, sind 
> jegliche Verwendung, Ver?ffentlichung, Weiterleitung, Abschrift oder 
> jeglicher Druck dieser E-Mail strengstens untersagt.
>
> Jede ausgehende E-Mail wird von uns mit h?chster Sorgfalt auf Viren gepr?ft. 
> Jedoch ?bernehmen weder BITO-Lagertechnik Bittmann GmbH noch der Absender 
> (Patrick Hoffmann) die Haftung f?r Viren; es obliegt Ihrer Verantwortung, die 
> E-Mail und deren Anh?nge auf Viren zu pr?fen.
>
>
>
> This email is exclusively meant for the addressee and may contain 
> confidential information or information which can be classified as 
> professional secret. Any view or opinion stated in this email is that of the 
> author and does not necessarily represent the view or the opinion of 
> BITO-Lagertechnik Bittmann GmbH. If you are not the addressee and if this 
> email has been transmitted to you by mistake, you may not make use of, 
> publish, transmit, reproduce or print the information contained therein for 
> whatever purpose. We take every reasonable care to check all out-bound emails 
> for viruses. However, neither BITO-Lagertechnik Bittmann GmbH nor the sender 
> (Patrick Hoffmann) can be held liable for the occurrence of viruses and any 
> consequential damages. It is therefore the addressee's sole responsibility to 
> check incoming emails and attachments for viruses.
>
>
>
> Anh?nge - :
>
> Versand am 17.06.2014 12:35 von Patrick Hoffmann
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
>
> Devel mailing list
>
> [email protected]<mailto:[email protected]>
>
> http://mailman.owncloud.org/mailman/listinfo/devel
>
>
>
>
> _______________________________________________
> Devel mailing list
> [email protected]
> http://mailman.owncloud.org/mailman/listinfo/devel

_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel

Reply via email to