User talk:GregorB/ConvertLocationMap.js

Latest comment: 9 years ago by GregorB in topic Some remarks about the script

Some remarks about the script edit

  • Should be used only for Croatian settlements that have a standalone {{Location map}} template in them (i.e. it is not embedded in a table or something like that).
  • The script is based on regex matching so not all conversions will succeed, depending on formatting. If that's the case, the script will do nothing.
  • After a successful conversion, a diff will automatically be displayed. If this is annoying, I could make it user-customizable.
  • Also, edit summary is auto-populated. Ditto.
  • {{coord}}, if present, is not touched. Infobox coordinates are always displayed inline, while title coordinates are set by {{coord}}, if it exists. This is perhaps not ideal.
  • I'll write the docs with more details soon; in the meantime, you can complain here. :-D GregorB (talk) 21:49, 3 January 2015 (UTC)Reply
Oh yeah, these articles are the candidates. GregorB (talk) 21:59, 3 January 2015 (UTC)Reply
I opened Adamovec in edit mode, and clicked on the newly listed "Convert Location map to Infobox settlement" tool item, but nothing happened. Can you add a few alert()s in the various else cases so that it becomes obvious what went wrong? --Joy [shallot] (talk) 16:27, 4 January 2015 (UTC)Reply
Yup, Adamovec is precisely the reason why I noted that the script does not always work. I've just managed to make it work for Adamovec by "cheating" (manually deleting the |label= beforehand). I could add the alert, but either the script worked (diff is displayed) or it didn't, in which case I could only say that Location map was not detected - or? GregorB (talk) 17:26, 4 January 2015 (UTC)Reply
Yes, do that, make it explicit, anything is better than clicking and having nothing happen :) I see it now, the logic is too simplistic - it would be better if we first found e.g. {{[Ll]ocation map[\s\S]*\|([^}]+)}} in the text, and then parsed $1 from that to find the parameters we want. --Joy [shallot] (talk) 18:36, 4 January 2015 (UTC)Reply
Well, it is simplistic, as I wanted to avoid both parsing and monstrous REs. I'm considering ignoring the |caption= parameter (might be as well hardcoded to "Location of Foo in Croatia") and extracting only latitude and longitude, that could be simpler and more reliable.
I'll add an alert for an unsuccessful run. GregorB (talk) 18:54, 4 January 2015 (UTC)Reply