diff --git a/config/assets.yml b/config/assets.yml index af2b105..0fc9928 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -19,6 +19,7 @@ javascripts: - public/javascripts/search.js - public/javascripts/store.js - public/javascripts/caching.js + - public/javascripts/title.js - public/javascripts/ajax/*.js - public/javascripts/animations/*.js - public/javascripts/layout.js diff --git a/public/javascripts/ajax/requests.js b/public/javascripts/ajax/requests.js index 930eef7..4cac973 100644 --- a/public/javascripts/ajax/requests.js +++ b/public/javascripts/ajax/requests.js @@ -43,14 +43,18 @@ function favourite_request(link, params){ } function load_site_request(link, params){ + changeDocumentTitle(link, params); + + // proof given params params = (typeof params == "undefined" || typeof params == "boolean") ? "" : params; show_flash(false); + // request to object cache if(link != user_path) cacheResponse = cacheRequest(link+params); else cacheResponse = false; - hide_flash(true); + hide_flash(true); // remove error messages if shown if(!cacheResponse) { console.info("=> Request to server"); diff --git a/public/javascripts/config.js b/public/javascripts/config.js index 75740ee..2033e8b 100644 --- a/public/javascripts/config.js +++ b/public/javascripts/config.js @@ -14,6 +14,9 @@ var logout_path = "/logout"; var favourite_path = "/favourize"; var search_video_path = "/search_video"; +// root title +var documentTitle = "9minutes"; + $(document).ready(function(){ // home site Path.root("#!/home"); diff --git a/public/javascripts/plugins/replaceall.js b/public/javascripts/plugins/replaceall.js new file mode 100644 index 0000000..3e2a700 --- /dev/null +++ b/public/javascripts/plugins/replaceall.js @@ -0,0 +1,22 @@ +String.prototype.replaceAll = function( + strTarget, + strSubString + ){ + var strText = this; + var intIndexOfMatch = strText.indexOf( strTarget ); + + while (intIndexOfMatch != -1) + { + strText = strText.replace( strTarget, strSubString ) + intIndexOfMatch = strText.indexOf( strTarget ); + } + + return(strText); +} + +String.prototype.urifyAll = function(){ + var strText = this; + var text = unescape(decodeURI(strText).replaceAll("+", " ")); + + return(text); +} \ No newline at end of file diff --git a/public/javascripts/title.js b/public/javascripts/title.js new file mode 100644 index 0000000..d369988 --- /dev/null +++ b/public/javascripts/title.js @@ -0,0 +1,18 @@ +function changeDocumentTitle(to, special) +{ + special = (typeof special == "undefined" || typeof special == "boolean") ? null : special; + + titleLink = (to.substring(to.length-1, to.length) == "/") ? + to.substring(0, to.length-1) : to; + + titleLink = titleLink.replaceAll("/",""); + + if(titleLink == "artists") + { + titleLink = special; + special = null; + } + + document.title = documentTitle + " » " + titleLink.urifyAll(); + if (special) document.title += " » " + special.urifyAll(); +} \ No newline at end of file