Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29044

Re: "weekly" javascript?

From super70s <super70s@super70s.invalid>
Newsgroups comp.lang.javascript
Subject Re: "weekly" javascript?
Date 2015-12-27 12:03 -0600
Organization albasani.net
Message-ID <super70s-2E4557.12031327122015@reader.albasani.net> (permalink)
References <super70s-3DE5C2.10244827122015@reader.albasani.net> <XmlHttpRequest-JSON-DHTML-20151227174128@ram.dialup.fu-berlin.de>

Show all headers | View raw


In article 
<XmlHttpRequest-JSON-DHTML-20151227174128@ram.dialup.fu-berlin.de>,
 ram@zedat.fu-berlin.de (Stefan Ram) wrote:

> super70s <super70s@super70s.invalid> writes:
> >I was just wondering if there's a good JS I could use for this, say put 
> >all 52 weekly items in a separate file and then have the appropriate 
> >item come up according to what week it is?
> >I just don't know if this could work with the HTML markup that's 
> >required for the above, when I tried to insert HTML (say, bold text) for 
> >the birthday one, it wouldn't work at all.
> 
>   The following example shows how to insert a strong element
>   read from a file »example«.
> 
> <!DOCTYPE HTML><html><head><meta charset="UTF-8">
> <title>Main</title>
> </head><body>
> <p id="id201512271754350100"></p>
> <pre><code>
> <script type="application/javascript;version=1.8">
> ( { "main": function()
>     { "use strict";
>       let mainThis = this;
>       var xmlhttp = new XMLHttpRequest();
>       xmlhttp.onreadystatechange = function()
>       { if( xmlhttp.readyState == 4 && xmlhttp.status == 200 )
>         { console.log( this.insert );
>           mainThis.insert( JSON.parse( xmlhttp.responseText )); }};
>       xmlhttp.open
>       ( "GET", "http://userpage.fu-berlin.de/~ram/pub/JSON/example",
>         true );
>       xmlhttp.send(); },
>     "insert" : function( object )
>     { "use strict";
>       let e = document.createElement( 'strong' );
>       let t = document.createTextNode( object[ 0 ] );
>       e.appendChild( t );
>       document.getElementById( 'id201512271754350100' ).
>       appendChild( e ); }}.main() );
> </script></code></pre></body></html>

OK, but how do I indicate the appropriate element to come up according 
to the week of year?

I think it would be way too complicated to pull off the more I think 
about it, in some years it would be "week ending Jan. 1, Jan. 8, Jan. 
15...," then in another one it would be something like "week ending Jan. 
3, Jan. 11, Jan. 17...."

For each of the 5 groups (1970/75, 1971/76, 1972/1977, 1973/1978 and 
1974/1979), I would need to indicate a firm date (plus 7 days since it's 
"week ending...") to pull up the appropriate element, I guess.

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: "weekly" javascript? super70s <super70s@super70s.invalid> - 2015-12-27 12:03 -0600
  Re: "weekly" javascript? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-28 12:26 +0100
  Re: "weekly" javascript? RobG <rgqld@iinet.net.au> - 2016-02-06 17:06 +1000
    Re: "weekly" javascript? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-02-06 10:59 +0100

csiph-web