Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLs #170

Open
EnricoBara opened this issue Jul 14, 2022 · 6 comments
Open

URLs #170

EnricoBara opened this issue Jul 14, 2022 · 6 comments
Labels
Feature This is new functionality to be added.

Comments

@EnricoBara
Copy link

EnricoBara commented Jul 14, 2022

Hi Max, I just discovered your widget and I don't know how I survived 1 year with the black calendar widget 😂 my compliments for your work, it's soo useful and really easy to set it up and customise! And moreover many many thanks for sharing it!

May I ask you if you can add a url for opening the calendar when I click the "date" element? Or if you can help me with a little input I'll update the code by myself.
edit: added calshow:// on the widget url (out from scriptable) as a workaround but it doesn't lands on today

Also, what's the url of the apple weather app for opening it instead of open weather?
edit: found weather:// opens weather in iOS 16!!!

Kind regards

@mzeryck
Copy link
Owner

mzeryck commented Jul 19, 2022

Hi there, I'm so glad to hear you're enjoying the widget! Both of these are great ideas, and I'm so excited that there's finally a way to open the weather app via URL in iOS 16!

The calshow:// format uses seconds since January 1, 2001. Javascript's getTime() function returns milliseconds since January 1, 1970. This means we need to use getTime() on the current time, divide it by 1,000 to get seconds, and subtract the seconds between 1970 and 2001:

const secondsForToday = Math.floor(new Date().getTime() / 1000) - 978307200
const calendarUrl = "calshow:" + secondsForToday

A variation of this calculation is used around line 1053 to make each calendar event tappable, and the calendar will show the day of the event. A similar approach could be used for the date element!

@mzeryck mzeryck added the Feature This is new functionality to be added. label Jul 19, 2022
@EnricoBara
Copy link
Author

EnricoBara commented Jul 19, 2022

Oh thanks for the info now I understand why there's secondsForToday!

I got it working in this way:

 // Display the date on the widget.
  async date(column) {
  	const secondsForToday = Math.floor(new Date().getTime() / 1000) - 978307200
		const dateUrl = "calshow:" + secondsForToday
    const dateSettings = this.settings.date
    if (!this.data.events && dateSettings.dynamicDateSize) { await this.setupEvents() }

    if (dateSettings.dynamicDateSize ? this.data.events.length : dateSettings.staticDateSize == "small") {
      this.provideText(this.formatDate(this.now,dateSettings.smallDateFormat), column, this.format.smallDate, true)
      column.url = dateUrl
      
    } else {
      const dateOneStack = this.align(column)
      const dateOne = this.provideText(this.formatDate(this.now,dateSettings.largeDateLineOne), dateOneStack, this.format.largeDate1)
      dateOneStack.setPadding(this.padding/2, this.padding, 0, this.padding)
      dateOneStack.url = dateUrl

      const dateTwoStack = this.align(column)
      const dateTwo = this.provideText(this.formatDate(this.now,dateSettings.largeDateLineTwo), dateTwoStack, this.format.largeDate2)
      dateTwoStack.setPadding(0, this.padding, this.padding, this.padding)
      dateTwoStack.url = dateUrl
    }
  },

for sure it would be interesting to also add a setting for a default app (if not calendar) but since my knowledge is limited to HTML and CSS I'm already satisfied with this one 😂

Thank you for the suggestion!

epizzarello added a commit to epizzarello/Weather-Cal that referenced this issue Jul 19, 2022
@epizzarello
Copy link
Contributor

I just submitted a pull request that does all of these things @mzeryck
I tried it on mine and it works

@EnricoBara
Copy link
Author

EnricoBara commented Jul 20, 2022

Thanks @epizzarello I'm using your code, everything works fine!

Is it also possibile to add an url to the background, when an empty space is tapped? Or this can only be done out from scriptable in the widget setting?

@epizzarello
Copy link
Contributor

Thanks @epizzarello I'm using your code, everything works fine!

Is it also possibile to add an url to the background, when an empty space is tapped? Or this can only be done out from scriptable in the widget setting?

@EnricoBara I don't know of a way to add a url to the background other than the widget settings, sorry!

@EnricoBara
Copy link
Author

No problem thanks anyway!

mzeryck pushed a commit that referenced this issue Jul 27, 2022
* Added check for cache files existing but being blank

* Modified urls for Feature #170

* Incorporated feature request #169

* Incorporated feature #151

* Incorporated feature request #107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature This is new functionality to be added.
Projects
None yet
Development

No branches or pull requests

3 participants