Skip to content

Commit

Permalink
Prototype Chrome/Webkit Desktop Notifications with our Application Sh…
Browse files Browse the repository at this point in the history
…ortcut Notifications
  • Loading branch information
haraldpdl committed Mar 24, 2011
1 parent a5744ca commit 3007a0f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
10 changes: 9 additions & 1 deletion osCommerce/OM/Core/Site/Admin/Application/Login/pages/main.php
Expand Up @@ -16,7 +16,7 @@
<div class="infoBox">
<h3><?php echo osc_icon('people.png') . ' ' . OSCOM::getDef('action_heading_login'); ?></h3>

<form name="login" class="dataForm" action="<?php echo OSCOM::getLink(null, null, 'Process'); ?>" method="post">
<form id="formLogin" name="login" class="dataForm" action="<?php echo OSCOM::getLink(null, null, 'Process'); ?>" method="post">

<p><?php echo OSCOM::getDef('introduction'); ?></p>

Expand All @@ -32,6 +32,14 @@

<script type="text/javascript">
$('#user_name').focus();

if (typeof webkitNotifications != 'undefined') {
$('#formLogin').submit(function() {
if ( webkitNotifications.checkPermission() == 1 ) {
webkitNotifications.requestPermission();
}
});
}
</script>

<?php
Expand Down
26 changes: 26 additions & 0 deletions osCommerce/OM/Core/Site/Admin/templates/oscom/header.php
Expand Up @@ -96,17 +96,43 @@
?>

<script type="text/javascript">
var wkn = new Object;

if ( $.cookie('wkn') ) {
wkn = $.secureEvalJSON($.cookie('wkn'));
}

function updateShortcutNotifications(resetApplication) {
$.getJSON('<?php echo OSCOM::getRPCLink('Admin', 'Dashboard', 'GetShortcutNotifications&reset=RESETAPP'); ?>'.replace('RESETAPP', resetApplication), function (data) {
$.each(data, function(key, val) {
if ( $('#shortcut-' + key + ' .notBubble').html != val ) {
if ( val > 0 || val.length > 0 ) {
$('#shortcut-' + key + ' .notBubble').html(val).show();

if ( (typeof webkitNotifications != 'undefined') && (webkitNotifications.checkPermission() == 0) ) {
if ( typeof wkn[key] == 'undefined' ) {
wkn[key] = new Object;
}

if ( wkn[key].value != val ) {
wkn[key].value = val;
wkn[key].n = webkitNotifications.createNotification('<?php echo OSCOM::getPublicSiteLink('images/applications/32/APPICON.png'); ?>'.replace('APPICON', key), key, val);
wkn[key].n.replaceId = key;
wkn[key].n.ondisplay = function(event) {
setTimeout(function() {
event.currentTarget.cancel();
}, 5000);
};
wkn[key].n.show();
}
}
} else {
$('#shortcut-' + key + ' .notBubble').hide();
}
}
});

$.cookie('wkn', $.toJSON(wkn));
});
}

Expand Down

0 comments on commit 3007a0f

Please sign in to comment.