User talk:TMg/currentDate.js

From Wikidata
Jump to navigation Jump to search

Whenever you add a retrieved (P813) property to a reference or somewhere else, this user script automatically pre-fills the input field with the current date.

Installation[edit]

Copy and paste the following line to your local common.js subpage.

// [[User:TMg/currentDate.js]]
mw.loader.load( '//www.wikidata.org/w/index.php?title=User:TMg/currentDate.js&action=raw&ctype=text/javascript' );

Discussion[edit]

Simplify property test (remove regex)[edit]

The current test whether the script should apply to the property being used (permalink, lines 9-10 and 24-28) seems over-engineered to me. Can we just replace it with if ( snakview.value().property === 'P813' )? (I’m mainly interested in the gadget code, but its discussion page redirects here, and I hope TMg wouldn’t mind if the same edit was made here as well.) Lucas Werkmeister (talk) 21:52, 10 December 2021 (UTC)[reply]

Yes, it's over-engineered. For a reason. The idea was to make it as easy as possible to add more property ids, even for users that don't know anything about JavaScript. Please feel free to simplify the gadget when this functionality isn't needed. I replaced the dev version here with a redirect to the gadget. --TMg 09:41, 13 December 2021 (UTC)[reply]