JavaScript Drag and Drop example 2

This post shows how to use REDIPS.drag library described in post “Drag and drop table content with JavaScript”. HTML table is stylized to have left column with content, main table and message line. Elements on the left side (green and orange) should be placed to the colored table cells. After element is correctly sited, appropriate message will be displayed.

Ad block

This post speaks about blocking ad sites without installing any kind of software (net filter, local proxy, browser add-ons …). Browsing without ads should be faster because browser has less content to render. It is can be used on Windows, Mac OS X, BeOS, Netware and so on. The trick is to define ad sites in the hosts file with localhost IP address. This way, browser will not be able to resolve real IP address and ad will not be loaded.

Select windows when the mouse moves over

After installation of Fedora Core 12, I couldn’t find option “focus window on mouse over”. In previous Fedora, there was Window Preferences in GNOME with following options: Window Selection, Titlebar Action and Movement Key. The solution was to install control-center-extra package.

Maintain vertical scroll position

This post describes how to maintain vertical scroll position after form submission or clicking on link. Script will read vertical scroll position and append scroll value to URL. After page is loaded, JavaScript function will search for scroll parameter in URL and set the scroll position.

Reading multiple parameters in PHP

Suppose you have to send four values: element Id, table, row and column compounded in one URL parameter. That is simple, parameters can be concatenated and delimited with special character. But how to send multiple of these complex URL parameters?

JavaScript dialog box

If prompt, confirm, alert or window.open are not good enough then JavaScript dialog box can be considered as an alternative choice. This dialog box is emulated with two DIV elements. First DIV overlays whole page while second DIV is positioned at the page center. That’s nothing new but JavaScript code is short, well commented and closed in its own namespace.

Disable image dragging in FireFox

FireFox 3 has a behaviour where clicking on image (even background image) and moving your mouse will start to drag that image around. Actually, when you drag an image, the browser thinks you want to save it to the desktop, so it starts default dragging action. To disable image dragging in FireFox, you will have to prevent default action on mousedown event for the image.

NodeList objects in the DOM are live

I was surprised when length of collected elements in DOM changed after new node was added. It seems that getElementsByTagName() doesn’t return static collection of found elements but a kind of reference to the node list. No, this is not a bug, it’s a feature and it has a name: “Live node list”.

Popular posts in WordPress

The main idea was to select posts marked by a custom field “popular”. I didn’t want to install a massive plugin with writing a page statistics to the database. My WordPress site is big (or small) enough so manually editing post list isn’t any problem for me. With custom fields, you can add extra meta-data to the post. Next it’s only needed to fetch posts marked with “popular” meta-data.

MySQL query logging

Small tip of how to log all queries done by the MySQL server. It is very useful if you want to preview SQL requests from WordPress, Joomla or any other system or client. After logging is enabled, server will write information to the log file when clients connect or disconnect, and it will log each SQL statement.