changeset 204:c054f01477c4

Use shorter name for the hash magic thing
author Edho Arief <edho@myconan.net>
date Wed, 08 May 2013 01:16:30 +0900
parents de168fde2df2
children 10f1eb74e6d7
files app/assets/javascripts/init.tabs.js
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/app/assets/javascripts/init.tabs.js	Wed May 08 00:56:45 2013 +0900
+++ b/app/assets/javascripts/init.tabs.js	Wed May 08 01:16:30 2013 +0900
@@ -6,12 +6,21 @@
     var paste = $('#paste'),
       mode = paste.data('mode'),
       width = paste.data('width'),
-      qstring = '#!' + mode + '.' + width;
+      short_mode = function(mode) {
+        if (mode == 'highlight') {
+          return 'hl'
+        } else if (mode =='markdown') {
+          return 'md'
+        } else {
+          return 'plain'
+        }
+      },
+      qstring = '#!' + short_mode(mode) + '.' + width;
     if (width == 'auto') {
       if (mode == 'plain') {
         qstring = ' ';
       } else {
-        qstring = '#!' + mode;
+        qstring = '#!' + short_mode(mode);
       }
     }
     if (history.replaceState) {
@@ -45,8 +54,8 @@
   },
   init_state = function() {
     mode = window.location.hash.substr(2).split('.');
-    if (mode[0] == 'highlight') { $('#paste-mode a:eq(1)').click(); }
-    else if (mode[0] == 'markdown') { $('#paste-mode a:eq(2)').click(); };
+    if (mode[0] == 'hl' || mode[0] == 'highlight') { $('#paste-mode a:eq(1)').click(); }
+    else if (mode[0] == 'md' || mode[0] == 'markdown') { $('#paste-mode a:eq(2)').click(); };
     if (mode[1] && mode[1].match(/^\d+px$/)) { paste_resize(mode[1]); }
   },
   init_tabs_base = function() {