Loading ...
Sorry, an error occurred while loading the content.

Re: [NH] is there any clips to help create cookie code

Expand Messages
  • Jody
    Hi James, You might check at Cut n Paste Javascript or somewhere else that has ready made scripts. ... Happy HTML n! Jody http://www.sureword.com/notetab The
    Message 1 of 6 , Jul 28, 2000
    • 0 Attachment
      Hi James,

      You might check at Cut 'n Paste Javascript or somewhere else that
      has ready made scripts.

      >> Is there any clips to help create cookies in html?
      >>
      >> What I am after is a site with that can offer two to three
      >> different selection of colors or a site where one can pick and
      >> choose what color they want the background forground etc and
      >> when they come back there selections will be what the selected.

      Happy HTML'n!
      Jody

      http://www.sureword.com/notetab

      The NoteTab and Html List...
      mailto:Ntb-html-Subscribe@...
      mailto:Ntb-html-UnSubscribe@...
    • Grant
      ... he following clip create a cookie with 3 values which can be individually returned with an index value i: getCookieValue(i) ;see example html The cookie
      Message 2 of 6 , Jul 31, 2000
      • 0 Attachment
        > Is there any clips to help create cookies in html?
        he following clip create a cookie with 3 values which can be individually
        returned with an index value i: getCookieValue(i) ;see example html
        The cookie expires in a years time


        H=cookieCreator
        ;place cursor in script block
        ^!SetListDelimiter ,
        ^!setArray %expireDate%=^$GetDate(yyyy,mm,dd,hh,mm,ss)$
        ^!inc %expireDate1%
        ^!dec %expireDate2%
        ^!set %name%=^?{name=test}
        ^!set %i%=^$StrSize(^%name%)$
        ^!inc:%i%
        function setCookie()
        {
        var cookieName = "^%name%";
        var cookieValue0 = escape("^?{value0=this}");
        var cookieValue1 = escape("^?{value1=that}");
        var cookieValue2 = escape("^?{value2=those}");
        /*Expires set to a years time*/
        var expires = new Date(^%expireDate%)
        var mix = ""
        mix += cookieName
        mix += "="
        mix += cookieValue0
        mix += "|"
        mix += cookieValue1
        mix += "|"
        mix += cookieValue2
        mix += "; expires = "
        mix += expires.toGMTString()
        document.cookie = mix
        }
        ;

        function getCookieValue(i)
        {
        var values = unescape(document.cookie);
        values = values.substr(^%i%,document.cookie.length)
        arrValue = values.split("|")
        return arrValue[i];
        }
        ;*******clip end*******


        Place cursor in html script block and run clip

        results example of How to use in html ; Tis just an example of how to set
        and retrieve cookie values
        and not a realworld example as you would most likely set
        cookieValue0,cookieValue1 etc; with a forms input controls.

        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
        <meta name="generator" content="HTML Tidy, see www.w3.org" />
        <title>Cookie Time</title>
        <script type="text/javascript">
        function setCookie()
        {
        var cookieName = "test";
        var cookieValue0 = escape("this");
        var cookieValue1 = escape("that");
        var cookieValue2 = escape("those");
        /*Expires set to a years time*/
        var expires = new Date(2001,7,01,10,48,42)
        var mix = ""
        mix += cookieName
        mix += "="
        mix += cookieValue0
        mix += "|"
        mix += cookieValue1
        mix += "|"
        mix += cookieValue2
        mix += "; expires = "
        mix += expires.toGMTString()
        document.cookie = mix
        }

        function getCookieValue(i)
        {
        var values = unescape(document.cookie);
        values = values.substr(5,document.cookie.length)
        arrValue = values.split("|")
        return arrValue[i];
        }
        </script>
        </head>
        <body>
        <form>
        <input type="button" value="set" onclick="setCookie()" />
        <input type="button" value="get0" onclick="alert(getCookieValue(0))" />
        <input type="button" value="get1" onclick="alert(getCookieValue(1))" />
        <input type="button" value="get2" onclick="alert(getCookieValue(2))" />
        </form>
        </body>
        </html>

        Hope this helps.
      • Grant
        To avoid wrath of J I ve replied on this list. Reply to Richard request from basic list Richard said ... Open the html doc in Notetab Run this clip once only.
        Message 3 of 6 , Jul 31, 2000
        • 0 Attachment
          To avoid wrath of J I've replied on this list.
          Reply to Richard request from basic list

          Richard said
          > Sorry if this is a question for the clips list or the HTML list, but
          > I'm a new NoteTab user and I have what I hope is a simple question.
          >
          > When I edit an HTML file, the standard format for my site is that the
          > last line before the </body></html> tags is a "Last modified:" line
          > with the current date. My question is, can I (with clips or any other
          > way) set things up so that when I save the file, the date gets
          > automatically updated?

          Open the html doc in Notetab
          Run this clip once only.
          It will insert A simple piece of javascript that will do the trick.

          H=lastModified
          ^!Find "</body" CIWS
          ^!Jump SELECT_START
          ^%NL%<script language="javascript" type="text/javascript">
          document.write('<hr /><p>lastModified: ' + document.lastModified + '</p>')
          </script>^%NL%
          ^!Save
        • Richard S. Smith
          Grant, that s a clever and elegant solution. Thanks. Unfortunately it won t work for me because I have to support multiple browsers including Lynx, so
          Message 4 of 6 , Aug 1, 2000
          • 0 Attachment
            Grant, that's a clever and elegant solution. Thanks. Unfortunately
            it won't work for me because I have to support multiple browsers
            including Lynx, so relying upon JavaScript behavior is a non-starter.

            So, I'm back to my original question, which is, can I "hook" a menu
            event like File->Save and "bind" a Clip to it? It's looking more and
            more like the answer is "No", so I guess I'll just write the Clip to
            do the text substitution and then instruct my users to manually run
            the clip when they need to save.

            I'm a tad disappointed that I can't make it into a passive, automated
            process, though. I guess I'm spoiled by Emacs, which allows you to
            bind code just about anywhere. But if NT-Emacs weren't so unfriendly
            to novice users, I wouldn't be using NoteTab, now would I? :-)

            Thanks again for the help.

            emerge@... (Grant) wrote:
            > Richard said
            > > Sorry if this is a question for the clips list or the HTML list, but
            > > I'm a new NoteTab user and I have what I hope is a simple question.
            > >
            > > When I edit an HTML file, the standard format for my site is that the
            > > last line before the </body></html> tags is a "Last modified:" line
            > > with the current date. My question is, can I (with clips or any other
            > > way) set things up so that when I save the file, the date gets
            > > automatically updated?
            >
            > Open the html doc in Notetab
            > Run this clip once only.
            > It will insert A simple piece of javascript that will do the trick.
            >
            > H=lastModified
            > ^!Find "</body" CIWS
            > ^!Jump SELECT_START
            > ^%NL%<script language="javascript" type="text/javascript">
            > document.write('<hr /><p>lastModified: ' + document.lastModified + '</p>')
            > </script>^%NL%
            > ^!Save

            --
            --------------------------------------------------------------------------
            Richard S. Smith / Email: rss@... / Web: http://www.idiom.com/~rss
            --------------------------------------------------------------------------
          • Larry Hamilton
            Hi Richard,On Tue, 1 Aug 2000 02:30:46 -0700, ntb-html@egroups.com wrote: Grant, that s a clever and elegant solution. Thanks. Unfortunately it won t
            Message 5 of 6 , Aug 1, 2000
            • 0 Attachment
              Hi Richard,

              On Tue, 1 Aug 2000 02:30:46 -0700, ntb-html@egroups.com wrote:
              >Grant, that's a clever and elegant solution. Thanks. Unfortunately
              >it won't work for me because I have to support multiple browsers
              >including Lynx, so relying upon JavaScript behavior is a
              non-starter.

              Here are two clips I use. One I made to change the last updated date
              for all open documents, you may need to tweak for the way you need it
              to work. The other clip is for updating only one document. If it is a
              new document, you can use a template with the code, or use the HTML
              clip library, which includes that information.

              If you are only saving the date, you could create a clip library with
              an on Open event, so that when the clip is selected it would find the
              open htm/html documents that you have open for editing, and update
              the dates.

              ______[Copy below this line]_______
              H="Find Last Updated-All Docs"
              ;Larry Hamilton, Jr. <lm_hamilton@...>
              ;08/01/2000, 07:55:31 AM
              ^!Set %COUNTER%=0
              ^!Set %DocCount%=^$GetDocCount$
              ^!StatusClose
              ^!StatusShow Updating "Last Updated"
              :LOOP
              ^!Inc:%COUNTER%
              ^!SetDocIndex ^%COUNTER%

              ^!IF ^%COUNTER% > ^%DocCount% END ELSE NEXT
              ^!Open ^$GetDocName(^%COUNTER%)$
              ^!Find "Last updated " GW
              ;^!Find "<B>" IS
              ^!IfError End
              ^!Select 0
              ^!Set %End%=^$GetRow$:^$GetCol$
              ^!SetCursor ^%Start%
              ^!SelectTo ^%End%
              ^!Keyboard DELETE
              ^$GetDate(mmmm dd, yyyy)$
              ;^!Keyboard CTRL+V
              ^!Goto LOOP
              ;^!Save
              _____[Copy above this line]______
              | right click over the clipbook |
              | and choose "Add from Clipboard" |
              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

              ______[Copy below this line]_______
              H="Last Updated for 1 Doc"
              ;Larry Hamilton, Jr. <lm_hamilton@...>
              ;08/01/2000, 07:59:23 AM
              ^!SetCursor 1:1
              ^!Find "Last updated "
              ^!Jump SELECT_END
              ;^!Find <p> IS
              ;^!Jump SELECT_END
              ^!Set %Start%=^$GetRow$:^$GetCol$
              ^!Find </p> IS
              ^!IfError End
              ^!Select 0
              ^!Set %End%=^$GetRow$:^$GetCol$
              ^!SetCursor ^%Start%
              ^!SelectTo ^%End%
              ^!Keyboard DELETE
              ^$GetDate(mmmm dd, yyyy)$
              ^!Save
              _____[Copy above this line]______
              | right click over the clipbook |
              | and choose "Add from Clipboard" |
              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

              -- Larry Hamilton, lm_hamilton@... on 08/01/2000


              __________________________________________________
              Do You Yahoo!?
              Talk to your friends online with Yahoo! Messenger.
              http://im.yahoo.com
            Your message has been successfully submitted and would be delivered to recipients shortly.