<commit_before><!DOCTYPE html>  
<html><head>  
<meta http-equiv="X-UA-Compatible" content="IE=edge" />  
<title>openui5-cards Search</title>  

<!--Standard sapui5 init-->
<script id="sap-ui-bootstrap" 
    src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" 
    data-sap-ui-theme="sap_bluecrystal"
    data-sap-ui-libs="sap.m,sap.ui.commons"></script> 

<!--CSS required by open.m.Card
Needs to be after sapui5 init in order to override styles-->
<link href="openui5-cards.css" type="text/css" rel="stylesheet"/>
<script src="openui5-cards.js"></script>

<style>
/*overwriting title size to smaller value*/
h1.cardTitle1 {
  font-size:1.5rem;
}
</style>

<script> 
var oModel = new sap.ui.model.json.JSONModel();

 
var cardFactory = function(sId, oContext) { 
    var oCard = new open.m.Card(sId)
        .bindProperty("title", oContext.sPath+"/title")
        .bindProperty("subtitle", oContext.sPath+"/actor/displayName")
        .bindProperty("image", oContext.sPath+"/object/attachments",function(postAttachments){
                //surely there is a better way of handling bindings like this one
                if(postAttachments!= null && postAttachments.length>=1){
                    return postAttachments[0].image.url;
                }else {
                    return null;
                }
            }
        ); 

    var viewLink = oContext.getModel().getProperty(oContext.sPath+"/url");
    
    var fullImageLink = null;
    var postAttachments = oContext.getModel().getProperty(oContext.sPath+"/object/attachments");
    if(postAttachments!= null && postAttachments.length>=1){
        fullImageLink= postAttachments[0].fullImage.url;
    }


    //add menu
    oCard.setMenu(new sap.m.ActionSheet(sId+"menu1",{
        title: "Options",
        showCancelButton: false,
        placement: sap.m.PlacementType.Bottom,
        buttons: [
            new sap.m.Button({
                icon: "sap-icon://arrow-top",
                text: "+1",
                press: function(){
                    jQuery.sap.require("sap.m.MessageToast");
                    sap.m.MessageToast.show("Not implemented (ie. Left as an exercise for the user)");
                }
            }),
        ]
        }));

    return oCard;
};

var headerCard = new open.m.Card("initialCard",
            {title:"<strong>About</strong>",
            subtitle:"Demonstrates binding to a dynamic JSONModel based on queries (to Google Places API)",})


var cardContainer = new open.m.CardContainer("myCardContainer", {
        showSearchField:true,
        SearchFieldPlaceHolderText:"Please search for places nearby",
        minHeight:"40em",
        searchLiveChange:function(oEvent){
            //strange. why do we need two getParameters?
            $.sap.log.error("Search field live change:" +oEvent.getParameters().getParameters().newValue);
        },
        headerCard:headerCard,
});

cardContainer.setModel(oModel);
//cardContainer.bindAggregation("content","/items", cardFactory); 

if (navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function(position){
        $.sap.log.error("LAT:"+position.coords.latitude + " LON:"+position.coords.longitude);

    }
        );
}



var app = new sap.m.App({initialPage:"openui5-cards"});
app.placeAt("content");

var pageContent = new sap.m.Page("openui5-cards",{title:"GooglePlaces OpenUI5-Cards"});
pageContent.addContent(cardContainer);
app.addPage(pageContent);

//ugly hack to get voice search 
//Believe I need to create my own subclass of sap.m.Input to avoid it 
$(document).ready(function() {
    $(".cardSearch > input").attr("x-webkit-speech", ""); 
})
</script>

</head>
<body class="sapUiBody">
    <div id="content"></div>
</body>
</html><commit_msg>Google places example<commit_after><!DOCTYPE html>  
<html><head>  
<meta http-equiv="X-UA-Compatible" content="IE=edge" />  
<title>openui5-cards Search</title>  

<!--Standard sapui5 init-->
<script id="sap-ui-bootstrap" 
    src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" 
    data-sap-ui-theme="sap_bluecrystal"
    data-sap-ui-libs="sap.m,sap.ui.commons"></script> 

<!--CSS required by open.m.Card
Needs to be after sapui5 init in order to override styles-->
<link href="openui5-cards.css" type="text/css" rel="stylesheet"/>
<script src="openui5-cards.js"></script>

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script>

<style>
/*overwriting title size to smaller value*/
h1.cardTitle1 {
  font-size:1.5rem;
}
</style>

<script> 
//Get location of user
var position = null;
if (navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function(aPosition){
        position=aPosition;
        jQuery.sap.require("sap.m.MessageToast");
        sap.m.MessageToast.show("Your location has been determined. Now the search will work");
        $.sap.log.error("LAT:"+position.coords.latitude + " LON:"+position.coords.longitude);
    });
}

//Model will be populated after each executed search
var oModel = new sap.ui.model.json.JSONModel();

//CardFactory is used to create a single card based on a JSON subset from the search  
var cardFactory = function(sId, oContext) { 
    var oCard = new open.m.Card(sId)
        .bindProperty("title", oContext.sPath+"/name")
        .bindProperty("subtitle", oContext.sPath+"/vicinity")
        .bindProperty("address", oContext.sPath+"/vicinity");


    //add menu
    oCard.setMenu(new sap.m.ActionSheet(sId+"menu1",{
        title: "Options",
        showCancelButton: false,
        placement: sap.m.PlacementType.Bottom,
        buttons: [
            new sap.m.Button({
                icon: "sap-icon://arrow-top",
                text: "+1",
                press: function(){
                    jQuery.sap.require("sap.m.MessageToast");
                    sap.m.MessageToast.show("Not implemented (ie. Left as an exercise for the user)");
                }
            }),
        ]
        }));

    return oCard;
};

//headerCard is always displayed first
var headerCard = new open.m.Card("initialCard",
            {title:"<strong>About</strong>",
            subtitle:"Demonstrates binding to a dynamic JSONModel based on queries (to Google Places API). Usage: Try search for pizza",})


var cardContainer = new open.m.CardContainer("myCardContainer", {
        showSearchField:true,
        SearchFieldPlaceHolderText:"Please search for places nearby",
        minHeight:"40em",
        searchLiveChange:function(oEvent){
            //Handle the search. Called once for each letter
            //strange. why do we need two getParameters?
            var searchQuery = oEvent.getParameters().getParameters().newValue;
            $.sap.log.error("Search field live change:" +searchQuery);
            if(searchQuery!=null && searchQuery.length>=4){
                if(position==null){
                    cardContainer.setHeaderCard(new open.m.Card(
                            {title:"<strong>Error</strong>",
                            subtitle:"Your location is not found. Accept the request for location determination and try again",})
                    );
                    return;
                }

                //Perform the search and update the model accordingly
                var myLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);

                var request = {
                    location: myLocation,
                    radius: '5000',
                    keyword: searchQuery
                };

                var mapsService = new google.maps.places.PlacesService(document.getElementById("mapsAttribution"));
                cardContainer.setHeaderCard(null);
                oModel.setData(null);

                //Perform the search
                mapsService.nearbySearch(request, function (results,status){
                    $.sap.log.error(status+ " "+ results);
                    
                    if (status == google.maps.places.PlacesServiceStatus.OK) {
                        //model will trigger update of view automatically
                        oModel.setData(results);
                    }else {
                        cardContainer.setHeaderCard(new open.m.Card(
                            {title:"<strong>Error</strong>",
                            subtitle:"Message:" + status,}));
                    }
                });
            }
        },
        headerCard:headerCard,
});



cardContainer.setModel(oModel);
cardContainer.bindAggregation("cards","/", cardFactory);


var app = new sap.m.App({initialPage:"openui5-cards"});
app.placeAt("content");

var pageContent = new sap.m.Page("openui5-cards",{title:"GooglePlaces OpenUI5-Cards"});
pageContent.addContent(cardContainer);
app.addPage(pageContent);

//ugly hack to get voice search 
//Believe I need to create my own subclass of sap.m.Input to avoid it 
$(document).ready(function() {
    $(".cardSearch > input").attr("x-webkit-speech", ""); 
})
</script>

</head>
<body class="sapUiBody">
    <div id="content"></div>
    <div id="mapsAttribution"></div>
</body>
</html>
{'fraction_non_alphanumeric': 0.13856080489938757, 'fraction_numerical': 0.004702537182852144, 'mean_word_length': 2.4692716236722307, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 66, 'https://': 2, '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': '5164739', 'n_tokens_mistral': 2721, 'n_tokens_neox': 2647, 'n_words': 558}