<commit_before>Ti.include("../assets/utils.js");

win.title = win.info && win.info.title ? win.info.title : "Forum";
//Ti.UI.createAlertDialog({title:"DEBUG",message:"Came this far!"}).show();
var spinner = Ti.UI.createActivityIndicator({ style: Ti.UI.iPhone.ActivityIndicatorStyle.BIG }),
    setupPageControl = false,
    pageSelect = $.create({
        type: "View",
        opacity: 0,
        backgroundColor: "#000",
        childElements: [{
            type: "Button",
            title: "Go",
            top: 80,
            height: 20,
            width: 50,
            color: "black",
            click: function(e){
                var val = Math.round(pageSelect.childrenById.slider.value);
                togglePageSelect();
                win.remove(view);
                win.rightNavButton.title = "page "+val+"/"+win.pages;
                $.ajax({
                    url: getREST(win.path,Math.round(val),win.perpage),
                    success: receiveData,
                    fail: function(e){ $.msg(win,"Network fail!"); }
                });
            }
        },{
            type: "Label",
            top: 50,
            height: 20,
            color: "#FFF",
            id: "label",
            text: "page",
            textAlign: "center"
        },{
            type: "Slider",
            min: 1,
            max: 666,
            id: "slider",
            width: 250,
            top: 30,
            eventListeners: {
                change: function(e){
                    pageSelect.childrenById.label.text = "page "+Math.round(e.value);
                }
            }
        }]
    }),
    showingPageSelect = false,
    view;
    
//Ti.UI.createAlertDialog({title:"DEBUG",message:"Came THIS far! WEEE!"}).show();

function getREST(path,page,perpage){
    var bit = (page>1 ? path.replace("/?wap2","/"+((page-1)*perpage)+"/?wap2") : path || "");
    REST = 'http://query.yahooapis.com/v1/public/yql?q=use "http://79.99.1.153/yql/trist/tristania_forum.xml?20" as tf; select * from tf where path = "@bit"&format=json'.esc({
		bit: bit
	});
    Ti.API.log(["REST",bit,REST]);
    return REST;
}

win.add(spinner);
spinner.show();
win.add(pageSelect);

$.ajax({
    url: getREST(win.path,win.page,win.perpage),
    success: receiveData,
    fail: function(e){ $.msg(win,"Network fail!"); }
});

function togglePageSelect(){
    (showingPageSelect ? pageSelect : view).animate({duration: 500, opacity: 0});
    (showingPageSelect ? view : pageSelect).animate({duration: 500, opacity: 1});
    showingPageSelect = !showingPageSelect;
    win.rightNavButton.selected = showingPageSelect;
}

function pageControl(){
    if (win.pages>1 && !setupPageControl){
        pageSelect.childrenById.slider.max = win.pages;
        pageSelect.childrenById.slider.value = win.page;
        win.rightNavButton = $.create({
            type: "Button",
            title:"page 1/"+win.pages,
            click: togglePageSelect
        });
        setupPageControl = true;
    }
}

function receiveData(d){
if (!d.query || !d.query.results || !d.query.results.res){
    Ti.API.error("WTF?!?!");
    Ti.API.log(d);
    return;
}
    d = d.query.results.res;
    win.title = d.title || win.title;
Ti.API.log("POOP!");

    if (d.posts){
        win.pages = d.posts.pages;
        win.page = d.posts.page;
        win.perpage = 5;
Ti.API.log(["WEBVIEWPOSTS!",d.posts]);<commit_msg>incremental build of tourdates table<commit_after>Ti.include("../assets/utils.js");

win.title = win.info && win.info.title ? win.info.title : "Forum";
//Ti.UI.createAlertDialog({title:"DEBUG",message:"Came this far!"}).show();
var spinner = Ti.UI.createActivityIndicator({ style: Ti.UI.iPhone.ActivityIndicatorStyle.BIG }),
    setupPageControl = false,
    pageSelect = $.create({
        type: "View",
        opacity: 0,
        backgroundColor: "#000",
        childElements: [{
            type: "Button",
            title: "Go",
            top: 80,
            height: 20,
            width: 50,
            color: "black",
            click: function(e){
                var val = Math.round(pageSelect.childrenById.slider.value);
                togglePageSelect();
                win.remove(view);
                win.rightNavButton.title = "page "+val+"/"+win.pages;
                $.ajax({
                    url: getREST(win.path,Math.round(val),win.perpage),
                    success: receiveData,
                    fail: function(e){ $.msg(win,"Network fail!"); }
                });
            }
        },{
            type: "Label",
            top: 50,
            height: 20,
            color: "#FFF",
            id: "label",
            text: "page",
            textAlign: "center"
        },{
            type: "Slider",
            min: 1,
            max: 666,
            id: "slider",
            width: 250,
            top: 30,
            eventListeners: {
                change: function(e){
                    pageSelect.childrenById.label.text = "page "+Math.round(e.value);
                }
            }
        }]
    }),
    showingPageSelect = false,
    view;
    
//Ti.UI.createAlertDialog({title:"DEBUG",message:"Came THIS far! WEEE!"}).show();

function getREST(path,page,perpage){
    var bit = (page>1 ? path.replace("/?wap2","/"+((page-1)*perpage)+"/?wap2") : path || "");
    REST = 'http://query.yahooapis.com/v1/public/yql?q=use "http://192.168.3.11/yql/trist/tristania_forum.xml?20" as tf; select * from tf where path = "@bit"&format=json'.esc({
		bit: bit
	});
    Ti.API.log(["REST",bit,REST]);
    return REST;
}

win.add(spinner);
spinner.show();
win.add(pageSelect);

$.ajax({
    url: getREST(win.path,win.page,win.perpage),
    success: receiveData,
    fail: function(e){ $.msg(win,"Network fail!"); }
});

function togglePageSelect(){
    (showingPageSelect ? pageSelect : view).animate({duration: 500, opacity: 0});
    (showingPageSelect ? view : pageSelect).animate({duration: 500, opacity: 1});
    showingPageSelect = !showingPageSelect;
    win.rightNavButton.selected = showingPageSelect;
}

function pageControl(){
    if (win.pages>1 && !setupPageControl){
        pageSelect.childrenById.slider.max = win.pages;
        pageSelect.childrenById.slider.value = win.page;
        win.rightNavButton = $.create({
            type: "Button",
            title:"page 1/"+win.pages,
            click: togglePageSelect
        });
        setupPageControl = true;
    }
}

function receiveData(d){
    if (!d.query || !d.query.results || !d.query.results.res || !d.query.results.res){
        $.create({
            type: "AlertDialog",
            title: "Error",
            message: "Forum seems to be offline. Please try again later!",
            click: function(){
                win.close();
            }
        }).show();
        return;
    }
    d = d.query.results.res;
    win.title = d.title || win.title;
Ti.API.log("POOP!");

    if (d.posts){
        win.pages = d.posts.pages;
        win.page = d.posts.page;
        win.perpage = 5;
Ti.API.log(["WEBVIEWPOSTS!",d.posts]);
{'fraction_non_alphanumeric': 0.16426553672316385, 'fraction_numerical': 0.013983050847457627, 'mean_word_length': 1.9777123633305298, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 2, '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': '7224874', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2170, 'n_words': 403}