JavaScript appears to be disabled. We recommend you enable JavaScript while visiting this site.

(All original content on this site is licensed under the Creative Commons License Attribution-Noncommercial-No Derivative Works 3.0.)

How to easily clear the window.applicationCache on select browsers

While I was working on tweaking my video game listing, and creating my offline Web application manager, I kept running into issues with the cache manifest holding onto data much longer than I would have liked.

After some research I found that Chrome's interface can easily be found by going to chrome://appcache-internals/.

On Safari, on the iPod Touch and iPad, you can stop/close Safari (hold down the home button on the home screen, and close the application) and then start it back up to clear the data. This is slightly unfortunate, since it would be nice if this would stick around after the application is closed, but is sufficient. It also isn't very obvious, as I spent a good deal of time trying to figure this out before I tried this as a last-ditch effort.

Tags: , ,

Categories: software, tutorials/guides

(All original content on this site is licensed under the Creative Commons License Attribution-Noncommercial-No Derivative Works 3.0.)

Interesting feature with parsing XML with jQuery on Safari

I've been playing around with HTML5 quite a bit recently, in particular with offline Web applications.

My second experiment (my first is on pause) was with making my video games available, so that I can access the listing when I'm out shopping at used game stores.

It's still in progress, but you can see my offline listing of video games now.

My main intention is to make this available on my iPod Touch, so I was a bit dismayed when I found that the listing didn't display the title of the game. Everything else displayed just fine, but not the titles. Naturally, after some searching about I posted my question to Stack Overflow - XMLDocument (via jQuery ajax call) stored as string in localStorage results in Safari not finding title elements.

After further research, it looks like I was missing a parseXML call, which results in the data correctly being pulled/displayed in Safari.

I decided to do some further testing on this issue, and I believe I've discovered why it's displaying as it is.

The test code

I created a bit of test code - jQuery XML parsing - and that I've posted below.

<!DOCTYPE html>
<html>
<head>
    <title>jQuery XML Parsing testing - JamesRSkemp.com</title>
</head>
<body>
	<h1>jQuery XML Parsing testing</h1>
	<p>The following test code was created to test Internet Explorer 9, Chrome 10, Firefox 4, Opera 11, Safari 5 (Windows), and Safari on iOS 4.3. Read more in <a href="http://strivinglife.com/words/post/Interesting-feature-with-parsing-XML-with-jQuery-on-Safari.aspx" rel="external">Interesting feature with parsing XML with jQuery on Safari</a>.</p>
	<noscript>You must have JavaScript enabled to view this test.</noscript>
	<div id="TestOutput"></div>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
	<script type="text/javascript">
		// We'll store an example of an XML file as a string of text.
		var xmlContent = "<?xml version='1.0'?><Books><Book><Title>Book 1</Title><Author>Book 1 Author</Author></Book><Book><Title>Book 2</Title><Author>Book 2 Author</Author></Book><Book><Title>Book 3</Title><Author>Book 3 Author</Author></Book><Book><Title>Book 4</Title><Author>Book 4 Author</Author></Book><Book><Title>Book 5</Title><Author>Book 5 Author</Author></Book></Books>";
		var testOutputText = "";

		var simpleCall = $(xmlContent);
		var simpleParse = $.parseXML(xmlContent);
		var parse = $($.parseXML(xmlContent));

		try {
			testOutputText += "Type of $(xmlContent): " + typeof simpleCall + "<br />";
			testOutputText += "To string: " + simpleCall.toString() + "<br />";
			testOutputText += "Length: " + simpleCall.length + "<br />";
			if (typeof simpleCall === 'object') {
				for (var prop in simpleCall) {
					//testOutputText += "	property: " + prop + " value: [" + simpleCall[prop] + "]\n";
				}
			}
			simpleCall.find("Book").each(function () {
				testOutputText += "<em>" + $(this).find('Title').text() + "</em> by " + $(this).find("Author").text() + "<br />";
			});
		} catch (e) {
			testOutputText += "<span style='color:red;'>There was an error processing at this point.</span><br />";
		}

		try {
			testOutputText += "Type of $.parseXML(xmlContent): " + typeof simpleParse + "<br />";
			testOutputText += "To string: " + simpleParse.toString() + "<br />";
			testOutputText += "Length: " + simpleParse.length + "<br />";
			if (typeof simpleParse === 'object') {
				for (var prop in simpleParse) {
					//testOutputText += "	property: " + prop + " value: [" + simpleParse[prop] + "]\n";
				}
			}
			simpleParse.find("Book").each(function () {
				testOutputText += "<em>" + $(this).find('Title').text() + "</em> by " + $(this).find("Author").text() + "<br />";
			});
		} catch (e) {
			testOutputText += "<span style='color:red;'>There was an error processing at this point.</span><br />";
		}

		try {
			testOutputText += "Type of $($.parseXML(xmlContent)): " + typeof parse + "<br />";
			testOutputText += "To string: " + parse.toString() + "<br />";
			testOutputText += "Length: " + parse.length + "<br />";
			if (typeof parse === 'object') {
				for (var prop in parse) {
					//testOutputText += "	property: " + prop + " value: [" + simpleParse[prop] + "]\n";
				}
			}
			parse.find("Book").each(function () {
				testOutputText += "<em>" + $(this).find('Title').text() + "</em> by " + $(this).find("Author").text() + "<br />";
			});
		} catch (e) {
			testOutputText += "<span style='color:red;'>There was an error processing at this point.</span><br />";
		}

		$('#TestOutput').append(testOutputText);
	</script>
</body>
</html>

What the test does

I did a couple of things with this test.

First, I created a string with the following XML, and saved it as xmlContent.

<?xml version='1.0'?>
<Books>
	<Book>
		<Title>Book 1</Title>
		<Author>Book 1 Author</Author>
	</Book>
	<Book>
		<Title>Book 2</Title>
		<Author>Book 2 Author</Author>
	</Book>
	<Book>
		<Title>Book 3</Title>
		<Author>Book 3 Author</Author>
	</Book>
	<Book>
		<Title>Book 4</Title>
		<Author>Book 4 Author</Author>
	</Book>
	<Book>
		<Title>Book 5</Title>
		<Author>Book 5 Author</Author>
	</Book>
</Books>

Next I created three variables, storing different things. First, I did $(xmlContent), then $.parseXML(xmlContent), and finally $($.parseXML(xmlContent)).

The results

Interestingly, on IE 9, Chrome 10, Firefox 4, Opera 11, Safari 5 (Windows), the first and third tests return the type of object Object.

For the second test we have object Document on IE 9, Chrome 10, Safari 5, and Safari on iOS 4.3, and object XMLDocument on Firefox 4 and Opera 11.

But for the first test, while we have a length of 2 on IE 9, Chrome 10, Firefox 4, and Opera 11, we only have a length of 1 on Safari 5 and Safari on iOS 4.3.

The fix, then, is to make sure to use the last of the three, but it seems odd that this wouldn't work on only one of the tested browsers.

Tags: , ,

Categories: article, Internet, software

(All original content on this site is licensed under the Creative Commons License Attribution-Noncommercial-No Derivative Works 3.0.)

Raw: Using OpenSSL to create a certificate authority and update IIS 7.5

A raw dump of information on how to create a certificate authority and etcetera.

Step 1: Basic folder and file structure creation

Directories: certs, keys, requests

Files: database.txt (empty), serial.txt (01, then new line), openssl.cnf (based on OpenSSL file)

Step 2: Create key

"c:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\openssl.exe" genrsa -des3 -out keys/_ca.key 2048

Step 3: Create certificate authority certificate

"c:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\openssl.exe" req -config openssl.cnf -new -x509 -days 365 -key keys/_ca.key -out certs/_ca.cer

Step 4: Create DER for public consumption

"c:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\openssl.exe" x509 -in certs\_ca.cer -outform DER -out certs\_ca.der

Step 5: Create request from IIS

IIS > click on main server, Server Certificates > populate all for request

save to requests directory locally

Step 6: Handle request

"c:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\openssl.exe" ca -policy policy_anything -config openssl.cnf -cert certs\_ca.cer -in requests\jamesrskemp_req.txt -keyfile keys\_ca.key -days 365 -out certs\jamesrskemp.cer -outdir certs

Step 7: Convert for IIS

"c:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\openssl.exe" x509 -in certs\jamesrskemp.cer -out certs\jamesrskemp_iis.cer

Step 8: Add to IIS

back in iis, complete request. use *.x.com if a wildcard for friendly name

install _ca.der certificate to Trusted Root Certification Authorities (do on clients as well - see this official FAQ)

associate actual site with certificate

Month List