2014-08-13 22:06:37 -07:00
2014-08-11 14:06:30 -07:00
2014-03-25 17:13:02 -07:00
2014-05-14 14:26:43 -07:00
2014-07-26 22:17:59 -07:00
2014-08-04 21:23:50 -07:00
2014-08-04 21:23:50 -07:00
2014-07-17 15:54:41 -07:00

Menubar WebKit

menubar-webkit helps you create Mac menubar app using HTML and JavaScript without writing any Objective-C code. menubar-webkit exposes an JavaScript object called mw to provide system functions.

Screenshot

API

APIs may change rapidly before 1.0.

// App info (in Xcode)
mw.appVersion
mw.appBundleVersion

// Open/close the popup window
mw.openPopup()
mw.closePopup()

// Quit application
mw.quit()

// Open URL in default browser
mw.openURL("http://pomotodo.com")

// Set menubar icon
mw.setMenubarIcon("data:image/png;base64,iVBORw...SuQmCC")
mw.setMenubarHighlightedIcon("data:image/png;base64,iVBORw...SuQmCC")
mw.resetMenubarIcon()

// Auto start with system
mw.setAutoStart(true) // not implemented yet

// Send system notification
mw.notify({
  title: "Pomotodo",
  content: "Break is over!",
  popupOnClick: true // popup when clicking notification
})

// Set global keyboard shortcut
mw.addKeyboardShortcut({
  keycode: 0x7A, // F1 key
  modifierFlags: 0, // no modifier key
  callback: function suchCallback() {
    console.log("wow")
  }
})

// Clear global keyboard shortcut
mw.clearKeyboardShortcut()

// Open new window
// "url" is relative to "public" folder
// Notice: You can only open one window at the same time,
// or the later window will replace the former window.
mw.newWindow({
  url: "about.html",
  width: 600,
  height: 400
}

// Close new window
mw.closeWindow()

// Pin/unpin pop-up window (wont close when click outside the window)
mw.pin()
mw.unpin()

Preferences

mw.setupPreferences([
  {"label": "General",  "identifier": "general",  "icon": "NSPreferencesGeneral", "height": 192},
  {"label": "Account",  "identifier": "account",  "icon": "NSUserAccounts",       "height": 102},
  {"label": "Shortcut", "identifier": "shortcut", "icon": "NSAdvanced",           "height": 120}
])

// Must be called after mw.setupPreferences()
mw.openPreferences()

Menubar WebKit also provides some native components for preferences.

More detail: Preferences.md

Auto Update

// Check for update
mw.checkUpdate("https://rawgit.com/HackPlan/menubar-webkit/master/updater/SampleAppcast.xml")
mw.checkUpdateInBackground("https://rawgit.com/HackPlan/menubar-webkit/master/updater/SampleAppcast.xml")

More detail: AutoUpdate.md

Integrating Web App

public/index.html is the portal of your menubar app. public/preferences/[identifier].html are the preference pages (for example, public/preferences/general.html).

To build your app:

  1. Delete the current public folder
  2. Put your files into the public folder
  3. Install CocoaPods
  4. cd into the project folder and run pod install
  5. Open menubar-webkit.xcworkspace in Xcode
  6. Build and have fun!

Remember that Menubar WebKit is still a WIP. When the project is stable enough, I will definitely simplify the build process.

FAQ

  • Can I use local storage? Yes.
  • Can I use WebSQL? Yes.
  • Is Menubar WebKit compatible with Mac App Store? Absolutely yes.

Credits

Menubar WebKit was created by LIU Dongyuan (@xhacker) in the development of Pomotodo for Mac.

Some of the code are taken from:

Used third-party libraries:

Contribution

Pull requests are welcome! If you want to do something big, please open an issue first.

License

MIT

Description
No description provided
Readme MIT 3.3 MiB
Languages
Objective-C 97.7%
Rich Text Format 0.9%
Ruby 0.6%
Makefile 0.4%
HTML 0.4%