| 1 | <?xml version="1.0" encoding="utf-8"?>
|
|---|
| 2 | <mx:Application
|
|---|
| 3 | xmlns:mx="http://www.adobe.com/2006/mxml"
|
|---|
| 4 | layout="absolute"
|
|---|
| 5 | height="504"
|
|---|
| 6 | width="400"
|
|---|
| 7 | cornerRadius="4"
|
|---|
| 8 | applicationComplete="init()"
|
|---|
| 9 | >
|
|---|
| 10 | <mx:Script>
|
|---|
| 11 | <![CDATA[
|
|---|
| 12 | import flash.net.URLRequestDefaults;
|
|---|
| 13 | import mx.events.ResizeEvent;
|
|---|
| 14 | import mx.managers.SystemManager;
|
|---|
| 15 | import mx.controls.Alert;
|
|---|
| 16 | import mx.controls.Text;
|
|---|
| 17 | import mx.controls.Image;
|
|---|
| 18 | import mx.containers.TitleWindow;
|
|---|
| 19 | import mx.managers.PopUpManager;
|
|---|
| 20 | import vc.kan.net.Wassr;
|
|---|
| 21 | import vc.kan.data.DBObject;
|
|---|
| 22 | import mx.formatters.DateFormatter;
|
|---|
| 23 |
|
|---|
| 24 | private const feedStyle:String = "<style>" +
|
|---|
| 25 | "* { color: white; font-size: 11px; " +
|
|---|
| 26 | " font-family:\"メイリオ\",\"Hiragino Kaku Gothic Pro\", \"ヒラギノ角ゴ Pro W3\",\"MS Pゴシック\", \"Osaka\", sans-selif; }" +
|
|---|
| 27 | "img.profile { width: 32px; height: 32px; margin: 2px; }" +
|
|---|
| 28 | "a.reply { color: #aaaaff; font-size: 9px; }" +
|
|---|
| 29 | "table { border: none; }" +
|
|---|
| 30 | "td.status { text-align: right; margin-bottom: 10px; }" +
|
|---|
| 31 | "span.time,span.user,span.area_name { font-size: 9px; margin: 2px; }" +
|
|---|
| 32 | "img.btn { width: 12px; height: 12px; padding: 1px; vertical-align:text-bottom; }" +
|
|---|
| 33 | "</style>";
|
|---|
| 34 |
|
|---|
| 35 | private const feedTemplate:XML =
|
|---|
| 36 | <div>
|
|---|
| 37 | <tr>
|
|---|
| 38 | <td rowspan="2">
|
|---|
| 39 | <a><img class="profile" src="" /></a>
|
|---|
| 40 | </td>
|
|---|
| 41 | <td></td>
|
|---|
| 42 | </tr>
|
|---|
| 43 | <tr>
|
|---|
| 44 | <td class="status">
|
|---|
| 45 | <span class="user"></span>
|
|---|
| 46 | <span class="time"></span>
|
|---|
| 47 | <a class="comment" href="javascript:void(0)"><img class="btn" src="app:assets/comment.png" /></a>
|
|---|
| 48 | <a class="iine" href="javascript:void(0)"><img class="btn" src="app:/assets/normal.png" /></a>
|
|---|
| 49 | <a href="#"><img class="btn" src="app:/assets/camera.png" /></a>
|
|---|
| 50 | <a href="#"><img class="btn" src="app:/assets/map.png" /><span class="area_name"></span></a>
|
|---|
| 51 | <a href="#"><img class="btn" src="app:/assets/world.png" /></a>
|
|---|
| 52 | </td>
|
|---|
| 53 | </tr>
|
|---|
| 54 | <tr>
|
|---|
| 55 | <td colspan="2" style="height: 5px">
|
|---|
| 56 | </td>
|
|---|
| 57 | </tr>
|
|---|
| 58 | </div>;
|
|---|
| 59 |
|
|---|
| 60 | public var timer:Timer = new Timer(60000);
|
|---|
| 61 |
|
|---|
| 62 | private var feed_view:Array = new Array(20);
|
|---|
| 63 |
|
|---|
| 64 | private var wassr:Wassr;
|
|---|
| 65 |
|
|---|
| 66 | public var user_id:String;
|
|---|
| 67 | public var password:String;
|
|---|
| 68 |
|
|---|
| 69 | public var feed_item:Object;
|
|---|
| 70 | private var iine_map:Object;
|
|---|
| 71 |
|
|---|
| 72 | private var settingDb:DBObject = new DBObject(Setting);
|
|---|
| 73 |
|
|---|
| 74 | private function init():void
|
|---|
| 75 | {
|
|---|
| 76 | URLRequestDefaults.userAgent = "wasaco/2.0.6; http://fushihara.net/wasaco.html";
|
|---|
| 77 |
|
|---|
| 78 | this.panel.addEventListener( MouseEvent.MOUSE_DOWN, doDrag );
|
|---|
| 79 | this.panel.addEventListener( MouseEvent.MOUSE_UP, savePosition );
|
|---|
| 80 | this.minimizeBtn.addEventListener( MouseEvent.MOUSE_UP, onMinimize );
|
|---|
| 81 | this.closeBtn.addEventListener( MouseEvent.MOUSE_UP, onClose );
|
|---|
| 82 | this.resizeBtn.addEventListener( MouseEvent.MOUSE_DOWN, startResize );
|
|---|
| 83 | this.resizeBtn.addEventListener( MouseEvent.MOUSE_UP, saveWindowSize );
|
|---|
| 84 | stage.addEventListener(Event.RESIZE, onResize);
|
|---|
| 85 | this.feedCanvas.addEventListener( Event.COMPLETE, feedLinkHook );
|
|---|
| 86 | this.feedCanvas.htmlLoader.paintsDefaultBackground = false;
|
|---|
| 87 | this.feedCanvas.htmlLoader.navigateInSystemBrowser = true;
|
|---|
| 88 | XML.prettyPrinting = false;
|
|---|
| 89 | iine_map = {};
|
|---|
| 90 |
|
|---|
| 91 | var mine:wasaco = this;
|
|---|
| 92 | settingDb.find(function (settings:Array):void {
|
|---|
| 93 | var setting_map:Object = {
|
|---|
| 94 | backColor: 0,
|
|---|
| 95 | backAlpha: 0.8,
|
|---|
| 96 | windowWidth: 400,
|
|---|
| 97 | windowHeight: 500,
|
|---|
| 98 | windowX: 100,
|
|---|
| 99 | windowY: 100
|
|---|
| 100 | };
|
|---|
| 101 | settings.forEach(function(conf:*, idx:Number, arr:Array):void {
|
|---|
| 102 | setting_map[conf.key] = conf.value;
|
|---|
| 103 | });
|
|---|
| 104 | panel.setStyle("backgroundColor", setting_map.backColor);
|
|---|
| 105 | panel.setStyle("backgroundAlpha", setting_map.backAlpha);
|
|---|
| 106 | stage.nativeWindow.width = setting_map.windowWidth;
|
|---|
| 107 | stage.nativeWindow.height = setting_map.windowHeight;
|
|---|
| 108 | stage.nativeWindow.x = setting_map.windowX;
|
|---|
| 109 | stage.nativeWindow.y = setting_map.windowY;
|
|---|
| 110 | });
|
|---|
| 111 | showLoginWindow();
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | private function doDrag(event:MouseEvent):void {
|
|---|
| 115 | if ( this.panel.contains(event.target as DisplayObject) ) return;
|
|---|
| 116 | applicationDragHandler(event);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | private function feedLinkHook(event:Event):void {
|
|---|
| 120 | var links:Object = feedCanvas.htmlLoader.window.document.links;
|
|---|
| 121 | for (var i:uint=0; i < links.length; i++) {
|
|---|
| 122 | if ( links[i].className == "comment" ) {
|
|---|
| 123 | links[i].addEventListener("click", replyClick);
|
|---|
| 124 | } else if ( links[i].className == "iine" ) {
|
|---|
| 125 | links[i].addEventListener("click", iineClick);
|
|---|
| 126 | }
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | private function replyClick(evt:Object):void {
|
|---|
| 131 | var comment:commentWindow = commentWindow(
|
|---|
| 132 | PopUpManager.createPopUp(this, commentWindow, true)
|
|---|
| 133 | );
|
|---|
| 134 | comment.target = this;
|
|---|
| 135 | comment.res_rid = evt.target.title;
|
|---|
| 136 | PopUpManager.centerPopUp(comment);
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | private function iineClick(evt:Object):void {
|
|---|
| 140 | iine_map[evt.target.title] = 1;
|
|---|
| 141 | favStatus(evt.target.title, function():void{
|
|---|
| 142 | evt.target.src = "app:/assets/good.png";
|
|---|
| 143 | });
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | public function saveSetting(key:String, value:*):void
|
|---|
| 147 | {
|
|---|
| 148 | settingDb.find(function(settings:Array):void{
|
|---|
| 149 | if ( settings[0] ) {
|
|---|
| 150 | settings[0].update({
|
|---|
| 151 | "value": value
|
|---|
| 152 | });
|
|---|
| 153 | }
|
|---|
| 154 | }, { "key": key }, null,
|
|---|
| 155 | function():void {
|
|---|
| 156 | settingDb.create({
|
|---|
| 157 | "key": key,
|
|---|
| 158 | "value": value
|
|---|
| 159 | }, function ():void {});
|
|---|
| 160 | });
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | public function startAutoGetFeed():void
|
|---|
| 164 | {
|
|---|
| 165 | timer.addEventListener(TimerEvent.TIMER, timerHandler);
|
|---|
| 166 | timer.start();
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | private function showLoginWindow():void
|
|---|
| 170 | {
|
|---|
| 171 | var login:loginWindow = loginWindow(
|
|---|
| 172 | PopUpManager.createPopUp(this, loginWindow, true)
|
|---|
| 173 | );
|
|---|
| 174 | login.target = this;
|
|---|
| 175 | login.loadProfile();
|
|---|
| 176 | PopUpManager.centerPopUp(login);
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | private function showSettingWindow():void
|
|---|
| 180 | {
|
|---|
| 181 | var setting:settingWindow = settingWindow(
|
|---|
| 182 | PopUpManager.createPopUp(this, settingWindow, true)
|
|---|
| 183 | );
|
|---|
| 184 | setting.target = this;
|
|---|
| 185 | setting.loadSetting()
|
|---|
| 186 | PopUpManager.centerPopUp(setting);
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | public function get_feed ():void
|
|---|
| 190 | {
|
|---|
| 191 | if (!wassr) {
|
|---|
| 192 | wassr = new Wassr(user_id, password, URLRequestDefaults.userAgent);
|
|---|
| 193 | wassr.addEventListener(IOErrorEvent.IO_ERROR, function (evt:IOErrorEvent):void { });
|
|---|
| 194 | }
|
|---|
| 195 | wassr.getFeed(displayFeed);
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | public function timerHandler(evt:TimerEvent):void
|
|---|
| 199 | {
|
|---|
| 200 | get_feed();
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | private function displayFeed(feed_item:Object):void
|
|---|
| 204 | {
|
|---|
| 205 | var html:String = feedStyle;
|
|---|
| 206 | var pattern:RegExp = /(?<!src=")https?:\/\/[-_.!~*'()\w;\/?:@&=+$,%#]+/g;
|
|---|
| 207 | html += "<table>";
|
|---|
| 208 | for (var j:int=0; j<20; j++) {
|
|---|
| 209 | if (feed_item[j]) {
|
|---|
| 210 | var reply:String = "";
|
|---|
| 211 | if (feed_item[j].reply_message) {
|
|---|
| 212 | reply = "<a class=\"reply\" href=\"" + feed_item[j].reply_status_url + "\"> >" +
|
|---|
| 213 | feed_item[j].reply_message + " by " +
|
|---|
| 214 | feed_item[j].reply_user_nick + "</a><br />";
|
|---|
| 215 | }
|
|---|
| 216 | var tmpl:XML = feedTemplate.copy();
|
|---|
| 217 | var text:String = feed_item[j].html;
|
|---|
| 218 | tmpl.tr[0].td[0].a.img.@src = feed_item[j].user.profile_image_url;
|
|---|
| 219 | tmpl.tr[0].td[0].a.@href = "http://wassr.jp/user/" + feed_item[j].user_login_id
|
|---|
| 220 | tmpl.tr[0].td[1] = XML("<td class=\"text\">" + reply + text.replace(pattern, "<a href=\"http://b.hatena.ne.jp/entry/$&\" target=\"_blank\">[URL]</a>")+"</td>");
|
|---|
| 221 | tmpl.tr[1].td.span[0] = XML("<span class=\"user\">by " + feed_item[j].user.screen_name + "</span>");
|
|---|
| 222 | var fmt:DateFormatter = new DateFormatter();
|
|---|
| 223 | fmt.formatString = "YYYY/MM/DD JJ:NN";
|
|---|
| 224 | tmpl.tr[1].td.span[1] = XML("<span class=\"time\">" + fmt.format(new Date(int(feed_item[j].epoch) * 1000)) + "</span>");
|
|---|
| 225 | tmpl.tr[1].td.a[0].img.@title = feed_item[j].rid;
|
|---|
| 226 | if (feed_item[j].user.protected) {
|
|---|
| 227 | tmpl.tr[1].td.a[1].@href = "javascript:void(0)";
|
|---|
| 228 | tmpl.tr[1].td.a[1].img.@src = "app:/assets/secret.png";
|
|---|
| 229 | } else {
|
|---|
| 230 | tmpl.tr[1].td.a[1].img.@title = feed_item[j].rid;
|
|---|
| 231 | if ( iine_map[feed_item[j].rid] == 1 ) {
|
|---|
| 232 | tmpl.tr[1].td.a[1].img.@src = "app:/assets/good.png";
|
|---|
| 233 | } else {
|
|---|
| 234 | tmpl.tr[1].td.a[1].img.@src = "app:/assets/normal.png";
|
|---|
| 235 | }
|
|---|
| 236 | }
|
|---|
| 237 | if (feed_item[j].photo_url) {
|
|---|
| 238 | tmpl.tr[1].td.a[2].@href = feed_item[j].photo_url;
|
|---|
| 239 | } else {
|
|---|
| 240 | tmpl.tr[1].td.a[2].@style = "display:none";
|
|---|
| 241 | }
|
|---|
| 242 | if (feed_item[j].areacode) {
|
|---|
| 243 | tmpl.tr[1].td.a[3].@href = "http://wassr.jp/area/code/" + feed_item[j].areacode;
|
|---|
| 244 | tmpl.tr[1].td.a[3].span = XML("<span class=\"area_name\">" + feed_item[j].areaname + "</span>");
|
|---|
| 245 | } else {
|
|---|
| 246 | tmpl.tr[1].td.a[3].@style = "display:none";
|
|---|
| 247 | }
|
|---|
| 248 | if (feed_item[j].slurl) {
|
|---|
| 249 | tmpl.tr[1].td.a[4].@href = feed_item[j].slurl;
|
|---|
| 250 | } else {
|
|---|
| 251 | tmpl.tr[1].td.a[4].@style = "display:none";
|
|---|
| 252 | }
|
|---|
| 253 | trace(tmpl.toXMLString());
|
|---|
| 254 | html += tmpl.toXMLString();
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 | feedCanvas.htmlText = html + "</table>";
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | private function displayParentComment(evt:Event):void
|
|---|
| 261 | {
|
|---|
| 262 | Alert.show(evt.currentTarget.data);
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | public function applicationDragHandler(event:MouseEvent):void
|
|---|
| 266 | {
|
|---|
| 267 | stage.nativeWindow.startMove();
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | private function onClose(evt:MouseEvent):void
|
|---|
| 271 | {
|
|---|
| 272 | stage.nativeWindow.close();
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 | private function onMinimize(evt:MouseEvent):void
|
|---|
| 276 | {
|
|---|
| 277 | stage.nativeWindow.minimize();
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | private function showPictWindow(evt:MouseEvent):void
|
|---|
| 281 | {
|
|---|
| 282 | var pict:pictWindow = pictWindow(
|
|---|
| 283 | PopUpManager.createPopUp(this, pictWindow, true)
|
|---|
| 284 | );
|
|---|
| 285 | pict.load(stat);
|
|---|
| 286 | PopUpManager.centerPopUp(pict);
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | public function statusUpdate(res_rid:String=null):void
|
|---|
| 290 | {
|
|---|
| 291 | if (stat.text == "") {
|
|---|
| 292 | get_feed();
|
|---|
| 293 | return;
|
|---|
| 294 | }
|
|---|
| 295 | wassr.statusUpdate(stat.text, function ():void {get_feed();}, res_rid);
|
|---|
| 296 | stat.text = "";
|
|---|
| 297 | }
|
|---|
| 298 |
|
|---|
| 299 | public function favStatus(status_rid:String, callback:Function):void
|
|---|
| 300 | {
|
|---|
| 301 | wassr.favStatus(status_rid, callback);
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | public function startResize(event:MouseEvent):void
|
|---|
| 305 | {
|
|---|
| 306 | stage.nativeWindow.startResize(NativeWindowResize.BOTTOM_RIGHT);
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 | public function onResize(event:Event):void
|
|---|
| 310 | {
|
|---|
| 311 | this.height = stage.nativeWindow.height;
|
|---|
| 312 | this.width = stage.nativeWindow.width;
|
|---|
| 313 | this.panel.height = stage.nativeWindow.height;
|
|---|
| 314 | this.panel.width = stage.nativeWindow.width;
|
|---|
| 315 | this.ControlArea.width = this.panel.width - 20;
|
|---|
| 316 | this.feedCanvas.width = this.panel.width - 20;
|
|---|
| 317 | this.feedCanvas.height = this.height - 145;
|
|---|
| 318 | this.stat.width = this.width - 94;
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | public function alwaysFront(event:Event):void
|
|---|
| 322 | {
|
|---|
| 323 | if (this.alwaysFrontChk.selected == true) {
|
|---|
| 324 | stage.nativeWindow.alwaysInFront = true;
|
|---|
| 325 | } else {
|
|---|
| 326 | stage.nativeWindow.alwaysInFront = false;
|
|---|
| 327 | }
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | private function saveWindowSize(event:Event):void
|
|---|
| 331 | {
|
|---|
| 332 | saveSetting("windowWidth", stage.nativeWindow.width);
|
|---|
| 333 | saveSetting("windowHeight", stage.nativeWindow.height);
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | private function savePosition(event:MouseEvent):void {
|
|---|
| 337 | if ( this.panel.contains(event.target as DisplayObject) ) return;
|
|---|
| 338 | saveSetting("windowX", stage.nativeWindow.x);
|
|---|
| 339 | saveSetting("windowY", stage.nativeWindow.y);
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | ]]>
|
|---|
| 343 | </mx:Script>
|
|---|
| 344 | <mx:Style>
|
|---|
| 345 | Application {
|
|---|
| 346 | background-image: "";
|
|---|
| 347 | background-color: "";
|
|---|
| 348 | background-alpha: 0;
|
|---|
| 349 | }
|
|---|
| 350 | Panel {
|
|---|
| 351 | color: #ffffff;
|
|---|
| 352 | borderStyle: solid;
|
|---|
| 353 | roundedBottomCorners: true;
|
|---|
| 354 | cornerRadius: 15;
|
|---|
| 355 | shadowDirection: right;
|
|---|
| 356 | backgroundColor: #000000;
|
|---|
| 357 | backgroundAlpha: 0.8;
|
|---|
| 358 | width: 400px;
|
|---|
| 359 | height: 500px;
|
|---|
| 360 | }
|
|---|
| 361 | </mx:Style>
|
|---|
| 362 | <mx:Panel id="panel" x="0" y="0" title="wasaco ver 2.0.6" titleIcon="@Embed(source='assets/wasaco.png')" width="374">
|
|---|
| 363 | <mx:Canvas x="0" y="0" width="100%" height="70" id="ControlArea">
|
|---|
| 364 | <mx:TextInput x="10" y="10" width="263" id="stat" color="#111111" enter="statusUpdate();" height="22"/>
|
|---|
| 365 | <mx:Button x="10" y="38" label="Pictogram" width="111" click="showPictWindow(event);" icon="@Embed('assets/heart.png')" />
|
|---|
| 366 | <mx:Button x="129" y="38" label="Post/Update" click="statusUpdate();" width="118" icon="@Embed('assets/action_refresh_blue.gif')"/>
|
|---|
| 367 | <mx:Image id="minimizeBtn" source="assets/minimize_icon.png" width="16" height="16" right="16" y="0"/>
|
|---|
| 368 | <mx:Image id="closeBtn" source="assets/close_icon.png" width="16" height="16" right="0" y="0"/>
|
|---|
| 369 | <mx:Button id="settingBtn" x="255" y="38" label="Setting" width="70" click="showSettingWindow()" />
|
|---|
| 370 | </mx:Canvas>
|
|---|
| 371 | <mx:HTML x="0" y="70" width="100%" height="356" color="#ffffff" id="feedCanvas" backgroundAlpha="0.0" />
|
|---|
| 372 | <mx:Canvas bottom="0" width="100%" height="20" color="#ffffff" id="statusBar" backgroundAlpha="0.0">
|
|---|
| 373 | <mx:Image id="resizeBtn" source="assets/resize_icon.png" width="16" height="16" right="0" bottom="0" />
|
|---|
| 374 | <mx:CheckBox id="alwaysFrontChk" x="0" y="0" label="常に最前面に表示する" click="alwaysFront(event)" />
|
|---|
| 375 | </mx:Canvas>
|
|---|
| 376 | </mx:Panel>
|
|---|
| 377 | </mx:Application>
|
|---|