');
var items = $('.infoitem:not(#homebtn)');
var len = items.length;
$(items[0]).find('a div .ilfr').remove();
$(items[len - 1]).find('a div .irtr').remove();
$('.subitem:not(.sect) a').prepend(
'
' +
'' +
'' +
//'' +
'
');
items = $('.subitem');
len = items.length;
if (items.length == 1) items.find('.configtools').remove();
$(items[0]).find('a div .silf').remove();
$(items[len - 1]).find('a div .sirt').remove();
$('.subitem2:not(.blink):not(.sect) a').prepend(
'
' +
'' +
'' +
//'' +
'' +
'
');
items = $('.subitem2');
len = items.length;
if (items.length == 1) items.find('.ilf,.irt').remove();
$(items[0]).find('a div .ilf').remove();
$(items[len - 1]).find('a div .irt').remove();
$('#homebtn a').prepend(
'' +
'' +
'');
$('.sect a').prepend(
'
' +
'' +
'' +
'
');
$('body').prepend(
'
' +
'' +
'
');
$('#articles .articlediv').first().prepend(
'
' +
'' +
'
');
$('.fc-header-center').html(
'
' +
'' +
'
');
$('.td-commentdiv').first().prepend(
'
' +
'' +
'
');
$('.config').show();
}
function bindConfigTools() {
$('.iplus').unbind().click(function(e) {
var newTopicName;
var targetTopicId;
//e.preventDefault();
if ($(this).parent().parent().parent('#homebtn').length > 0) {
targetTopicId = rootBlogTopicId;
newTopicName = prompt('.');
}
else {
targetTopicId = blogTopicId;
newTopicName = prompt(' "' + blogTopicTitle + '".');
}
if (!newTopicName) return false;
newTopicName = newTopicName.trim();
var isDiscussion = (newTopicName.toLowerCase() == "discuss");
var options = [];
var guid = screwtopDb.guid();
screwtopDb().url(DBURL)
.invalidateCache()
.logout()
.login(APPNAME,APPNAME,configpass,60,true)
.topicById(targetTopicId,{elide: true})
.push()
.tag('./options')
.values()
.text()
.fn(function(opts) {
options = opts;
})
.pop()
.each(function(topic) {
var obj = {
text: newTopicName + guid,
options: options
};
obj['title-' + lang] = newTopicName;
obj['subtitle-' + lang] = topic["title-" + lang][0];
if (isDiscussion) obj['options'] = ["nonewbutton", "afterlogin"];
//alert(JSON.stringify(obj));
screwtopDb(topic).url(DBURL)
.addTags('subblogs',newTopicName + guid)
.addTopics(obj)
.end();
})
.logout()
.authentication(APPNAME,username,password)
.end(function() {
window.location.reload();
});
return false;
});
$('.icpy').unbind().click(function(e) {
var newTopicName;
var targetTopicId;
var srcTopicTitle = $(this).parent().parent().attr('href').substr(1);
//e.preventDefault();
/*
if ($(this).parent().parent().parent('#homebtn').length > 0) {
targetTopicId = rootBlogTopicId;
newTopicTitle = prompt(' ' + srcTopicTitle + '.');
}
else {
targetTopicId = blogTopicId;
newTopicTitle = prompt(' ' + srcTopicTitle + '.');
}
if (!newTopicTitle) return false;
newTopicTitle = newTopicTitle.trim();
newTopicName = newTopicTitle + screwtopDb.guid();
//alert(srcTopicTitle + '\n\n' + newTopicTitle + '\n\n' + newTopicName);
*/
screwtopDb().url(DBURL)
/*
.invalidateCache()
.logout()
.login(APPNAME,APPNAME,configpass)
.topicByName(srcTopicTitle,{include: 'inbound'})
.tags()
.tag('./title-' + lang)
.values()
.topics({include: 'inbound'}) // this is the subblog topic
.tag('./subblogs')
.values()
.topics() // this is the owning blog topic
.addTags('subblogs',newTopicName)
.tag('./subblogs')
.values()
.select("text = '" + srcTopicName + "'")
//.deleteValues(oldVid)
.topicByName(srcTopicName,{include: 'outbound'})
.tags()
.each(function(tag) {
var owner = tag.text.replace(/^(.+?)\/.*$/,"$1");
var tagtext = tag.tagText(true);
var topic = {};
screwtopDb().url(DBURL)
.login(APPNAME,owner,'')
.fn(function() {
topic.text = newTopicName;
screwtopDb(tag).url(DBURL)
.values()
.text()
.fn(function(textarr) {
topic[tagtext] = textarr;
})
.addTopics(topic)
.end();
})
.login(APPNAME,APPNAME,configpass)
.end();
})
.logout()
.authentication(APPNAME,username,password)
*/
.end(function() {
alert("");
//alert(window.location);
//window.location.reload();
});
return false;
});
$('.idel').unbind().click(function(e) {
$('#spinner').fadeIn('fast');
var topicname = $(this).closest('a').attr('href');
topicname = topicname.replace(/\/(.*)$/,"$1");
var cur = $(this).closest('.subitem2,.infoitem');
if (confirm(topicname + ': ')) {
var topicId;
screwtopDb().url(DBURL)
.invalidateCache()
.logout()
.login(APPNAME,APPNAME,configpass)
//.beginServerExecution()
.topicByName(topicname,{include: 'inbound'})
.tag('./title-' + lang)
.values()
.topics({include: 'inbound'})
.each(function(topic) {
var valId = "";
screwtopDb(topic).url(DBURL)
.tag('./subblogs')
.values()
.topics({elide:true, tagfilter: APPNAME + '/subblogs'})
.tags()
.values()
.each(function(v) {
if (valId == "") {
screwtopDb(v).url(DBURL)
.topics()
.select('text = /^' + topic.text + '/')
.ifAny(function() {
valId = v.valueId;
})
.end();
}
})
.fn(function() {
screwtopDb().url(DBURL)
.valueById(valId)
.push()
.topics()
.values()
.deleteValues()
.pop()
.deleteValues()
.end();
})
.end();
})
.logout()
.authentication(APPNAME,username,password)
.end(function() {
cur.remove();
$('#spinner').stop().hide();
});
}
return false;
});
var spec = '.ilf, .irtr';
if (rootBlogOptions.indexOf('layoutpitch') < 0) {
spec = '.irt, .ilfr';
}
$(spec).unbind().click(function(e) {
$('#spinner').fadeIn('fast');
var topicname = $(this).closest('a').attr('href');
topicname = topicname.replace(/\/(.*)$/,"$1");
var cur = $(this).closest('.subitem2,.infoitem');
var nxt = cur.prev().closest('.subitem2,.infoitem');
var subblogName;
screwtopDb().url(DBURL)
.invalidateCache()
.logout()
.login(APPNAME,APPNAME,configpass,3600,true)
.topicByName(topicname,{include: 'inbound'})
.tag('./title-' + lang)
.values()
.each(function(v) { subblogName = v.text; })
.topics({elide:true, include: "inbound"})
.tag('./subblogs')
.values()
.topics({elide:true, tagfilter: APPNAME + '/subblogs'})
.values()
.fn(function(vals) {
var prev = null;
vals.forEach(function(v) {
if (v.text != subblogName) {
prev = v;
}
else if (prev != null) {
screwtopDb().url(DBURL)
.moveValue(prev.valueId, v.valueId)
.end();
prev = null;
}
})
})
.logout()
.authentication(APPNAME,username,password)
.end(function() {
cur.insertBefore(nxt);
bindConfig();
$('#spinner').stop().hide();
});
return false;
});
spec = '.irt, .ilfr';
if (rootBlogOptions.indexOf('layoutpitch') < 0) {
spec = '.ilf, .irtr';
}
$(spec).unbind().click(function(e) {
$('#spinner').fadeIn('fast');
var topicname = $(this).closest('a').attr('href');
topicname = topicname.replace(/\/(.*)$/,"$1");
var cur = $(this).closest('.subitem2,.infoitem');
var nxt = cur.next().closest('.subitem2,.infoitem');
var subblogName;
screwtopDb().url(DBURL)
.invalidateCache()
.logout()
.login(APPNAME,APPNAME,configpass,3600,true)
.topicByName(topicname,{include: 'inbound'})
.tag('./title-' + lang)
.values()
.each(function(v) { subblogName = v.text; })
.topics({elide:true, include: "inbound"})
.tag('./subblogs')
.values()
.topics({elide:true, tagfilter: APPNAME + '/subblogs'})
.values()
.fn(function(vals) {
var targ = null;
vals.forEach(function(v) {
if (v.text == subblogName) {
targ = v;
}
else if (targ != null) {
screwtopDb().url(DBURL)
.moveValue(targ.valueId,v.valueId)
.end();
targ = null;
}
})
})
.logout()
.authentication(APPNAME,username,password)
.end(function() {
cur.insertAfter(nxt);
bindConfig();
$('#spinner').stop().hide();
});
return false;
});
spec = '.silf';
//if (rootBlogOptions.indexOf('layoutpitch') < 0) {
// spec = '.sirt';
//}
$(spec).unbind().click(function(e) {
$('#spinner').fadeIn('fast');
var topicid = $(this).closest('a').attr('href');
topicid = topicid.replace(/.*\/(.*)$/,"$1");
var cur = $(this).closest('.subitem');
var prv = cur.prev().closest('.subitem');
screwtopDb().url(DBURL)
.invalidateCache()
.logout()
.login(APPNAME,APPNAME,configpass, 3600, true)
.topicById(topicid,{elide:true, include:'inbound'})
.tags()
.select('text = /^.*?\\/article-month\\/.*$/')
.values()
.topics({elide:true})
.tags()
.select('text = /^.*?\\/article-month\\/.*$/')
.values() // This is the article list
.topics({elide:true})
.sort(function(a,b) {
var af = parseFloat(screwtopDb.isDefined(a.priority) ? a.priority[0] : 100);
var bf = parseFloat(screwtopDb.isDefined(b.priority) ? b.priority[0] : 100);
if (af < bf) return -1;
else if (af > bf) return 1;
else return 0;
})
.fn(function(topics) {
var i = 100;
screwtopDb(topics).url(DBURL)
.each(function(t) {
var p = i++;
if (t.topicId == topicid) {
p -= 1.5;
}
//"New priority: " + p);
screwtopDb(t).url(DBURL)
.tags()
.select('text = /.*\\/priority$/')
.values()
.ifNone(function() {
screwtopDb(t).url(DBURL)
.addTags('priority',p)
.end();
}, function(vals) {
screwtopDb(vals).url(DBURL)
.updateValue(p)
.end()
})
.end();
})
.end();
})
.logout()
.authentication(APPNAME,username,password)
.end(function() {
cur.insertBefore(prv);
bindConfig();
$('#spinner').stop().hide();
});
return false;
});
spec = '.sirt';
//if (rootBlogOptions.indexOf('layoutpitch') < 0) {
// spec = '.silf';
//}
$(spec).unbind().click(function(e) {
$('#spinner').fadeIn('fast');
var topicid = $(this).closest('a').attr('href');
topicid = topicid.replace(/.*\/(.*)$/,"$1");
var cur = $(this).closest('.subitem');
var nxt = cur.next().closest('.subitem');
screwtopDb().url(DBURL)
.invalidateCache()
.logout()
.login(APPNAME,APPNAME,configpass,3600,true)
.beginServerExecution()
.topicById(topicid,{elide:true, include:'inbound'})
.tags()
.select('text = /^.*?\\/article-month\\/.*$/')
.values()
.topics({elide:true})
.tags()
.select('text = /^.*?\\/article-month\\/.*$/')
.values() // This is the article list
.topics({elide:true})
.endServerExecution()
.sort(function(a,b) {
var af = parseFloat(screwtopDb.isDefined(a.priority) ? a.priority[0] : 100);
var bf = parseFloat(screwtopDb.isDefined(b.priority) ? b.priority[0] : 100);
if (af < bf) return -1;
else if (af > bf) return 1;
else return 0;
})
.fn(function(topics) {
var i = 100;
screwtopDb(topics).url(DBURL)
.each(function(t) {
var p = i++;
if (t.topicId == topicid) {
p += 1.5;
}
//console.log("New priority: " + p);
screwtopDb(t).url(DBURL)
.tags()
.select('text = /.*\\/priority$/')
.values()
.ifNone(function() {
screwtopDb(t).url(DBURL)
.addTags('priority',p)
.end();
}, function(vals) {
screwtopDb(vals).url(DBURL)
.updateValue(p)
.end()
})
.end();
})
.end();
})
.logout()
.authentication(APPNAME,username,password)
.end(function() {
cur.insertAfter(nxt);
$('#subblogs .subitem').removeClass('sect');
$('#subblogs .subitem').first().addClass('sect');
bindConfig();
$('#spinner').stop().hide();
});
return false;
});
function showhidehome() {
if (blogTopicId == rootBlogTopicId) {
$('.homepageonly').show();
$('.nohome').hide();
}
else {
$('.homepageonly').hide();
$('.nohome').show();
}
}
var configScriptLoaded = false;
$('.igearmain').unbind().click(function() {
var dialog = $("#igearmaindlg").dialog({
autoOpen: false,
height: 800,
width: 800,
modal: true,
buttons: {
Close: function() {
dialog.dialog( "close" );
}
},
close: function() {
//form[ 0 ].reset();
//allFields.removeClass( "ui-state-error" );
}
});
if (!configScriptLoaded) {
$.getScript('/js/colorpicker/js/colorpicker.js');
$.getScript('xl/js/configure.js').done(function(data, textStatus) {
populateConfig(configpass);
showhidehome();
dialog.dialog('open');
configScriptLoaded = true;
})
.fail(function(jqxhr, settings, e) {
console.log(e);
})
}
else {
populateConfig(configpass);
showhidehome();
dialog.dialog('open');
}
});
$('.igear').unbind().click(function() {
var dialog = $("#igearsectdlg").dialog({
autoOpen: false,
height: 800,
width: 800,
modal: true,
buttons: {
Close: function() {
dialog.dialog( "close" );
}
},
close: function() {
//form[ 0 ].reset();
//allFields.removeClass( "ui-state-error" );
}
});
if (!configScriptLoaded) {
$.getScript('/js/colorpicker/js/colorpicker.js');
$.getScript('xl/js/configure.js').done(function(data, textStatus) {
populateConfig(configpass);
dialog.dialog('open');
configScriptLoaded = true;
})
.fail(function(jqxhr, settings, e) {
console.log(e);
})
}
else {
populateConfig(configpass);
dialog.dialog('open');
}
});
}
$('#config').unbind().click(function() {
if (hasSessionStorage()) configActive = getSessionStorage(APPNAME + '-configActive') == 'true';
if (configActive) {
configActive = false;
setSessionStorage(APPNAME + '-configActive','false');
$('.configtools').remove();
$('.config').hide();
$('#infoline, #main').css('position','').css("top", "0");
if (rootBlogOptions.indexOf('layoutpitch') < 0) {
$('#infoline').css('margin-top','0px');
}
$('#bannerbtndiv').remove();
if (isBlogPoster()) {
$('.authoractions').show();
$('.commentactions').show();
$('#addarticlebtn').show();
}
return false;
}
else {
$('#addarticlebtn, .authoractions, .commentactions').hide();
}
if (hasSessionStorage()) configpass = getSessionStorage(APPNAME + '-configpass');
if (!configpass || configpass == "false") {
var pswd = prompt("Password");
if (pswd != null && pswd.trim().length > 0) {
screwtopDb().url(DBURL)
.onError(function() {
alert('');
screwtopDb().abort().end();
})
.login(APPNAME,APPNAME,pswd)
.onError()
.logout()
.authentication(APPNAME,username,password)
.end(function() {
configpass = pswd;
configActive = 'true';
if (hasSessionStorage()) {
setSessionStorage(APPNAME + '-configpass',pswd);
setSessionStorage(APPNAME + '-configActive','true');
}
showConfigTools();
bindConfigTools();
enableTitlePositioning();
enableBannerCropping();
});
}
}
else {
configActive = 'true';
if (hasSessionStorage()) {
setSessionStorage(APPNAME + '-configActive','true');
}
showConfigTools();
bindConfigTools();
enableTitlePositioning();
enableBannerCropping();
}
// ##### TODO: DISABLE ADD, EDIT, AND DELETE ARTICLES WHILE CONFIG TOOLS ARE SHOWN (BECAUSE THEY ARE
// LOGGED IN AS THE SUPERUSER.) -- Check to see if this is really needed now.
});
if (hasSessionStorage()) configActive = getSessionStorage(APPNAME + '-configActive') == 'true';
if (configActive) {
configpass = getSessionStorage(APPNAME + '-configpass');
showConfigTools();
bindConfigTools();
enableTitlePositioning();
enableBannerCropping();
}
}
function bindSettings() {
$('#settings').unbind().click(function() {
$('#settings').unbind().click(function() {
$('#settingscancelbtn').click();
});
var showSpinner = true;
setTimeout(function() {
if (showSpinner) {
$('#spinner').fadeIn('fast');
}
}, 1000);
//$('.wrapper, .commentdiv, #nominatediv, #logindiv, #regdiv, #faqdiv').hide();
$('#settingsstreet').val('');
$('#settingscity').val('');
$('#settingsstate').val('');
$('#settingszip').val('');
$('#settingsphone').val('');
$('#settingsemail').val('');
if (includeDues) $('#settingsduespaid').val('');
$('#settingspassword').val('');
$('#settingsconfirmpassword').val('');
$('.container').hide();
$('#settingsdiv').show('blind', 500);
screwtopDb().url(DBURL)
.session(function(s) {
if (!screwtopDb.isEmpty(getCookie(rootBlogTopicId + '-impersonating'))) {
$('#settingsusername').val(getCookie(rootBlogTopicId + '-impersonating'));
screwtopDb().url(DBURL)
.logout()
.login(APPNAME, getCookie(rootBlogTopicId + '-username'), getCookie(rootBlogTopicId + '-password'))
.login(APPNAME, getCookie(rootBlogTopicId + '-impersonating'), '')
.attributes()
// Login is required to get attributes with an empty password (don't know why…)
//.login(APPNAME,username, password)
.func(function(arr) {
screwtopDb.forEach(arr, function(pair) {
if (pair.name == "street") $('#settingsstreet').val(pair.value);
else if (pair.name == "city") $('#settingscity').val(pair.value);
else if (pair.name == "state") $('#settingsstate').val(pair.value);
else if (pair.name == "zip") $('#settingszip').val(pair.value);
else if (pair.name == "phone") $('#settingsphone').val(pair.value);
else if (pair.name == "email") $('#settingsemail').val(pair.value);
else if (includeDues && pair.name == "Year Paid") $('#settingsduespaid').val(pair.value);
});
if (includeDues) {
// Highlight unpaid dues
var dt = new Date();
var thisYr = dt.getFullYear();
if ($('#settingsduespaid').val() < thisYr) $('#duespaidlabel').css('color', 'red');
}
})
.end();
}
else {
$('#settingsusername').val(s.username);
screwtopDb().url(DBURL)
.login(APPNAME,username, password)
.attributes()
// Login is required to get attributes with an empty password (don't know why…)
//.login(APPNAME,username, password)
.func(function(arr) {
screwtopDb.forEach(arr, function(pair) {
if (pair.name == "street") $('#settingsstreet').val(pair.value);
else if (pair.name == "city") $('#settingscity').val(pair.value);
else if (pair.name == "state") $('#settingsstate').val(pair.value);
else if (pair.name == "zip") $('#settingszip').val(pair.value);
else if (pair.name == "phone") $('#settingsphone').val(pair.value);
else if (pair.name == "email") $('#settingsemail').val(pair.value);
else if (includeDues && pair.name == "Year Paid") $('#settingsduespaid').val(pair.value);
});
if (includeDues) {
// Highlight unpaid dues
var dt = new Date();
var thisYr = dt.getFullYear();
if ($('#settingsduespaid').val() < thisYr) $('#duespaidlabel').css('color', 'red');
}
})
.end();
}
})
/*
// Login is required to get attributes with an empty password (don't know why…)
//.login(APPNAME,username, password)
.func(function(arr) {
screwtopDb.forEach(arr, function(pair) {
if (pair.name == "street") $('#settingsstreet').val(pair.value);
else if (pair.name == "city") $('#settingscity').val(pair.value);
else if (pair.name == "state") $('#settingsstate').val(pair.value);
else if (pair.name == "zip") $('#settingszip').val(pair.value);
else if (pair.name == "phone") $('#settingsphone').val(pair.value);
else if (pair.name == "email") $('#settingsemail').val(pair.value);
});
})
//.attributes('email')
*/
.end(function() {
//$('#settingsemail').val(em[0].value);
showSpinner = false;
$('#spinner').stop().hide();
});
$('#settingscancelbtn').unbind().click(function() {
$('#settingsstreet').val('');
$('#settingscity').val('');
$('#settingsstate').val('');
$('#settingszip').val('');
$('#settingsphone').val('');
$('#settingsemail').val('');
if (includeDues) $('#settingsduespaid').val('');
$('#settingspassword').val('');
$('#settingsconfirmpassword').val('');
$('#settingsdiv').hide('blind', 500);
bindSettings();
})
$('#settingsbutton').unbind().click(function() {
var p = '';
if ($('#settingspassword').val() == $('#settingsconfirmpassword').val()) {
p = $('#settingspassword').val().trim();
}
else {
alert('');
return;
}
var e = $('#settingsemail').val().trim();
var obj = {};
var doIt = false;
if (e != '') {
obj["email"] = e;
doIt = true;
}
if (p != '') {
obj["password"] = p;
doIt = true;
}
obj["street"] = $('#settingsstreet').val().trim();
obj["city"] = $('#settingscity').val().trim();
obj["state"] = $('#settingsstate').val().trim();
obj["zip"] = $('#settingszip').val().trim();
obj["phone"] = $('#settingsphone').val().trim();
if (doIt) {
var showSpinner = true;
setTimeout(function() {
if (showSpinner) {
$('#spinner').fadeIn('fast');
}
}, 1000);
screwtopDb().url(DBURL)
.updateUser(obj)
.end(function() {
showSpinner = false;
$('#spinner').stop().hide();
$('#settingsstreet').val('');
$('#settingscity').val('');
$('#settingsstate').val('');
$('#settingszip').val('');
$('#settingsphone').val('');
$('#settingsemail').val('');
$('#settingspassword').val('');
$('#settingsconfirmpassword').val('');
$('#settingsdiv').hide('blind', 500);
setSingleUseToken(function(tok) {
$.ajax(addlang('attr?token=' + tok));
})
alert('');
});
}
});
$('#deleteaccountbtn').unbind().click(function() {
var delpswd = prompt("All your contributions to this website will be removed.\n\n" +
"Enter your password below to delete your account.\n\n");
//if (!screwtopDb.isEmpty(delpswd)) {
$('#spinner').fadeIn('fast');
screwtopDb().url(DBURL)
.logout()
.onError(function() {
$('#spinner').stop().hide();
alert('')
screwtopDb().url(DBURL).onError().abort().end();
})
.login(APPNAME, username, delpswd)
.onError()
.func(function() {
$('#settingsemail').val('');
$('#settingspassword').val('');
$('#settingsconfirmpassword').val('');
$('#settingsdiv').hide('blind', 500);
})
.deleteUser(username)
.func(localLogout)
.invalidateCache()
.end(function() {
$('#spinner').stop().hide();
location = '/';
});
//}
})
});
}
var shifted = false;
$(document).on('keyup keydown', function(e){shifted = e.shiftKey} );
function bindMenuLinks() {
$('#touchdiv').unbind().click(function() {
showLoginForm();
});
$('.infoitem')
.unbind()
.click(function(ev) {
$('.infoitem.selected').removeClass('selected');
$(this).addClass('selected');
if (shifted && !isLoggedIn()) {
showLoginForm();
return false;
}
else {
$('#main').show();
$('#newarticle').hide("blind");
var href = $(ev.target).find('a').attr('href');
showContent(href);
//var articleId = $(ev.target).attr('articleId');
}
return false;
});
$('.infoitem a').unbind().click(function() {
$(this).parent().click();
return false;
});
}
function schedEvent(localms, dur, title, loc, topicId, color) {
// Event times stored as UTC
var dt = new Date(localms);
var utcms = dt.getTime() + (dt.getTimezoneOffset() * 60 * 1000);
var event = {
text: screwtopDb.guid(),
startTime: utcms,
duration: dur,
//title: title,
//location: loc,
textColor: 'white',
color: color,
owner: username,
articleTopicId: topicId };
event["title-" + lang] = title;
event["location-" + lang] = loc;
//console.log(JSON.stringify(event,null,' '));
return { text: 'schedule', events: event };
}
function schedEvent2(localms, dur, title, loc, link, color) {
// Event times stored as UTC
var dt = new Date(localms);
var utcms = dt.getTime() + (dt.getTimezoneOffset() * 60 * 1000);
var event = {
text: screwtopDb.guid(),
startTime: utcms,
duration: dur,
//title: title,
//location: loc,
textColor: 'white',
color: color,
owner: username,
infolink: link };
event["title-" + lang] = title;
event["location-" + lang] = loc;
//alert(JSON.stringify(event,null,' '));
return { text: 'schedule', events: event };
}
function recurEvent(ev, nth, xDay, endMo, endYr, color) {
var startDt = new Date(ev.startTime);
var endDt = new Date();
endDt.setHours(0);
endDt.setMinutes(0);
endDt.setSeconds(0);
endDt.setMonth(endMo);
endDt.setDate(1);
endDt.setFullYear(endYr);
var recurSpec = {
text: screwtopDb.guid(),
nth: nth, // every 2nd
recurwkday: xDay, // friday
//location: ev["location"],
startHr: ((startDt.getHours() - startDt.getTimezoneOffset()/60) + 24) % 24, // Local timezone hour
startMin: ((startDt.getMinutes() - startDt.getTimezoneOffset()%60) + 60) % 60, // Local timezone minute
duration: ev.duration,
owner: ev.owner,
//title: ev["title"],
start: ev.startTime,
end: endDt.getTime(),
color: color,
textColor: 'white'
};
recurSpec["title-" + lang] = ev["title-" + lang];
recurSpec["location-" + lang] = ev["location-" + lang];
if (!screwtopDb.isEmpty(ev.infolink)) recurSpec.infolink = ev.infolink;
if (!screwtopDb.isEmpty(ev.articleTopicId)) recurSpec.articleTopicId = ev.articleTopicId;
return { text: 'recurringEvents', specifications: recurSpec };
}
function initCalendar() {
$('#startdate2').unbind().change(function() {
var dt = new Date(Date.parse($(this).val()));
$('#enddate2').datepicker('setDate',dt);
$('#starttime2').timepicker('setTime', dt);
});
$('#starttime2').unbind().change(function() {
$('#endtime2').timepicker({'minTime': $(this).val(), 'showDuration': true });
$('#endtime2').val($(this).val());
});
var holsAdded = false;
$('#calendardiv').fullCalendar({
theme: true,
timeFormat: { '': 'h(:mm)t' },
eventAfterAllRender: function() {
if (!holsAdded) {
holsAdded = true;
addHolidays();
}
},
eventColor: '#4488bb',
eventRender: function(event, element) {
element.click(function() {
var delbtnstr = ""
if (event.recur == true) {
delbtnstr = '' +
'';
}
else {
delbtnstr = '';
}
var morebtnstr = "";
if (!screwtopDb.isEmpty(event.infolink)) {
morebtnstr = '';
}
else if (!screwtopDb.isEmpty(event.articleTopicId)) {
morebtnstr = '';
}
$('#eventdiv').html('' + event["title"] + ''
+ ''
+ $.fullCalendar.formatDate(event.start, 'MMMM d, h:mm TT')
+ ''
+ event.duration
+ ' min'
+ ''
+ event["location"]
+ ''
+ ''
+ morebtnstr
+ delbtnstr).show('blind',500);
if (!screwtopDb.isEmpty(event.owner) && event.owner != username) $('#deleventbtn,#delinstbtn,#delrecurbtn').hide();
else $('#deleventbtn,#delinstbtnm,#delrecurbtn').show();
$('#deleventbtn').unbind().click(function() {
showSpinner();
screwtopDb().url(DBURL)
.deleteValues(event.valueId)
.invalidateCache()
.end(function() {
hideSpinner();
location = '/' + lang + '/calendar';
})
});
$('#delrecurbtn').unbind().click(function() {
showSpinner();
screwtopDb().url(DBURL)
.deleteValues(event.valueId)
.invalidateCache()
.end(function() {
hideSpinner();
location = '/' + lang + '/calendar';
})
});
$('#delinstbtn').unbind().click(function() {
showSpinner();
screwtopDb().url(DBURL)
//.beginServerExecution()
.topicById(event.id, {elide:true})
.addTags('exceptions',event.start.getMonth())
//.endServerExecution()
.invalidateCache()
.end(function() {
hideSpinner();
location = '/' + lang + '/calendar';
})
});
$('#eventclosebtn').unbind().click(function() {
$('#eventdiv').hide('blind', 500);
});
bindLinks();
$('.morebtn2, .closebtn').corner('6px');
$('#eventdiv').corner('6px');
//if (isBlogPoster()) $('#deleventbtn').show();
});
}
});
}
function localLogout() {
//username = '';
//$('.userinfoitem').hide();
//setAuthorActions();
epi.hidePersonalSidebar();
deleteCookie(rootBlogTopicId + '-impersonating');
deleteCookie(rootBlogTopicId + '-username');
deleteCookie(rootBlogTopicId + '-password');
//$('#addarticlebtn, #logoutbtn, #schedbtn, #deleventbtn, .localitem').hide();
//$('#loginbtn, #registerbtn').show();
deleteCookie(APPNAME + '-configpass')
if (hasSessionStorage) sessionStorage[APPNAME + '-configActive'] = false;
if (hasSessionStorage) sessionStorage[APPNAME + '-configpass'] = false;
configActive = false;
$('.configtools').remove();
window.location = '/';
}
var theAnimator = null;
/*
function animator(targetImg,targetDiv) {
if (theAnimator != null) {
theAnimator.stopAnimation();
}
theAnimator = this;
var curLeftPx = 0;
var curTopPx = 0;
var curHeight;
var leftInc = 0;
var topInc = 0;
var heightInc = 0;
var divh;
var divw;
var ih,iw;
var ratio;
var frameRate;
var frames;
var startTime;
var abort = false;
var maxmag;
var minmag;
var delay;
var rt;
iw = targetImg.width();
ih = targetImg.height();
divh = parseInt(targetDiv.css('height'));
divw = parseInt(targetDiv.css('width'));
targetImg.css('height',(ih * (divw/iw)) + 'px');
targetImg.css('margin-left', '0px');
//alert('iwxih=' + iw + 'x' + ih + '\n' + 'divwxdivh=' + divw + 'x' + divh);
this.stopAnimation = function stopAnimation() {
//$('#alog').remove();
abort = true;
}
this.toggle = function toggle() {
if (abort) {
this.resumeAnimation();
}
else this.stopAnimation();
}
this.initAnimation = function initAnimation() {
$('body').prepend('');
leftInc = -0.1;
topInc = -0.1;
heightInc = 0.05;
targetImg.css('height',((divw/iw) * ih) + 'px');
targetImg.css('margin-left', '0px');
curLeftPx = 0;
curTopPx = 0;
curHeight = (divw/iw) * ih;
ratio = divw/divh;
hdir = 0;
vdir = 0;
mdir = 0;
startTime = (new Date()).getTime();
frames = 0;
delay = 10;
rt = 0;
maxmag = ih * (divw/iw) * 2.5;
minmag = ih * (divw/iw);
abort = false;
}
this.resumeAnimation = function resumeAnimation() {
abort = false;
setTimeout(anim,0);
}
this.startAnimation = function startAnimation() {
this.initAnimation();
setTimeout(anim,0);
}
function anim() {
//var imgh = parseInt(targetImg.css("height"));
//var imgw = parseInt(targetImg.css("width"));
var threshold = 0;
var hthresh = 0;
var vthresh = 0;
var mthresh = 0;
// First zoom in...
if (0 && curHeightPct < minmag * 100) {
heightInc = 0.1;
leftInc = 0.1;
topInc = 0.1;
curHeightPct += heightInc;
curLeftPx -= heightInc*ratio;
curTopPx -= heightInc*1;
targetImg
.css('margin-left',curLeftPx + 'px')
.css('margin-top',curTopPx + 'px')
.css('height',(ih * (curHeightPct/100)) + 'px');
//$('#alog').html('curHeightPct=' + Math.round(curHeightPct) + ' heightInc=' + heightInc + ', frames=' + frames + ', rt=' + rt + ', frameRate=' + Math.round(frameRate) + ', delay=' + Math.round(delay));
}
else {
var imgh = parseInt(targetImg.css("height"));
var imgw = parseInt(targetImg.css("width"));
mthresh = ((maxmag - minmag) / 2) + minmag;
var distFromThresh = Math.abs(mthresh - imgh);
var howClose = distFromThresh / ((maxmag - minmag) / 2);
if (howClose >= 1) {
if (imgh <= minmag) mdir = 0;
else mdir = 1;
}
var minHeightInc = 0.5;
var maxHeightInc = 2.0;
heightInc = (((1-Math.abs(howClose)) * (maxHeightInc - minHeightInc)) + minHeightInc) * (mdir ? -1 : 1);
curHeight += heightInc;
//curLeftPx -= heightInc;
//curTopPx -= heightInc/ratio;
targetImg.css('height',curHeight + 'px');
var imgh = parseInt(targetImg.css("height"));
var imgw = parseInt(targetImg.css("width"));
hthresh = ((imgw - divw) / 2) * -1;
howClose = Math.abs(((hthresh - curLeftPx) / hthresh));
if (howClose >= 1) {
if (curLeftPx >= 0) hdir = 1;
else hdir = 0;
}
// if (imgw + curLeftPx - divw <= 0) hdir = 1;
// if (curLeftPx >= 0) hdir = 0;
var minLeftInc = 0.1;
var maxLeftInc = 4.0;
leftInc = (((1-Math.abs(howClose)) * (maxLeftInc - minLeftInc)) + minLeftInc) * (hdir ? 1 : -1);
//console.log('(((1-'+ Math.abs(howClose) + ')) * (' + maxLeftInc + ' - ' + minLeftInc + ')) + ' + minLeftInc + ') * ' + (hdir ? 1 : -1) + ' = ' + leftInc);
//vthresh = ((imgh - divh) / 2) * -1;
//if (imgh + curTopPx - divh <= 0) vdir = 1;
//if (curTopPx >= 0) vdir = 0;
//howClose = Math.abs(((vthresh - curTopPx) / vthresh));
//var minTopInc = 0.1;
//var maxTopInc = 4.0;
//topInc = (((1-Math.abs(howClose)) * (maxTopInc - minTopInc)) + minTopInc) * (vdir ? 1 : -1);
curLeftPx += leftInc;
//curTopPx += topInc;
targetImg
//.css('height',curHeight + 'px')
.css('margin-left',curLeftPx + 'px')
.css('margin-top',curTopPx + 'px');
$('#alog').html('xyz inc: ' + Math.round(leftInc*100) + ' ' + Math.round(topInc*100) + ' ' + Math.round(heightInc*100)
+ ', curLeftPx: ' + curLeftPx
+ ', hthresh: ' + Math.round(hthresh) + ', howClose: ' + Math.round(howClose*100)
);
}
frames++;
rt = (new Date()).getTime() - startTime;
frameRate = (frames*1000)/rt;
if (rt > 500) {
delay = delay * (frameRate/60);
startTime = (new Date()).getTime();
frames = 0;
}
if (!abort) setTimeout(anim,delay);
}
return this;
}
*/
function showLoginForm() {
$('#usernametext').val("");
$('#passwordtext').val("");
$('#loginloginbtn').attr('disabled', false);
$('#logindiv').show("blind", 500, function() {
$('#usernametext').focus();
});
}
$(document).ready(function() {
$('#perf').html(perfstr);
$('#endyr').html(yroptionlist);
if (rootBlogOptions.indexOf('layoutpitch') >= 0) $('.nopitch').hide();
window.onpopstate = function(ev) {
if (ev.state) {
$('#articles').html(ev.state);
bindLinks();
localize8601Dates();
fixup();
initCalendar();
updateCalendar();
}
}
$('.altlang').click(function() {
var newlang = $(this).attr('data-lang');
var re = new RegExp('/' + lang);
var newpathname = window.location.pathname + newlang;
if (window.location.pathname !="/")
newpathname = window.location.pathname.replace(re,'/' + newlang);
window.location = newpathname;
})
$('#loginbtn').click(function() {
showLoginForm();
$('#loginbtn, #registerbtn').hide();
});
$('#schedbtn').click(function() {
$('#logoutbtn, #schedbtn, #addarticlebtn').hide();
$('#scheddiv').show("blind", 500);
});
$('#cancelschedbtn').click(function() {
$('#logoutbtn, #schedbtn, #addarticlebtn').show();
$('#scheddiv').hide("blind", 500);
});
$('#logincancelbtn').click(function() {
$('#logindiv').hide("blind", function() {
$('#loginbtn, #registerbtn').show();
});
});
$('#registerbtn').click(function() {
$('#regfirstname').val("");
$('#reglastname').val("");
$('#regstreet').val("");
$('#regcity').val("");
$('#regstate').val("CA");
$('#regzip').val("");
$('#regphone').val("");
$('#regpassword').val("");
$('#regconfpassword').val("");
$('#regemail').val("");
$('#loginbtn, #registerbtn').hide();
$('#regregisterbtn').attr('disabled', false);
$('#registerdiv').show("blind", 500, function() {
$('#regfirstname').focus();
});
});
$('#regcancelbtn').click(function() {
$('#registerdiv').hide("blind", function() {
$('#registerbtn, #loginbtn').show();
});
});
function setInfoline(cb) {
screwtopDb().url(DBURL)
//.beginServerExecution()
.topicById(rootBlogTopicId)
.tag(APPNAME + '/subblogs')
.values()
.topics({elide:true, tagfilter: APPNAME + '/title-' + lang})
.values()
.text()
//.endServerExecution()
.fn(function() {
// Remove all but Home
$('.infoitem:not(#homebtn)').remove();
})
.each(function(subblog) {
if (rootBlogOptions.indexOf("layout3") < 0 && rootBlogOptions.indexOf("layout4") < 0) {
$('#infoline').append('