dracoblue.net

Spezielle XML Zeichen in Javascript Enkodieren/Dekodieren

Wenn man in Javascript die

HtmlSpecialChars in ungefährlichen Text und wieder zurück konvertieren möchte, hat man meist die zugänglichen Funktionen auf den Dom-Elementen (in mootools sind das .get('html') und .get('text')).

Wenn man aber einfach simple Strings html enkodieren/dekodieren will, benutze ich die folgenden Funktionen:

var xml_special_to_escaped_one_map = {
    '&': '&',
    '"': '"',
    '<': '<',
    '>': '>'
};
 
var escaped_one_to_xml_special_map = {
    '&': '&',
    '"': '"',
    '<': '<',
    '>': '>'
};
 
function encodeXml(string) {
	return string.replace(/([\&"<>])/g, function(str, item) {
		return xml_special_to_escaped_one_map[item];
	});
};
 
function decodeXml(string) {
	return string.replace(/("|<|>|&)/g,
		function(str, item) {
			return escaped_one_to_xml_special_map[item];
	});
}

In JavaScript, Mootools by DracoBlue @ 2009-12-23 | 94 Words

amx/amxfile.c, fails in fputs_cell:

When trying to run my pawn script on a new linux server, I received the following error:

samp03svr: amx/amxfile.c:222: fputs_cell:
Assertion `fp!=((void *)0)' failed.

This was actually caused by a missing

scriptfiles directory (or the directory was not writeable).

So take care in your scripts if an fopen really gives you a vaild file pointer and handle the situation if it does not!

In pawn by DracoBlue @ 2009-10-31 | 63 Words

Running Dedicated XServer applications on your Windows

Today I came across the problem that I had to run a Linux X-Server application on a Server, which has no X-Server installed.

Since I didn't want to mess around with the installation (by installing a fullblown xserver and all it's friends), I thought using XForward configuration should do it.

As extra challenge, I ran the X-Server on a windows machine.

First of all, download + install cygwin. When installing, be sure to select xauth package (it's not enabled by default, but important for the XForward process).

You may have to do some changes to your server configuration like the Cygwin FAQ says, but on the remote ubuntu machine XForwardTrusted was already set to [em]yes[/em].

Now open your cygwin console and type:

startx

Now open yet another cygwin console and type:

ssh -Y [email protected] -p12345

where name is your username, example.org is your server name (or ip) and 12345 is the servers ssh port (default is 22, though). The

-Y (the capital Y is important) tries to connect with ForwardXTrusted, thats what we enabled some lines earlier.

You'll be right on the ssh server and can type [em]xterm[/em] or whatever application you want to run. No extra configuration!

The best about all that, you don't have forward router ports or anything!

In Cygwin, Linux by DracoBlue @ 2009-10-31 | 212 Words

Mootools Youtube Chromeless Player

Heute habe ich das Release für YtMooPlayer.js fertig gemacht. Einen Youtube Chromeless Player für Mootools.

Der einfache youtube chromeless player läuft nämlich leider nicht in einem eigenen Namespace und macht dadurch das Einbauen mehrerer Player auf einer Internetseite umständlich und kompliziert. Weil der Chromeless Player eine SWF als "echten" Player benutzt, muss man warten, bis dieser geladen ist.

Das und viele ander enützliche Events sind in dieser Klasse vereint. Also viel Spaß mit Youtube und Mootools! Ich benutze die Bibliothek seit knapp 6 Monaten mit meiner koala search engine um den Youtube Player mit einer custom Javascript Playlist zu benutzen.

Neben dem YtMooPlayer.js-Download, gibt es auch eine Demo und Api-Docs (generiert mit dem ausgezeichneten jsdoc toolkit).

In JavaScript, Mootools, open source by DracoBlue @ 2009-10-20 | 118 Words

Finished first version of Video Playlist for Koala

Today I finished the first version of the video playlist for koala (a search engine interface for google, located at http://erstmal.com).

You have a small icon next to every youtube video, which enables you to add the video to the playlist. The playlist is capable of playing all videos in list order but also has a shuffle-button.

Since koala is "AJAX" driven, you are able to continue searching without any interruption in the video playback.

In Koala by DracoBlue @ 2009-10-10 | 76 Words

Page 22 - Page 23 - Page 24