From 586e35130d97d2829620e03167797b06d7fe07f2 Mon Sep 17 00:00:00 2001
From: Tristan Zur <tzur@ccwn.org>
Date: Fri, 18 May 2012 19:00:31 +0200
Subject: =?UTF-8?q?Javascript=20String=20Funktionalit=C3=A4t=20hinzugef?=
 =?UTF-8?q?=C3=BCgt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 js/string.js | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 js/string.js

diff --git a/js/string.js b/js/string.js
new file mode 100644
index 0000000..fa25527
--- /dev/null
+++ b/js/string.js
@@ -0,0 +1,24 @@
+/**
+ * Strips all leading and ending whitespaces.
+ * @returns the trimmed string.
+ */
+function trim() {
+	var str = this.replace(/^\s+/, "");
+	var ws = /\s/;
+	var i = str.length;
+	while (ws.test(str.charAt(--i)));
+	return str.slice(0, i + 1);
+}
+
+/**
+ * Checks whether a string is empty or not.
+ * The string is trimmed before checking if the length is 0.
+ * @return <code>true</code> if the trimmed string has a length of 0.
+ */
+function isEmpty() {
+	var testString = this.trim();
+	return 0 == testString.length;
+}
+
+String.prototype.trim = trim;
+String.prototype.isEmpty = isEmpty;
\ No newline at end of file
-- 
cgit v1.0-28-g1787

