<commit_before>//
//  WikiArticleViewController.swift
//  HiChongSwift
//
//  Created by eagle on 14/12/25.
//  Copyright (c) 2014年 多思科技. All rights reserved.
//

import UIKit
import WebKit

class WikiArticleViewController: UIViewController {
    
    @IBOutlet private weak var icyWebView: UIWebView!
    
    var wikiArticleID: String?
    var wikiCollected: Bool? {
        didSet {
            if let collected = wikiCollected {
                navigationItem.rightBarButtonItem?.enabled = true
                if collected {
                    navigationItem.rightBarButtonItem?.title = "取消收藏"
                } else {
                    navigationItem.rightBarButtonItem?.title = "加入收藏"
                }
            } else {
                navigationItem.rightBarButtonItem?.enabled = false
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
        if let wikiID = wikiArticleID {
            // 显示详情
            let URLString = LCYNetworking.sharedInstance.WikiHTMLAddress(wikiID)
            let URLRequest = NSURLRequest(URL: NSURL(string: URLString)!)
            println("URL =||| \(URLString)")
            icyWebView.loadRequest(URLRequest)
            // 判断收藏情况
            if let collected = wikiCollected {
                wikiCollected = collected
            } else {
                let parameters = [
                    "user_name" : LCYCommon.sharedInstance.userName!,
                    "ency_id"   : wikiID
                ]
                LCYNetworking.sharedInstance.POSTNONEJSON(LCYApi.WikiIsCollect, parameters: parameters, success: { [weak self] in
                    if $0 == "true" {
                        self?.wikiCollected = true
                    } else {
                        self?.wikiCollected = false
                    }
                    return
                    }, failure: { (error) -> Void in
                        return
                })
            }
        } else {
            alert("无法加载信息")
        }
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        
        icyWebView.reload()<commit_msg>修复了每次阅读数量＋2的bug<commit_after>//
//  WikiArticleViewController.swift
//  HiChongSwift
//
//  Created by eagle on 14/12/25.
//  Copyright (c) 2014年 多思科技. All rights reserved.
//

import UIKit
import WebKit

class WikiArticleViewController: UIViewController {
    
    @IBOutlet private weak var icyWebView: UIWebView!
    
    var wikiArticleID: String?
    var wikiCollected: Bool? {
        didSet {
            if let collected = wikiCollected {
                navigationItem.rightBarButtonItem?.enabled = true
                if collected {
                    navigationItem.rightBarButtonItem?.title = "取消收藏"
                } else {
                    navigationItem.rightBarButtonItem?.title = "加入收藏"
                }
            } else {
                navigationItem.rightBarButtonItem?.enabled = false
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
        if let wikiID = wikiArticleID {
            // 显示详情
            let URLString = LCYNetworking.sharedInstance.WikiHTMLAddress(wikiID)
            let URLRequest = NSURLRequest(URL: NSURL(string: URLString)!)
            println("URL =||| \(URLString)")
            icyWebView.loadRequest(URLRequest)
            // 判断收藏情况
            if let collected = wikiCollected {
                wikiCollected = collected
            } else {
                let parameters = [
                    "user_name" : LCYCommon.sharedInstance.userName!,
                    "ency_id"   : wikiID
                ]
                LCYNetworking.sharedInstance.POSTNONEJSON(LCYApi.WikiIsCollect, parameters: parameters, success: { [weak self] in
                    if $0 == "true" {
                        self?.wikiCollected = true
                    } else {
                        self?.wikiCollected = false
                    }
                    return
                    }, failure: { (error) -> Void in
                        return
                })
            }
        } else {
            alert("无法加载信息")
        }
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        
//        icyWebView.reload()
{'fraction_non_alphanumeric': 0.0819562304600268, 'fraction_numerical': 0.00513622152746762, 'mean_word_length': 1.3635883905013193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3423626', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1195, 'n_words': 243}