Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10 from pyofwave/master
Browse files Browse the repository at this point in the history
Prettying last pull
  • Loading branch information
ozten committed Mar 13, 2012
2 parents 17b91bf + bdfc711 commit 3d0324b
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/include.js
Expand Up @@ -34,7 +34,7 @@ require(

chan.call({
method: "registerProtocolHandler",
params: {'scheme': scheme, 'url': url, 'title':title, 'default':true},
params: {scheme: scheme, url: url, title:title, icon:utils.getFavicon()},
success: function (rv) {
cleanup();
},
Expand Down
9 changes: 9 additions & 0 deletions src/utils.js
Expand Up @@ -12,6 +12,15 @@ define('utils', ['config'],

return {
iframe: iframe,
getFavicon : function() {
// In any URL based element, href is the full path, which is accessed here
var link = document.querySelector('link[rel~=icon]');
if (link != undefined) return link.href;

link = document.createElement('a');
link.href = "/favicon.ico";
return link.href;
},
};
});

Expand Down
Binary file added www/playlist.com/favicon.ico
Binary file not shown.
Binary file added www/playlist.com/home.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions www/playlist.com/index.html
@@ -0,0 +1,15 @@
<html>
<head><title>playlist.com! (Okay a fake for a demo)</title>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body style="background: url(home.png) no-repeat;">
<script src="jquery-1.6.1.min.js"></script>
<script src="http://dev.repotheweb.org:8001/include.js"></script>
<script>
$(document).ready(function () {
var url = 'http://' + window.location.host + '/music_protocol_handler.html?uri=%s';
window.navigator.xregisterProtocolHandler('music', url, 'Music');
});
</script>
</body>
</html>
18 changes: 18 additions & 0 deletions www/playlist.com/jquery-1.6.1.min.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions www/playlist.com/music_protocol_handler.html
@@ -0,0 +1,13 @@
<html>
<!--
This page is the rph handler page for the music protocol...
http://rhapsody.com/rph/relay.html?uri=%s
-->
<head><title>Elvis Presly - playlist.com! (Okay a fake for a demo)</title>
<link rel="shortcut icon" href="/favicon.ico" />
<head>
</head>
<body style="background: url(protocol_handler.png);">

</body>
</html>
Binary file added www/playlist.com/protocol_handler.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions www/repotheweb.org/aesthetics.css
@@ -1,6 +1,8 @@
li {list-style: none;}
ul, ol {padding-left:0;}
/* I have strived to make this a non-style and instead appear as part of the browser */
/* Note the lack of font selection (or in code language selection), instead integrating into browser preferences. */
li {list-style: none;} /* use icons or radio buttons as bullets instead. */
ul, ol {padding-left:0;} /* Do not indent lists, unclarifies the lists*/

header {background: #dddddd; width: 100%;
padding: 10px;}
padding: 10px;} /*Seperate the title and config links from the page. Grey is the least brand-y color I can think of. */
body {margin:0;}
8 changes: 8 additions & 0 deletions www/repotheweb.org/config.appcache
@@ -0,0 +1,8 @@
CACHE MANIFEST
#12-03-12:v1
config.html
config.ico
aesthetics.css
http://code.jquery.com/jquery-1.6.1.min.js
utils.js

3 changes: 2 additions & 1 deletion www/repotheweb.org/config.html
@@ -1,5 +1,6 @@
<html>
<html manifest="config.appcache">
<head><title>RePo Config</title>
<link rel="shortcut icon" href="config.ico" />
<link type="text/css" rel="stylesheet" href="aesthetics.css" />
</head>
<body>
Expand Down
Binary file added www/repotheweb.org/config.ico
Binary file not shown.
11 changes: 10 additions & 1 deletion www/repotheweb.org/include.js
Expand Up @@ -791,6 +791,15 @@ define('utils', ['config'],

return {
iframe: iframe,
getFavicon : function() {
// In any URL based element, href is the full path, which is accessed here
var link = document.querySelector('link[rel~=icon]');
if (link != undefined) return link.href;

link = document.createElement('a');
link.href = "/favicon.ico";
return link.href;
},
};
});

Expand Down Expand Up @@ -869,7 +878,7 @@ require(

chan.call({
method: "registerProtocolHandler",
params: {'scheme': scheme, 'url': url, 'title':title, 'default':true},
params: {scheme: scheme, url: url, title:title, icon:utils.getFavicon()},
success: function (rv) {
cleanup();
},
Expand Down
22 changes: 18 additions & 4 deletions www/repotheweb.org/index.html
@@ -1,5 +1,6 @@
<html>
<html manifest="select.appcache">
<head><title>Select Service</title>
<link rel="shortcut icon" href="select.ico" />
<link type="text/css" rel="stylesheet" href="aesthetics.css" />
</head>
<body>
Expand All @@ -8,19 +9,32 @@
<script type="text/javascript">
var url = location.hash.substr(1), // Cut off '#'
scheme = url.split(':')[0],
rphs = data('protocolhandlers-' + scheme);
rphs = data('protocolhandlers-' + scheme),
default_rph;

// Redirect if there's only one choice or a default
if (rphs && rphs.length === 1) default_rph = rphs[0];
else each(rphs, function() {
if (this.defaultH) {
default_rph = this;
return true;
}
});
if (default_rph) {
location.replace(default_rph.url.replace('%s', escape(url)));
}
</script>
<script type="text/template">
<header>
<h1>{{= _('select Handler', scheme) }}</h1>
<h2>{{= url }}</h2>
<p><a href="/config.html" title="{{= _('config Tooltip') }}">{{= _('service') }}</a></p>
<p><a href="/config.html" title="{{= _('config Tooltip') }}">
<img src="/config.ico" alt="{{= _('config Tooltip') }}" />{{= _('service') }}</a></p>
</header>
<ul>
{{ console.log('rphs', rphs); if (rphs && rphs.length) each(rphs, function() { }}
{{ if (rphs && rphs.length) each(rphs, function() { }}
<li><a href="{{= this.url.replace('%s', escape(url)) }}" title="{{= _('service tooltip', this.title) }}">
<img src="{{= this.icon}}" alt="Favicon for {{= this.url.split('/')[2] }} @ {{= this.icon}}" />
<strong>{{= this.title }}</strong> ({{= this.url }})</a></li>
{{ }); }}
</ul>
Expand Down
10 changes: 10 additions & 0 deletions www/repotheweb.org/lang/en.i18n
@@ -0,0 +1,10 @@
{
"Protocol Handlers" : "Protocol Handlers",
"config Tooltip" : "Configure all registered protocol handlers.",
"service tooltip" : "Open link with %s.",
"select Handler" : "Select \"%s\" Service",
"service" : "Configure all handlers",
"no default" : "Select handler each time",
"confirm delete" : "Are you sure you want to unregister this %s handler?\n\nYou will need to go to it's site to reregister it.",
"confirm register" : "Add %s (%s) as a handler for %s links?"
}
Binary file added www/repotheweb.org/nofavicon.ico
Binary file not shown.
7 changes: 7 additions & 0 deletions www/repotheweb.org/rph_iframe.appcache
@@ -0,0 +1,7 @@
CACHE MANIFEST
#12-03-12:v1
rph_iframe.html
jschannel.js
http://code.jquery.com/jquery-1.6.1.min.js
utils.js
rph_iframe.js
2 changes: 1 addition & 1 deletion www/repotheweb.org/rph_iframe.html
@@ -1,4 +1,4 @@
<html>
<html manifest="rph_iframe.appcache">
<head><title>non-interactive iframe</title>
<script src="jschannel.js"></script>
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script><!-- Required for utils.js -->
Expand Down
3 changes: 1 addition & 2 deletions www/repotheweb.org/rph_iframe.js
Expand Up @@ -42,7 +42,7 @@
phs = JSON.parse(raw_phs);
}

if (! hasRPH(phs, rph)) {
if (! hasRPH(phs, rph) && confirm(_('confirm register', rph.title, rph.url.split('/')[2], rph.scheme))) {
phs.push(rph);
localStorage.setItem(key, JSON.stringify(phs));

Expand All @@ -64,7 +64,6 @@
}; /* store_rph */

chan.bind("registerProtocolHandler", function(trans, rph) {
if (confirm(_('confirm register', rph.title, rph.url.split('/')[2], rph.scheme)))
store_rph(rph);
//trans.complete('okay');
});
Expand Down
10 changes: 10 additions & 0 deletions www/repotheweb.org/select.appcache
@@ -0,0 +1,10 @@
CACHE MANIFEST
#12-03-12:v1
index.html
select.ico
config.ico
aesthetics.css
http://code.jquery.com/jquery-1.6.1.min.js
utils.js

# App caches are used as an easy way to dramatically lower requests for this clientside service.
Binary file added www/repotheweb.org/select.ico
Binary file not shown.
31 changes: 18 additions & 13 deletions www/repotheweb.org/utils.js
@@ -1,6 +1,6 @@
var _ = function() {
var args = Array.prototype.slice.call(arguments),
string = _.lang[args.shift()];
string = _.lang[args.shift()] || "";

for (var i=0;i<args.length;i++)
string = string.replace('%s', args[i]);
Expand Down Expand Up @@ -43,21 +43,26 @@ var _ = function() {
each = $.each;

$(function() {
// Download language file, executes synchronously before templates are rendered.
function setLang(userLang) {
$.ajax('/lang/' + userLang + '.i18n', {
async : false,
datatype : 'json',
success : function(res) {_.lang = JSON.parse(res);},
error : function() {setLang("en");}
});
}
setLang((navigator.language || navigator.userLanguage || "en").toLowerCase().split('-')[0]);

// execute templates
$('script[type="text/template"]').each(function() {
var html = tmpl($(this).html(), window);
$(this).replaceWith(html);
});

// Fix broken images after they're created but before they load
$('img').error(function() {
$(this).attr('src', '/nofavicon.ico');
});
});

// Temporary english translations, will be moved out once defined
_.lang = {
'Protocol Handlers' : 'Protocol Handlers',
'config Tooltip' : 'Configure all registered protocol handlers.',
'service tooltip' : 'Open link with %s.',
'select Handler' : 'Select "%s" Service',
'service' : 'Configure all handlers',
'no default' : 'Select handler each time',
'confirm delete' : 'Are you sure you want to unregister this %s handler?\n\nYou will need to go to it\'s site to reregister it.',
'confirm register' : 'Add %s (%s) as a handler for %s links?'
}

Binary file added www/rhapsody.com/favicon.ico
Binary file not shown.

0 comments on commit 3d0324b

Please sign in to comment.