<commit_before>//
//  SettingTableViewController.swift
//  MT_iOS
//
//  Created by CHEEBOW on 2015/05/19.
//  Copyright (c) 2015年 Six Apart, Ltd. All rights reserved.
//

import UIKit
import SVProgressHUD
import SwiftyJSON

class SettingTableViewController: BaseTableViewController {
    enum Section: Int {
        case Item = 0,
        Logout,
        _Num
    }
    
    enum Item: Int {
        case Help = 0,
        License,
        ReportBug,
        _Num
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
        
        self.title = NSLocalizedString("Setting", comment: "Setting")
        self.tableView.backgroundColor = Color.tableBg

        self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "btn_close"), left: true, target: self, action: "closeButtonPushed:")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return Section._Num.rawValue
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete method implementation.
        // Return the number of rows in the section.
        switch section {
        case Section.Item.rawValue:
            return Item._Num.rawValue
        case Section.Logout.rawValue:
            return 1
        default:
            return 0
        }
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = UITableViewCell()

        switch indexPath.section {
        case Section.Item.rawValue:
            cell = tableView.dequeueReusableCellWithIdentifier("ItemCell", forIndexPath: indexPath) as! UITableViewCell

            self.adjustCellLayoutMargins(cell)

            switch indexPath.row {
            case Item.Help.rawValue:
                cell.textLabel?.text = NSLocalizedString("Help", comment: "Help")
            case Item.License.rawValue:
                cell.textLabel?.text = NSLocalizedString("License", comment: "License")
            case Item.ReportBug.rawValue:
                cell.textLabel?.text = NSLocalizedString("Report bug", comment: "Report bug")
            default:
                break
            }
        case Section.Logout.rawValue:
            cell = tableView.dequeueReusableCellWithIdentifier("LogoutCell", forIndexPath: indexPath) as! UITableViewCell
            cell.textLabel?.text = NSLocalizedString("Logout", comment: "Logout")
        default:
            break
        }

        // Configure the cell...

        return cell
    }

    /*
    // Override to support conditional editing of the table view.
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return NO if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            // Delete the row from the data source
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return NO if you do not want the item to be re-orderable.
        return true
    }
    */
    
    // MARK: - Table view delegte
    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        switch indexPath.section {
        case Section.Item.rawValue:
            switch indexPath.row {
            case Item.Help.rawValue:
                var vc = CommonWebViewController()
                vc.urlString = HELP_URL
                if Utils.preferredLanguage() != "ja" {
                    vc.urlString += "/en"
                }
                self.navigationController?.pushViewController(vc, animated: true)
            case Item.License.rawValue:
                var vc = CommonWebViewController()
                let path = NSBundle.mainBundle().pathForResource("license", ofType: "html")
                vc.filePath = path!<commit_msg>Fixed invalid url.<commit_after>//
//  SettingTableViewController.swift
//  MT_iOS
//
//  Created by CHEEBOW on 2015/05/19.
//  Copyright (c) 2015年 Six Apart, Ltd. All rights reserved.
//

import UIKit
import SVProgressHUD
import SwiftyJSON

class SettingTableViewController: BaseTableViewController {
    enum Section: Int {
        case Item = 0,
        Logout,
        _Num
    }
    
    enum Item: Int {
        case Help = 0,
        License,
        ReportBug,
        _Num
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
        
        self.title = NSLocalizedString("Setting", comment: "Setting")
        self.tableView.backgroundColor = Color.tableBg

        self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "btn_close"), left: true, target: self, action: "closeButtonPushed:")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return Section._Num.rawValue
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete method implementation.
        // Return the number of rows in the section.
        switch section {
        case Section.Item.rawValue:
            return Item._Num.rawValue
        case Section.Logout.rawValue:
            return 1
        default:
            return 0
        }
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = UITableViewCell()

        switch indexPath.section {
        case Section.Item.rawValue:
            cell = tableView.dequeueReusableCellWithIdentifier("ItemCell", forIndexPath: indexPath) as! UITableViewCell

            self.adjustCellLayoutMargins(cell)

            switch indexPath.row {
            case Item.Help.rawValue:
                cell.textLabel?.text = NSLocalizedString("Help", comment: "Help")
            case Item.License.rawValue:
                cell.textLabel?.text = NSLocalizedString("License", comment: "License")
            case Item.ReportBug.rawValue:
                cell.textLabel?.text = NSLocalizedString("Report bug", comment: "Report bug")
            default:
                break
            }
        case Section.Logout.rawValue:
            cell = tableView.dequeueReusableCellWithIdentifier("LogoutCell", forIndexPath: indexPath) as! UITableViewCell
            cell.textLabel?.text = NSLocalizedString("Logout", comment: "Logout")
        default:
            break
        }

        // Configure the cell...

        return cell
    }

    /*
    // Override to support conditional editing of the table view.
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return NO if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            // Delete the row from the data source
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return NO if you do not want the item to be re-orderable.
        return true
    }
    */
    
    // MARK: - Table view delegte
    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        switch indexPath.section {
        case Section.Item.rawValue:
            switch indexPath.row {
            case Item.Help.rawValue:
                var vc = CommonWebViewController()
                vc.urlString = HELP_URL
                if Utils.preferredLanguage() != "ja" {
                    vc.urlString += "en"
                }
                self.navigationController?.pushViewController(vc, animated: true)
            case Item.License.rawValue:
                var vc = CommonWebViewController()
                let path = NSBundle.mainBundle().pathForResource("license", ofType: "html")
                vc.filePath = path!
{'fraction_non_alphanumeric': 0.07957707289927657, 'fraction_numerical': 0.0029679094787608976, 'mean_word_length': 2.244959374059585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6273039', 'n_tokens_mistral': 2933, 'n_tokens_neox': 2710, 'n_words': 809}