|
/** |
|
A Project in the Future using Skeleton CSS. |
|
*/ |
|
|
|
var SharePointNews = function() { |
|
// Use Powershell to get siteGUID. |
|
this.siteGUID = '504db699a61e4ad4b39bbeae516e0af4' || ''; |
|
// use JSOM to get webGUID: |
|
this.webGUID = '769d73c8a3f240e18129382f5f6d6ce9'; |
|
this.api_domain = |
|
window.location.protocol + |
|
'//' + |
|
window.location.host + |
|
'/sites/thewire/' || _spPageContextInfo.webAbsoluteUrl + '/'; |
|
}; |
|
|
|
SharePointNews.prototype = (function() { |
|
// Deal with Individual GET Requests: |
|
var getspListItemURL = function(listurl_, callback) { |
|
var def = $.Deferred(); |
|
return $.ajax({ |
|
url: listurl_, |
|
method: 'GET', |
|
headers: { |
|
Accept: 'application/json; odata=minimalmetadata' |
|
}, |
|
success: function() { |
|
callback(); |
|
def.resolve(); |
|
}, |
|
error: function(data) { |
|
callback(); |
|
def.resolve(); |
|
} |
|
}); |
|
return def.promise(); |
|
}; // getspListItemURL |
|
|
|
var checkVideoPresence = function(item, options, category, catId) { |
|
var _folderGUID = ''; |
|
|
|
$.when( |
|
getspListItemURL(item.Folder.__deferred.uri, function(data) {}) |
|
).done(function(data) { |
|
_folderGUID = data.d.UniqueId; |
|
|
|
// prettier-ignore |
|
var videoMarkup = '<div class="column small large-6">'+ |
|
'<a href="'+ api_domain +'pages/single_cascade_article.aspx#'+item.ID+'" class="clearfix">'+ |
|
'<div class="box_casc">'+ |
|
'<div class="casc_image">'+ |
|
'<iframe type="text/html" width="100%" height="100%" style="margin-top: 1px;"'+ |
|
'src="'+api_domain+'_layouts/15/videoembedplayer.aspx?'+ |
|
'site=' + options.siteGUID +'&web=' +options.webGUID +'&folder=' +_folderGUID +'&'+ |
|
'img=' +options.thumbnail +'">'+ |
|
'</iframe><span style="bottom: -0.50px;">'+category+'</span></div>'+ |
|
'<div class="casc_description eventTitle">'+ |
|
'<h1>'+item.Title+'</h1><p>'+options.description+'....</p><span>'+ |
|
customdateformats(item.Created, 'Day MonthShort Year')+'</span></div></div>'+ |
|
'</a></div>'; |
|
$('#' + catId).append(videoMarkup); |
|
}); |
|
}; // checkVideoPresence |
|
|
|
var getAllNewsFragments = function(listName, categoryID) { |
|
var req = $.ajax({ |
|
// prettier-ignore |
|
url: api_domain + "_api/web/lists/GetByTitle('"+listName+"')/items?$select=EncodedAbsUrl,*&$orderby=ID desc", |
|
type: 'GET', |
|
headers: { |
|
accept: 'application/json;odata=verbose' |
|
} |
|
}); |
|
|
|
req.done(function(data) { |
|
var defaultView = new Array(); |
|
$.each(data.value, function(index, item) { |
|
var _contentType = item.VideoHeightInPixels != null ? 'video' : 'image'; |
|
// prettier-ignore |
|
var _thumbNail = item.AlternateThumbnailUrl != null ? item.AlternateThumbnailUrl.Url : item.EncodedAbsUrl; |
|
var options = { |
|
contenttype: _contentType, |
|
thumbnail: _thumbNail |
|
}; |
|
|
|
if (_contentType !== 'video') { |
|
// prettier-ignore |
|
var $evrythng = '<div class="column small large-6">'+ |
|
'<a href="'+ api_domain +'pages/single_cascade_article.aspx#'+item.ID+'" class="clearfix">'+ |
|
' <div class="box_casc">'+ |
|
' <div class="casc_image" style="background-image: url('+item.EncodedAbsUrl+');"><span>'+item.bulletins+'</span></div>'+ |
|
' <div class="casc_description">'+ |
|
' <h1>' +item.Title +'</h1>'+ |
|
' <span>'+String.format("{0:d}", new Date(item.Created)) +'</span>'+ |
|
' </div>'+ |
|
' </div>'+ |
|
'</a></div>'; |
|
defaultView.push($evrythng); |
|
} else { |
|
// prettier-ignore |
|
checkVideoPresence(item,options,item.bulletins,categoryID); |
|
} |
|
}); // Loop |
|
|
|
// Render your Markup |
|
$('body').html(defaultView); |
|
}); |
|
}; |
|
|
|
return { |
|
getAllNewsFragments: getAllNewsFragments |
|
}; |
|
})(); |
|
|
|
// Consume the Module: |
|
var newsGetter = new SharePointNews(); |
|
newsGetter.getAllNewsFragments('', ''); |