]> git.saurik.com Git - cydia.git/commitdiff
Slightly better semantics.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 27 Oct 2008 03:41:11 +0000 (03:41 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:08:55 +0000 (07:08 +0000)
Cydia.mm

index 1cecb660e91181c7eda8ef06930d0b3ed3802ba9..4b3fa9f172015358fcbd330f1a3ccc0c8353b409 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -780,6 +780,7 @@ bool isSectionVisible(NSString *section) {
 - (RVPage *) pageForURL:(NSURL *)url hasTag:(int *)tag;
 - (RVPage *) pageForPackage:(NSString *)name;
 - (void) openMailToURL:(NSURL *)url;
+- (void) clearFirstResponder;
 @end
 /* }}} */
 
@@ -1817,14 +1818,9 @@ class Progress :
 }
 
 - (NSString *) rating {
-    if (NSString *rating = [Indices_ objectForKey:@"Rating"]) {
-        rating = [NSString stringWithFormat:@"%@?package=%@", rating,
-            [id_ stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
-        if (latest_ != nil)
-            rating = [NSString stringWithFormat:@"%@&version=%@", rating,
-                [latest_ stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
-        return rating;
-    } else
+    if (NSString *rating = [Indices_ objectForKey:@"Rating"])
+        return [rating stringByReplacingOccurrencesOfString:@"@P" withString:[id_ stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+    else
         return nil;
 }
 
@@ -4955,7 +4951,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 
 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
     UIActionSheet *sheet = [[[UIActionSheet alloc]
-        initWithTitle:@"JavaScript Alert"
+        initWithTitle:nil
         buttons:[NSArray arrayWithObjects:@"OK", nil]
         defaultButtonIndex:0
         delegate:self
@@ -4968,7 +4964,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 
 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
     UIActionSheet *sheet = [[[UIActionSheet alloc]
-        initWithTitle:@"JavaScript Confirm"
+        initWithTitle:nil
         buttons:[NSArray arrayWithObjects:@"OK", @"Cancel", nil]
         defaultButtonIndex:0
         delegate:self
@@ -4993,8 +4989,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 + (NSString *) webScriptNameForSelector:(SEL)selector {
     if (selector == @selector(getPackageById:))
         return @"getPackageById";
-    else if (selector == @selector(setButton:withStyle:toFunction:))
-        return @"setButton";
+    else if (selector == @selector(setButtonTitle:withStyle:toFunction:))
+        return @"setButtonTitle";
     else if (selector == @selector(supports:))
         return @"supports";
     else
@@ -5013,10 +5009,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
     return [[Database sharedInstance] packageWithName:id];
 }
 
-- (void) setButton:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
-    NSLog(@"b:%@", button);
-    NSLog(@"f:%@", [function class]);
-
+- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
     if (button_ != nil)
         [button_ autorelease];
     button_ = button == nil ? nil : [button retain];
@@ -5509,6 +5502,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
         reloading_ = true;
         [self reloadURL];
     } else {
+        [delegate_ clearFirstResponder];
         JSObjectRef function([function_ JSObject]);
         JSGlobalContextRef context([[[webview_ webView] mainFrame] globalContext]);
         JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
@@ -7437,6 +7431,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
 #endif
 }
 
+- (void) clearFirstResponder {
+    if (id responder = [window_ firstResponder])
+        [responder resignFirstResponder];
+}
+
 - (RVPage *) pageForPackage:(NSString *)name {
     if (Package *package = [database_ packageWithName:name]) {
         PackageView *view = [[[PackageView alloc] initWithBook:book_ database:database_] autorelease];