<!-- Retrieve Data For Events-->
<script type="text/javascript">
window.onload = loadv;
function loadv() {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveAllListPropertiesEvent);
}
var collListItemEvent;
var collListItemAnnouncement;
function retrieveAllListPropertiesEvent() {
var clientContext = new SP.ClientContext.get_current();
var clientContextAnn = new SP.ClientContext.get_current();
var oWebsite = clientContext.get_web();
var oWebsiteAnn = clientContextAnn.get_web();
var collList = oWebsite.get_lists().getByTitle('OoredooEvents');
var collListAnn = oWebsiteAnn.get_lists().getByTitle('OoredooAnnouncement');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name=\'ID\' Ascending=\'FALSE\'/></OrderBy></Query><RowLimit>4</RowLimit></View>');
collListItemEvent = collList.getItems(camlQuery);
collListItemAnnouncement = collListAnn.getItems(camlQuery);
clientContext.load(collListItemAnnouncement)
clientContextAnn.load(collListItemEvent);
clientContextAnn.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededAnn), Function.createDelegate(this, this.onQueryFailedAnn));
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededEvent), Function.createDelegate(this, this.onQueryFailedEvent));
}
function onQuerySucceededAnn(){
var countAnn = 0;
var listEnumeratorAnn = collListItemAnnouncement.getEnumerator();
while(listEnumeratorAnn.moveNext()){
var oListAnn = listEnumeratorAnn.get_current();
countAnn++;
$("#AnnouncementTitle" + countAnn).text(oListAnn.get_item("Title"));
$("#AnnouncementDesc" + countAnn).text(oListAnn.get_item("Values"));
}
var count = 0;
var listEnumerator = collListItemEvent.getEnumerator();
var imgID = '';
while (listEnumerator.moveNext()) {
var oList = listEnumerator.get_current();
count++;
$("#EventTitle" + count).text(oList.get_item("Title"));
imgID = 'EventURL' + count;
var imageSrc =oList.get_item("url");
var input = document.getElementById(imgID);
input.src = imageSrc;
}
}
function onQueryFailedAnn(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
<!--End of Retrieve Data For Events-->
No comments:
Post a Comment