Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    490

    Diialog: Some settings were changed. Do you want to save them?

    When the user try to leave a setting page without "apply" changes, the dialog "Settings" with message "Some settings were changed. Do you want to save them?" is shown.

    I'm quite fresh with html and JS and i'm fumbling with the code but I could not find where and how is triggered.

    One of my prefs is an hash rendered as a table of CB, moddification of elements in this table is not catched and the Dialog is not show, so I would like to manually trigger it.

    Thx.

    Marco
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,733

    Diialog: Some settings were changed. Do you wantto save them?

    > I'm quite fresh with html and JS and i'm fumbling with the code but I
    > could not find where and how is triggered.


    Once the settings page has rendered, it will register change handles to
    check for change:

    https://github.com/Logitech/slimserv...ttings.js#L283

    > One of my prefs is an hash rendered as a table of CB, moddification of
    > elements in this table is not catched and the Dialog is not show, so I
    > would like to manually trigger it.


    I'm not 100% sure I do understand what you're doing there. But if you
    dynamically load content after the page had been rendered (through some
    ajax call or the like), you'd have to register those change handlers
    yourself. You could just call the same method as outlined above.

    --

    Michael

  3. #3
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    490
    Quote Originally Posted by mherger View Post
    > I'm quite fresh with html and JS and i'm fumbling with the code but I
    > could not find where and how is triggered.


    Once the settings page has rendered, it will register change handles to
    check for change:

    https://github.com/Logitech/slimserv...ttings.js#L283

    > One of my prefs is an hash rendered as a table of CB, moddification of
    > elements in this table is not catched and the Dialog is not show, so I
    > would like to manually trigger it.


    I'm not 100% sure I do understand what you're doing there. But if you
    dynamically load content after the page had been rendered (through some
    ajax call or the like), you'd have to register those change handlers
    yourself. You could just call the same method as outlined above.

    --

    Michael
    I'm doing this:

    a. PREF FILE:

    Code:
    ...
    codecs:
        aac: ~
        aif: on
        alac: ~
        alc: on
        dff: on
        dsf: on
        flc: on
        mp3: ~
        wav: on
    ...
    b. PlayerSettings.pm sub handler:

    Code:
    my $prefCodecs   = $prefs->client($client)->get('codecs');
    $params->{'prefs'}->{'codecs'}=$prefCodecs;
    c. in player.html

    Code:
    ...
    <table>
            <tr>
                        <td>    
                            <input type="checkbox" name="pref_codecs[% codec.key %]" 
                                   id="codec[% codec.key %]" value="1" 
                                   [% codec.value ? "checked" : "" %]>
                            </input>
                        </td>
            </tr>
    </table>
    ...
    d. then, back in PlayerSettings.pm sub handler:

    Code:
     
    if ($params->{'saveSettings'}){
    
         for my $k (keys %$prefCodecs){
    
            $prefCodecs->{$k} = $params->{'pref_codecs'.$k} ? 'on' : undef;
    
        }
        ...
        $prefs->writeAll();
        $prefs->savenow();
    }
    The above, just to let you understand, is not the actual code.

    adding: onchange="this._checkModified"

    to any checkbox createt, like that:

    Code:
    <input type="checkbox" name="pref_codecs[% codec.key %]" 
                id="codec[% codec.key %]" value="1" 
                [% codec.value ? "checked" : "" %]
                onchange="this._checkModified" 
                onblur="this._checkModified">
    </input>
    does not work, sure there is something obvious that I miss...

    Thanks for your time.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,733

    Diialog: Some settings were changed. Do you wantto save them?

    > The above, just to let you understand, is not the actual code.

    Then please show me the actual code. Because there's no reason to
    discuss code you're not using.

    > adding: onchange="this._checkModified"


    That's not how it works. As I said in my previous mail you would only
    have to care about this if you created your table _after_ the page had
    been rendered, eg. using AJAX.

    --

    Michael

  5. #5
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    490
    Quote Originally Posted by mherger View Post
    > The above, just to let you understand, is not the actual code.

    Then please show me the actual code. Because there's no reason to
    discuss code you're not using.

    > adding: onchange="this._checkModified"


    That's not how it works. As I said in my previous mail you would only
    have to care about this if you created your table _after_ the page had
    been rendered, eg. using AJAX.

    --

    Michael
    here the repo and the branch you could look a (please forgive the typo in the branch name):

    https://github.com/marcoc1712/C-3PO/...ettings_change, files are:

    1. player.html build up the page assembling different smaller components, the one to look at is functionsPerCodecs.html

    https://github.com/marcoc1712/C-3PO/...odecs.html#L60

    2. PlayerSettings.pm :

    https://github.com/marcoc1712/C-3PO/...ettings.pm#L82
    https://github.com/marcoc1712/C-3PO/...ttings.pm#L232

    and


    https://github.com/marcoc1712/C-3PO/...ttings.pm#L145

    thanks.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  6. #6
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,733

    Diialog: Some settings were changed. Do you wantto save them?

    Wow... what shall I say?... hard to tell what is breaking things.
    There's a lot of potential for it in your code :-). You seem to be
    re-inventing LMS. Transcoding, logging, prefs handling, html templates...

    One potential issue wrt. to your initial request is the fact that you're
    creating multiple html headers in the settings pages. You write your own
    with a few JS snippets, then include LMS' default header. Most likely
    this is killing LMS' JS initialization, as your browser would ignore the
    second header section.

    --

    Michael

  7. #7
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    490
    Quote Originally Posted by mherger View Post
    Wow... what shall I say?... hard to tell what is breaking things.
    There's a lot of potential for it in your code :-). You seem to be
    re-inventing LMS. Transcoding, logging, prefs handling, html templates...

    One potential issue wrt. to your initial request is the fact that you're
    creating multiple html headers in the settings pages. You write your own
    with a few JS snippets, then include LMS' default header. Most likely
    this is killing LMS' JS initialization, as your browser would ignore the
    second header section.

    --

    Michael
    This plugin is born to facilitate transcoding, but - at least in the on line part - it uses all of the standard LMS features, that's why I'm asking how to use this one, if possible.

    Logging, prefs and others are redefined to be used in the 'batch' part of the transcoder, nothing todo with the plugin itself, other than sharing as much code as possible.

    The reason why I need a 'batch' part is that transcoding in LMS 'lack' the capability to setup transcoder chain depending on the actual file/stream being played, patching LMS was maybe simpler, but I did not want take that route.

    Back on the Hash preferenxe problem, I could write a smaller dummy plugin to replicate the problem , if you like to investigate it, but, debugging, I verified that "this._checkModified" is called when I click on one of the CB, but values are always :

    modifed: false
    input.value = 1
    default.value = 1

    no matter the actual value of the CB, so resulting "modified" var is always false, so no alert or dialog is shown. I'll have som further debiugging to uunderstand why this happen.

    Thanks for your help.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  8. #8
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,733

    Diialog: Some settings were changed. Do you wantto save them?

    > Back on the Hash preferenxe problem, I could write a smaller dummy
    > plugin to replicate the problem , if you like to investigate it, but,
    > debugging, I verified that "this._checkModified" is called when I click
    > on one of the CB, but values are always :


    As I said before: you don't have to call _checkModified. You have to fix
    your HTML.

    --

    Michael

  9. #9
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    490
    Quote Originally Posted by mherger View Post
    > Back on the Hash preferenxe problem, I could write a smaller dummy
    > plugin to replicate the problem , if you like to investigate it, but,
    > debugging, I verified that "this._checkModified" is called when I click
    > on one of the CB, but values are always :


    As I said before: you don't have to call _checkModified. You have to fix
    your HTML.

    --

    Michael
    In the version I've submitted to you , _checkModified is not called manually, indeed my intent was just to confirm you that it was triggered, but - seems to me - with wrong values.

    Anyway,

    here; https://github.com/marcoc1712/dummy

    Is a very simple plugin doing NOTHING, no extra html in it, just exposing some fake settings. You could verify the problem I was asking an help for.

    Sure it's me, but I could not understand what part of HTML I have to modify, could you please articulate a bit for me?

    thanks.

    EDIT: the p.s was partially incorrect, please forget it.
    Last edited by marcoc1712; 2017-04-18 at 08:13.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  10. #10
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    490
    HI,

    with more debugging I've found that the problem rise when you impose the value for the input CB:

    Code:
     <input name="pref_checkbox" type="checkbox"[% IF prefs.checkbox %] checked [% END %]>
    works,

    Code:
     <input name="pref_checkbox" type="checkbox" value="on" [% IF prefs.checkbox %] checked [% END %]>
    does not.

    this is just becouse the test:


    Code:
    modified = modified || (input.value != input.defaultValue);
    is fired every time the user enter and exits (blur) from the input, BUT with CB is does not really compare current value versus default value, just if a default value where imposed.

    Works, but not how one could expect and only in certain circumstance.

    I'll add a note in the code at least.

    Hope it helps someone to avoid same troubles.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •