New: added CPUserNotification and CPUserNotificationCenter in Foundation

This PR adds the features CPUserNotification and CPUserNotificationCenter in Foundation.
The CPUserNotificationCenter allows you to send user notification to the system.
Right now, we only propose what the W3C proposes. We can set for a notification the title, informativeText and the icon.
We only support local notification yet.

The protocol CPUserNotificationCenterDelegate has been added as well.

Test app in Tests/Manual/CPUserNotificationTest
This commit is contained in:
Alexandre Wilhelm committed 2015-06-26 16:36:11 -07:00
1 parent 9694c796e3
commit 3a6a84917b
10 files changed
+1072

No files matched your search

+109
View File
@@ -0,0 +1,109 @@
/*
* CPUserNotification.j
* Foundation
*
* Created by Alexandre Wilhelm.
* Copyright 2015, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPAttributedString.j"
@import "CPArray.j"
@import "CPDate.j"
@import "CPDictionary.j"
@import "CPObject.j"
@import "CPTimeZone.j"
// We need something from the AppKit in Foundation ???
@class CPImage
@typedef CPUserNotificationAction
@typedef CPUserNotificationActivationType
/*!
@global CPUserNotificationActivationType
@group CPUserNotificationActivationType
The user did not interact with the notification alert.
*/
CPUserNotificationActivationTypeNone = 0;
/*!
@global CPUserNotificationActivationType
@group CPUserNotificationActivationType
The user clicked on the contents of the notification alert.
*/
CPUserNotificationActivationTypeContentsClicked = 1;
/*!
@global CPUserNotificationActivationType
@group CPUserNotificationActivationType
The user clicked on the action button of the notification alert.
*/
CPUserNotificationActivationTypeActionButtonClicked = 2;
/*!
@global CPUserNotificationActivationType
@group CPUserNotificationActivationType
The user replied to the notification.
*/
CPUserNotificationActivationTypeReplied = 3,
/*!
@global CPUserNotificationActivationType
@group CPUserNotificationActivationType
The user clicked on the additional action button of the notification alert.
*/
CPUserNotificationActivationTypeAdditionalActionClicked = 4;
/*!
@class CPUserNotification
@ingroup foundation
@brief The CPUserNotification class is used to configure a notification that is scheduled for display by the UserNotificationCenter class.
*/
@implementation CPUserNotification : CPObject
{
BOOL _presented @accessors(getter=isPresented);
BOOL _remote @accessors(getter=isRemote);
CPDate _actualDeliveryDate @accessors(getter=actualDeliveryDate);
CPDate _deliveryDate @accessors(property=deliveryDate);
CPDictionary _userInfo @accessors(property=userInfo);
CPImage _contentImage @accessors(property=contentImage);
CPString _identifier @accessors(property=identifier);
CPString _informativeText @accessors(property=informativeText);
CPString _title @accessors(property=title);
CPTimeInterval _deliveryRepeatInterval @accessors(property=deliveryRepeatInterval);
CPTimeZone _deliveryTimeZone @accessors(property=deliveryTimeZone);
CPUserNotificationActivationType _activationType @accessors(getter=activationType);
}
#pragma mark -
#pragma mark Creating an user notification
- (id)init
{
self = [super init];
if (self)
{
_identifier = [self UID];
}
return self
}
@end
+290
View File
@@ -0,0 +1,290 @@
/*
* CPUserNotificationCenter.j
* Foundation
*
* Created by Alexandre Wilhelm.
* Copyright 2015, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import "CPArray.j"
@import "CPObject.j"
@import "CPTimer.j"
@import "CPUserNotification.j"
@protocol CPUserNotificationCenterDelegate <CPObject>
@optional
- (BOOL)userNotificationCenter:(CPUserNotificationCenter)center shouldPresentNotification:(CPUserNotification)notification;
- (void)userNotificationCenter:(CPUserNotificationCenter)center didDeliverNotification:(CPUserNotification)notification;
- (void)userNotificationCenter:(CPUserNotificationCenter)center didActivateNotification:(CPUserNotification)notification;
@end
@global CPApp
var CPUserNotificationCenterDelegate_userNotificationCenter_shouldPresentNotification_ = 1 << 0,
CPUserNotificationCenterDelegate_userNotificationCenter_didDeliverNotification_ = 1 << 1,
CPUserNotificationCenterDelegate_userNotificationCenter_didActivateNotification_ = 1 << 2;
var CPUserNotificationDefaultCenter = nil;
/*!
@class CPUserNotificationCenter
@ingroup foundation
@brief The CPUserNotificationCenter class delivers user notifications to the user from applications or helper applications.
*/
@implementation CPUserNotificationCenter : CPObject
{
CPArray _deliveredNotifications @accessors(property=deliveredNotifications);
CPArray _scheduledNotifications @accessors(property=scheduledNotifications);
id <CPUserNotificationCenterDelegate> _delegate;
CPInteger _implementedDelegateMethods;
CPMutableDictionary _timersForUserNotification;
}
#pragma mark -
#pragma mark Creating Default User Notification Center
/*!
Returns the user's notification center
*/
+ (CPNotificationCenter)defaultUserNotificationCenter
{
if (!CPUserNotificationDefaultCenter)
CPUserNotificationDefaultCenter = [[CPUserNotificationCenter alloc] init];
return CPUserNotificationDefaultCenter;
}
- (id)init
{
self = [super init];
if (self)
{
_deliveredNotifications = [];
_scheduledNotifications = [];
_timersForUserNotification = @{};
}
return self;
}
#pragma mark -
#pragma mark Getting and Setting the Delegate
- (void)setDelegate:(id <CPUserNotificationCenterDelegate>)aDelegate
{
if (_delegate === aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(userNotificationCenter:shouldPresentNotification:)])
_implementedDelegateMethods |= CPUserNotificationCenterDelegate_userNotificationCenter_shouldPresentNotification_;
if ([_delegate respondsToSelector:@selector(userNotificationCenter:didDeliverNotification:)])
_implementedDelegateMethods |= CPUserNotificationCenterDelegate_userNotificationCenter_didDeliverNotification_;
if ([_delegate respondsToSelector:@selector(userNotificationCenter:didActivateNotification:)])
_implementedDelegateMethods |= CPUserNotificationCenterDelegate_userNotificationCenter_didActivateNotification_;
}
#pragma mark -
#pragma mark Managing the Scheduled Notification Queue
/*!
Schedules the given user notification
@param anUserNotification the user notification
*/
- (void)scheduleNotification:(CPUserNotification)anUserNotification
{
var scheduledDate = [[anUserNotification deliveryDate] copy];
[scheduledDate _dateWithTimeZone:[anUserNotification deliveryTimeZone]];
var timer = [[CPTimer alloc] initWithFireDate:scheduledDate
interval:[anUserNotification deliveryRepeatInterval]
target:self
selector:@selector(_scheduledUserNotificationTimerDidFire:)
userInfo:anUserNotification
repeats:([anUserNotification deliveryRepeatInterval] ? YES : NO)];
[_scheduledNotifications addObject:anUserNotification];
_timersForUserNotification[[anUserNotification UID]] = timer;
[[CPRunLoop currentRunLoop] addTimer:timer forMode:CPDefaultRunLoopMode];
}
- (void)_scheduledUserNotificationTimerDidFire:(CPTimer)aTimer
{
[self deliverNotification:[aTimer userInfo]];
}
/*!
Removes the given user notification for the scheduled notifications.
@param anUserNotification the user notification
*/
- (void)removeScheduledNotification:(CPUserNotification)anUserNotification
{
if ([_scheduledNotifications indexOfObject:anUserNotification] != CPNotFound)
{
[_scheduledNotifications removeObject:anUserNotification];
[_timersForUserNotification[[anUserNotification UID]] invalidate];
delete _timersForUserNotification[[anUserNotification UID]];
}
}
#pragma mark -
#pragma mark Managing the Delivered Notifications
/*!
Deliver the given user notification
@param aNotification the user notification
*/
- (void)deliverNotification:(CPUserNotification)aNotification
{
[self _launchUserNotification:aNotification];
}
/*!
Remove a delivered user notification from the user notification center.
@param aNotification the user notification
*/
- (void)removeDeliveredNotification:(CPUserNotification)aNotification
{
[_deliveredNotifications removeObject:aNotification];
}
/*!
Remove all delivered user notifications from the user notification center.
*/
- (void)removeAllDeliveredNotifications
{
[_deliveredNotifications removeAllObjects];
}
#pragma mark -
#pragma mark Permission Utilities
- (void)_askPermissionForUserNotification:(CPUserNotification)anUserNotification
{
Notification.requestPermission(function (permission) {
if (permission == "granted")
// We need to relaunch the notification if the permission are granted
[self _launchUserNotification:anUserNotification];
});
}
#pragma mark -
#pragma mark Notification Utilities
- (void)_launchUserNotification:(CPUserNotification)anUserNotification
{
// If the browser version is unsupported, remain silent.
if (!window || !'Notification' in window)
return;
if (Notification.permission === 'default')
[self _askPermissionForUserNotification:anUserNotification];
if (Notification.permission === 'granted')
{
if (([self _delegateRespondsToShouldPresentNotification] && [self _sendDelegateShouldPresentNotification:anUserNotification])
|| ![CPApp isActive])
{
var notification = new Notification(
[anUserNotification title],
{
'body': [anUserNotification informativeText],
'icon': [[anUserNotification contentImage] filename],
// ...prevent duplicate notifications
'tag' : [anUserNotification identifier]
}
);
anUserNotification._presented = YES;
notification.onclick = function () {
anUserNotification._activationType = CPUserNotificationActivationTypeContentsClicked;
[self _sendDelegateDidActivateNotification:anUserNotification];
// Remove the notification from Notification Center when clicked.
this.close();
};
// Callback function when the notification is closed.
notification.onclose = function () {
};
}
else
{
anUserNotification._presented = NO;
}
anUserNotification._activationType = CPUserNotificationActivationTypeNone;
anUserNotification._actualDeliveryDate = [CPDate date];
[_deliveredNotifications addObject:anUserNotification];
if (![anUserNotification deliveryRepeatInterval])
[self removeScheduledNotification:anUserNotification];
[self _sendDelegateDidDeliverNotification:anUserNotification];
}
}
@end
@implementation CPUserNotificationCenter (CPUserNotificationCenterDelegate)
- (BOOL)_delegateRespondsToShouldPresentNotification
{
return _implementedDelegateMethods & CPUserNotificationCenterDelegate_userNotificationCenter_shouldPresentNotification_;
}
- (BOOL)_sendDelegateShouldPresentNotification:(CPUserNotification)aNotification
{
return [_delegate userNotificationCenter:self shouldPresentNotification:aNotification];
}
- (void)_sendDelegateDidActivateNotification:(CPUserNotification)aNotification
{
if (!(_implementedDelegateMethods & CPUserNotificationCenterDelegate_userNotificationCenter_didActivateNotification_))
return;
[_delegate userNotificationCenter:self didActivateNotification:aNotification];
}
- (void)_sendDelegateDidDeliverNotification:(CPUserNotification)aNotification
{
if (!(_implementedDelegateMethods & CPUserNotificationCenterDelegate_userNotificationCenter_didDeliverNotification_))
return;
[_delegate userNotificationCenter:self didDeliverNotification:aNotification];
}
@end
+2
View File
@@ -78,6 +78,8 @@
@import "CPURLRequest.j"
@import "CPURLResponse.j"
@import "CPUserDefaults.j"
@import "CPUserNotification.j"
@import "CPUserNotificationCenter.j"
@import "CPUserSessionManager.j"
@import "CPValue.j"
@import "CPValueTransformer.j"
@@ -0,0 +1,105 @@
/*
* AppController.j
* CPUserNotificationTest
*
* Created by You on June 25, 2015.
* Copyright 2015, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
var icon = [[CPImage alloc] initWithContentsOfFile:@"Resources/Icon.png"];
@implementation AppController : CPObject
{
CPUserNotification _scheduleUserNotification;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[label setStringValue:@"User Notification Test!"];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
[label sizeToFit];
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setCenter:[contentView center]];
[contentView addSubview:label];
var deliverButton = [CPButton buttonWithTitle:@"Deliver Notification"];
[deliverButton setTarget:self];
[deliverButton setAction:@selector(deliverUserNotification:)];
[deliverButton setFrameOrigin:CGPointMake(10, 50)];
[contentView addSubview:deliverButton]
var scheduleButton = [CPButton buttonWithTitle:@"Schedule Notification"];
[scheduleButton setTarget:self];
[scheduleButton setAction:@selector(scheduleUserNotification:)];
[scheduleButton setFrameOrigin:CGPointMake(10, 80)];
[contentView addSubview:scheduleButton]
var removeButton = [CPButton buttonWithTitle:@"Remove Scheduled Notifications"];
[removeButton setTarget:self];
[removeButton setAction:@selector(removeNotification:)];
[removeButton setFrameOrigin:CGPointMake(10, 110)];
[contentView addSubview:removeButton]
[theWindow orderFront:self];
[[CPUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
}
- (void)deliverUserNotification:(id)sender
{
var note = [CPUserNotification new];
[note setTitle:@"This is a delivered notification"];
[note setInformativeText:@"Informative text for the delivered notification"];
[note setContentImage:icon];
[[CPUserNotificationCenter defaultUserNotificationCenter] deliverNotification:note];
}
- (void)scheduleUserNotification:(id)sender
{
if (_scheduleUserNotification)
return;
_scheduleUserNotification = [CPUserNotification new];
[_scheduleUserNotification setTitle:@"This is a scheduled notification"];
[_scheduleUserNotification setInformativeText:@"A notifications will pop up every 5 seconds"];
[_scheduleUserNotification setDeliveryDate:[CPDate dateWithTimeIntervalSinceNow:1]];
[_scheduleUserNotification setDeliveryRepeatInterval:5];
[_scheduleUserNotification setContentImage:icon];
[[CPUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:_scheduleUserNotification];
}
- (void)removeNotification:(id)sender
{
[[CPUserNotificationCenter defaultUserNotificationCenter] removeScheduledNotification:_scheduleUserNotification];
_scheduleUserNotification = nil;
}
- (BOOL)userNotificationCenter:(id)n shouldPresentNotification:(id)aNotification
{
return YES;
}
- (void)userNotificationCenter:(CPUserNotificationCenter)center didDeliverNotification:(CPUserNotification)notification
{
CPLog.warn(@"didDeliverNotification");
}
- (void)userNotificationCenter:(CPUserNotificationCenter)center didActivateNotification:(CPUserNotification)notification
{
CPLog.warn(@"didActivateNotification");
}
@end
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>CPUserNotificationTest</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
@@ -0,0 +1,184 @@
/*
* Jakefile
* CPUserNotificationTest
*
* Created by You on June 25, 2015.
* Copyright 2015, Your Company All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os"),
projectName = "CPUserNotificationTest";
app (projectName, function(task)
{
ENV["OBJJ_INCLUDE_PATHS"] = "Frameworks";
if (configuration === "Debug")
ENV["OBJJ_INCLUDE_PATHS"] = FILE.join(ENV["OBJJ_INCLUDE_PATHS"], configuration);
task.setBuildIntermediatesPath(FILE.join("Build", "CPUserNotificationTest.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPUserNotificationTest");
task.setIdentifier("com.yourcompany.CPUserNotificationTest");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPUserNotificationTest");
task.setSources(new FileList("**/*.j").exclude(FILE.join("Build", "**")).exclude(FILE.join("Frameworks", "Source", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", [projectName], function()
{
printResults(configuration);
});
task ("build", ["default"], function()
{
updateApplicationSize();
});
task ("debug", function()
{
configuration = ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
configuration = ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", projectName, "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", projectName, "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", projectName));
OS.system(["press", "-f", FILE.join("Build", "Release", projectName), FILE.join("Build", "Deployment", projectName)]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", projectName));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", projectName), FILE.join("Build", "Desktop", projectName, "CPUserNotificationTest.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", projectName, "CPUserNotificationTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, projectName));
print("----------------------------");
}
function updateApplicationSize()
{
print("Calculating application file sizes...");
var contents = FILE.read(FILE.join("Build", configuration, projectName, "Info.plist"), { charset:"UTF-8" }),
format = CFPropertyList.sniffedFormatOfString(contents),
plist = CFPropertyList.propertyListFromString(contents),
totalBytes = {executable:0, data:0, mhtml:0};
// Get the size of all framework executables and sprite data
var frameworksDir = "Frameworks";
if (configuration === "Debug")
frameworksDir = FILE.join(frameworksDir, "Debug");
var frameworks = FILE.list(frameworksDir);
frameworks.forEach(function(framework)
{
if (framework !== "Source")
addBundleFileSizes(FILE.join(frameworksDir, framework), totalBytes);
});
// Read in the default theme name, and attempt to get its size
var themeName = plist.valueForKey("CPDefaultTheme") || "Aristo2",
themePath = nil;
if (themeName === "Aristo" || themeName === "Aristo2")
themePath = FILE.join(frameworksDir, "AppKit", "Resources", themeName + ".blend");
else
themePath = FILE.join("Frameworks", "Resources", themeName + ".blend");
if (FILE.isDirectory(themePath))
addBundleFileSizes(themePath, totalBytes);
// Add sizes for the app
addBundleFileSizes(FILE.join("Build", configuration, projectName), totalBytes);
print("Executables: " + totalBytes.executable + ", sprite data: " + totalBytes.data + ", total: " + (totalBytes.executable + totalBytes.data));
var dict = new CFMutableDictionary();
dict.setValueForKey("executable", totalBytes.executable);
dict.setValueForKey("data", totalBytes.data);
dict.setValueForKey("mhtml", totalBytes.mhtml);
plist.setValueForKey("CPApplicationSize", dict);
FILE.write(FILE.join("Build", configuration, projectName, "Info.plist"), CFPropertyList.stringFromPropertyList(plist, format), { charset:"UTF-8" });
}
function addBundleFileSizes(bundlePath, totalBytes)
{
var bundleName = FILE.basename(bundlePath),
environment = bundleName === "Foundation" ? "Objj" : "Browser",
bundlePath = FILE.join(bundlePath, environment + ".environment");
if (FILE.isDirectory(bundlePath))
{
var filename = bundleName + ".sj",
filePath = new FILE.Path(FILE.join(bundlePath, filename));
if (filePath.exists())
totalBytes.executable += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "dataURLs.txt"));
if (filePath.exists())
totalBytes.data += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLData.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLPaths.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html lang="en">
<!--
index-debug.html
CPUserNotificationTest
Created by You on June 25, 2015.
Copyright 2015, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPUserNotificationTest</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks"];
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: 0;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
@@ -0,0 +1,161 @@
<!DOCTYPE html>
<html lang="en">
<!--
index.html
CPUserNotificationTest
Created by You on June 25, 2015.
Copyright 2015, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPUserNotificationTest</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: 0;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPUserNotificationTest
*
* Created by You on June 25, 2015.
* Copyright 2015, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}