added dynamic document titles;

This commit is contained in:
Tobias Klika
2011-07-02 17:31:04 +02:00
parent 44876963e9
commit b9413ed53d
5 changed files with 49 additions and 1 deletions
+1
View File
@@ -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
+5 -1
View File
@@ -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");
+3
View File
@@ -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");
+22
View File
@@ -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);
}
+18
View File
@@ -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();
}