A userscript to generate CentralNotice banner code that targets particular parts of subnational areas (north, south, east or west of a given line).
Description
Related Objects
- Mentioned In
- T414842: CentralNotice toolkit
Event Timeline
Can you link me to some example code for east/west? I want to double check what the code says for longitude.
It's in the Pennsylvania part of the New York City metro area example,
which specifices the northernand eastern part of the state:
else if( region == 'PA' && Geo.lat >= 40.1 && Geo.lon <= 75.4) {
region = 'PA-northeast';
Hah. I'm glad I double checked with you. I was gonna guess long, which would have been incorrect :)
Alright, MVP (minimum viable product) is complete. You can install it by adding the below code to https://meta.wikimedia.org/wiki/User:Pharos/common.js
importScript( 'en:User:Novem Linguae/Scripts/CentralNoticeHelper.js' );
Visit any page. Go into the more menu and click on "CentralNotice Helper".
Fill in the form:
Enjoy your code!
As you use it and find bugs or want more features, let me know and we can slowly work on improving the script.
Beautiful!
Here are some feature requests:
(1) There should be up to four directional statements per subnational unit, enough to draw a box if you want.
(2) You should be able to pick more than one subnational unit at a time, maybe up to four. Each would have its own set of directional statements.
(3) We should have Canadian provinces as well as US states, and the ability to use them in combination.
Can you please add some sample code to https://meta.wikimedia.org/wiki/Talk:North_American_Wikimedians/Communication_project#Examples_for_of_JavaScript_banners_for_possible_gadget containing Canadian provinces? I want to see if they use the same two-letter capital letter codes, or something special.
#3 is done since it was easy. #1 and #2 are harder so haven't done them yet.
I'm removing all tags except hackathon since this ticket doesn't require code changes to those codebases.
Perhaps it makes sense to have drop-down selector for country as a first step, and then a drop-down selector for state/province as a second step. That way, it will be a bit easier to find the appropriate 2-letter subnational code.
continents (we often get requests for all of Africa or LATAM which implies clicking dozens of countries manually instead of checking a continent and removing wrong or adding more countries) > countries > states > subregions, please :)
This is slightly different I think because that would be at the campaign level, while this userscript is acting at the banner level. Is there even a way to edit a campaign by a userscript?
This is slightly different I think because that would be at the campaign level, while this userscript is acting at the banner level. Is there even a way to edit a campaign by a userscript?
Oh, sorry, I misunderstood. No, I don't think that JavaScripts can change the campaign settings (easily).
@Novem_Linguae: Thanks for participating in the Hackathon!
- If this task was being worked on and resolved at the Hackathon: Please change the task status to resolved via the Add Action... → Change Status dropdown, and make sure that this task has a link to the public codebase.
- If this task is still valid and should stay open: Please add another active project tag to this task, so others can find this task (as likely nobody in the future will look back at the Hackathon workboard when trying to find something they are interested in).
- In case there is nothing else to do for this task, or nobody plans to work on this task anymore: Please set the task status to declined.
Thank you,
Phabricator housekeeping service
I'm done working on this for the moment. Setting to resolved since I was able to get a basic user script done.


