Testbed

Revisiting and revising the operation of functions and items in common.js or to prototype new functions, CSS and HTML5 features.

Memo

7 Mar 2017: whole common.js checked
Now go through GLOBAL VARIABLEs to see what can be made local.

Global Variables both Native and created by site JavaScript.

See globals.xls for lists of Global variable and functions that need checking and documenting.

The following functions are discontinued. Deleted in April by commenting out. Remove permanebtly in May unless users report problems.

nCookie transfer to be deleted from common.js varCookie() function and old nCookie setting to be removed from end of save_notes().

Delete a member from members_db[] once it has been found and tooltipped on a page. At the beginning and end of insertNameTips() save and resurrect members_db[].

Peter Wright aka Wishbone.

Checking links to this page, off site and recent News update for effect of wiseUp().
The website Calendar is a special case that shows the next event.
Remove flickr subroutine from wiseLinks()

What happens when something is crossed out.

What is the matter with the fixed font-family? It needs to be monospace!

Look for somebody on this page. Or somebody else or Thomas Rot. The findperson() function now searches inside paragraphs, blockquotes, tables and lists and then moves on to IDs and name attributes.

Several fieldFromXXX functions have either been converted to Object constructs or commented out for deletion with corresponding Global Variables.

Breadcrumb will not show if the page is not in the menu. It can be filled by page script as follows...
document.getElementByID("IDcrumb") .innerHTML="You are in <a href=admin_index.htm>Admin</a> > <b>Testbed</b>";

pinchthis from dev_ajaxtarget.htm
pinchthis from dev_ajaxtarget.htm

The above two shaded paragraphs are AJAXed (or Jiffied) in from dev_ajaxtarget.htm. Or not in the case of the Chrome browser!

On 24 Feb 2017 the use of <object id=Xpinchthis> was comprehensively removed throughout the website (It mainly involved Megaphone articles used elsewhere).

The bottom of page star rating system replaced by a single transparent star system that shows the "rating" at the back as a background-color that shows through. This way it can illustrate non integer average star ratings.

First: Streamline and polish the existing code that document.writes the HTML.

Second: Make a better backward and forward link system that is no longer section limited but takes into account member pages rewriting without reloading.

Third: Rewite the whole star() system using document.createElements to insert nodes in the DOM.

The Dragon Rally page should show lots of stars.

Fourth: Same for bottommenu() system.
outer = document.getElementById("IDcontent")
IDCONTENT = outer      (<DIV>)
           .firstChild (<TABLE>)
           .firstChild (<tbody> implicit)
           .firstChild (<TR>)
           .firstChild (<TD>)

The getWhen() function produces a coloquial English expression from a UK format date. The saywhen() function prints it into a page with document.write so it is not to be used once the page is written.

If something happened on 25/12/2016 then getWhen() produces "this phrase". Variables used in these functions have been localised.

UK Date       Says      

There is another date function in common.js to find the date of Easter Sunday. It is getEaster(); If an argument is passed it needs to be a date in the year that Easter is required. Without an argument it should default to the current year.

This year the date of Easter Sunday is written here

There is a checkLinkOut() function that hides photos and enclosing links if the photo is missing such as this... ... but it only seems to be used on the Devon Rally report, so is it necessary or should it be used more?

The local getElementByClassName() function written by Jonathan Snook may now conflict with the HTML native version that is available in all browsers except early Internet Explorere (that may still be in use on Windows XP computers!) Therefore Jonathan's function has been discontinued and references to it replaced by a work-around..

The main place this function was used is in "box" class elements that only show until or after a defined date.

Permanently delete all functions mentioned in the table at the top of the page by the end of March 2017.

All functions mentioned in the table at the top of the page should have been deleted by the end of March 2017.

contextMenu():

Major development of the Main Menu system using CSS and HTML5 continues on flyout_v4.htm.

Implementing a CSS Main Menu would require all the submenus to be written and hidden rather than writing and deleting them.

System to check that all the Foz Annuals have consecutive AJAX address ids from foz01 so that news_foz01.htm can present random jokes.

Checked by selective function in news/standard.js.

Results sent to Contact Centre.

Check that error message jokes are within the annual ranges.

Some of the Megaphone page descriptions are too long to fit comfortably into the new bottom author banners. This is a list of the descriptions and their lengths.

Filename variables

These global variables are set in common.js as the page opens (before onload is complete) this is a check for different passed URL formats.

no urlsrch or urlanch
finds urlsrch AND urlanch
thinks urlsrch is part of urlanch

incquery = ?
menubit = ?
endname = ?
uniname = ?
endid = ?
idonly = ?
spath = ?
urlsrch = ?
urlanch = ?

Therefore, when mixing queries and hash anchors, always put the query FIRST!

This is where Joe Soap lives.

Prototypes shuffle() & unique()

Operate on arrays of number and string.

Start with array[1,2,3,4,5,6,7,8,9,10,11,12, 1,2,3,4,5,6,7,8,9,10,11,12, 1,2,3,4,5,6,7,8,9,10,11,12]

Array.unique().shuffle() produces ...

Result

String

Start with array["Jan","Feb","Mar","Apr", "May","Jun","Jul","Aug", "Sep","Oct","Nov","Dec", "Jan","Feb","Mar","Apr", "May","Jun","Jul","Aug", "Sep","Oct","Nov","Dec"]

Array.unique().shuffle() produces ...

Result

Big Problem

For some reason the resulting array items are changed from strings (that can be split) into objects that cannot be split into arrays.

var menu = ["01|Archie|Eats apples","02|Bertie|Rides a bike","03|Charlie|Cleans his car","04|David|Cooks dinner"];

Result: menu.shuffle().[0].split("|") is

This is done by checking if the contents of the array to be shuffled are strings and if they are, putting them into the returned array as object.toString()

found()

Returns TRUE* if the searched for string is found in the source.
Thus source.found("sfs")

var source = "Look inside this string";
source.found("Look")
is ?
source.found("look") is ?
source.found("ng") is ?
source.found("s s") is ?

* NOTE! This prototype function actually returns a number where 0 is interpreted as FALSE. To get true/false results above we use a double NOT in front of the result ie !!

stripHTML()

This is a development prototype to replace the function HTML2JS() that has served well in "common.js" & elsewhere.
This section is 'copied and pasted' into the textarea below, first as the raw HTML and then after it has had the tags and other material stripped out by the new stripHTML 'prototype'.

The new prototype stripHTML() keeps non break spaces (&nbsp;) and converts both <br> and trailing </p> tags to newlines.

Test Line: ¼ ½ ¾ £ ©

Important: The ᐸ and ᐳ characters are not the real < and > characters that enclose HTML tags. Don't try to transfer template code this way.

New: There is a global string variable in common.js...
var nbsp = String.charFromCode(160);
... for general JavaScript use where a non breaking space is essential.

The difference between a standard title attribute and a site specific tooltip attribute is - title must be free of HTML using the stripHTML() if necessary - tooltip can contain HTML including images and links.

It is also possible to use var text = ("1 "+pp.innerText)||"2 "+pp.textContent)||"3 "+pp.innerHTML.stripHTML()); that is not browser dependent.

Yes, it works but the original function is only called twice (within common.js) so it is not worth muddying the whole Object prototype. Left as it is!

Off-centre

Math.max and Math.min

I thought these functions only compared two numbers but they are supposed to compare a comma seperated list. Thus Math.max(1,2,3,4,5,4,3,2,1) returns answer.

The interesting thing is, can Math.max work on a numeric array?. Here is the test ...

var v = [1,2,3,4,5,4,3,2,1];
var m = Math.max(v);
does not work.
var m = eval("Math.max(" + v.join(',') + ")");

And the answer is answer !

There may be a case for writing arrayMax() and arrayMin() functions.

Page Years

This is a new system to select and chart pages by the years that they apply to. Especially for the Rally Section (to start with).

The dates are added to field 8 of menu_db[] entries. They are simple numbers between 61 and the current 2 digit year as a comma delimited list. They may also be a range of numbers as 72-83. They need to be converted to full 4 digit year numbers.

They are to be used to ..

Histogram of rally reports per year. Includes rallies and rally albums. Also add relevent Megaphone and Gallery pages.

Random Thumbnails

This is a test of choosing random generic rally thumbnails to illustrate rally pages if there aren't any thumbnails that apply to the page.

To be incorporated into the bottom of page promotion banners.

Design of Bottom Banner

More content from Ben Crossley...

MALCOLM & THE MOPED KID

Bogri suffers the children

And sometimes Joe Soap comes here for a posh holiday.

 

If there are quotes that came with star ratings at the very end of the page, the star rating box appears before them.