Scroll view doesn't scroll after inserting widget buttons - view

I'm making our capstone project, its for disaster preparedness, but my problem is this scroll view wont scroll after placing widget tabs. It scrolled before placing the buttons. I use widget buttons so that it will look like this.
Code:
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local widget = require "widget"
function scene:createScene( event )
local group = self.view
background = display.newImage("ehead.png", true)
background.x = 360
background.y = 150
group:insert(background)
local function onBackbuttonRelease()
storyboard.gotoScene( "mainmenu", "slideRight", 200)
return true
end
local Backbutton = widget.newButton
{
defaultFile = "back.png",
overFile = "back2.png",
onRelease = onBackbuttonRelease
}
Backbutton.x = 45 ; Backbutton.y = 105
group:insert( Backbutton )
local scrollView = widget.newScrollView
{
top = 180,
left = 6,
width = display.contentWidth,
height = display.contentHeight,
scrollWidth = display.contentWidth,
scrollHeight = 8000
}
group:insert(scrollView)
local options = {
text = "",
width = 700,
font = "HelveticaNeue",
fontSize = 50,
align = "center"
}
local altavas= widget.newButton
{
defaultFile = "al.png",
overFile = "al2.png",
onRelease = onaltavasRelease
}
altavas.x = 354; altavas.y = 70
scrollView:insert( altavas )
local balete= widget.newButton
{
defaultFile = "ba.png",
overFile = "ba2.png",
onRelease = onbaleteRelease
}
balete.x = 354; balete.y = 190
scrollView:insert( balete )
local banga= widget.newButton
{
defaultFile = "ban.png",
overFile = "ban2.png",
onRelease = onbangaRelease
}
banga.x = 354; banga.y = 310
scrollView:insert( banga )
local buruanga = widget.newButton
{
defaultFile = "bu.png",
overFile = "bu2.png",
onRelease = onburuangaRelease
}
buruanga.x = 354; buruanga.y = 430
scrollView:insert( buruanga )
local ibajay = widget.newButton
{
defaultFile = "ib.png",
overFile = "ib2.png",
onRelease = onibajayRelease
}
ibajay.x = 354; ibajay.y = 550
scrollView:insert( ibajay )
local kalibo = widget.newButton
{
defaultFile = "ka.png",
overFile = "ka2.png",
onRelease = onkaliboRelease
}
kalibo.x = 354; kalibo.y = 670
scrollView:insert( kalibo )
local lezo = widget.newButton
{
defaultFile = "le.png",
overFile = "le2.png",
onRelease = onlezoRelease
}
lezo.x = 354; lezo.y = 790
scrollView:insert( lezo )
local libacao = widget.newButton
{
defaultFile = "li.png",
overFile = "li2.png",
onRelease = onlibacaoRelease
}
libacao.x = 354; libacao.y = 910
scrollView:insert( libacao )
local madalag = widget.newButton
{
defaultFile = "ma.png",
overFile = "ma2.png",
onRelease = onmadalagRelease
}
madalag.x = 354; madalag.y = 1030
scrollView:insert( madalag )
local makato = widget.newButton
{
defaultFile = "mak.png",
overFile = "mak2.png",
onRelease = onmakatoRelease
}
makato.x = 354; makato.y = 1150
scrollView:insert( makato )
local malay = widget.newButton
{
defaultFile = "mal.png",
overFile = "mal2.png",
onRelease = onmalayRelease
}
malay.x = 354; malay.y = 1270
scrollView:insert( malay )
local malinao = widget.newButton
{
defaultFile = "mali.png",
overFile = "mali2.png",
onRelease = onmalinaoRelease
}
malinao.x = 354; malinao.y = 1390
scrollView:insert( malinao )
local nabas = widget.newButton
{
defaultFile = "na.png",
overFile = "na2.png",
onRelease = onnabasRelease
}
nabas.x = 354; nabas.y = 1510
scrollView:insert( nabas )
local nw = widget.newButton
{
defaultFile = "nw.png",
overFile = "nw2.png",
onRelease = onnwRelease
}
nw.x = 354; nw.y = 1630
scrollView:insert( nw )
local numancia = widget.newButton
{
defaultFile = "nu.png",
overFile = "nu2.png",
onRelease = onnumanciaRelease
}
numancia.x = 354; numancia.y = 1750
scrollView:insert( numancia )
local tangalan = widget.newButton
{
defaultFile = "ta.png",
overFile = "ta2.png",
onRelease = ontangalanRelease
}
tangalan.x = 354; tangalan.y = 1870
scrollView:insert( tangalan )
end
scene:addEventListener( "createScene", scene )
return scene

This is quite simple just use: https://docs.coronalabs.com/api/type/ScrollViewWidget/takeFocus.html
but I encourage You to make custom buttons instead of using widget.newButton.
But if You still prefer to use widget.newButton take a look here:
https://forums.coronalabs.com/topic/42033-widget-button-inside-a-scrollview-doesnt-work-when-i-use-the-takefocus-method/

Related

Multiple People Picker Columns (fields) on one form

SharePoint Online: I have multiple people picker columns and enter in a number of places people. I get the people OK but it won't update. It says it the entry is undefined. I thought maybe separating each out would work but obviously not. I hope I get some help on this one. What I want to do is to allow users to enter names into where the div entries are and as a people picker. I accomplished that but when you submit the form it says that any entry other than the first is undefined.
<script type = "text/javascript" src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js" > < /script>
<script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
<script type="text/javascript" src="/_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="/_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="/_layouts/15/clientpeoplepicker.js"></script>
<script type="text/javascript" src="/_layouts/15/autofill.js"></script>
<script type="text/javascript" src="/_layouts/15/1033/sts_strings.js"></script>
<script type="text/javascript">
var prim5 = 0;var sec4 = 0;var auth5 = 0;
var EorB25 = "";var BorE25 = "";var BorE35 = "";var siteUrl = "https://sp-cloud.kp.org/sites/MedicaidRepository";var cat25 = "";var regimpact = "";var regimpact1 = "";var prim25="";var sec25="";
var auth25="";var s1 = "";var soxD1 = "";var k1 = 'No';var com2 = "";var sDate1 = "";var sSever = "";var kDate1 = "";var finalusersP = [];var finalusers22 = [];var finalusersK = [];var user22 = [];var userK = [];var userP = [];var users22 = [];var usersK = [];var usersP = [];var userPemail = "";var userKemail = "";var user22email = "";
var tDay = new Date();
var dd = tDay.getDate();
var mm = tDay.getMonth()+1;
var yy = tDay.getFullYear();
var sDate = mm+ '/' +dd+ '/' +yy;
$(document).ready(function() {
prim5 = 1;
initializePeoplePickerP('peoplePickerDivP');
registerPPOnChangeEventP($('#peoplePickerDivP'));
});
$(document).ready(function() {
sec5 = 1;
initializePeoplePickerS('peoplePickerDivS');
registerPPOnChangeEventS($('#peoplePickerDivS'));
});
$(document).ready(function() {
auth5 = 1;
initializePeoplePickerK('peoplePickerDivK');
registerPPOnChangeEventK($('#peoplePickerDivK'));
});
function initializePeoplePickerP(peoplePickerElementIdP, UsersP) {
if (typeof(UsersP) == 'undefined') UsersP = null;
console.log('UsersP: ' +UsersP);
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = true;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementIdP, null, schema);
}
function initializePeoplePickerS(peoplePickerElementIdS, Users22) {
if (typeof(Users22) == 'undefined') Users22 = null;
console.log('Users22: ' +Users22);
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = true;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementIdS, null, schema);
}
function initializePeoplePickerK(peoplePickerElementIdK, UsersK) {
if (typeof(UsersK) == 'undefined') UsersK = null;
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = true;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementIdK, null, schema);
}
function registerPPOnChangeEventP(ppElement) {
var ppId = ppElement.attr('id') + "_TopSpan";
console.log('ppID: ' +ppId);
//var addOnChanged = function(ctx) {
if (SPClientPeoplePicker &&
SPClientPeoplePicker.SPClientPeoplePickerDict &&
SPClientPeoplePicker.SPClientPeoplePickerDict[ppId]) {
console.log("In registerPPOnChangeEvent if");
var picker = SPClientPeoplePicker.SPClientPeoplePickerDict[ppId];
picker.oldChanged = picker.OnControlResolvedUserChanged;
//var ppidTest = picker.toString();
console.log("picker: " +picker);
//OnControlResolvedUserChanged
picker.OnControlResolvedUserChanged = function () {
if (picker.TotalUserCount == 0) {
$('#resolvedUsers').html("");
$('#userKeys').html("");
$('#userProfileProperties').html("");
$('#userID').html("");
} else {
setTimeout(function () {
getUserInfoP();
},
100);
}
picker.oldChanged();
}
} else {
// setTimeout(function () { addOnChanged(ctx); }, 100);
console.log("In registerPPOnChangeEvent else");
}
//}
}
function registerPPOnChangeEventS(ppElement) {
var ppId = ppElement.attr('id') + "_TopSpan";
console.log('ppID: ' +ppId);
//var addOnChanged = function(ctx) {
if (SPClientPeoplePicker &&
SPClientPeoplePicker.SPClientPeoplePickerDict &&
SPClientPeoplePicker.SPClientPeoplePickerDict[ppId]) {
console.log("In registerPPOnChangeEvent if");
var picker = SPClientPeoplePicker.SPClientPeoplePickerDict[ppId];
picker.oldChanged = picker.OnControlResolvedUserChanged;
var ppidTest = picker.toString();
console.log("picker: " +ppidTest);
//OnControlResolvedUserChanged
picker.OnControlResolvedUserChanged = function () {
if (picker.TotalUserCount == 0) {
$('#resolvedUsers22').html("");
$('#user22Keys').html("");
$('#user22ProfileProperties').html("");
$('#user22ID').html("");
} else {
setTimeout(function () {
getUserInfoS();
},
100);
}
picker.oldChanged();
}
} else {
//setTimeout(function () { addOnChanged(ctx); }, 100);
console.log("In registerPPOnChangeEvent else");
}
//}
}
function registerPPOnChangeEventK(ppElement) {
var ppId = ppElement.attr('id') + "_TopSpan";
console.log('ppID: ' +ppId);
//var addOnChanged = function(ctx) {
if (SPClientPeoplePicker &&
SPClientPeoplePicker.SPClientPeoplePickerDict &&
SPClientPeoplePicker.SPClientPeoplePickerDict[ppId]) {
console.log("In registerPPOnChangeEvent if");
var picker = SPClientPeoplePicker.SPClientPeoplePickerDict[ppId];
picker.oldChanged = picker.OnControlResolvedUserChanged;
var ppidTest = picker.toString();
console.log("picker: " +ppidTest);
//OnControlResolvedUserChanged
picker.OnControlResolvedUserChanged = function () {
if (picker.TotalUserCount == 0) {
$('#resolvedUsers').html("");
$('#userKeys').html("");
$('#userProfileProperties').html("");
$('#userID').html("");
} else {
setTimeout(function () {
getUserInfoK();
},
100);
}
picker.oldChanged();
}
} else {
// setTimeout(function () { addOnChanged(ctx); }, 100);
console.log("In registerPPOnChangeEvent else");
}
//}
}
// Query the picker for user information.
var userPropertyP = "";
var userPropertyS = "";
var userPropertyK ="";
var userPemail = "";
var i = 0;
var j = 0;
var m = 0;
var keysP = "";
var keysS = "";
var keysK = "";
function getUserInfoP() {
// Get the people picker object from the page.
var peoplePickerP = this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDivP_TopSpan;
// Get information about all users.
var usersP = peoplePickerP.GetAllUserInfo();
//var keysP = peoplePickerP.GetAllUserKeys();
//finalusersP = new Array();
console.log('Users: ' +usersP);
var ownerP = usersP[0];
for(i = 0; i < usersP.length; i++){
userPemail = usersP[i];
}
console.log('Owner: ' +ownerP);
$("#siteOwenerEmail").val(ownerP.AutoFillSubDisplayText);
$("#siteOwenerClaim").val(ownerP.Key);
$("#siteOwnerName").val(ownerP.DisplayText);
$("#siteOwnerLogin").val(ownerP.Description);console.log('Get People Picker NameP: ' +ownerP.DisplayText);
var userInfo = '';
if(prim5 > 0){
for (var i = 0; i < usersP.length; i++) {
userP = usersP[i];
if(userP !== null){
//userPemail = userP.EntityData.Email;
userPemail = ownerP.DisplayText;
}
console.log("userPemail: " +userPemail);
return userPemail;
console.log('i= ' +i+ 'User= ' +userP);
for (userPropertyP in userP) {
prim25 += userPropertyP + ': ' + userP[userPropertyP] + '<br>';
}
}
$('#resolvedUsers').html(prim25);
// Get user keys.
keysP = peoplePickerP.GetAllUserKeys();
$('#userKeys').html(keysP);
// Get the first user's ID by using the login name.
getUserIdP(usersP[0].Key);
console.log('Initial: ' +prim25);
}
}
function getUserInfoS() {
// Get the people picker object from the page.
var peoplePickerS = this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDivS_TopSpan;
// Get information about all users.
users22 = peoplePickerS.GetAllUserInfo();
//var keysP = peoplePickerP.GetAllUserKeys();
//finalusersS = new Array();
console.log('Users: ' + users22);
var ownerS = users22[0];
/*for(i = 0; i < usersS.length; j++){
userSemail = usersS[i];
}*/
console.log('Owner: ' +ownerS);
$("#siteOwenerEmail").val(ownerS.AutoFillSubDisplayText);
$("#siteOwenerClaim").val(ownerS.Key);
$("#siteOwnerName").val(ownerS.DisplayText);
$("#siteOwnerLogin").val(ownerS.Description);console.log('Get People Picker NameS: ' +ownerS.DisplayText);
var userInfo = '';
if(sec4 > 0){
for (j = 0; j < users22.length; j++) {
user22 = users22[j];
if(user22 !== null){
//userPemail = userP.EntityData.Email;
user22email = ownerS.DisplayText;
}
for (userPropertyS in user22) {
sec25 += userPropertyS + ': ' + user22[userPropertyS] + '<br>';
}
}
$('#resolvedUsers').html(sec25);
// Get user keys.
keysS = peoplePickerS.GetAllUserKeys();
$('#user22Keys').html(keysS);
// Get the first user's ID by using the login name.
getUserIdS( users22[0].Key);
}
}
function getUserInfoK() {
// Get the people picker object from the page.
var peoplePickerK = this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDivK_TopSpan;
// Get information about all users.
usersK = peoplePickerK.GetAllUserInfo();
//var keysP = peoplePickerP.GetAllUserKeys();
//finalusersK = new Array();
console.log('Users: ' +usersK);
var ownerK = usersK[0];
/*for(i = 0; i < usersK.length; i++){
userKemail = usersK[i];
}*/
console.log('Owner: ' +ownerK);
$("#siteOwenerEmail").val(ownerK.AutoFillSubDisplayText);
$("#siteOwenerClaim").val(ownerK.Key);
$("#siteOwnerName").val(ownerK.DisplayText);
$("#siteOwnerLogin").val(ownerK.Description);console.log('Get People Picker NameK: ' +ownerK.DisplayText);
var userInfo = '';
if(auth5 > 0){
for (m = 0; m < usersK.length; m++) {
userK = usersK[m];
if(userK !== null){
//userPemail = userP.EntityData.Email;
userKemail = ownerK.DisplayText;
}
for (userPropertyK in userK) {
auth25 += userPropertyK + ': ' + userK[userPropertyK] + '<br>';
}
}
$('#resolvedUsers').html(auth25);
// Get user keys.
keysK = peoplePickerK.GetAllUserKeys();
$('#userKeys').html(keysK);
// Get the first user's ID by using the login name.
getUserIdK(usersK[0].Key);
}
}
// Get the user ID.
function getUserIdP(loginName) {
console.log('Get User ID-P');
var context = new SP.ClientContext.get_current();
this.userP = context.get_web().ensureUser(loginName);
context.load(this.userP);
context.executeQueryAsync(
Function.createDelegate(null, ensureUserSuccessP),
Function.createDelegate(null, onFail)
);
}
function ensureUserSuccessP() {
$('#userId').html(this.userP.get_id());
$("#siteOwenerId").val(this.userP.get_id());
userP = $("#siteOwenerId").val(this.userP.get_id());
}
function getUserIdS(loginName) {
console.log("Get User ID-S");
var context = new SP.ClientContext.get_current();
this.user22 = context.get_web().ensureUser(loginName);
context.load(this.user22);
context.executeQueryAsync(
Function.createDelegate(null, ensureUserSuccessS),
Function.createDelegate(null, onFail)
);
}
function ensureUserSuccessS() {
$('#userId').html(this.user22.get_id());
$("#siteOwenerId").val(this.user22.get_id());
userS = $("#siteOwenerId").val(this.user22.get_id());
}
function getUserIdK(loginName) {
console.log('Get User ID-K');
var context = new SP.ClientContext.get_current();
this.userK = context.get_web().ensureUser(loginName);
context.load(this.userK);
context.executeQueryAsync(
Function.createDelegate(null, ensureUserSuccessK),
Function.createDelegate(null, onFail)
);
}
function ensureUserSuccessK() {
$('#userId').html(this.userK.get_id());
$("#siteOwenerId").val(this.userK.get_id());
userK = $("#siteOwenerId").val(this.userK.get_id());
}
function onFail(sender, args) {
alert('Query failed. Error: ' + args.get_message());
}
function addNewIntake(){
SP.SOD.executeFunc('sp.js', 'SP.ClientContext',updateListItem1);
}
function updateListItem1() {
finalusersP.push(SP.FieldUserValue.fromUser(userP.Key));
finalusers22.push(SP.FieldUserValue.fromUser(user22.Key));
finalusersK.push(SP.FieldUserValue.fromUser(userK.Key));
var clientContext = new SP.ClientContext(siteUrl);
var oList =
clientContext.get_web().get_lists().getByTitle('Issue_Tracker_List');
this.oListItem = oList.addItem();
//console.log('primary person info: ' + finalusersP);
oListItem.set_item('MainContact2',finalusersP);
if(finalusers22 !== ""){
//console.log('secondary person info: ' +finalusers22);
oListItem.set_item('AdditionalContact_x0028_s_x0029_',finalusersS);
}
if(finalusersK !== ""){
oListItem.set_item('ITSupportOwner',finalusersK);
}
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
document.getElementById('main12').style.display="none";
document.getElementById('main22').style.display="block";
setTimeout(CloseDlg, 2000);
}
function CloseDlg() {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
}
function onQueryFailed(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>

Do you suggest a script that shows a random comment of my blog, created with bloggers?

good evening.
Do you suggest a script that shows a random comment of my blog, created with bloggers?
thank you
That should be possible to generate using the global comment feed provided by Blogger -
http://blogname.blogspot.com/feeds/comments/default
A working snippet for the same would look like -
<div id='stylify_random_comments'></div>
<script style='text/javascript'>
//<![CDATA[
var commentTitleOriginal, myLink, myDiv, myImage;
var main;
function getcomment(json) {
var s;
var entry = json.feed.entry[0];
var commentTitle = entry.title.$t;
commentTitleOriginal = commentTitle;
if (isNaN(titleLength) || titleLength == 0) {
commentTitle = '';
} else if (commentTitle.length > titleLength) commentTitle = commentTitle.substring(0, titleLength) + "...";
var commentUrl;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
var commentText = entry.link[k].title;
var commentUrl = entry.link[k].href;
}
if (entry.link[k].rel == 'alternate') {
commentUrl = entry.link[k].href;
break;
}
}
if (showThumbs == true) {
var thumbUrl = "";
try {
thumbUrl = entry.author["0"].gd$image.src;
if (imgDim == "80" || imgDim == "85" || imgDim == "90" || imgDim == "95" || imgDim == "100") thumbUrl = thumbUrl.replace("/s72-c/", "/s104-c/");
} catch (error) {
if ("content" in entry) s = entry.content.$t;
else s = "";
if (thumbUrl == "" && mediaThumbsOnly == false) {
a = s.indexOf("<img");
b = s.indexOf("src=\"", a);
c = s.indexOf("\"", b + 5);
d = s.substr(b + 5, c - b - 5);
if ((a != -1) && (b != -1) && (c != -1) && (d != "")) thumbUrl = d;
}
}
if (thumbUrl == "" && showNoImage == true) thumbUrl = 'http://1.bp.blogspot.com/_u4gySN2ZgqE/SosvnavWq0I/AAAAAAAAArk/yL95WlyTqr0/s400/noimage.png';
} //end ifcommenthumbs
if (showcommentDate == true) {
var commentdate = entry.published.$t;
var cdyear = commentdate.substring(0, 4);
var cdmonth = commentdate.substring(5, 7);
var cdday = commentdate.substring(8, 10);
var monthnames = new Array();
monthnames[1] = "Jan";
monthnames[2] = "Feb";
monthnames[3] = "Mar";
monthnames[4] = "Apr";
monthnames[5] = "May";
monthnames[6] = "Jun";
monthnames[7] = "Jul";
monthnames[8] = "Aug";
monthnames[9] = "Sep";
monthnames[10] = "Oct";
monthnames[11] = "Nov";
monthnames[12] = "Dec";
} //end if date
code = "";
main = document.getElementById('stylify_random_comments');
myDiv = document.createElement('div');
myDiv.setAttribute("class", "stylify_item_title");
myDiv.style.clear = "both";
myDiv.style.marginTop = "4px";
myLink = createLink(commentUrl, "_top", commentTitleOriginal)
if (commentTitle != '') myDiv.appendChild(myLink);
main.appendChild(myDiv);
if (commentTitle != '') myLink.innerHTML = commentTitle;
if (showThumbs == true && thumbUrl != "") {
myImage = document.createElement('img');
myImage.style.border = "0px solid transparent";
myImage.style.margin = "5px";
myImage.style.boxShadow = "0 0 0px rgba(0, 0, 0, 0.3)";
myImage.setAttribute("src", thumbUrl);
myImage.style.cssFloat = imgFloat;
myImage.style.styleFloat = imgFloat;
//myImage.setAttribute("alt", commentTitleOriginal);
myImage.setAttribute("width", imgDim);
//myImage.setAttribute("align", imgFloat);
myImage.setAttribute("height", imgDim);
myLink = document.createElement('a');
myLink.setAttribute("href", commentUrl + "?utm_source=blog&utm_medium=gadget&utm_campaign=stylify_random_comments");
myLink.setAttribute("target", "_top");
myLink.setAttribute("title", commentTitleOriginal);
myLink.appendChild(myImage);
myDiv = document.createElement('div');
myDiv.setAttribute("class", "stylify_item_thumb");
myDiv.appendChild(myLink);
main.appendChild(myDiv);
}
try {
if ("content" in entry) {
var commentContent = entry.content.$t;
} else if ("summary" in entry) {
var commentContent = entry.summary.$t;
} else var commentContent = "";
var re = /<\S[^>]*>/g;
commentContent = commentContent.replace(re, "");
if (showSummary == true) {
myDiv = createDiv("stylify_item_summary");
if (commentContent.length < summaryLength) {
myDiv.innerHTML = commentContent;
} else {
commentContent = commentContent.substring(0, summaryLength);
var quoteEnd = commentContent.lastIndexOf(" ");
commentContent = commentContent.substring(0, quoteEnd);
myDiv.innerHTML = commentContent + '...';
}
main.appendChild(myDiv);
}
} //end try
catch (error) {}
myDiv = createDiv("stylify_item_meta");
myDiv.style.clear = "both";
myDiv.style.marginBottom = "4px";
var flag = 0;
if (showcommentDate == true) {
myDiv.appendChild(document.createTextNode(monthnames[parseInt(cdmonth, 10)] + '-' + cdday + '-' + cdyear));
flag = 1;
}
if (showCommentCount == true) {
if (flag == 1) {
myDiv.appendChild(document.createTextNode(" | "));
}
if (commentText == '1 Comments') commentText = '1 Comment';
if (commentText == '0 Comments') commentText = 'No Comments';
var myLink = createLink(commentUrl, "_top", commentText + " on " + commentTitleOriginal)
myDiv.appendChild(myLink);
myLink.innerHTML = commentText;
flag = 1;;
}
if (showReadMore == true) {
if (flag == 1) {
myDiv.appendChild(document.createTextNode(" | "));
}
var myLink = createLink(commentUrl, "_top", commentTitleOriginal)
myDiv.appendChild(myLink);
myLink.innerHTML = readMore + " ยป";
flag = 1;;
}
if (flag == 1 || showSummary || commentTitle != "") main.appendChild(myDiv);
}
function getRandom(json) {
var feedUrl = '/feeds/comments/default';
if (mediaThumbsOnly || !showThumbs) feedUrl = feedUrl.replace("comments/default", "comments/summary");
totalcomments = parseInt(json.feed.openSearch$totalResults.$t);
var rand = [];
if (numberOfcomments > totalcomments) numberOfcomments = totalcomments;
if (numberOfcomments > 15) numberOfcomments = 15;
while (rand.length < numberOfcomments) {
var randomNumber = Math.ceil(Math.random() * totalcomments);
var found = false;
for (var i = 0; i < rand.length; i++) {
if (rand[i] == randomNumber) {
found = true;
break;
}
}
if (!found) rand[rand.length] = randomNumber;
}
var head = document.getElementsByTagName("head")[0] || document.documentElement;
for (var i = 0; i < rand.length; i++) {
script = document.createElement("script");
script.src = feedUrl + "?start-index=" + rand[i] + "&max-results=1&alt=json-in-script&callback=getcomment";
script.charSet = "utf-8";
head.appendChild(script);
}
}
function createDiv(className) {
var myDiv = document.createElement('div');
myDiv.setAttribute("class", className);
return myDiv;
}
function createLink(href, target, title) {
var myLink = document.createElement('a');
if (href.indexOf("?utm_source=") == -1) href = href + "?utm_source=blog&utm_medium=gadget&utm_campaign=stylify_random_comments";
myLink.setAttribute("href", href);
myLink.setAttribute("target", target);
myLink.setAttribute("title", title);
return myLink;
}
//]]>
</script>
<script style='text/javascript'>
var numberOfcomments = 5;
var showcommentDate = false;
var showSummary = true;
var summaryLength = 200;
var titleLength = 100;
var showCommentCount = false;
var showThumbs = true;
var showNoImage = false;
var imgDim = 50;
var imgFloat = 'left';
var myMargin = 0;
var mediaThumbsOnly = true;
var showReadMore = false;
var readMore = 'More';
</script>
<script src='/feeds/comments/default?max-results=1&alt=json-in-script&callback=getRandom'></script>

How to use babel into appcelerator project?

I'm importend in my workspace, a project build in appcelerator.
So I have some error like this:
If I open any file, I have this situation:
I don't know, how to fix this.
So this is my plugin.js
"use strict";
exports.__esModule = true;
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require("babel-runtime/helpers/inherits");
var _inherits3 = _interopRequireDefault(_inherits2);
var _optionManager = require("./file/options/option-manager");
var _optionManager2 = _interopRequireDefault(_optionManager);
var _babelMessages = require("babel-messages");
var messages = _interopRequireWildcard(_babelMessages);
var _store = require("../store");
var _store2 = _interopRequireDefault(_store);
var _babelTraverse = require("babel-traverse");
var _babelTraverse2 = _interopRequireDefault(_babelTraverse);
var _assign = require("lodash/assign");
var _assign2 = _interopRequireDefault(_assign);
var _clone = require("lodash/clone");
var _clone2 = _interopRequireDefault(_clone);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* eslint max-len: 0 */
var GLOBAL_VISITOR_PROPS = ["enter", "exit"];
var Plugin = function (_Store) {
(0, _inherits3.default)(Plugin, _Store);
function Plugin(plugin, key) {
(0, _classCallCheck3.default)(this, Plugin);
var _this = (0, _possibleConstructorReturn3.default)(this, _Store.call(this));
_this.initialized = false;
_this.raw = (0, _assign2.default)({}, plugin);
_this.key = key;
_this.manipulateOptions = _this.take("manipulateOptions");
_this.post = _this.take("post");
_this.pre = _this.take("pre");
_this.visitor = _this.normaliseVisitor((0, _clone2.default)(_this.take("visitor")) || {});
return _this;
}
Plugin.prototype.take = function take(key) {
var val = this.raw[key];
delete this.raw[key];
return val;
};
Plugin.prototype.chain = function chain(target, key) {
if (!target[key]) return this[key];
if (!this[key]) return target[key];
var fns = [target[key], this[key]];
return function () {
var val = void 0;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
for (var _iterator = fns, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var fn = _ref;
if (fn) {
var ret = fn.apply(this, args);
if (ret != null) val = ret;
}
}
return val;
};
};
Plugin.prototype.maybeInherit = function maybeInherit(loc) {
var inherits = this.take("inherits");
if (!inherits) return;
inherits = _optionManager2.default.normalisePlugin(inherits, loc, "inherits");
this.manipulateOptions = this.chain(inherits, "manipulateOptions");
this.post = this.chain(inherits, "post");
this.pre = this.chain(inherits, "pre");
this.visitor = _babelTraverse2.default.visitors.merge([inherits.visitor, this.visitor]);
};
/**
* We lazy initialise parts of a plugin that rely on contextual information such as
* position on disk and how it was specified.
*/
Plugin.prototype.init = function init(loc, i) {
if (this.initialized) return;
this.initialized = true;
this.maybeInherit(loc);
for (var key in this.raw) {
throw new Error(messages.get("pluginInvalidProperty", loc, i, key));
}
};
Plugin.prototype.normaliseVisitor = function normaliseVisitor(visitor) {
for (var _iterator2 = GLOBAL_VISITOR_PROPS, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var key = _ref2;
if (visitor[key]) {
throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. Please target individual nodes.");
}
}
_babelTraverse2.default.explode(visitor);
return visitor;
};
return Plugin;
}(_store2.default);
exports.default = Plugin;
module.exports = exports["default"];
How can I fixed it?
import syntax is from ECMAScript 6 - which is yet to be added in the Appcelerator Studio.
https://jira.appcelerator.org/browse/TISTUD-6927

an internal error occurred . Source editor functionality is limited . Attempting to restore

I am developing application for tvOS in swift using Xcode 7.3, I had written a Class to split events on the basis of my requirements like -
import UIKit
class SplitEvents: NSObject
{
var eventDisplayArray:NSMutableArray = []
var eventHiddenArray:NSMutableArray = []
var lastMemorisedDate:NSDate?
var tempEventStartDateEndDateArray:NSMutableArray?
func InitialiseFunction (displayArray:NSMutableArray, HiddenArray hiddenArray:NSMutableArray, ResultArray result:NSArray, completionHandler:(NSMutableArray?,NSMutableArray?, NSError?)->Void?) ->Void
{
eventDisplayArray = displayArray
eventHiddenArray = hiddenArray
SplitEvent(result.mutableCopy() as! NSMutableArray)
completionHandler(eventDisplayArray,eventHiddenArray, nil)
}
func SplitEvent(result:NSMutableArray)->Void
{
if(eventDisplayArray.count>0)
{
for event in result
{
for existingEvent in eventDisplayArray
{
if ((existingEvent as! Event).eventID == (event as! Event) .eventID)
{
result.removeObject(event)
break
}
}
}
}
for event in result
{
tempEventStartDateEndDateArray = []
for dict in (event as! Event).eventSatrtEndDateRange
{
tempEventStartDateEndDateArray!.addObject(dict)
}
if (tempEventStartDateEndDateArray!.count>1)
{
event.eventSatrtEndDateRange.removeAllObjects()
var tempStartEndDateArray:NSMutableArray = []
var i:Int = 0
for fisrtDict in tempEventStartDateEndDateArray!
{
let df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if ((fisrtDict["start"] as! NSDate) == (fisrtDict["end"] as! NSDate))
{
tempStartEndDateArray.addObject(fisrtDict)
var currentDate:NSDate = fisrtDict["start"]
var calendar:NSCalendar = NSCalendar().currentCalendar
var dayComponent:NSDateComponents = NSDateComponents()
dayComponent.day = 1
currentDate = calendar.dateByAddingComponents(dayComponent, toDate:fisrtDict["start"], options:0)
if (i+1>=tempEventStartDateEndDateArray.count)
{
event.eventSatrtEndDateRange.removeAllObjects()
var temp:Event = CreateTemporaryObject(event)
if (event.savedEventsEndDates.count>0)
{
if (event.savedEventsEndDates.containsObject(fisrtDict["end"]) == false)
{
temp.attending = ""
}
else
{
temp.attending = event.attending
}
}
else
{
temp.attending = event.attending
}
temp.eventStartDate = empStartEndDateArray[0]["start"]
temp.eventEndDate = tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"]
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray)
GroupObjectArray(temp)
tempStartEndDateArray.removeAllObjects()
}
else
{
var secondDict: NSMutableDictionary = tempEventStartDateEndDateArray[i+1]
if ((currentDate == secondDict["start"]) == false)
{
event.eventSatrtEndDateRange.removeAllObjects()
var temp:Event = CreateTemporaryObject(event)
if (event.savedEventsEndDates.count>0)
{
if (event.savedEventsEndDates.containsObject(fisrtDict["end"]) == false)
{
temp.attending = ""
}
else
{
temp.attending = event.attending
}
}
else
{
temp.attending = event.attending
}
temp.eventStartDate = tempStartEndDateArray[0]["start"]
temp.eventEndDate = tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"]
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray)
GroupObjectArray(temp)
tempStartEndDateArray.removeAllObjects()
}
}
}
else if((fisrtDict["end"] as NSDate).timeIntervalSinceDate(fisrtDict["start"]) > 0 )
{
tempStartEndDateArray.addObject(fisrtDict)
event.eventSatrtEndDateRange.removeAllObjects()
var temp:Event = CreateTemporaryObject(event)
if (event.savedEventsEndDates.count>0)
{
if (event.savedEventsEndDates.containsObject(fisrtDict["end"]) == false)
{
temp.attending = ""
}
else
{
temp.attending = event.attending
}
}
else
{
temp.attending = event.attending
}
temp.eventStartDate = tempStartEndDateArray[0]["start"]
temp.eventEndDate = tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"]
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray)
GroupObjectArray(temp)
tempStartEndDateArray.removeAllObjects()
}
i = i+1
}
}
else
{
GroupObjectArray(event)
}
}
if (result.count>0)
{
if (result.count>=10)
{
self.lastMemorisedDate = result[(result.count-1)].eventEndDate
}
else
{
self.lastMemorisedDate = nil
}
}
ShortArrayByDate()
}
func CreateTemporaryObject(event:Event) ->Event
{
var temp: Event = Event()
temp.hasEventTime=event.hasEventTime
temp.newForUser=event.newForUser
temp.name=event.name
temp.eventID=event.eventID
temp.imageURLString=event.imageURLString
temp.city=event.city
temp.venueID=event.venueID
temp.venueName=event.venueName
temp.distance=event.distance
temp.latitude=event.latitude
temp.savedEventsEndDates=event.savedEventsEndDates
temp.longitude=event.longitude
temp.eventDate=event.eventDate
// temp.eventEndDate=event.eventEndDate;
// temp.eventStartDate=event.eventStartDate;
// temp.attending=event.attending;
temp.trackbackUrlString=event.trackbackUrlString
temp.categories=event.categories
temp.artists=event.artists
temp.schedules=event.schedules
temp.friendsGoing=event.friendsGoing
temp.friendsWantTo=event.friendsWantTo
temp.friends=event.friends
temp.prices=event.prices
temp.currency=event.currency
temp.venue=event.venue
temp.watchImageURLString=event.watchImageURLString
temp.watchImageMobURLString=event.watchImageMobURLString
temp.eventDescription=event.eventDescription
temp.shortURLString=event.shortURLString
return temp
}
func ShortArrayByDate() ->Void
{
var sortDescriptor: NSSortDescriptor = NSSortDescriptor(key: "eventStartDate", ascending: YES)
var sortDescriptors = NSArray(array:sortDescriptor)
var sortedArray: NSArray?
sortedArray = eventHiddenArray.sortedArrayUsingDescriptors(sortDescriptors)
eventHiddenArray = sortedArray.mutableCopy()
// self.eventDisplayArray= [sortedArray mutableCopy];
if (self.lastMemorisedDate)
{
var predicate: NSPredicate = NSPredicate(format: "(eventStartDate =< %#)",lastMemorisedDate)
eventDisplayArray = eventHiddenArray.filter { pred.evaluateWithObject($0) };
}
else
{
self.eventDisplayArray = sortedArray.mutableCopy()
}
}
func GroupObjectArray(event:Event)->Void
{
if (eventHiddenArray == nil)
{
eventHiddenArray = [];
}
self.eventHiddenArray.addObject(event)
}
func GetFirstSlotEventStartEndDate(eventStartDateEndDateArray:NSMutableArray )->NSMutableArray
{
var tempStartEndDateArray:NSMutableArray = [];
var i:Int = 0
for fisrtDict in eventStartDateEndDateArray
{
var df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if (fisrtDict["start"] == fisrtDict ["end"])
{
tempStartEndDateArray.addObject(fisrtDict)
var currentDate: NSDate = fisrtDict["start"];
var calendar: NSCalendar = NSCalendar().currentCalendar
var dayComponent:NSDateComponents = NSDateComponents()
dayComponent.day = 1
currentDate = calendar.dateByAddingComponents(dayComponent, toDate:fisrtDict["start"], options:0)
if (i+1>=eventStartDateEndDateArray.count)
{
break
}
else
{
var secondDict:NSMutableDictionary = eventStartDateEndDateArray[i+1];
if ((currentDate == secondDict ["start"]) == false)
{
break
}
}
}
else if((fisrtDict["end"] as NSDate?).timeIntervalSinceDate(fisrtDict["start"]) > 0 )
{
tempStartEndDateArray.addObject(fisrtDict)
break
}
i = i+1
}
//
return tempStartEndDateArray;
}
func GetFirstSlotEndDate(eventStartDateEndDateArray:NSMutableArray) ->String
{
var firstSlotEventEndDate:String = ""
var i:Int = 0
for fisrtDict in eventStartDateEndDateArray
{
var df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if (fisrtDict["start"] == fisrtDict["end"])
{
var currentDate: NSDate = fisrtDict["start"];
var calendar: NSCalendar = NSCalendar().currentCalendar
var dayComponent:NSDateComponents = NSDateComponents()
dayComponent.day = 1;
currentDate = calendar.dateByAddingComponents(dayComponent, toDate:fisrtDict["start"], options:0);
if (i+1>=eventStartDateEndDateArray.count)
{
firstSlotEventEndDate = df.stringFromDate(fisrtDict["end"])
break;
}
else
{
var secondDict:NSMutableDictionary = eventStartDateEndDateArray[i+1];
if (!(currentDate == secondDict["start"]))
{
firstSlotEventEndDate = df.stringFromDate(fisrtDict["end"])
break;
}
}
}
else if((fisrtDict["end"] as NSDate?).timeIntervalSinceDate(fisrtDict["start"]) > 0 )
{
firstSlotEventEndDate = df.stringFromDate(fisrtDict["end"]);
break;
}
}
return firstSlotEventEndDate;
}
}
when i am including above file in my application Xcode giving me compile time error an internal error occurred . Source editor functionality is limited . Attempting to restore...
after step by step reviewing of my code finally i figured out issues in my code. If you have more syntax mistakes in your code the swift 2.x Xcode compile stops showing the syntax mistakes & gives the error an internal error occurred . Source editor functionality is limited . Attempting to restore...
The corrected formatting of code is -
import UIKit
class SplitEvents: NSObject
{
var eventDisplayArray = NSMutableArray()
var eventHiddenArray = NSMutableArray()
var lastMemorisedDate:NSDate?
var tempEventStartDateEndDateArray = NSMutableArray()
func InitialiseFunction (displayArray:NSMutableArray, hiddenArray:NSMutableArray, result:NSArray, completionHandler:(NSMutableArray?,NSMutableArray?, NSError?)->Void) ->Void
{
eventDisplayArray = displayArray
eventHiddenArray = hiddenArray
SplitEvent(result.mutableCopy() as! NSMutableArray)
completionHandler(eventDisplayArray,eventHiddenArray, nil)
}
func SplitEvent(result:NSMutableArray)->Void
{
if(eventDisplayArray.count>0)
{
for event in result
{
for existingEvent in eventDisplayArray
{
if ((existingEvent as! Event).eventID == (event as! Event) .eventID)
{
result.removeObject(event)
break
}
}
}
}
for event in result
{
tempEventStartDateEndDateArray = []
for dict in (event as! Event).eventSatrtEndDateRange
{
tempEventStartDateEndDateArray.addObject(dict)
}
if (tempEventStartDateEndDateArray.count>1)
{
event.eventSatrtEndDateRange.removeAllObjects()
var tempStartEndDateArray:NSMutableArray = []
var i:Int = 0
for fisrtDict in tempEventStartDateEndDateArray
{
let df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if ((fisrtDict["start"] as! NSDate).isEqualToDate((fisrtDict["end"] as! NSDate)))
{
tempStartEndDateArray.addObject(fisrtDict)
var currentDate:NSDate = fisrtDict["start"] as! NSDate
var calendar:NSCalendar = NSCalendar.currentCalendar()
var dayComponent:NSDateComponents = NSDateComponents()
dayComponent.day = 1
currentDate = calendar.dateByAddingComponents(dayComponent, toDate:(fisrtDict["start"] as! NSDate), options:NSCalendarOptions(rawValue: 0))!
if (i+1 >= tempEventStartDateEndDateArray.count)
{
event.eventSatrtEndDateRange.removeAllObjects()
var temp:Event = CreateTemporaryObject(event as! Event)
if ((event as! Event).savedEventsEndDates.count > 0)
{
if ((event as! Event).savedEventsEndDates.containsObject(fisrtDict["end"] as! NSDate ) == false)
{
temp.attending = ""
}
else
{
temp.attending = (event as! Event).attending
}
}
else
{
temp.attending = (event as! Event).attending
}
temp.eventStartDate = ((tempStartEndDateArray[0]["start"]) as! NSDate)
temp.eventEndDate = (tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"] as! NSDate)
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray as [AnyObject])
GroupObjectArray(temp)
tempStartEndDateArray.removeAllObjects()
}
else
{
var secondDict: NSMutableDictionary = tempEventStartDateEndDateArray[i+1] as! NSMutableDictionary
if (currentDate.isEqualToDate(secondDict["start"] as! NSDate) == false)
{
event.eventSatrtEndDateRange.removeAllObjects()
var temp:Event = CreateTemporaryObject(event as! Event)
if ((event as! Event).savedEventsEndDates.count>0)
{
if ((event as! Event).savedEventsEndDates.containsObject(fisrtDict["end"] as! NSDate) == false)
{
temp.attending = ""
}
else
{
temp.attending = (event as! Event).attending
}
}
else
{
temp.attending = (event as! Event).attending
}
temp.eventStartDate = (tempStartEndDateArray[0]["start"] as! NSDate)
temp.eventEndDate = (tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"] as! NSDate)
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray as [AnyObject])
GroupObjectArray(temp as Event)
tempStartEndDateArray.removeAllObjects()
}
}
}
else if((fisrtDict["end"] as! NSDate).timeIntervalSinceDate(fisrtDict["start"] as! NSDate) > 0 )
{
tempStartEndDateArray.addObject(fisrtDict)
(event as! Event).eventSatrtEndDateRange.removeAllObjects()
let temp:Event = CreateTemporaryObject((event as! Event))
if ((event as! Event).savedEventsEndDates.count>0)
{
if ((event as! Event).savedEventsEndDates.containsObject(fisrtDict["end"] as! NSDate) == false)
{
temp.attending = ""
}
else
{
temp.attending = (event as! Event).attending
}
}
else
{
temp.attending = (event as! Event).attending
}
temp.eventStartDate = (tempStartEndDateArray[0]["start"] as! NSDate)
temp.eventEndDate = (tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"] as! NSDate)
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray as [AnyObject])
GroupObjectArray(temp)
tempStartEndDateArray.removeAllObjects()
}
i = i+1
}
}
else
{
GroupObjectArray(event as! Event)
}
}
if (result.count>0)
{
if (result.count>=10)
{
self.lastMemorisedDate = (result[(result.count-1)] as! Event).eventEndDate
}
else
{
self.lastMemorisedDate = nil
}
}
ShortArrayByDate()
}
func CreateTemporaryObject(event:Event) ->Event
{
let temp: Event = Event()
temp.hasEventTime=event.hasEventTime
temp.newForUser=event.newForUser
temp.name=event.name
temp.eventID=event.eventID
temp.imageURLString=event.imageURLString
temp.city=event.city
temp.venueID=event.venueID
temp.venueName=event.venueName
temp.distance=event.distance
temp.latitude=event.latitude
temp.savedEventsEndDates=event.savedEventsEndDates
temp.longitude=event.longitude
temp.eventDate=event.eventDate
// temp.eventEndDate=event.eventEndDate;
// temp.eventStartDate=event.eventStartDate;
// temp.attending=event.attending;
temp.trackbackUrlString=event.trackbackUrlString
temp.categories=event.categories
temp.artists=event.artists
temp.schedules=event.schedules
temp.friendsGoing=event.friendsGoing
temp.friendsWantTo=event.friendsWantTo
temp.friends=event.friends
temp.prices=event.prices
temp.currency=event.currency
temp.venue=event.venue
temp.eventDescription=event.eventDescription
temp.shortURLString=event.shortURLString
return temp
}
func ShortArrayByDate() ->Void
{
let sortDescriptor: NSSortDescriptor = NSSortDescriptor(key: "eventStartDate", ascending: true)
let sortDescriptors = [sortDescriptor]
let sortedArray:NSArray = eventHiddenArray.sortedArrayUsingDescriptors(sortDescriptors)
eventHiddenArray = sortedArray.mutableCopy() as! NSMutableArray
if (self.lastMemorisedDate != nil)
{
let pred = NSPredicate(format: "eventStartDate =< %#", lastMemorisedDate!)
let displayArray:NSArray = eventHiddenArray.filter { pred.evaluateWithObject($0) } ;
eventDisplayArray = displayArray.mutableCopy() as! NSMutableArray
}
else
{
self.eventDisplayArray = sortedArray.mutableCopy() as! NSMutableArray
}
}
func GroupObjectArray(event:Event)->Void
{
self.eventHiddenArray.addObject(event)
}
func GetFirstSlotEventStartEndDate(eventStartDateEndDateArray:NSMutableArray )->NSMutableArray
{
let tempStartEndDateArray = NSMutableArray();
var i:Int = 0
for fisrtDict in eventStartDateEndDateArray
{
let df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if ((fisrtDict["start"] as! NSDate).isEqualToDate((fisrtDict ["end"] as! NSDate)))
{
tempStartEndDateArray.addObject(fisrtDict)
var currentDate: NSDate = fisrtDict["start"] as! NSDate;
let calendar: NSCalendar = NSCalendar.currentCalendar()
let dayComponent:NSDateComponents = NSDateComponents()
dayComponent.day = 1
currentDate = calendar.dateByAddingComponents(dayComponent, toDate:(fisrtDict["start"] as! NSDate), options:NSCalendarOptions(rawValue: 0))!
if (i+1>=eventStartDateEndDateArray.count)
{
break
}
else
{
let secondDict:NSMutableDictionary = eventStartDateEndDateArray[i+1] as! NSMutableDictionary;
if (currentDate.isEqualToDate(secondDict ["start"] as! NSDate))
{
break
}
}
}
else if((fisrtDict["end"] as! NSDate).timeIntervalSinceDate(fisrtDict["start"] as! NSDate) > 0 )
{
tempStartEndDateArray.addObject(fisrtDict)
break
}
i = i+1
}
//
return tempStartEndDateArray;
}
func GetFirstSlotEndDate(eventStartDateEndDateArray:NSMutableArray) ->String
{
var firstSlotEventEndDate:String = ""
var i:Int = 0
for fisrtDict in eventStartDateEndDateArray
{
let df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if ((fisrtDict["start"] as! NSDate).isEqualToDate((fisrtDict ["end"] as! NSDate)))
{
var currentDate: NSDate = fisrtDict["start"] as! NSDate;
let calendar: NSCalendar = NSCalendar.currentCalendar()
let dayComponent:NSDateComponents = NSDateComponents()
dayComponent.day = 1;
currentDate = calendar.dateByAddingComponents(dayComponent, toDate:(fisrtDict["start"] as! NSDate), options:NSCalendarOptions(rawValue: 0))!;
if (i+1>=eventStartDateEndDateArray.count)
{
firstSlotEventEndDate = df.stringFromDate(fisrtDict["end"] as! NSDate)
break;
}
else
{
let secondDict:NSMutableDictionary = eventStartDateEndDateArray[i+1] as! NSMutableDictionary;
if (currentDate.isEqualToDate(secondDict["start"] as! NSDate))
{
firstSlotEventEndDate = df.stringFromDate(fisrtDict["end"] as! NSDate)
break;
}
}
}
else if((fisrtDict["end"] as! NSDate).timeIntervalSinceDate(fisrtDict["start"] as! NSDate) > 0 )
{
firstSlotEventEndDate = df.stringFromDate(fisrtDict["end"] as! NSDate);
break;
}
i = i+1
}
return firstSlotEventEndDate;
}
}

Excanvas does not work in IE8

Excanvas does not work in IE8!!! I write program to paint by mouse on canvas element. There are fragment of my js-code
window.attachEvent('onload', function () {
function init() {
var w = document.getElementById('signatureImage').getAttribute('width');
var h = document.getElementById('signatureImage').getAttribute('height');
var removeSignatureImage = document.getElementById('signatureImage');
removeSignatureImage.parentNode.removeChild(removeSignatureImage);
var canvasDiv = document.getElementById('canvasDiv');
canvas = document.createElement('canvas');
canvas.setAttribute('width', w);
canvas.setAttribute('height', h);
canvas.setAttribute('style', 'border:1px solid #000000');
canvas.setAttribute('id', 'signatureImage');
canvasDiv.appendChild(canvas);
if (typeof G_vmlCanvasManager != 'undefined') {
canvas = window.G_vmlCanvasManager.initElement(canvas);
}
context = canvas.getContext("2d");
tool = new tool_pencil();
// Attach the mousedown, mousemove and mouseup event listeners.
var trackend = false;
var trackstart = false;
var trackmid = false;
canvas.onselectstart = function () {
canvas.onmousemove(); trackstart = true;
return false; }
canvas.onclick = function () { trackend = true; }
canvas.onmousemove = function () {
var mtarget = document.getElementById('signatureImage');
var x = event.clientX - canvas.offsetLeft;
var y = event.clientY - canvas.offsetTop;
var mtype = 'mousemove';
if (trackstart) {
trackstart = false;
trackmid = true;
mtype = 'mousedown';
}
if (trackend) {
trackmid = false;
mtype = 'mouseup';
}
if (trackend || trackmid || trackstart) {
trackend = false;
ev_canvas({
type: mtype,
_x: x,
_y: y,
target: mtarget
});
}
}
}
function tool_pencil() {
var tool = this;
this.started = false;
function getCoord(ev) {
var x = ev._x;
var y = ev._y;
if (tool.started == true) {
coords += x + "," + y + " ";
}
return [x, y];
}
this.mousedown = function (ev) {
context.beginPath();
context.moveTo(ev._x, ev._y);
tool.started = true;
};
this.mousemove = function (ev) {
if (tool.started) {
context.lineTo(ev._x, ev._y);
context.stroke();
var coord = getCoord(ev);
}
};
this.mouseup = function (ev) {
if (tool.started) {
tool.mousemove(ev);
tool.started = false;
coordList += coords + ";";
document.getElementById('coord').value = coordList;
coords = "";
}
};
}
When there is context.lineTo(ev._x, ev._y);
context.stroke(); - nothing happens! Although the coordinates are passed and canvas painted and initialized

Resources