aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js/util.js
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-30 14:21:14 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-30 14:21:14 -0400
commite6ebc011f255596f09fec40f69049514d52bebef (patch)
tree20685173557726f1f470a7f40321281e1347d4eb /data/assets/js/util.js
parentb0083827f30fccc9aabcabed0557ace83d570b8c (diff)
downloadguff-e6ebc011f255596f09fec40f69049514d52bebef.tar.bz2
guff-e6ebc011f255596f09fec40f69049514d52bebef.zip
add tabs to site-add, refactor textarea handling, and fix site_id post edit dialogs
Diffstat (limited to 'data/assets/js/util.js')
-rw-r--r--data/assets/js/util.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/data/assets/js/util.js b/data/assets/js/util.js
index 7986120..6379961 100644
--- a/data/assets/js/util.js
+++ b/data/assets/js/util.js
@@ -28,8 +28,22 @@ jQuery(function($) {
// display error message
alert(prefix + error);
+ };
+
+ // slugify string
+ window.slugify = function(s) {
+ return s.toLowerCase()
+ .replace(/[^a-z0-9_-]+/g, '-')
+ .replace(/^-+|-+$/g, '');
+ };
+
+ // convert textarea to jsonified array of strings
+ window.listify = function(el) {
+ var r = $(el).val().replace(/^\s+|\s+$/m, '');
+ return JSON.stringify((r.length > 0) ? r.split(/\s+/m) : []);
}
+
LuigiTemplate.FILTERS.json = function(val) {
return JSON.stringify(val);
};