Yay, my first patch to the dojotoolkit got checked in !

While I’ve been working on my remote file explorer I noticed that the dijit tree remembers the state of opened/closed nodes but not of selections. So I filed a bug and created a patch, which got checked in yesterday.

How to read a Mac-formatted disk from Windows

More of a note to myself: Just download and install the free tool HFSExplorer from Catacombae. Then select “Load file system from file”. Please remember you need to be logged in as an administrator on Windows 7 or have elevated privileges to be able to read external USB drives.

Installing Xdebug on Windows and PhpStorm

There is a catch when installing Xdebug on windows: You need to set the full path of the extension directive in the php.ini, since the default directory is only used for non-zend extensions. Also don’t forget to use quotes.

;used only for 'normal' extensions
extension_dir = "C:Program Files (x86)PHPext"

;still necessary to use full path
zend_extension = "C:Program Files (x86)PHPextphp_xdebug.dll"

;won't work
;zend_extension = php_xdebug.dll

To make Xdebug work in PhpStorm you also need to enable remote debugging:

xdebug.remote_enable = 1

Why I love PhpStorm: SQL table aliases

Here’s another example for the reason why I like JetBrains PhpStorm so much: SQL code assist in the Database Console completes statements either in upper case or lower case depending on how you started typing, not to speak of understanding aliased tables when suggesting column names after typing a dot.

Screenshot: SQL code assist in PhpStorm understands aliased tables.

More PhpStorm love:
SQL GROUP BY handling
JavaScript code completion with dojo

HTML5 tutorial: How to pause/resume a file upload

I wrote a HTML5 tutorial about ‘How to pause/resume a file upload‘ which just got published on hacks.mozilla.org.

I’m very happy and excited about having contributed something to mozilla aside from a few bug reports. I started working as a web developer in 1998 at the peak of the first browser war when it could take you hours just to make simple things work across Netscape and Internet Explorer. That’s why I’ve become a firm believer of web standards and a lover of Mozilla since Mozilla 0.8.

Simon Speich started as a web developer in 1998 at the peak of the
> first browser war when it could take you hours just to make simple
> things work across Netscape and Internet Explorer. That's why he's
> been a believer of web standards and a lover of Mozilla since
> Mozilla 0.8.

Dojo Demo: Multiple file uploading with pause/resume

Update 09.2013: You can also use the file picker (file input) now.

I implemented a demo of a file uploader with dojo and PHP that lets you upload multiple files at once with drag and drop. The upload of each file can be paused/resumed thanks to the slice method of the new Blob interface.

Download: The php and js code is available for download on github.com.
More info: How to resume a paused or broken file upload Continue reading “Dojo Demo: Multiple file uploading with pause/resume”

Creating a ‘blocking’ confirm dialog with dojo

Update 30.03.2018: Version 1.10 of dojotoolkit includes a dijit/DialogConfirm now, which is simply a dijit/Dialog featuring ‘OK’ and ‘Cancel’ buttons, no blocking though.

Update 15.10.2012: Code is available on githup now. I also fixed updating the content of the dialog after creation (e.g. dialog.set(‘content’, newContent) overwrote the confirm/cancel buttons because they were part of the content.

Update 03.12.2011: I updated the code to use dojo 1.7 with AMD. I also moved the creation of the Deferred to the show() method as suggested by ben, which will make the instance of the dialog reusable. Added new property hasUnderlay: true, which can be set to false.

JavaScript has a window.confirm() method, which opens a dialog and stops code execution until the user presses either the ‘OK’ or ‘Cancel’ button. Dojo also comes with a dijit.Dialog widget, but that doesn’t exhibit the same blocking behavior. Since I needed to simulate the native blocking behavior for an application I am currently developing, I extended the widget and created the DialogConfirm widget with the following features:

  • shows an ‘OK’ and ‘Cancel’ button by default (can be set to false)
  • shows a check box, which when set will remember the decision and not ask again (can be set to false)
  • the show() method returns a dojo.Deferred() which allows you to simulate the code blocking
  • underlay can be hidden

The demo of the DialogConfirm widget shows you how to halt code execution by just using the then() method of the returned deferred as follows:

var dialog = new snet.DialogConfirm({
   title: 'Confirm',
   content: '<p>Dialog content lore ipsum</p>'
});
dialog.show().then(function(remember) {
   // user pressed ok button
   // remember is true, when user wants you to remember his decision (user ticked the check box)
   if (remember) {
      // do something and never show this dialog again
   }
   else {
      // do something
   }
}, function() {
   // user pressed cancel button
   // do something
});

phpStorm and documenting JavaScript

I’m awed again and again by phpStorm‘s features. I just came across this one: When I comment my JavaScript methods/functions with the @param, all IDEs I have tried out so far, let you only set a primitive type in curly braces, e.g.:

/**
 * Some method description.
 * @param {Object} deferred dojo.Deferred
 */
someMethod: function(deferrede) {
   // ...
}

Anything else would be marked as an error. But phpStorm is a lot, lot smarter.  When I’m using dojo it recognizes all classes and I can use them as a type, e.g.:

 /**
 * Some method description.
 * @param {dojo.Deferred} deferred
 **/
someMethod: function(deferred) {
  // ...
}

How to create JavaScript documentation in PhpStorm

Update 19.07.2013: This guide is outdated. Read How to Generate JavaScript Documentation with JSDoc 3 and PhpStorm

PhpStorm’s code assist feature nicely displays our own JavaScript code documentation. But what if you wanted to create a separate documentation you can hand out or integrate into your website? Then you should use jsdoc-toolkit. You can configure and run jsdoc-toolkit directly from PhpStorm. Here is what you have to do:

Continue reading “How to create JavaScript documentation in PhpStorm”

How to create PHP documentation in PhpStorm

PhpStorm displays your own code documentation in the code assist. But what if you wanted to create a separate documentation you can hand out or integrate into your website? Then you should use phpDocumentor. You can configure and run phpDocumentor directly from PhpStorm as an external tool. Here is what you have to do:

Continue reading “How to create PHP documentation in PhpStorm”