OSDN Git Service

client is version0.4.30, bugfix around path.
[pettanr/pettanr.git] / public / assets / common.js
index 3711638..41b7c91 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  * pettanR common.js\r
- *   version 0.4.29\r
+ *   version 0.4.30\r
  * \r
  * author: itozyun\r
  */\r
@@ -75,7 +75,7 @@
 \r
 var pettanr = ( function(){\r
        var     FUNCTION_ARRAY = [],\r
-               URL = document.location.href.split( '#')[ 0],\r
+               URL = document.location.href.split( '#')[ 0 ],\r
                IS_LOCAL = URL.indexOf( 'file:') === 0,\r
                URL_PARAMS = ( function(){\r
                        var search = document.location.search,\r
@@ -110,9 +110,9 @@ var pettanr = ( function(){
        return {\r
                version: '0.4.28',\r
                init: function(){\r
-                       jqWindow = $( window);\r
-                       jqDocument = $( document);\r
-                       jqBody = $( document.body);\r
+                       jqWindow   = $( window );\r
+                       jqDocument = $( document );\r
+                       jqBody     = $( document.body );\r
                        \r
                        var l = FUNCTION_ARRAY.length,\r
                                _fn;\r
@@ -161,8 +161,7 @@ var pettanr = ( function(){
                        var pre = document.createElement('pre');\r
                        pre.appendChild( document.createTextNode('\n'));\r
                        return pre.firstChild.data;\r
-               })(),\r
-               IS_IFRAME: !!window.parent\r
+               })()\r
        }\r
 })();\r
 \r
@@ -663,61 +662,41 @@ pettanr.ua = ( function(){
 \r
 \r
 pettanr.CONST = ( function(){\r
-       var isLocal = pettanr.LOCAL === true || pettanr.URL_PARAMS.exjson === false,\r
-               isLocalhost = document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0,\r
-               PETTANR_ROOT_PATH = isLocalhost === true ? 'http:\/\/localhost:3000\/' : 'http:\/\/pettanr.heroku.com\/',\r
-               location = document.location.pathname,\r
-               deep =  location.indexOf( '\/diary\/' ) !== -1 ||\r
-                               location.indexOf( '\/test\/' ) !== -1 ||\r
-                               location.indexOf( '\/help\/' ) !== -1 ||\r
-                               location.indexOf( '\/sitemap\/' ) !== -1 ||\r
-                               location.indexOf( '\/wiki\/' ) !== -1;\r
-               \r
+       var SERVER_SUPPORT    = !( 'has_server_support' in window && has_server_support === false ),\r
+               PETTANR_ROOT_PATH = ( function(){\r
+                       if( SERVER_SUPPORT === false ){\r
+                               var h1 = document.getElementsByTagName( 'h1' )[ 0 ];\r
+                               if( h1 ){\r
+                                       var a = h1.getElementsByTagName( 'a' )[ 0 ];\r
+                                       return a ? a.href : '';\r
+                               }\r
+                               return '';\r
+                       }\r
+                       var loc = document.location;\r
+                       return [ loc.protocol, '\/\/', loc.host, '\/' ].join( '' );\r
+               })(),\r
+               DEPTH = document.location.pathname.split( '\/' ).length;\r
        return {\r
                PETTANR_ROOT_PATH:                      PETTANR_ROOT_PATH,\r
-               URL_ORIGINAL_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'original_pictures.json',\r
-               URL_RESOURCE_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'resource_pictures.json',\r
-               URL_COMICS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'comics.json',\r
-               URL_PANELS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'panels.json',\r
+               URL_ORIGINAL_PICTURES_JSON: ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'original_pictures.json',\r
+               URL_RESOURCE_PICTURES_JSON: ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'resource_pictures.json',\r
+               URL_COMICS_JSON:                        ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'comics.json',\r
+               URL_PANELS_JSON:                        ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'panels.json',\r
                NS_PETTANR_COMIC:                       'pettanr-comic',\r
-               RESOURCE_PICTURE_PATH:          ( isLocal === true ? ( deep === true ? '..\/' : '' ) : PETTANR_ROOT_PATH ) + 'resource_pictures\/',\r
-               CREATE_COMIC_JS:                        isLocal === true ? 'js\/create_new_comic.js' : PETTANR_ROOT_PATH + 'comics\/new.js',\r
-               CREATE_PANEL_JS:                        isLocal === true ? 'js\/create_new_panel.js' : PETTANR_ROOT_PATH + 'panels\/new.js',\r
-               UPLOAD_PICTURE_JS:                      isLocal === true ? 'js\/upload_picture.js' : PETTANR_ROOT_PATH + 'original_pictures\/new.js',\r
-               REGISTER_ARTIST_JS:                     isLocal === true ? 'js\/register_artist.js' : PETTANR_ROOT_PATH + 'artists\/new.js',\r
-               JQUERY_URL:                                     isLocal === true ? 'javascripts\/jquery-1.6.2.min.js' : PETTANR_ROOT_PATH + 'assets\/jquery-162_min.js'\r
+               RESOURCE_PICTURE_PATH:          ( SERVER_SUPPORT === false ? ( DEPTH === 1 ? '..\/' : '' ) : PETTANR_ROOT_PATH ) + 'resource_pictures\/',\r
+               CREATE_COMIC_JS:                        SERVER_SUPPORT === false ? 'js\/create_new_comic.js' : PETTANR_ROOT_PATH + 'comics\/new.js',\r
+               CREATE_PANEL_JS:                        SERVER_SUPPORT === false ? 'js\/create_new_panel.js' : PETTANR_ROOT_PATH + 'panels\/new.js',\r
+               UPLOAD_PICTURE_JS:                      SERVER_SUPPORT === false ? 'js\/upload_picture.js' : PETTANR_ROOT_PATH + 'original_pictures\/new.js',\r
+               REGISTER_ARTIST_JS:                     SERVER_SUPPORT === false ? 'js\/register_artist.js' : PETTANR_ROOT_PATH + 'artists\/new.js',\r
+               JQUERY_URL:                                     SERVER_SUPPORT === false ? 'javascripts\/jquery-1.6.2.min.js' : PETTANR_ROOT_PATH + 'assets\/jquery-162_min.js',\r
+               SERVER_SUPPORT:                         SERVER_SUPPORT,\r
+               DEPTH:                                          DEPTH\r
        }\r
 })();\r
 \r
 pettanr.view = ( function(){\r
        /* create iframe overlay for user console */\r
-       var location = document.location.pathname,\r
-               isWorkPage =    document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0 ||\r
-                                               document.location.href.indexOf( pettanr.CONST.PETTANR_ROOT_PATH ) === 0 ||\r
-                                               location.indexOf( '\/work.html') !== -1 ||\r
-                                               location.indexOf( '\work.html') !== -1, // for ie6\r
-               deep =  location.indexOf( '\/diary\/') !== -1 ||\r
-                               location.indexOf( '\/test\/') !== -1 ||\r
-                               location.indexOf( '\/help\/') !== -1 ||\r
-                               location.indexOf( '\/sitemap\/') !== -1 ||\r
-                               location.indexOf( '\/wiki\/') !== -1,\r
-               LoginUserNavi;\r
-\r
-       if( isWorkPage === false){\r
-               LoginUserNavi = {\r
-                       show: function(){\r
-                               var i = pettanr.util.getChildIndex( this.parentNode, this );\r
-                               document.location.href = [\r
-                                               deep === true ? '../' : '',\r
-                                               'work.html',\r
-                                               typeof i === 'number' ? '?view=' + i : ''\r
-                                       ].join( '');\r
-                               return false;\r
-                       },\r
-                       hide: function(){}\r
-               }\r
-       } else {\r
-               LoginUserNavi = {\r
+       var LoginUserNavi = {\r
                        show: function(){\r
                                var i = pettanr.util.getChildIndex( this.parentNode, this );\r
                                i !== -1 && bootApplication( i );\r
@@ -725,7 +704,6 @@ pettanr.view = ( function(){
                        },\r
                        hide: function(){}\r
                }\r
-       }\r
 \r
        /* debug info */\r
        // ua version, lang, os, plugin ( vml, svg), standerdmode, balloon, rimg\r
@@ -835,8 +813,6 @@ pettanr.view = ( function(){
        }\r
 \r
        function bootApplication( APPLICATIONorINDEX, _arguments ){\r
-               if( isWorkPage === false ) return;\r
-\r
                var _application,\r
                        i, j, l, \r
                        nodesA = document.getElementById('global-navi').getElementsByTagName( 'a') || [],\r