masakih

OSXを起動したらそこには『艦隊これくしょん -艦これ-』の世界が広がっていたのです!?

  • R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

Commit MetaInfo

修订版efaa8f22798c8983fd9c2d6a6219723fb25e5fe7 (tree)
时间2015-07-09 21:23:26
作者masakih <masakih@user...>
Commitermasakih

Log Message

処理を可能な限り削除

更改概述

差异

--- a/KanColleBrowserForOSX/KCBFOMainWindowController.swift
+++ b/KanColleBrowserForOSX/KCBFOMainWindowController.swift
@@ -19,13 +19,6 @@ class KCBFOMainWindowController: NSWindowController {
1919 let gamePageURL = "http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/"
2020 let loginPageURLPrefix = "https://www.dmm.com/my/-/login/=/"
2121
22- override init(window: NSWindow?) {
23- super.init(window: window)
24- }
25- required init?(coder: NSCoder) {
26- super.init(coder: coder)
27- }
28-
2922 override class func new() -> KCBFOMainWindowController {
3023 return KCBFOMainWindowController(windowNibName: "KCBFOMainWindowController")
3124 }
@@ -43,8 +36,7 @@ class KCBFOMainWindowController: NSWindowController {
4336 }
4437
4538 @IBAction func reloadContent(sender : AnyObject?) {
46- let currentURL = webView.mainFrameURL
47- if currentURL != gamePageURL {
39+ if webView.mainFrameURL != gamePageURL {
4840 adjustFlash()
4941 webView.mainFrameURL = gamePageURL
5042 return
@@ -53,8 +45,7 @@ class KCBFOMainWindowController: NSWindowController {
5345 webView.reload(nil)
5446 }
5547 @IBAction func reloadAndRecache(sender :AnyObject?) {
56- let cache = NSURLCache.sharedURLCache()
57- cache.removeAllCachedResponses()
48+ NSURLCache.sharedURLCache().removeAllCachedResponses()
5849 reloadContent(sender)
5950 }
6051
@@ -63,64 +54,65 @@ class KCBFOMainWindowController: NSWindowController {
6354 }
6455
6556 // MARK: - WebFrameLoadDelegate
66- override func webView(sender: WebView!, didFinishLoadForFrame frame: WebFrame!) {
67- func handler(c : JSContext! , e : JSValue!) {
68- println("caught exception in evaluateScript: -> \(e)")
57+ func handler(c : JSContext! , e : JSValue!) {
58+ println("caught exception in evaluateScript: -> \(e)")
59+ }
60+ func adjustIFrame(frame: WebFrame) {
61+ let context = frame.javaScriptContext!
62+ context.exceptionHandler = handler
63+ context.evaluateScript(
64+ [ "var emb = document.getElementById('flashWrap');",
65+ "var rect = emb.getBoundingClientRect();",
66+ "var atop = rect.top;",
67+ "var aleft = rect.left;"
68+ ].reduce(""){ $0 + $1 }
69+ )
70+ let top = context.objectForKeyedSubscript("atop")
71+ let left = context.objectForKeyedSubscript("aleft")
72+ let x = CGFloat(left.toDouble())
73+ let y = webView.frame.size.height - CGFloat(top.toDouble()) - 480
74+ flashTopLeft = NSMakePoint(x, y)
75+ }
76+ func adjustGameFrame(frame: WebFrame) {
77+ let context = frame.javaScriptContext!
78+ context.exceptionHandler = handler
79+ context.evaluateScript(
80+ [ "var iframe = document.getElementById('game_frame');",
81+ "var validIframe = 0;",
82+ "if(iframe) {",
83+ " validIframe = 1;",
84+ " var rect = iframe.getBoundingClientRect();",
85+ " var atop = rect.top;",
86+ " var aleft = rect.left;",
87+ "}"
88+ ].reduce(""){ $0 + $1 }
89+ )
90+ if let validIframe = context.objectForKeyedSubscript("validIframe")?.toInt32() {
91+ if validIframe == 0 { return }
92+
93+ let top = context.objectForKeyedSubscript("atop")
94+ let left = context.objectForKeyedSubscript("aleft")
95+ let x = flashTopLeft.x + CGFloat(left.toDouble())
96+ let y = flashTopLeft.y - CGFloat(top.toDouble())
97+ flashTopLeft = NSMakePoint(x, y)
98+ adjustFlash()
6999 }
70-
100+ }
101+ override func webView(sender: WebView!, didFinishLoadForFrame frame: WebFrame!) {
71102 if let path = frame.dataSource?.initialRequest.URL?.path {
72103 if path.hasSuffix("gadgets/ifr") {
73- let context = frame.javaScriptContext!
74- context.exceptionHandler = handler
75- context.evaluateScript(
76- [
77- "var emb = document.getElementById('flashWrap');",
78- "var rect = emb.getBoundingClientRect();",
79- "var atop = rect.top;",
80- "var aleft = rect.left;"
81- ].reduce(""){ $0 + $1 }
82- )
83- let top = context.objectForKeyedSubscript("atop")
84- let left = context.objectForKeyedSubscript("aleft")
85- flashTopLeft = NSMakePoint(0, webView.frame.size.height)
86- let x = CGFloat(left.toDouble()) as CGFloat
87- let y = webView.frame.size.height - CGFloat(top.toDouble()) - 480
88- flashTopLeft = NSMakePoint(x, y)
104+ adjustIFrame(frame)
89105 }
90106
91107 if path.hasSuffix("app_id=854854") {
92- let context = frame.javaScriptContext!
93- context.exceptionHandler = handler
94- context.evaluateScript(
95- [
96- "var iframe = document.getElementById('game_frame');",
97- "var validIframe = 0;",
98- "if(iframe) {",
99- " validIframe = 1;",
100- " var rect = iframe.getBoundingClientRect();",
101- " var atop = rect.top;",
102- " var aleft = rect.left;",
103- "}"
104- ].reduce(""){ $0 + $1 }
105- )
106-
107- if let validIframe = context.objectForKeyedSubscript("validIframe")?.toInt32() {
108- if validIframe == 0 { return }
109-
110- let top = context.objectForKeyedSubscript("atop")
111- let left = context.objectForKeyedSubscript("aleft")
112- let x = flashTopLeft.x + CGFloat(left.toDouble())
113- let y = flashTopLeft.y - CGFloat(top.toDouble())
114- flashTopLeft = NSMakePoint(x, y)
115- adjustFlash()
116- }
108+ adjustGameFrame(frame)
117109 }
118110 }
119111 }
120112
121113 // MARK: - WebUIDelegate
122114 override func webView(sender: WebView!, contextMenuItemsForElement element: [NSObject : AnyObject]!, defaultMenuItems: [AnyObject]!) -> [AnyObject]! {
123- var items:[AnyObject] = defaultMenuItems.flatMap(){
115+ return defaultMenuItems.flatMap(){
124116 item in
125117 switch item.tag() {
126118 case WebMenuItemTagOpenLinkInNewWindow,
@@ -136,6 +128,5 @@ class KCBFOMainWindowController: NSWindowController {
136128 return [item]
137129 }
138130 }
139- return items
140131 }
141132 }