チェンジセット 2200

差分発生行の前後
無視リスト:
コミット日時:
2009/01/31 17:21:11 (3 年前)
コミッタ:
uwi
ログメッセージ:

DataGridEventThread?でEventが重複する場合に対応
protectedに対応
DB仕様の変更

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • air/TLife/src/uwi/bean/Status.as

    r2183 r2200  
    1414                private var _iconurl : String; // iconのURL 
    1515                private var _fav : Boolean; 
     16                private var _tag : String; 
    1617 
    1718                public function Status(postid : String, postername : String, posterid : String, content : String, replyid : String, postedtime : Date, iconurl : String, fav : Boolean) { 
     
    9394                } 
    9495                 
     96                public function get tag():String { return _tag; } 
     97                 
     98                public function set tag(value:String):void  
     99                { 
     100                        _tag = value; 
     101                } 
     102                 
    95103        } 
    96104         
  • air/TLife/src/uwi/db/DB.as

    r2183 r2200  
    4646                                ")"); 
    4747                        execute(conn,  
    48                                 "create table if not exists " + CommonData.TABLE_FOLLOWING + "(" +  
     48                                "create table if not exists " + CommonData.TABLE_RELATION + "(" +  
    4949                                "userid varchar(15) not null," +  
    5050                                "posterid varchar(15) not null," +  
     51                                "following boolean not null," +  
     52//                              "followed boolean not null," +  
     53                                "protected boolean not null," + 
     54                                "lastupdated date not null," +  
    5155                                "primary key(userid, posterid)" +  
    5256                                ")"); 
    53                          
    5457                } 
    5558                 
  • air/TLife/src/uwi/db/SimpleTransactionThread.as

    r2139 r2200  
    1515                private var args : Array; // Array<Object> 
    1616                 
    17                 public function SimpleTransactionThread(conn : SQLConnection, basetext : String, args : Array )  
     17                public function SimpleTransactionThread(conn : SQLConnection, basetext : String, args : Array = null)  
    1818                {  
    1919                        super(conn); 
     
    3434                        stmt.text = basetext; 
    3535                         
    36                         for each(var obj : Object in args) { 
    37                                 for (var key : String in obj) { 
    38                                         stmt.parameters[key] = obj[key]; 
     36                        if (args != null) { 
     37                                for each(var obj : Object in args) { 
     38                                        for (var key : String in obj) { 
     39                                                stmt.parameters[key] = obj[key]; 
     40                                        } 
     41                                        try { 
     42                                                stmt.execute(); 
     43                                        }catch (e : SQLError) { 
     44                                                trace(e.message); 
     45                                        } 
    3946                                } 
     47                        }else { 
    4048                                try { 
    4149                                        stmt.execute(); 
  • air/TLife/src/uwi/thread/ContextMenuItemEventThread.as

    r2183 r2200  
    207207                } 
    208208                 
     209                /** 
     210                 * TODO protectedな相手をfollowするときのrequest 
     211                 * @param       e 
     212                 */ 
    209213                private function onFollow(e : ContextMenuEvent) : void 
    210214                { 
     
    217221                                } 
    218222                                var pe : ParallelExecutor = new ParallelExecutor(); 
     223                                var now : Date = new Date(); 
    219224                                pe.addThread(new SimpleTransactionThread(CommonData.db_memory.conn,  
    220                                         "insert into " + CommonData.TABLE_FOLLOWING + " (userid, posterid) values ('" + CommonData.configxml.userid + "', :posterid", 
     225                                        "replace into " + CommonData.TABLE_RELATION + " (userid, posterid, following, protected, lastupdated) values ('" + CommonData.configxml.userid + "', :posterid, true, false, '" + now + "')", 
    221226                                        args)); 
    222227                                pe.addThread(new SimpleTransactionThread(CommonData.db_disk.conn,  
    223                                         "insert into " + CommonData.TABLE_FOLLOWING + " (userid, posterid) values ('" + CommonData.configxml.userid + "', :posterid", 
     228                                        "replace into " + CommonData.TABLE_RELATION + " (userid, posterid, following, protected, lastupdated) values ('" + CommonData.configxml.userid + "', :posterid, true, false, '" + now + "')", 
    224229                                        args)); 
    225230                                pe.start(); 
     
    239244                                var pe : ParallelExecutor = new ParallelExecutor(); 
    240245                                pe.addThread(new SimpleTransactionThread(CommonData.db_memory.conn,  
    241                                         "delete from " + CommonData.TABLE_FOLLOWING + " where posterid = :posterid", 
     246                                        "delete from " + CommonData.TABLE_RELATION + " where userid = '" + CommonData.configxml.userid + "' and posterid = :posterid", 
    242247                                        args)); 
    243248                                pe.addThread(new SimpleTransactionThread(CommonData.db_disk.conn,  
    244                                         "delete from " + CommonData.TABLE_FOLLOWING + " where posterid = :posterid", 
     249                                        "delete from " + CommonData.TABLE_RELATION + " where userid = '" + CommonData.configxml.userid + "' and posterid = :posterid", 
    245250                                        args)); 
    246251                                pe.start(); 
  • air/TLife/src/uwi/thread/DataGridEventThread.as

    r2199 r2200  
    4040                        event(dg, Event.CHANGE, onChange); 
    4141                        event(dg, KeyboardEvent.KEY_DOWN, onKeyDown); 
    42                         event(dg, KeyboardEvent.KEY_UP, onKeyUp); 
    4342                        event(dg, ScrollEvent.SCROLL, onScroll); 
    4443                } 
     
    4645                private function onScroll(e : ScrollEvent) : void 
    4746                { 
    48                         dgrt.flag = 1; 
     47                        trace("scroll"); 
     48                        dgrt.flag |= 1; 
    4949                        next(run); 
    5050                } 
     
    8181                private function onKeyDown(e : KeyboardEvent) : void 
    8282                { 
     83                        trace("down"); 
    8384                        if (dg.selectedIndex != -1){ 
    8485                                switch(e.keyCode) { 
     
    8687                                        dg.selectedIndex = searchSamePoster(dg.selectedIndex, 1); 
    8788                                        dg.scrollToIndex(dg.selectedIndex); 
    88                                         dgrt.flag = 2
     89                                        dgrt.flag |= 3
    8990                                        break; 
    9091                                case Keyboard.LEFT: 
    9192                                        dg.selectedIndex = searchSamePoster(dg.selectedIndex, -1); 
    9293                                        dg.scrollToIndex(dg.selectedIndex); 
    93                                         dgrt.flag = 2
     94                                        dgrt.flag |= 3
    9495                                        break; 
     96                                // up,downでscrollした場合、changeが打ち消されるため 
    9597                                case Keyboard.UP: 
    9698                                case Keyboard.DOWN: 
    97                                         dgrt.flag = 2
     99                                        dgrt.flag |= 3
    98100                                        break; 
    99101                                default: 
     
    102104                                dgrt.suspended = true; 
    103105                        } 
    104                         next(run); 
     106                        event(dg, KeyboardEvent.KEY_UP, onKeyUp); 
     107//                      next(run); 
    105108                } 
    106109                 
    107110                private function onKeyUp(e : KeyboardEvent) : void 
    108111                { 
     112                        trace("up"); 
    109113                        dgrt.suspended = false; 
    110114                        next(run); 
     
    117121                public function onChange(e : Event) : void 
    118122                { 
    119                         dgrt.flag = 2; 
     123                        trace("change"); 
     124                        dgrt.flag |= 3; 
    120125                        next(run); 
    121126                }  
  • air/TLife/src/uwi/thread/DataGridRoutineThread.as

    r2199 r2200  
    3939                { 
    4040                        if (flag == 0 || suspended) return; 
     41                        trace("flag : " + flag); 
    4142                         
    4243                        var obj : Object = dg.selectedItem; 
     
    4647                        } 
    4748                        var index : int = dg.selectedIndex; 
    48                                  
    49                         switch(flag) { 
    50                                 case 2: 
     49                         
     50                        if((flag & 2) != 0){ 
    5151                                // friendpost欄に表示 
    5252                                friendname.text = obj.postername + " / " + obj.posterid; 
     
    6969                                        CommonData.rgt.start(); 
    7070                                } 
    71                                  
    72                                 case 1: 
     71                        } 
     72                         
     73                        if((flag & 1) != 0){ 
    7374                                // 背景色変更 
    7475                                var len : int = CommonData.timeline.length - dg.maxVerticalScrollPosition + 1; 
     
    8788                                        } 
    8889                                } 
    89                                 break; 
    90                                  
    91                                 default: 
    92                                 break; 
    9390                        } 
    9491                        flag = 0; 
  • air/TLife/src/uwi/thread/FrameTimerThread.as

    r2199 r2200  
    3131                        } 
    3232                        next(repeated); 
     33                        error(Error, onError); 
     34                } 
     35                 
     36                private function onError(e : Error, t : Thread) : void 
     37                { 
     38                        trace(e.getStackTrace()); 
     39                        next(repeated); 
    3340                } 
    3441                 
  • air/TLife/src/uwi/thread/HTMLLoaderThread.as

    r2199 r2200  
    1717                public function HTMLLoaderThread(req : URLRequest, html : HTMLLoader = null)  
    1818                { 
    19                         if (_html == null) _html = new HTMLLoader(); 
     19                        if (html != null) { 
     20                                _html = html; 
     21                        }else { 
     22                                _html = new HTMLLoader(); 
     23                        } 
    2024                        _req = req; 
    2125                } 
  • air/TLife/src/uwi/thread/ReplyGetThread.as

    r2199 r2200  
    3939                protected override function run() : void 
    4040                { 
     41                        checkRelation(); 
     42                } 
     43                 
     44                private function checkRelation() : void 
     45                { 
    4146                        retryct++; 
     47                        var sql : String = "select lastupdated from " +  
     48                                CommonData.TABLE_RELATION +  
     49                                " where userid = '" + CommonData.configxml.userid + "'" +  
     50                                " and posterid = '" + posterid + "'" + 
     51                                " and protected = true"; 
     52                        dbst = new DBSelectThread(CommonData.db_disk.conn, sql); // _disk? 
     53                        dbst.start(); 
     54                        dbst.join(); 
     55                        next(checkStatus); 
     56                } 
     57                         
     58                private function checkStatus() : void 
     59                { 
    4260                        var sql : String = "select postid, posterid, content, postedtime, replyid, fav from " +  
    4361                                CommonData.TABLE_STATUS +  
     
    6078                                        tbsgt.start(); 
    6179                                        tbsgt.join(); 
    62                                         next(run); 
     80                                        next(checkRelation); 
    6381                                } 
    6482                        }else { 
  • air/TLife/src/uwi/thread/StatusInsertThread.as

    r2199 r2200  
    2020                 * @param       conn 
    2121                 * @param       statuses 
    22                  * @param       following followingが確定しているかどうか。falseの場合はposter上のfollowingの値を変えない。 未実装 
     22                 * @param       following followingが確定しているかどうか。falseの場合はfollowingの値を変えない。 未実装 
    2323                 */ 
    2424                public function StatusInsertThread(conn : SQLConnection, statuses : Vector.<Status>, following : Boolean) { 
     
    2626                        this.statuses = statuses; 
    2727                        this.following = following; 
    28                          
    29                         // 時間昇順にソート 
    30                         statuses.sort(function(x : Status, y : Status) : Number { 
    31                                 return x.postedtime.getTime() - y.postedtime.getTime(); 
    32                         }); 
    3328                } 
    3429                 
     
    8782                        if (following) { 
    8883                                trace("INSERT3"); 
     84                                var now : Date = new Date(); 
    8985                                var stmt_rep_following : SQLStatement = new SQLStatement(); 
    9086                                stmt_rep_following.sqlConnection = conn; 
    91                                 stmt_rep_following.text = "replace into " + CommonData.TABLE_FOLLOWING + " (userid, posterid) values (:userid, :posterid)"; 
     87                                stmt_rep_following.text = "replace into " + CommonData.TABLE_RELATION + " (userid, posterid, following, protected, lastupdated) values (:userid, :posterid, true, false, :lastupdated)"; 
    9288                                 
    9389                                for (key in postermap) { 
    9490                                        stmt_rep_following.parameters[":userid"] = CommonData.configxml.userid.toString(); 
    9591                                        stmt_rep_following.parameters[":posterid"] = key; 
     92                                        stmt_rep_following.parameters[":lastupdated"] = now; 
    9693                                        try { 
    9794                                                stmt_rep_following.execute(); 
  • air/TLife/src/uwi/thread/TimelineThread.as

    r2199 r2200  
    4747                                                                        CommonData.TABLE_STATUS; 
    4848                        var condfollowing : String = " where posterid in (select posterid from " +  
    49                                                                                         CommonData.TABLE_FOLLOWING +  
    50                                                                                         " where userid = '" + CommonData.configxml.userid + "')";  
     49                                                                                        CommonData.TABLE_RELATION +  
     50                                                                                        " where userid = '" + CommonData.configxml.userid + "'" +  
     51                                                                                        " and following = true)";  
    5152                        var sql : String = null; 
    5253                        if (query != null) { 
  • air/TLife/src/uwi/twitter/TwitterBitStatusGetThread.as

    r2199 r2200  
    66        import org.libspark.thread.utils.ParallelExecutor; 
    77        import uwi.bean.Status; 
     8        import uwi.db.SimpleTransactionThread; 
    89        import uwi.thread.HTMLLoaderThread; 
    910        import uwi.thread.LinkResolveThread; 
     
    2223                private var pe : ParallelExecutor = null; 
    2324                 
    24                 private var s : Status
     25                private var s : Status = null
    2526                 
    2627                private var posterid : String; 
     
    4546                private function onGetComplete() : void 
    4647                { 
    47                         s = StatusDOMScraper.scrapeBit(hlt.html); 
    48                         lrt = new LinkResolveThread(s.content); 
    49                         lrt.start(); 
    50                         lrt.join(); 
    51                         next(resolveComplete); 
     48                        trace("getcomplete"); 
     49                        var ret : Object = StatusDOMScraper.scrapeBit(hlt.html); 
     50                        if (ret.code == 1) { 
     51                                // protected 
     52                                pe = new ParallelExecutor(); 
     53                                var now : Date = new Date(); 
     54                                pe.addThread(new SimpleTransactionThread(CommonData.db_memory.conn,  
     55                                        "replace into " + CommonData.TABLE_RELATION + " (userid, posterid, following, protected, lastupdated) values ('" + CommonData.configxml.userid + "', '" + posterid + "', false, true, '" + now + "')")); 
     56                                pe.addThread(new SimpleTransactionThread(CommonData.db_disk.conn,  
     57                                        "replace into " + CommonData.TABLE_RELATION + " (userid, posterid, following, protected, lastupdated) values ('" + CommonData.configxml.userid + "', '" + posterid + "', false, true, '" + now + "')")); 
     58                                pe.start(); 
     59                                pe.join(); 
     60                        }else { 
     61                                s = ret.status; 
     62                                lrt = new LinkResolveThread(s.content); 
     63                                lrt.start(); 
     64                                lrt.join(); 
     65                                next(resolveComplete); 
     66                        } 
    5267                        interrupted(onInterrupted); 
    5368                } 
     
    5570                private function resolveComplete() : void 
    5671                { 
     72                        trace("resolvecomplete"); 
    5773                        s.content = lrt.dst; 
    5874                        var v : Vector.<Status> = Vector.<Status>([s]); 
  • air/TLife/src/uwi/twitter/TwitterLoginThread.as

    r2183 r2200  
    66        import org.libspark.thread.Thread; 
    77        import org.libspark.thread.threads.net.URLLoaderThread; 
     8        import uwi.util.CommonData; 
    89        import uwi.util.StatusBarUtility; 
    910         
     
    7475                { 
    7576                        trace("response : " + event.status); 
    76                         if (event.status == 401) { 
    77                                 Alert.show("ログインできなかたー", "Login"); 
     77                        if (event.status == 200) { 
     78                                StatusBarUtility.write("ログイン成功!"); 
     79                        }else{ 
     80                                Alert.show(CommonData.TWITTER_RESPONSE[event.status], "Login"); 
    7881                                StatusBarUtility.write("ログイン失敗!"); 
    7982                                return; 
    8083                        } 
    81                         if (event.status == 403) { 
    82                                 Alert.show("アク禁されてる><", "Login"); 
    83                                 StatusBarUtility.write("ログイン失敗!"); 
    84                                 return; 
    85                         } 
    86                         StatusBarUtility.write("ログイン成功!"); 
    8784                } 
    8885        } 
  • air/TLife/src/uwi/twitter/TwitterPostThread.as

    r2139 r2200  
    44        import mx.controls.Alert; 
    55        import org.libspark.thread.Thread; 
     6        import uwi.util.CommonData; 
    67        import uwi.util.StatusBarUtility; 
    78        import uwi.util.URLPostThread; 
     
    3738                { 
    3839                        if (eventname != null) { 
     40                                Alert.show("なぞのエラー", "Login"); 
    3941                                StatusBarUtility.write(eventname + "失敗!"); 
    4042                        } 
     
    4244                } 
    4345                 
    44                 protected override function onResponse(e : HTTPStatusEvent) : void 
     46                protected override function onResponse(event : HTTPStatusEvent) : void 
    4547                { 
    46                         if (e.status == 401) { 
    47                                 Alert.show("ログイン失敗", eventname); 
     48                        if (event.status == 200) { 
     49                                StatusBarUtility.write(eventname + "成功!"); 
     50                        }else{ 
     51                                Alert.show(CommonData.TWITTER_RESPONSE[event.status], eventname); 
     52                                StatusBarUtility.write(eventname + "失敗!"); 
    4853                                return; 
    49                         } 
    50                         if (eventname != null) { 
    51                                 StatusBarUtility.write(eventname + "成功!"); 
    5254                        } 
    5355                } 
  • air/TLife/src/uwi/twitter/TwitterReloadThread.as

    r2183 r2200  
    102102                         
    103103                        for each(var hlt : HTMLLoaderThread in hlts) { 
    104                                 statuses = statuses.concat(StatusDOMScraper.scrape(hlt.html, posterid != CommonData.HOME)); 
     104                                var ret : Object = StatusDOMScraper.scrape(hlt.html, posterid != CommonData.HOME); 
     105                                if(ret.code == 0)statuses = statuses.concat(ret.statuses); 
    105106                        } 
    106107                         
  • air/TLife/src/uwi/util/CommonData.as

    r2199 r2200  
    2424                public static const TABLE_STATUS : String = "status"; 
    2525                public static const TABLE_POSTER : String = "poster"; 
    26                 public static const TABLE_FOLLOWING : String = "following"; 
     26                public static const TABLE_RELATION : String = "relation"; 
    2727                 
    2828                public static const LIMLEN_POST : int = 140; 
     
    6565                 
    6666                public static var urlcache : Object; 
     67                 
     68                public static const TWITTER_RESPONSE : Object = { 
     69                        "200" : "OK",  
     70                        "304" : "新着情報がない",  
     71                        "400" : "リクエスト却下",  
     72                        "401" : "認証失敗",  
     73                        "403" : "権限のないAPIの実行",  
     74                        "404" : "存在しないAPI・ユーザー",  
     75                        "500" : "Twitterの問題",  
     76                        "502" : "Twitterサーバーが停止・メンテ中",  
     77                        "503" : "Twitterサーバーの過負荷" 
     78                }; 
    6779        } 
    6880         
  • air/TLife/src/uwi/util/StatusDOMScraper.as

    r2199 r2200  
    1010        public class StatusDOMScraper 
    1111        { 
     12                // return code 
     13                // 0 : OK 
     14                // 1 : protected 
     15                // 2 : not found 
     16                 
    1217                // homeタイムライン用 
    1318                // userid以外埋まったstatusを返す 
    14                 public static function scrape(html : HTMLLoader, locally : Boolean = false) : Vector.<Status> 
     19                public static function scrape(html : HTMLLoader, locally : Boolean = false) : Object // {statuses : Vector.<Status>, code : int} 
    1520                { 
    1621                        var ret : Vector.<Status> = new Vector.<Status>(); 
     
    2126                        var postername : String; 
    2227                         
    23                         if (locally) { 
    24                                 iconurl = doc.getElementById("profile-image").getAttribute("src"); 
    25                                 posterid = doc.title.substr(10); // "Twitter / ***" 
    26                                 // <div id="side"><div class="section"><ul class="about vcard entry-author"><li><span class="fn"> 
    27                                 postername = doc.getElementById("side").firstChild.childNodes[2].firstChild.lastChild.innerHTML; 
     28                        try { 
     29                                if (locally) { 
     30                                        iconurl = doc.getElementById("profile-image").getAttribute("src"); 
     31                                        posterid = doc.title.substr(10); // "Twitter / ***" 
     32                                        // <div id="side"><div class="section"><ul class="about vcard entry-author"><li><span class="fn"> 
     33                                        postername = doc.getElementById("side").firstChild.childNodes[2].firstChild.lastChild.innerHTML; 
     34                                } 
     35                                 
     36                                var timeline : Object = html.window.document.getElementById("timeline_body").getElementsByTagName("tr"); 
     37                                for (var i : int = 0; i < timeline.length; i++) { 
     38                                        var element : Object = timeline[i]; 
     39                                        var atags : Object = element.getElementsByTagName("a"); 
     40                                        var spantags : Object = element.getElementsByTagName("span"); 
     41                                         
     42                                        var postid : String = element.id.substr(7); 
     43                                         
     44                                        if(!locally){ 
     45                                                iconurl = atags[0].firstChild.getAttribute("src"); 
     46                                                posterid = atags[1].innerHTML; 
     47                                                postername = atags[1].getAttribute("title"); 
     48                                        } 
     49                                         
     50                                        var content : String = spantags[0].innerHTML; // <span class="entry-content"> 
     51                                         
     52                                        // <span class="published"> 
     53                                        var datestr : String = spantags[2].getAttribute("title"); 
     54                                        var postedtime : Date = new Date(Date.UTC( 
     55                                                datestr.substr(0, 4), // year 
     56                                                Number(datestr.substr(5, 2)) - 1, // month 
     57                                                datestr.substr(8, 2), // day 
     58                                                datestr.substr(11, 2), // hour 
     59                                                datestr.substr(14, 2), // minute 
     60                                                datestr.substr(17, 2) // second 
     61                                        )); 
     62                                         
     63                                        var replyid : String = "0"; 
     64                                        var replyhref : String = spantags[1].lastChild.getAttribute("href"); 
     65                                        if(replyhref != null){ 
     66                                                replyid = replyhref.match(/[0-9]++$/)[0]; 
     67                                        } 
     68                                         
     69                                        var fav : Boolean = doc.getElementById("status_star_" + postid).className == "fav"; 
     70                                         
     71        //                              trace(new Status(postid, postername, posterid, content, replyid, postedtime, iconurl, fav)); 
     72                                        ret.push(new Status(postid, postername, posterid, content, replyid, postedtime, iconurl, fav)); 
     73                                } 
     74                        }catch (e : Error) { 
     75                                trace(e.getStackTrace()); 
     76                                return { statuses : null, code : 1 }; 
    2877                        } 
    2978                         
    30                         var timeline : Object = html.window.document.getElementById("timeline_body").getElementsByTagName("tr"); 
    31                         for (var i : int = 0; i < timeline.length; i++) { 
    32                                 var element : Object = timeline[i]; 
     79                        return { statuses : ret, code : 0 }; 
     80                } 
     81                 
     82                public static function scrapeBit(html : HTMLLoader) : Object // {status : Status, code : int} 
     83                { 
     84                        try { 
     85                                var userinfo : Object = html.window.document.getElementById("permalink").childNodes[3]; 
     86                                var element : Object = html.window.document.getElementById("timeline_body"); 
    3387                                var atags : Object = element.getElementsByTagName("a"); 
    3488                                var spantags : Object = element.getElementsByTagName("span"); 
    3589                                 
    36                                 var postid : String = element.id.substr(7); 
     90                                var inputtags : Object = html.window.document.getElementById("content").getElementsByTagName("input"); 
    3791                                 
    38                                 if(!locally){ 
    39                                         iconurl = atags[0].firstChild.getAttribute("src"); 
    40                                         posterid = atags[1].innerHTML; 
    41                                         postername = atags[1].getAttribute("title"); 
     92                                var iconurl : String = userinfo.childNodes[1].firstChild.firstChild.getAttribute("src"); 
     93                                var posterid : String = userinfo.childNodes[3].firstChild.innerHTML; // <div class="screen-name"> 
     94                                var postername : String; 
     95                                if(userinfo.childNodes.length >= 6){ 
     96                                        postername = userinfo.childNodes[5].innerHTML; // <div class="full-name"> 
     97                                }else { 
     98                                        postername = posterid; 
    4299                                } 
    43100                                 
     101                                var postid : String = element.firstChild.id.substr(7); 
    44102                                var content : String = spantags[0].innerHTML; // <span class="entry-content"> 
    45                                  
    46103                                // <span class="published"> 
    47104                                var datestr : String = spantags[2].getAttribute("title"); 
     
    57114                                var replyid : String = "0"; 
    58115                                var replyhref : String = spantags[1].lastChild.getAttribute("href"); 
    59                                 if(replyhref != null)
     116                                if (replyhref != null)
    60117                                        replyid = replyhref.match(/[0-9]++$/)[0]; 
    61118                                } 
    62                                  
    63                                 var fav : Boolean = doc.getElementById("status_star_" + postid).className == "fav"; 
    64                                  
    65 //                              trace(new Status(postid, postername, posterid, content, replyid, postedtime, iconurl, fav)); 
    66                                 ret.push(new Status(postid, postername, posterid, content, replyid, postedtime, iconurl, fav)); 
     119                                var fav : Boolean = inputtags[inputtags.length - 1].className == "non-fav"; 
     120                        }catch (e : Error) { 
     121                                return { status : null, code : 1 }; 
    67122                        } 
    68123                         
    69                         return ret; 
    70                 } 
    71                  
    72                 public static function scrapeBit(html : HTMLLoader) : Status 
    73                 { 
    74                         var y : int; 
    75                          
    76                         var userinfo : Object = html.window.document.getElementById("permalink").childNodes[3]; 
    77                         var element : Object = html.window.document.getElementById("timeline_body"); 
    78                         var atags : Object = element.getElementsByTagName("a"); 
    79                         var spantags : Object = element.getElementsByTagName("span"); 
    80                          
    81                         var inputtags : Object = html.window.document.getElementById("content").getElementsByTagName("input"); 
    82                          
    83                         var iconurl : String = userinfo.childNodes[1].firstChild.firstChild.getAttribute("src"); 
    84                         var posterid : String = userinfo.childNodes[3].firstChild.innerHTML; // <div class="screen-name"> 
    85                         var postername : String; 
    86                         if(userinfo.childNodes.length >= 6){ 
    87                                 postername = userinfo.childNodes[5].innerHTML; // <div class="full-name"> 
    88                         }else { 
    89                                 postername = posterid; 
    90                         } 
    91                          
    92                         var postid : String = element.firstChild.id.substr(7); 
    93                         var content : String = spantags[0].innerHTML; // <span class="entry-content"> 
    94                         // <span class="published"> 
    95                         var datestr : String = spantags[2].getAttribute("title"); 
    96                         var postedtime : Date = new Date(Date.UTC( 
    97                                 datestr.substr(0, 4), // year 
    98                                 Number(datestr.substr(5, 2)) - 1, // month 
    99                                 datestr.substr(8, 2), // day 
    100                                 datestr.substr(11, 2), // hour 
    101                                 datestr.substr(14, 2), // minute 
    102                                 datestr.substr(17, 2) // second 
    103                         )); 
    104                          
    105                         var replyid : String = "0"; 
    106                         var replyhref : String = spantags[1].lastChild.getAttribute("href"); 
    107                         if (replyhref != null) { 
    108                                 replyid = replyhref.match(/[0-9]++$/)[0]; 
    109                         } 
    110                         var fav : Boolean = inputtags[inputtags.length - 1].className == "non-fav"; 
    111                          
    112124//                      trace(new Status(postid, postername, posterid, content, replyid, postedtime, iconurl, fav)); 
    113                         return new Status(postid, postername, posterid, content, replyid, postedtime, iconurl, fav)
     125                        return { status : new Status(postid, postername, posterid, content, replyid, postedtime, iconurl, fav), code : 0 }
    114126                } 
    115127