· 4 years ago · Jul 31, 2021, 06:30 AM
1// Opera 8.0+
2var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
3// Firefox 1.0+
4var isFirefox = typeof InstallTrigger !== 'undefined';
5// Safari 3.0+ "[object HTMLElementConstructor]"
6var isSafari = /constructor/i.test(window.HTMLElement) || (function(p) {
7 return p.toString() === "[object SafariRemoteNotification]";
8})(!window['safari'] || (typeof safari !== 'undefined' && window['safari'].pushNotification));
9// Internet Explorer 6-11
10var isIE = /*@cc_on!@*/ false || !!document.documentMode;
11// Edge 20+
12var isEdge = !isIE && !!window.StyleMedia;
13// Chrome 1 - 79
14var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
15// Edge (based on chromium) detection
16var isEdgeChromium = isChrome && (navigator.userAgent.indexOf("Edg") != -1);
17// Blink engine detection
18var isBlink = (isChrome || isOpera) && !!window.CSS;
19
20if (isOpera) { // *bleep* you, opera....
21 console.log("opera css fix");
22 var s = document.createElement("style");
23 s.innerHTML = `
24
25.tdbgimg !important {
26 background: rgba(0,0,0,0.5);
27 background-image: '';
28 transition: all 0.5s;
29}
30
31
32#wizSyncButton {
33 padding-left: 15px !important;
34 padding-right: 60px !important;
35 background: #000;
36 background-position-x: 0px;
37 background-position-y: 0px !important;
38 background-repeat: no-repeat;
39 background-size: 277px 48px !important;
40 /* background-origin: padding-box, padding-box; */
41 /* background-clip: border-box, border-box; */
42
43 /* background: rgb(0,0,0); /* Old browsers */
44 /* background: -moz-linear-gradient(-45deg, rgba(76,76,76,1) 0%, rgba(89,89,89,1) 12%, rgba(102,102,102,1) 25%, rgba(71,71,71,1) 35%, rgba(76,76,76,1) 42%, rgba(76,76,76,1) 46%, rgba(44,44,44,1) 50%, rgba(0,0,0,1) 55%, rgba(17,17,17,1) 60%, rgba(43,43,43,1) 76%, rgba(28,28,28,1) 91%, rgba(19,19,19,1) 100%);
45 /* background: -webkit-linear-gradient(-45deg, rgba(76,76,76,1) 0%,rgba(89,89,89,1) 12%,rgba(102,102,102,1) 25%,rgba(71,71,71,1) 35%,rgba(76,76,76,1) 42%,rgba(76,76,76,1) 46%,rgba(44,44,44,1) 50%,rgba(0,0,0,1) 55%,rgba(17,17,17,1) 60%,rgba(43,43,43,1) 76%,rgba(28,28,28,1) 91%,rgba(19,19,19,1) 100%);
46
47 /* background-image: url("sync.png"), -moz-linear-gradient(-45deg, rgba(76,76,76,1) 0%, rgba(89,89,89,1) 12%, rgba(102,102,102,1) 25%, rgba(71,71,71,1) 35%, rgba(76,76,76,1) 42%, rgba(76,76,76,1) 46%, rgba(44,44,44,1) 50%, rgba(0,0,0,1) 55%, rgba(17,17,17,1) 60%, rgba(43,43,43,1) 76%, rgba(28,28,28,1) 91%, rgba(19,19,19,1) 100%); */
48 background-image: url("sync.png"), -webkit-linear-gradient(-45deg, rgba(76,76,76,1) 0%,rgba(89,89,89,1) 12%,rgba(102,102,102,1) 25%,rgba(71,71,71,1) 35%,rgba(76,76,76,1) 42%,rgba(76,76,76,1) 46%,rgba(44,44,44,1) 50%,rgba(0,0,0,1) 55%,rgba(17,17,17,1) 60%,rgba(43,43,43,1) 76%,rgba(28,28,28,1) 91%,rgba(19,19,19,1) 100%) !important;
49 /* background-image: url("sync.png"), linear-gradient(135deg, rgba(76,76,76,1) 0%,rgba(89,89,89,1) 12%,rgba(102,102,102,1) 25%,rgba(71,71,71,1) 35%,rgba(76,76,76,1) 42%,rgba(76,76,76,1) 46%,rgba(44,44,44,1) 50%,rgba(0,0,0,1) 55%,rgba(17,17,17,1) 60%,rgba(43,43,43,1) 76%,rgba(28,28,28,1) 91%,rgba(19,19,19,1) 100%); */
50 /* background-image: url("sync.png"), linear-gradient(135deg, rgba(76,76,76,1) 0%,rgba(89,89,89,1) 12%,rgba(102,102,102,1) 25%,rgba(71,71,71,1) 35%,rgba(76,76,76,1) 42%,rgba(76,76,76,1) 46%,rgba(44,44,44,1) 50%,rgba(0,0,0,1) 55%,rgba(17,17,17,1) 60%,rgba(43,43,43,1) 76%,rgba(28,28,28,1) 91%,rgba(19,19,19,1) 100%); */
51 /* filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313',GradientType=1 ); */
52
53
54}
55
56
57 `;
58 document.getElementsByTagName("head")[0].appendChild(s);
59}
60
61
62
63// var height = $(window).height();//gets height from device
64// var width = $(window).width(); //gets width from device
65var activeTrid = [];
66var offset = '0';
67var timezone = "0";
68var refreshList = 0;
69var progressDiv = '';
70var reverseoffset = '0';
71var postoffset = '0';
72var posttimezone = '0';
73var recentPosts = [];
74var favPosts = [];
75var postreverseoffset = '0';
76var eventoffset = '0';
77var eventtimezone = '0';
78var utimezone;
79var tz;
80var eventreverseoffset = '0';
81var pageevent = '';
82var eventArray = {};
83var page = '';
84var globalEurl = '';
85var page_url = '';
86var page_title = '';
87var dayName = '';
88var postTimes = [];
89var varWinload = '';
90var slideshow = [];
91var sseurl = '';
92var frameTitle = '';
93var rating = 'T';
94var date = new Date();
95var curDay = date.toLocaleDateString("en-US", {
96 weekday: 'long'
97});
98var prefix = '';
99var ratingMode = readCookie("rating");
100var currentTags = '';
101var currentKeywords = '';
102var closeBtn = '<input type="button" class="okBtn defaultBtn" value="Close" onclick=\'$(".popup").fadeOut()\'>';
103var userdatacenter = 'Crystal';
104var cookiedatacenter = readCookie('datacenter');
105var today = new Date();
106var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
107var dayOfWeek = days[today.getDay()].toString().substring(0, 3).toLowerCase();
108var zoneAbbr = 'EST';
109var headerwidth = $(window).width();
110var featuredInterval;
111// $("#contain").width(width+"px");
112// $("#contain").height(height+"px");
113
114var wizId = '';
115var curWizEurl = '';
116
117
118var database;
119
120function addZero(i) {
121 if (i < 10) {
122 i = "0" + i;
123 }
124 return i;
125}
126
127var faded = 0;
128
129$( document ).ajaxError(function( xhr, status, error ) {
130 var jsonData = {};
131 jsonData["arguments"] = JSON.stringify(arguments);
132 jsonData["error"] = error;
133 // jsonData["status"] = JSON.stringify(status);
134 // jsonData["xhr"] = JSON.stringify(xhr);
135 jsonData["status"] = status;
136 jsonData["xhr"] = xhr;
137 $.ajax({
138 type: 'POST',
139 url: 'error.php',
140 global: false,
141 data: jsonData,
142 // dataType: 'json',
143 success: function(data) {
144 if ( data == 1 ) {
145 // msg("Error processing request. This issue should be resolved within 24 hours. We apologize for the peccadillo." );
146 $("#loading-img").fadeOut(500);
147 } else {
148 // msg("An error occurred processing your request. An additional error occurred processing the error.");
149 $("#loading-img").fadeOut(500);
150 }
151 },
152 error: function(e) {
153 console.log(e);
154 msg("An error occurred processing your request. An additional error occurred processing the error.");
155 $("#loading-img").fadeOut(500);
156 }
157 });
158});
159
160function getKeyByValue(object, value) {
161 return Object.keys(object).find(key => object[key] === value);
162}
163
164function ajaxNonFatalError(result,status = '',xhr = '', silent = false) {
165 var jsonData = {};
166 // jsonData["result"] = JSON.stringify(result);
167 // jsonData["status"] = JSON.stringify(status);
168 // jsonData["xhr"] = JSON.stringify(xhr);
169 jsonData["arguments"] = JSON.stringify(arguments);
170 jsonData["result"] = result;
171 jsonData["status"] = status;
172 jsonData["xhr"] = xhr;
173 $.ajax({
174 type: 'POST',
175 url: 'error.php',
176 global: false,
177 // processData: true,
178 data: jsonData,
179 // dataType: 'json',
180 success: function(data) {
181 if ( data == 1 ) {
182 // if (!silent) { msg("Error processing request. This issue should be resolved within 24 hours. We apologize for the peccadillo." ); }
183 $("#loading-img").fadeOut(500);
184 } else {
185 // if (!silent) { msg("An error occurred processing your request. An additional error occurred processing the error."); }
186 $("#loading-img").fadeOut(500);
187 }
188 },
189 error: function(e) {
190 console.log(e);
191 if (!silent) { msg("An error occurred processing your request. An additional error occurred processing the error.");}
192 $("#loading-img").fadeOut(500);
193 }
194 });
195}
196
197window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {
198 ajaxNonFatalError(errorMsg, url, lineNumber);
199 return false;
200}
201
202function showNav() {
203 faded = 0;
204 var newHeight = $(".navbuttons").height() - 15 + "px";
205 $(".navbuttons").animate({
206 height: newHeight
207 });
208 $(".header").animate({
209 top: "15px"
210 });
211 $(".header").fadeTo(1000, 0.9);
212 $(".footer").animate({
213 bottom: "15px"
214 });
215 $(".footer").fadeTo(1000, 1);
216 $(".nav").animate({
217 left: "15px"
218 });
219 $(".nav").fadeTo(1000, 0.9);
220}
221
222function hideNav() {
223 faded = 1;
224 var newHeight = $(".navbuttons").height() + 15 + "px";
225 $(".navbuttons").animate({
226 height: newHeight
227 });
228 $(".header").animate({
229 top: "0px"
230 });
231 $(".header").fadeTo(1000, 0.5);
232 $(".nav").animate({
233 left: "0px"
234 });
235 $(".nav").fadeTo(1000, 0.8);
236 $(".footer").animate({
237 bottom: "-1px"
238 });
239 $(".footer").fadeTo(1000, 0.5);
240}
241
242(function($) {
243 $.fn.color = function color(color, type = 'wizSteps') {
244 color = capitalizeWords(color);
245 // if (color == 'Green') {return;}
246 var selector = this.selector;
247 $(this.selector).removeClass(type + "Green").removeClass(type + "Red").removeClass(type + "Yellow").addClass(type + color);
248 return;
249 }
250})(jQuery);
251
252function receedHeaders() {
253 var scrollTop = $("#content").scrollTop();
254 if (scrollTop <= 10 && faded == 1) {
255 showNav();
256 } else if (scrollTop >= 50 && faded == 0) {
257 hideNav();
258 }
259}
260
261var dclist = '';
262var datacenters = '';
263
264function populatedcs(target = '#datacenter', selected = userdatacenter) {
265 if (dclist == '') {
266 $.ajax({
267 type: 'GET',
268 url: 'https://xivapi.com/servers/dc',
269 data: {},
270 dataType: 'json',
271 success: function(dcs) {
272 processdcs(dcs, target, selected);
273 }
274 });
275 } else {
276 processdcs(dclist, target, selected);
277 }
278}
279
280function processdcs(dcs = dclist, target, selected) {
281 // dclist = dcs;
282 // if (typeof dcs == "undefined" ) { return; }
283 datacenters = '';
284
285 for (i in dcs) {
286 datacenters = `${datacenters}<option dir="ltr" value="${i}">${i}</option>`;
287 }
288 $(target).html(datacenters);
289 // $('#datacenter select').val(userdatacenter);
290 $(`${target} option[value=${selected}]`).attr('selected', 'selected');
291}
292
293
294
295function isJson(str) {
296 try {
297 JSON.parse(str);
298 } catch (e) {
299 return false;
300 }
301 return true;
302}
303
304function isEmpty(str) {
305 return (!str || 0 === str.length);
306}
307
308var total = 0;
309var opentoday = 0;
310var opensoon = 0;
311var opennow = 0;
312
313function gcd(a, b) {
314 return (b == 0) ? a : gcd(b, a % b);
315}
316
317function urlify(text, nullout = '0') {
318 if (typeof text == 'undefined' || text == null) {
319 return;
320 }
321 var urlRegex = /(https?:\/\/[^\s]+)/g;
322 return text.replace(urlRegex, function(url) {
323 if (url.endsWith('.mp4')) {
324 if (nullout != '0') {
325 return '';
326 } else {
327 return '<center><video width="80%" controls class="video-background" controls preload="none" loop="loop" muted autoplay="autoplay"><source type="video/mp4" src="' + url + '"></video></center>';
328 }
329 } else if (url.endsWith('.gif') || url.endsWith('.jpg') || url.endsWith('.png')) {
330 if (nullout != '0') {
331 return '';
332 } else {
333 return '<center><img src="' + url + '" width="80%"></center>';
334 }
335 } else {
336 if (nullout != '0') {
337 return '';
338 } else {
339 return '<a target="_black" href="' + url + '">' + url + '</a>';
340 }
341 }
342 })
343}
344
345var savedHtml = [];
346var savedHtmlId = [];
347var savedHtmlBg = [];
348
349function collapsePost(eurl, prefix = '') {
350 // console.log(eurl, prefix);
351 if (typeof mode == 'undefined') {
352 mode = '';
353 }
354 if (typeof eurl == 'undefined') {
355 return;
356 }
357 if (prefix == '') {
358 if (eurl.toString().startsWith('event-') || mode == 'getevent') {
359 // mode = mode+'event';
360 eurl = eurl.replace(/^event-/, "");
361 // mode = mode.replace(/tab$/, "event");
362 // mode = ;
363 prefix = 'event-';
364 }
365 if (eurl.toString().startsWith('group-') || mode == 'getgroup') {
366 // mode = mode+'group';
367 eurl = eurl.replace(/^group-/, "");
368 // mode = mode+"group";
369 // mode = mode.replace(/tab$/, "group");
370 prefix = 'group-';
371 }
372 }
373 // console.log(activeTrid);
374 var id = savedHtmlId[prefix + eurl];
375 var bg = savedHtmlBg[prefix + eurl];
376 var html = savedHtml[prefix + eurl];
377 delete activeTrid[prefix + eurl];
378 // console.log(id, prefix, eurl, html);
379 $(`div#${prefix}${eurl}`).fadeOut(750, function() {
380 $(`#${id}`).fadeTo(500, 0, function() {
381 $(`#${id}`).animate({ height: "122px" });
382 $(`#${id}`).prop('outerHTML', html);
383 $(`#${id}`).fadeTo(500, 1);
384 // $('.image').fadeOut();
385 // $(".mainPic").mouseenter(function(){
386 // if ($(this).parent('td').children('div.image').length) {
387 // $(this).parent('td').children('div.image').fadeIn();
388 // } else {
389 // var image_name=$(this).data('image');
390 // var imageTag='<div class="image imgdropshadow" style="position:absolute;">'+'<img src="'+image_name+'" alt="image" height="100%" />'+'</div>';
391 // $(this).parent('td').append(imageTag);
392 // $(this).parent('td').children('div.image').fadeIn();
393 // }
394 // });
395 // $(".mainPic").mouseleave(function(){
396 // $(this).parent('td').children('div.image').fadeOut();
397 // });
398 });
399 });
400}
401
402var getMode = '';
403
404function getPost(eurl = '', target = '#events', mode = '', id = '', data = '', titleList = '0', tab = '') {
405 $("#loading-img").fadeIn(500);
406
407 if (eurl == '[object HTMLInputElement]') { eurl = eurl.value; }
408
409 if (mode == '') {
410 prefix = '';
411 if (eurl.toString().startsWith('event-') || mode == 'getevent') {
412 // mode = mode+'event';
413 eurl = eurl.replace(/^event-/, "");
414 mode = "getevent";
415 prefix = 'event-';
416 }
417
418
419 if (eurl.toString().startsWith('group-') || mode == 'getgroup') {
420 // mode = mode+'group';
421 eurl = eurl.replace(/^group-/, "");
422 mode = "getgroup";
423 prefix = 'group-';
424 }
425 if (prefix == '') {
426 mode = 'get';
427 }
428 }
429
430 if (target == '#postDiv-body') {
431 collapsePost(prefix + eurl);
432 }
433
434 if (mode == 'events') {
435 prefix = 'event-';
436 }
437 if (mode == 'groups') {
438 prefix = 'group-';
439 }
440
441 // console.log(getMode, prefix, prefix+eurl, mode, recentPosts);
442 if (prefix != '' || mode == 'get') {
443 recentPosts.unshift(prefix + eurl);
444 var uniqueRecent = [];
445 $.each(recentPosts, function(i, el) {
446 if ($.inArray(el, uniqueRecent) === -1) uniqueRecent.push(el);
447 });
448 recentPosts = uniqueRecent;
449 // console.log(prefix, mode, eurl, recentPosts);
450
451 if (recentPosts.length > 10) {
452 recentPosts = recentPosts.slice(0, 10);
453 }
454 createCookie('recentPosts', JSON.stringify(recentPosts));
455 }
456
457 if (tab == '') {
458 // if ( target != '#postDiv-body' ) { $(target).text(''); }
459 $("#postDiv-title").html('Loading...');
460 $('#event_titles').text('');
461 } else {
462 $(target).addClass('tab-inactive');
463 $(target).removeClass('tab-active');
464 $(id).addClass('tab-active');
465 $(id).removeClass('tab-inactive');
466 }
467 globalEurl = prefix+eurl;
468 var jsonData = {};
469 jsonData["mode"] = mode;
470 jsonData["eurl"] = eurl;
471 jsonData["id"] = eurl;
472 jsonData["dc"] = userdatacenter;
473 jsonData["data"] = data;
474
475 $.ajax({
476 type: 'POST',
477 url: 'api.php',
478 data: jsonData,
479 dataType: 'json',
480 success: function(rows) {
481 if (typeof rows.status != 'undefined' && data.status == '255') {
482 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
483 return;
484 }
485 if (getMode == 'siteevent') {
486 getMode = 'website';
487 }
488 w = '80%';
489 if (target != '#postDiv-body') {
490 w = '80%';
491 h = 'auto';
492 } else {
493 w = 'auto';
494 h = '80%';
495 }
496
497 if ((!tab || tab == '') && (rows.ids.length == 0 || typeof rows[0] == 'undefined')) {
498 // $('#loadpicPost').css('background-color', '#595a5d');
499 $('#postDiv-title').text("404");
500 $(`#${globalEurl}-loadpicPost`).attr('src', 'deadlink.png').css("padding", "0").attr('id', 'deadlink').animate({
501 width: w,
502 height: h
503 }).before(`<br><button id="${globalEurl}-fourohfour" class="defaultBtn" value="Close" onclick="setLocation(); $('${target}').parent().fadeOut(500);">Close</button><br>`);
504 $(`#${globalEurl}-fourohfour`).removeClass('.headertitlenohover, .headertitle').css('-webkit-text-fill-color', 'initial');
505 }
506 $(`#${globalEurl}-loadpicPost`).fadeOut();
507
508 $(tab).text('');
509 var get = '';
510 var ctday = [];
511 var d = new Date();
512 var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
513 var today = days[d.getDay()];
514 var tabsarray = ['website','menu','employment','calendar','events','info'];
515
516 if (mode.toString().startsWith('get') && prefix != '') {
517 rows = rows.posts;
518 }
519 for (var i in rows) {
520 // console.log(i);
521 manage = '';
522 if (tab != '' && ( !tabsarray.includes(i)&& !isNumber(i))) {
523 // console.log(tab,i);
524 continue;
525 }
526 if (typeof rows[i] == 'object') {
527 var row = rows[i];
528 } else {
529 row = rows;
530 }
531 var category = row['category'];
532 var day = row['day'];
533 // var row.sametime = '0';
534 var times = decodeEntities(row['times']);
535 var allTimes = '';
536 if (isJson(times)) {
537 times = JSON.parse(times);
538
539 timesBlock: if (row.sametime != '1') {
540 for (var i in times) {
541 Day = times[i];
542 dayName = i;
543 oTime = Day['otime'];
544 cTime = Day['ctime'];
545 if (moment.utc(oTime, 'hh:mm A')._isValid) {
546 var oTime = moment.utc(oTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
547 }
548 if (moment.utc(cTime, 'hh:mm A')._isValid) {
549 var cTime = moment.utc(cTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
550 }
551 if (dayName == today) {
552 ctday = [oTime, cTime];
553 }
554
555 var biweekly = 'On';
556 if (row.biweekly == '2') {
557 biweekly = 'Monthly on';
558 }
559 if (row.biweekly == '1') {
560 biweekly = 'On every other';
561 }
562
563 allTimes = `${allTimes} ${biweekly} ${dayName} from ${oTime} to ${cTime} ${zoneAbbr}`;
564 }
565 if (!ctday.length) {
566 ctday = [oTime, cTime];
567 }
568 } else
569 if (isJson(row.day) && JSON.parse(row.day)) {
570 Day = times[JSON.parse(row.day)[0]];
571 if (typeof Day == 'undefined') {
572 break timesBlock;
573 }
574 dayName = i;
575 oTime = Day['otime'];
576 cTime = Day['ctime'];
577 ctday = [oTime, cTime];
578
579 if (moment.utc(oTime, 'hh:mm A')._isValid) {
580 var oTime = moment.utc(oTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
581 }
582 if (moment.utc(cTime, 'hh:mm A')._isValid) {
583 var cTime = moment.utc(cTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
584 }
585 var biweekly = 'On';
586 if (row.biweekly == '2') {
587 biweekly = 'Monthly on';
588 }
589 if (row.biweekly == '1') {
590 biweekly = 'On every other';
591 }
592
593 var niceDay = niceList(JSON.parse(row.day));
594 allTimes = `${biweekly} ${niceDay} from ${oTime} to ${cTime} ${zoneAbbr}`;
595 }
596 }
597 ctday = [oTime, cTime];
598 var otime = '';
599 if (moment.utc(row['otime'], 'hh:mm A')._isValid) {
600 var otime = moment.utc(row['otime'], 'hh:mm A').add(offset, 'hour').format('h:mm A');
601 }
602 var ctime = '';
603 if (moment.utc(row['ctime'], 'hh:mm A')._isValid) {
604 var ctime = moment.utc(row['ctime'], 'hh:mm A').add(offset, 'hour').format('h:mm A') + " " + zoneAbbr;
605 }
606 var managers = row['manager'];
607
608 if (isJson(day)) {
609 niceDay = niceList(JSON.parse(day));
610 } else {
611 niceDay = day;
612 }
613 if (isJson(managers)) {
614 niceManager = niceList(JSON.parse(managers));
615 } else {
616 niceManager = decodeEntities(managers);
617 }
618
619 if (isJson(managers) && JSON.parse(managers).length > 1) {
620 managerTag = "Managers:";
621 } else {
622 managerTag = "Manager:";
623 }
624 if (managers == '' || managers == '[""]') {
625 managerTag = '';
626 }
627
628 if (typeof row['title'] == 'undefined') {
629 row['title'] = "";
630 }
631
632 if (row.aetheryte) {
633 row.aetheryte = `<br>by ${row['aetheryte']} Aetheryte`;
634 }
635 titlefiltered = row['title'].replace(/'/g, "\\'");
636
637 if (moment.utc(row['otime'], 'hh:mm A')._isValid) {
638 var otime = moment.utc(row['otime'], 'hh:mm A').add(offset, 'hour').format('h:mm A');
639 }
640 if (moment.utc(row['ctime'], 'hh:mm A')._isValid) {
641 var ctime = moment.utc(row['ctime'], 'hh:mm A').add(offset, 'hour').format('h:mm A') + " " + zoneAbbr;
642 }
643 if (moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss')._isValid) {
644 row['date'] = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hour').format('YYYY-MM-DD HH:mm:ss');
645 }
646 if (moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss')._isValid) {
647 row['edate'] = moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hour').format('YYYY-MM-DD HH:mm:ss');
648 }
649
650 // define the rest of the template data
651 var prefix = '';
652 if (mode == 'newevents' || mode == 'events' || mode == 'showevents' || mode == 'getevent' || mode == 'postevent') {
653 prefix = 'event-';
654 }
655 if (mode == 'newgroups' || mode == 'groups' || mode == 'showgroups' || mode == 'getgroup' || mode == 'postgroup') {
656 prefix = 'group-';
657 }
658 var pa = 'Plot ' + row.plot;
659 if (row.ward != '') {
660 row.ward = `Ward ${row['ward']}`;
661 } else {
662 row.ward = '';
663 }
664 if (row.psize == 'Apartment') {
665 pa = 'Apt ' + row.apt;
666 }
667 if (row.plot == '' && row.apt == '') {
668 pa = '';
669 }
670 var biweekly = 'On';
671 if (row.biweekly == '2') {
672 biweekly = 'Monthly on';
673 }
674 if (row.biweekly == '1') {
675 biweekly = 'On every other';
676 }
677 if (row.website == 'N/A' || row.website == null || typeof row.website == 'undefined') {
678 row.website = '';
679 }
680
681 var event = {
682 hurl: row['hiringurl'],
683 evurl: row['eventurl'],
684 eurl: row['eurl'],
685 category: category,
686 day: niceDay,
687 managers: niceManager,
688 description: urlify(row['description']),
689 website: row['website'],
690 title: truncate(row['title'], 60),
691 id: row['id'],
692 discord: row['discord'],
693 twitter: row['twitter'],
694 lstream: row['lstream'],
695 otime: otime,
696 ctime: ctime,
697 owner: row['owner'],
698 // location: `${row['datacenter']} on ${row['server']} in ${row['housing']} at ${row['ward']} ${pa}${row['aetheryte']}`
699
700 };
701
702 var housing = `${row['housing']} at ${row['ward']} ${pa} ${row['aetheryte']}`;
703 if (row.housing == 'Other Location') {
704 housing = row.location;
705 }
706 event.location = `${row['datacenter']} on ${row['server']} in ${housing}`;
707 // location: `${row['datacenter']} on ${row['server']} in ${row['housing']} at ${row['ward']} ${pa}${row['aetheryte']}`
708
709 var eurl = row.eurl;
710 if (row['psize']) {
711 row['psize'] = "(" + row['psize'] + ")";
712 }
713
714 var calid = row['calid'];
715
716 if (isJson(calid)) {
717 calid = JSON.parse(calid);
718 }
719 row.title = decodeEntities(row.title);
720 var escapedTitle = row['title'].replace(/'/g, "\\'");
721 if (target == '#postDiv-body') {
722 document.title = siteTitle + ' - ' + row.title;
723 var obj = {
724 url: "?" + prefix + eurl
725 };
726 history.pushState(obj, 'flooboo' + row.title, "?" + prefix + eurl);
727 }
728
729 if (row["server"] == "Anywhere" || row["server"] == "") {
730 event.location = "N/A";
731 }
732
733 editicon = `<img src='edit.png' onclick="$('#postDiv').fadeOut();msg('Loading editor...', '');postWizard('${row.eurl}', '${prefix}');" title='Edit Post'>`;
734
735 if ( prefix == 'group-' ) {
736 calendar = '';
737 // editicon = `<img src='edit.png' onclick="groups('group-edit','${event.id}');" title='Edit Group'>`;
738 }
739
740 // if (prefix == 'event-') {
741 // editicon = `<img src='edit.png' onclick="$('#postDiv').fadeOut();msg('Loading editor...', '');postWizard('${row.eurl}', 'event-');" title='Edit Event'>`;
742 // } else if (prefix == 'group-') {
743 // calendar = '';
744 // editicon = `<img src='edit.png' onclick="$('#postDiv').fadeOut();msg('Loading editor...', '');postWizard('${row.eurl}', 'group-');" title='Edit Group'>`;
745 // } else {
746 // editicon = `<img src='edit.png' onclick="$('#postDiv').fadeOut();msg('Loading editor...', '');postWizard('${row.eurl}', '', 'who', '${escapedTitle}');" title='Edit Post'>`;
747 // }
748
749 var verifyCheckmark = '';
750 var dayst = 2;
751 var verifyPost = "Verify Post";
752
753 if (row.verified != '' && row.limited == '0') {
754 var dateFuture = new Date();
755 var dateNow = moment(row.verified);
756 var seconds = Math.floor((dateFuture - (dateNow)) / 1000);
757 var minutes = Math.floor(seconds / 60);
758 var hours = Math.floor(minutes / 60);
759 var dayst = Math.floor(hours / 24);
760
761 hours = hours - (dayst * 24);
762 minutes = minutes - (dayst * 24 * 60) - (hours * 60);
763 seconds = seconds - (dayst * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60);
764
765 var daysp = 'days';
766 if (dayst == 1) {
767 daysp = 'day';
768 }
769 var hoursp = 'hours';
770 if (hours == 1) {
771 hoursp = 'hour';
772 }
773 var minutesp = 'minutes';
774 if (minutes == 1) {
775 minutesp = 'minute';
776 }
777
778 var verifyPost = `Post verified ${dayst} ${daysp}, ${hours} ${hoursp}, and ${minutes} ${minutesp} ago by ${row.verifier}`;
779 }
780
781 if (dayst > 1 && row.limited == '0') {
782 var verifyCheckmark = `<span class='icon link'>
783 <img src='checkmark.png' title='${verifyPost}' onclick=\"verifyPost('${prefix}${event.eurl}', '${escapedTitle}')\">
784 </span>`
785 }
786 if (row.limited == '1') {
787 verifyCheckmark = '';
788 }
789
790 if (event.owner == '1' || acct == "2") {
791 var calendar = `<span class='icon link'>
792 <img src='cal.png' title='Import to Calendar' onclick='calendar("${prefix}${event.eurl}", "${calid}")'>
793 </span>`
794
795 if (row.shoutstamp != '') {
796 //var dateFuture = new Date(new Date().getFullYear() +1, 0, 1);
797 var dateFuture = new Date();
798 var dateNow = moment(row.shoutstamp);
799 var seconds = Math.floor((dateFuture - (dateNow)) / 1000);
800 var minutes = Math.floor(seconds / 60);
801 var hours = Math.floor(minutes / 60);
802 var dayst = Math.floor(hours / 24);
803
804 hours = hours - (dayst * 24);
805 minutes = minutes - (dayst * 24 * 60) - (hours * 60);
806 seconds = seconds - (dayst * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60);
807
808 var daysp = 'days';
809 if (dayst == 1) {
810 daysp = 'day';
811 }
812 var hoursp = 'hours';
813 if (hours == 1) {
814 hoursp = 'hour';
815 }
816 var minutesp = 'minutes';
817 if (minutes == 1) {
818 minutesp = 'minute';
819 }
820 var shoutedWhen = `Post shouted ${dayst} ${daysp}, ${hours} ${hoursp}, and ${minutes} ${minutesp} ago.`;
821
822 var shout = ''; //.substring(0, 5)
823 if ((dayst > 6 || row.shoutstamp == null) && row.limited == '0') {
824 shout = `<span id='shoutBtn-${eurl}' class='icon link'>
825 <img src='shout.png' onclick="shout('${prefix}${event.eurl}');" title='Shout Post'>
826 </span>`
827 }
828 }
829
830 var manage = `
831 ${calendar}
832 ${shout}
833 <span class='icon link'>
834 ${editicon}
835 </span>
836 <span id='openBtn-${eurl}' class='icon link'>
837 <img src='opensign.png' onclick="toggleOpen('${prefix}${event.eurl}');" title='Popup Mode - Toggle Venue Open/Closed for popup events'>
838 </span>
839 <span id='boostBtn-${eurl}' class='icon link'>
840 <img src='powerup.png' onclick="boost('${prefix}${event.eurl}');" title='Boost Post'>
841 </span>
842 <span class='icon link'>
843 <img src='delete.png' title='Delete Listing' onclick='deletePost("${prefix}${event.eurl}", "${event.title}")'>
844 </span>`;
845 }
846 if (scout != '0') {
847 manage = `${manage}
848 <span class='icon link'>
849 <img src='alert.png' title='Send Alert' onclick=\"alertPost('${prefix}${event.eurl}', '${escapedTitle}')\">
850 </span>
851 <span class='icon link'>
852 ${editicon}
853 </span>
854 <span class='icon link'>
855 <img src='question.png' title='Send alert to scouts that venue is Vacant or Closed' onclick=\"questionPost('${prefix}${event.eurl}', '${escapedTitle}')\">
856 </span>`;
857 } else {
858 var escapedTitle = row['title'].replace(/'/g, "\\'");
859 manage = `${manage}
860 <span class='icon link'>
861 <img src='alert.png' title='Send Alert' onclick=\"alertPost('${prefix}${event.eurl}', '${escapedTitle}')\">
862 </span>
863 <span class='icon link'>
864 <img src='question.png' title='Mark Venue as Vacant/Closed' onclick=\"questionPost('${prefix}${event.eurl}', '${escapedTitle}')\">
865 </span>`;
866 }
867 if (user != '' && acct != '0' && row.limited == '0') {
868 manage += verifyCheckmark;
869 }
870
871 if (row['tag'] === undefined || row.tag === '' || row.tag === 'N/A') { //row.tag != '' ||
872 event.tag = '';
873 } else {
874 event.tag = `<< ${row.tag} >>`;
875 }
876
877 var closeduntil = row.closeduntil;
878 if (closeduntil == '0000-00-00 00:00:00') {
879 closeduntil = -999;
880 } else {
881 closeduntil = moment().diff(moment(closeduntil, 'YYYY-MM-DD HH:mm:ss'), 'seconds');
882 }
883
884 // event title template
885 var closedmsg = '';
886 if (row['closed'] != 0 && closeduntil < 0) {
887 event.title = event.title + " (Closed)";
888 if (row.closedmsg != '') {
889 closedmsg = "Information regarding closure:<br><pre>" + row.closedmsg + "</pre>";
890 }
891 }
892 var hiringList = '';
893 if (row['hiringurl'] != '' && typeof(row['hiringurl']) !== 'undefined') {
894 row.title = row.title + " (Now Hiring)";
895 var hurl = row['hiringurl'];
896 var hiring = decodeEntities(row['hiring']);
897 if (isJson(hiring)) {
898 hiring = JSON.parse(hiring);
899 var hiringList = 'Currently hiring for:<br><p>';
900 for (var key in hiring) {
901 if (hiring.hasOwnProperty(key) && hiring[key] != null) {
902 hiringList += "Position: <hlink class='link'>" + capitalizeWords(hiring[key]['position']) + "</hlink><br>Details: " + hiring[key]['rate'] + "<br><br>";
903 }
904 }
905 hiringList += "</p>";
906 } else {
907 hiringList = '';
908 }
909 }
910
911 var postURL = `https://www.${domain}/?${prefix}${event.eurl}`
912 if (row['tinyurl'] != '') {
913 postURL = row.tinyurl;
914 }
915
916 const eventTitle = `
917 <span class="link" onclick="scrollToId('${prefix}${event.eurl}')">
918 ${event.title}
919 </span><br>
920 `;
921 // Event post template
922 if (target == '#postDiv-body') {
923 var header = `<div class='post-title postdivDraggableHandle'>
924 <a href='./?${prefix}${event.eurl}' id="title-${prefix}${row.eurl}">
925 ${event.title} ${event.tag}
926 </a>
927 <img src='link.png' height='30px' class="link" alt="Copy Link" onclick="copyToClipboard('${postURL}');">
928 <img class="link submitCloseBtn" src="close.png" alt="Close" onclick="setLocation(); $('#postDiv').fadeOut(500);" style="float:left; margin:5px;" height="25px">
929 <img class="link imgdropshadowgold minmaxBtn" src="maximize.png" alt="Maximize Window" onclick="maximizeWin();" style="float:left; margin:5px;" height="25px">
930 ${manage}
931 </div><br>`;
932 $("#postDiv-title").html(header);
933 $('#postDiv-title span.icon img').click(function() {
934 maximizeWin(true);
935 });
936 header = '';
937 } else {
938 var header = `<div class='event-title'>
939 <a href='./?${prefix}${event.eurl}' title="${row.title}" id="title-${prefix}${row.eurl}">
940 ${event.title} ${event.tag}
941 </a>
942 <img src='link.png' height='30px' class="link" alt="Copy Link" onclick="copyToClipboard('https://www.${domain}/?${prefix}${event.eurl}');">
943 <span class='icon link' style="float:left;">
944 <img src='close.png' title='Collapse Post' onclick="collapsePost('${prefix}${event.eurl}')">
945 </span>
946 <span class='icon link' style="float:left;">
947 <img src='popout.png' title='Pop Out Post' onclick="collapsePost('${prefix}${event.eurl}');loadPostDiv('${prefix}${event.eurl}');">
948 </span>
949 ${manage}
950 </div><br>`;
951 }
952
953 var eventPost = `
954 <div class='event-wrapper-div' id='${prefix}${event.eurl}' style='text-align: center'>
955 ${header}`;
956
957 // Tabs
958 var tabs = `<div id='${prefix}${event.eurl}-posttab' eurl='${prefix}${event.eurl}' name='${prefix}${event.eurl}-tab' class='tab-active tabs'>
959 Info
960 </div>
961 <div id='${prefix}${event.eurl}-menutab' eurl='${prefix}${event.eurl}' name='${prefix}${event.eurl}-tab' class='tab-inactive tabs'>
962 Menu
963 </div>
964 <div id='${prefix}${event.eurl}-eventtab' eurl='${prefix}${event.eurl}' name='${prefix}${event.eurl}-tab' class='tab-inactive tabs'>
965 Events
966 </div>
967 <div id='${prefix}${event.eurl}-calurltab' eurl='${prefix}${event.eurl}' name='${prefix}${event.eurl}-tab' class='tab-inactive tabs'>
968 Calendar
969 </div>
970 <div id='${prefix}${event.eurl}-sitetab' eurl='${prefix}${event.eurl}' name='${prefix}${event.eurl}-tab' class='tab-inactive tabs'>
971 Website
972 </div>
973 <div id='${prefix}${event.eurl}-employmenttab' eurl='${prefix}${event.eurl}' name='${prefix}${event.eurl}-tab' class='tab-inactive tabs'>
974 Employment
975 </div><br>
976 <div id='wrapper' name='${prefix}${event.eurl}-tab-wrapper' class="wrapper">`
977 switch (mode) {
978 case 'employment':
979 tabs = '';
980 if (row['id'] == '0') {
981 row['id'] = '1';
982 }
983
984 var hurl = row['hiringurl'];
985 var hiringList = '';
986 var hiring = decodeEntities(row['hiring']);
987 if (isJson(hiring)) {
988 hiring = JSON.parse(hiring);
989 var hiringList = 'Currently hiring for:<br><p>';
990 for (var key in hiring) {
991 if (hiring.hasOwnProperty(key)) {
992 if (typeof hiring[key] == 'null') { continue; }
993 hiringList += "Position: " + hiring[key]['position'] + "<br>Details: " + hiring[key]['rate'] + "<br><br>";
994 }
995 }
996 hiringList += "</p>";
997 } else {
998 hiringList = '';
999 }
1000 var post = `<center><font class='white'>${hiringList}<br>Details for employment<br>opportunities can be found at:<br><a href="${row.hiringurl}" class="link" target="_blank">${row.hiringurl}</a></font><br>
1001 <iframe src="${row.hiringurl}" width="100%" height="800px"></iframe>`;
1002 break;
1003 case 'website':
1004 case 'siteevent':
1005 case 'sitegroup':
1006 tabs = '';
1007 if (row['id'] == '0') {
1008 row['id'] = '1';
1009 }
1010 var hurl = row['website'];
1011 if (typeof hurl != 'undefined' && hurl.includes("twitter.com")) {
1012 var post = twitterfy(hurl);
1013 } else {
1014 var post = `<iframe src="${hurl}" width="100%" height="800px"></iframe>`;
1015 }
1016 break;
1017 case 'calurl':
1018 tabs = '';
1019 if (row['id'] == '0') {
1020 row['id'] = '1';
1021 }
1022 var calurl = row['calurl'];
1023 var post = `<iframe src="${calurl}" width="100%" height="800px"></iframe>`;
1024 break;
1025 case 'eventurl':
1026 var eventurl = row['eventurl'];
1027 if (eventurl == '') {
1028 break;
1029 }
1030 tabs = '';
1031 if (row['id'] == '0') {
1032 row['id'] = '1';
1033 }
1034 var post = `<iframe src="${eventurl}" width="100%" height="800px"></iframe>`;
1035 break;
1036 case 'menu':
1037 tabs = '';
1038 if (typeof menu != 'undefined' ) {
1039 break;
1040 }
1041
1042 if (typeof row.menu != 'undefined' ) {
1043 var menu = row['menu'];
1044 var post = `<iframe src="${menu}" width="100%" height="800px"></iframe>`;
1045 }
1046 break;
1047 case 'get':
1048 case 'venues':
1049 case 'new':
1050 case 'show':
1051 case '':
1052 var rating = 'T';
1053 var taggedTitle = " (All Ages)";
1054 if (domain == 'roleplayfinder.com') {
1055 taggedTitle = "";
1056 } else {
1057 if (typeof row['category'] != 'undefined' && row['category'] != null) {
1058 if (row['category'].includes("#escort") || row['category'].includes("#18+") || row['category'].includes("#erp") || row['rating'] == '1') {
1059 taggedTitle = ' (18+ Only)';
1060 rating = 'M';
1061 }
1062 }
1063 if (typeof row['category'] != 'undefined' && row['category'] != null) {
1064 if (row['category'].includes("#21+") || row['rating'] == '2') {
1065 taggedTitle = ' (21+ Only)';
1066 rating = 'M';
1067 }
1068 }
1069 }
1070 //row['title'] += taggedTitle;
1071 if (row['free'] == '1') {
1072 taggedTitle += ' (No Gil Required)<br>';
1073 } else {
1074 taggedTitle += '';
1075 }
1076 if (row['openrp'] == '1') {
1077 taggedTitle += ' (OpenRP Venue)<br>';
1078 } else {
1079 taggedTitle += '';
1080 }
1081 taggedTitle += '<br>';
1082 if (row.day != null && row.day != '' && isJson(row.day) && JSON.parse(row.day)) {
1083 var jsonDay = JSON.parse(row.day);
1084 var nondays = ['Service', 'Event', 'Popup', 'Determined'];
1085 const checker = value =>
1086 !jsonDay.some(element => value.includes(element));
1087 if ((nondays.filter(checker).length != nondays.length) || row['day'] == '["Service"]' || row['day'] == '["Event Only"]' || row['day'] == '["Popup Venue"]' || row['day'] == '["To be Determined"]' || otime == 'Invalid date' || row.day == '["Service"]') {
1088 row.day = '';
1089 allTimes = '';
1090 event.day = '';
1091 times = '';
1092 }
1093 } else {
1094 row.day = '';
1095 allTimes = '';
1096 event.day = '';
1097 times = '';
1098 }
1099
1100 var location = event.location.replace(/<br>/gi, ' ');
1101 var escapedLocation = decodeEntities(location);
1102 escapedLocation = escapedLocation.replace(/'/gi, "\\'");
1103 if (allTimes != '') {
1104 event.day = '';
1105 times = '';
1106 }
1107 var lstream = '';
1108 if (event.category != null && event.category != '') {
1109 event.category = event.category.replace(/#/g, '', true);
1110 var tags = event.category.split(" ");
1111 event.category = '';
1112 for (var tag in tags) {
1113 var tagName = tags[tag];
1114 event.category = event.category + `<span class="link" onclick="$('#timeWhen').val('');$('#postDiv').fadeOut(); venueList('', '#comms-search-results', '${tagName}', 'categories');">` + tagName + '</span> ';
1115 }
1116 }
1117 var updated = '';
1118 if (row.date != '0000-00-00 00:00:00') {
1119 updated = 'Updated on ' + prettyDate(row.date) + "<br>";
1120 }
1121
1122
1123 var verified = '';
1124 if (row.verified != '') {
1125 verified = 'This post has been verified on ' + prettyDate(row.verified) + " by " + row['verifier'] + "<br><br>";
1126 }
1127
1128 var ffsync = '';
1129 if (row['ffxivrpsync'] != '0000-00-00 00:00:00') {
1130 ffsync = 'This post has been synced with FFXIV-RP on ' + prettyDate(row['ffxivrpsync']) + "<br><br>";
1131 }
1132
1133 if (row['public'] != '1' && typeof(row['public']) !== 'undefined' && user != "Guest") {
1134 verified = verified + "<br>(Private Listing)";
1135 }
1136
1137 var notedate = moment(row.notedate, "YYYY-MM-DD");
1138 var note = '';
1139 if (row.note != '' && moment().diff(notedate, 'hours') < 0) {
1140 note = '<pre>' + row.note + '</pre><br>';
1141 }
1142
1143 if (row['day'] == '["Anytime"]') {
1144 times = '';
1145 allTimes = 'Anytime';
1146 event.day = '';
1147 }
1148 if (row.datacenter == 'Anywhere') {
1149 event.location = "Anywhere";
1150 }
1151 if (event.location == 'N/A' && row.location != '') {
1152 event.location = row.location;
1153 }
1154 var showWhenTag = 'block';
1155 var rentable = '';
1156 if (row.rent == '1') {
1157 rentable = 'Venue Rental Available<br>';
1158 }
1159 var unlisted = '';
1160 if (row.listed == '0') {
1161 unlisted = '<font color="red" class="red">Post Unlisted</font><br>';
1162 }
1163 var newcomers = '';
1164 if (row.newcomers == '1') {
1165 newcomers = "RP Newcomers Welcome!<br><br>";
1166 }
1167 // console.log(eurl, row.day);
1168 if (row.day == '') {
1169 showWhenTag = 'none';
1170 }
1171 if (row.lstream != '' && row.lstream != null) {
1172 lstream = `<p><a href='${event.lstream}' class='link' target='_blank'>${event.lstream}</a> <span onclick='showstream("${event.lstream}")'><img src="note.gif" height="20"></span></p>`;
1173 }
1174 if (row.customtimes != '') {
1175 allTimes = row.customtimes;
1176 event.day = '';
1177 times = '';
1178 if (ctday.length) {
1179 allTimes = allTimes.replaceAll('%t', '<br>from ' + ctday[0] + ' to ' + ctday[1] + ' ' + zoneAbbr);
1180 } else {
1181 allTimes = allTimes.replaceAll('%t', '');
1182 }
1183 }
1184 if (rating == 'M' && ratingMode == 'T') {
1185 tabs = '';
1186 var post = "<h2>This post is 18+ only.</h2><br><img src='mido.png' height='50%'><br> Please <span class='link' onclick='setRatingMode();'>verify your age</span> and reload page to view this post.";
1187 } else {
1188 var post = `
1189 <div class='event-info right imgborder'>
1190 ${updated}${verified} ${ffsync} ${taggedTitle} ${unlisted} ${rentable} ${newcomers}
1191 ${closedmsg}<br>
1192 <whentag style="color: white; display: ${showWhenTag}">
1193 When:
1194 <img src='link.png' height='15px' class="link" alt="Copy Link" onclick="copyToClipboard('${allTimes}');">
1195 <p>${allTimes} ${event.day} ${times}</p>
1196 </whentag>
1197 <br>Where:
1198 <img src='link.png' height='15px' class="link" alt="Copy Link" onclick="copyToClipboard('` + escapedTitle + ` on ` + escapedLocation + `');">
1199 <p>${event.location}<br>${row.psize}</p>
1200
1201 <br>Keywords/Tags:
1202 <p>${event.category}</p>
1203 <br>Details:
1204 ${note}<pre>${event.description}</pre>
1205 <br>
1206 ${hiringList}
1207 <br>
1208 <p><a target="_blank" class="grey" href="${event.website}">${event.website}</a></p>
1209 <p><a target="_blank" class="grey" href="${event.discord}">${event.discord}</a></p>
1210 <p><a target="_blank" class="grey" href="${event.twitter}">${event.twitter}</a></p>
1211 ${lstream}
1212 <br>${managerTag}
1213 <p>${event.managers}</p>
1214 <br>
1215 </div>
1216 <div class="slideshow-container" id='slideshow-container-${eurl}'>
1217 <img src='getimage.php?1' width="100%" class='imgrounded imgborder imgdropshadow'>
1218 </div>`;
1219 }
1220 break;
1221 case 'getgroup':
1222 case 'groups':
1223 case 'newgroups':
1224 case 'showgroups':
1225 row['crest'] = row['crest'].replace(/(?:\\(.))/g, '$1');
1226 if (isJson(row['crest'])) {
1227 row['crest'] = JSON.parse(decodeEntities(row['crest']));
1228 }
1229 var crest1 = row['crest'][0];
1230 var crest2 = row['crest'][1];
1231 var crest3 = row['crest'][2];
1232 if (row.rank != '') {
1233 row.rank = '<p> Rank: ' + row.rank + '</p>';
1234 }
1235 if (row.recruit == 'true') {
1236 row.recruit = '<p><font class="green">Currently Recruiting</font></p>';
1237 } else {
1238 row.recruit = '';
1239 }
1240 if (isJson(managers) && JSON.parse(managers).length > 1) {
1241 managerTag = "Leaders:";
1242 } else {
1243 managerTag = "Leader:";
1244 }
1245 var location = '';
1246 if (row.psize != '') {
1247 row.psize = `(${row.psize})`;
1248 }
1249 var details = '';
1250 if (row.description != '') {
1251 details = `<br>Details:
1252 <pre>${event.description}</pre>`;
1253 }
1254 var managerlisting = '';
1255 var location = '';
1256 if (event.managers != '') {
1257 managerlisting = `<br>${managerTag}
1258 <p>${event.managers}</p>`;
1259 }
1260 if (row.ward != '') {
1261 location = `Estate:
1262 <p>Housing: ${row.housing}, Ward: ${row.ward}, ${pa}<br>${row.psize}</p>`
1263 }
1264 var post = `
1265 <div class='event-info right imgborder'>
1266 ${category}<br>
1267 ${row.recruit}${row.rank}
1268 <br>Datacenter:
1269 <p>${row.datacenter}</p>
1270 Server:
1271 <p>${row.server}</p>
1272 ${location}
1273 ${details}
1274 <br>
1275 <p><a target="_blank" class='grey' href="${event.website}">${event.website}</a></p>
1276 <p><a target="_blank" class='grey' href="${event.discord}">${event.discord}</a></p>
1277 ${managerlisting}
1278 <br>
1279 </div>
1280 <div class="slideshow-container" id='slideshow-container-group-${eurl}'>
1281 <img src='getimage.php?1' width="100%" class='imgrounded imgborder imgdropshadow'>
1282 </div>`
1283 break;
1284 case 'events':
1285 case 'newevents':
1286 case 'getevent':
1287 case 'postevent':
1288 case 'showevents':
1289 case 'event':
1290 // console.log('event ',i);
1291 case 'eventgroup':
1292 var post = '';
1293 var postiframe = '';
1294 var eventurl = row['eventurl'];
1295 if (eventurl != '' && typeof eventurl != 'undefined') {
1296 tabs = '';
1297 if (row['id'] == '0') {
1298 row['id'] = '1';
1299 }
1300 postiframe = `<iframe src="${eventurl}" width="100%" height="800px"></iframe>`;
1301 }
1302
1303 //tabs = '';
1304 if (row.hours == '') {
1305 row.hours = "Anytime";
1306 }
1307 if (row.date == '1970-01-01 00:00:00' || row.date == null) {
1308 var pdate = row.hours;
1309 row.date = null;
1310 }
1311 if (row.date != null) {
1312 if (row.date == row.edate || row.edate == null || row.edate == '1970-01-01 00:00:00' || row.edate == '') {
1313 var pdate = prettyDate(row.date) + " " + zoneAbbr;
1314 } else {
1315 var pdate = "From " + prettyDate(row.date) + " to " + prettyDate(row.edate) + " " + zoneAbbr;
1316 }
1317 } else {
1318 pdate = row.hours;
1319 }
1320 var title = '';
1321 var prefix = "event-";
1322 if (row['location'] == '' || row['location'] == null) {
1323 row['location'] = event.location;
1324 }
1325 if (page != 'events' || !isEmpty(page)) {
1326 title = `<center><h3><a href='./?${prefix}${row.eurl}' id="title-event-${row.eurl}">${row['title']}</a> <img src='link.png' height='18px' class="link" alt="Copy Link" onclick="copyToClipboard('https://www.${domain}/?${prefix}${row.eurl}');"><br></h3></center><br>`;
1327 }
1328 var lstream = '';
1329 if (row.lstream != '' && row.lstream != null) {
1330 lstream = `<p>🎼<span onclick='showstream("${event.lstream}")'>${event.lstream}</span>🎼</p>`;
1331 }
1332 post = `
1333 <div class='event-info right imgborder'>
1334 ${title}
1335 When:
1336 <p>${pdate}</p>
1337 <br>Where:
1338 <p>${row.location}${row.psize}</p>
1339 <br>Category:
1340 <p>${event.category}</p>
1341 <br>Keywords:
1342 <p>${row.keywords}</p>
1343 <br>Details:
1344 <pre>${event.description}</pre>
1345 <br>
1346 <p><a target="_blank" href="${event.website}">${event.website}</a></p>
1347 <p><a target="_blank" href="${event.discord}">${event.discord}</a></p>
1348 ${lstream}
1349 <br>${managerTag}
1350 <p>${event.managers}</p>
1351 <br>
1352 </div>
1353 <div class="slideshow-container" id='slideshow-container-event-${eurl}'>
1354 <img src='getimage.php?1' width="100%" class='imgrounded imgborder imgdropshadow'>
1355 </div>
1356 ${postiframe}`;
1357 if (typeof row.eurl == 'undefined') {
1358 post = postiframe;
1359 }
1360 break;
1361 }
1362
1363 var eventPost = `${eventPost}${tabs}${post}
1364 </div>
1365 </div>
1366 `;
1367
1368 if (titleList == '1') {
1369 $('#event_titles').append(eventTitle);
1370 }
1371 $(`#${prefix}${eurl}-loadpicPost`).fadeOut();
1372 if (row['id'] != '0') {
1373 if (tab != '') {
1374 $(tab).append(post);
1375 $("#content").fadeIn(500);
1376 $(tab).animate({
1377 width: "100%"
1378 });
1379 } else {
1380 $(`#${eurl}-loadpicPost`).fadeOut();
1381 if (target == '#postDiv-body') {
1382 $(target).text('');
1383 } else {
1384 // console.log(`${prefix}${eurl}`);
1385 $(target).parent().css('background', `url("getimage.php?${prefix}${eurl}") no-repeat fixed center center / 100%`);
1386 // $(target).parent().css('background-image', `url('getimage.php?${eurl}')`);
1387 $(target).parent().css('background-size', '100% auto');
1388 $(target).parent().css('background-color', 'rgba(0, 0, 0, 0)');
1389 $(target).css('background-color', 'rgba(0, 0, 0, 0)');
1390 // $(target).parent().css('background-size', 'cover');
1391 }
1392 $(target).append(eventPost);
1393 // console.log(eventPost);
1394 $("#content").fadeIn(500);
1395 $(".event-wrapper").animate({
1396 width: '95%'
1397 });
1398 if (target != '#postDiv-body') {
1399 $(".event-wrapper").animate({
1400 minHeight: '400px'
1401 });
1402 }
1403
1404 if (typeof row["eventfccount"] === 'undefined') {
1405 row["eventfccount"] = 0;
1406 }
1407 if (typeof row["eventcount"] === 'undefined') {
1408 row["eventcount"] = 0;
1409 }
1410 if (typeof row["eventfcurl"] === 'undefined') {
1411 row["eventfcurl"] = 0;
1412 }
1413 // if (typeof row["events"] === 'undefined') { row["eventscount"] = 0; }
1414 // if ( row["events"] != '') { row["eventurl"] = 1; }
1415 if (typeof row["eventurl"] === 'undefined' || row.eventurl == '') {
1416 row["eventurl"] = 0;
1417 }
1418 var eventscount = parseFloat(row["eventfccount"]) + parseFloat(row["eventcount"]) + parseFloat(row["eventurl"]) + parseFloat(row["eventfcurl"]);
1419 if (eventscount === 0) {
1420 $('#' + prefix + event.eurl + '-eventtab').css("display", "none");
1421 }
1422 if (row.menu === '' || typeof row.menu === 'undefined') {
1423 $('#' + prefix + event.eurl + '-menutab').css("display", "none");
1424 }
1425 if (row.website === '' || typeof row.website === 'undefined') {
1426 $('#' + prefix + event.eurl + '-sitetab').css("display", "none");
1427 }
1428 if (row.calurl === '' || typeof row.calurl === 'undefined') {
1429 $('#' + prefix + event.eurl + '-calurltab').css("display", "none");
1430 }
1431 if (row["hiringurl"] == '' || typeof row["hiringurl"] === 'undefined' || prefix != '') {
1432 $('#' + prefix + event.eurl + '-employmenttab').css("display", "none");
1433 }
1434 }
1435 } else if (tab == '') {
1436 $(target).html(`<br><br><img src="404.png" height="60%"><br><h3>An error occurred loading data!</h3>`);
1437 }
1438
1439 var photo;
1440 if (row.photo != '') {photo = row.photo;}
1441
1442 var eurl = prefix + event.eurl;
1443 if ($('#slideshow-container-' + eurl).length > 0) {
1444 slideshow[eurl] = ``;
1445 $("#loading-img").fadeIn(500);
1446 $.ajax({
1447 type: "POST",
1448 url: "api.php",
1449 dataType: 'json',
1450 data: {
1451 mode: "pictures",
1452 eurl: eurl,
1453 photo: photo
1454 },
1455 success: function(data) {
1456 if (typeof data.status != 'undefined' && data.status == '255') {
1457 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
1458 return;
1459 }
1460 if (typeof data.posts == 'undefined') {
1461 return;
1462 }
1463
1464
1465 var total = data.posts.length;
1466 if (!total) {
1467 total = Object.keys(data.ids).length;
1468 }
1469
1470 // console.log(total, data.ids)
1471 var count = 0;
1472 if (data) {
1473 // data = data.posts;
1474 for (var i in data) {
1475 var row = data[i];
1476
1477 if (!isNumber(i) ) { continue;}
1478 var type = row['type'];
1479 var sseurl = row['eurl'];
1480 var id = row['id'];
1481 var image = row['image'];
1482 var banner = row['banner'];
1483 var main = row['main'];
1484 if (banner == '1' && main == '0') {
1485 total--;
1486 continue;
1487 }
1488
1489 count++
1490
1491 var media = `<img src='getimage.php?${row["id"]}' id='ss-${row.id}'width="100%" class='imgrounded imgborder imgdropshadow'>`;
1492 if (row['type'] == 'video') {
1493 media = `<iframe name="${row.eurl}-vid" class="vidMain imgdropshadowGold imgdropshadow" src="https://www.youtube-nocookie.com/embed/${row['image']}?&autoplay=0&loop=1&rel=0&showinfo=0&iv_load_policy=3&playlist=${image}" allow="accelerometer; clipboard-write; encrypted-media; gyroscope;" allowfullscreen="" style="height: 800px;display: inline;" frameborder="0"></iframe>`;
1494 }
1495
1496 slideshow[sseurl] = `${slideshow[sseurl]}
1497 <div class="mySlides fade" name='ss-${sseurl}'>
1498 <div class="numbertext">${count} / <totalpics class="numbertext-${eurl} numbertextdeco"></totalpics></div>
1499 ${media}
1500 </div>`;
1501 }
1502 slideshow[sseurl] = `${slideshow[sseurl]} <a class="prev ss-nav-${eurl}" onclick="plusSlides(-1,'${sseurl}')">❮</a>
1503 <a class="next ss-nav-${eurl}" onclick="plusSlides(1,'${sseurl}')">❯</a>`;
1504 $('#slideshow-container-' + sseurl).html(slideshow[sseurl]);
1505 if (total == 1) {
1506 $(`.ss-nav-${eurl}`).fadeOut()
1507 }
1508 $(`.numbertext-${eurl}`).html(`${total}`);
1509
1510 slideshow[sseurl] = '';
1511 slideIndex[sseurl] = 1;
1512 showSlides(slideIndex[sseurl], sseurl);
1513 } else {
1514 $('#slideshow-container-' + eurl).html(`<img src='getimage.php?1' width="100%" class='imgrounded imgborder imgdropshadow'>`);
1515 }
1516 $("#loading-img").fadeOut(500);
1517 },
1518 error: function() {
1519 msg("An error occurred processing your subrequest | " + eurl);
1520 $("#loading-img").fadeOut(500);
1521 }
1522 });
1523 }
1524 }
1525 $("#loading-img").fadeOut(500);
1526 },
1527 error: function(e) {
1528 console.log(e);
1529 msg("An error occurred processing your request | " + eurl + "<br>");
1530 $("#loading-img").fadeOut(500);
1531 }
1532 });
1533}
1534
1535// $('#postDiv').dblclick(maximizeWin());
1536// $('.post-title span.icon').not('.minmaxBtn').on("click", maximizeWin(true));
1537
1538
1539var postdiv = {};
1540function maximizeWin(resizeRestore) {
1541
1542 // console.log(resizeRestore,isSelected);
1543
1544
1545 var win = $('#postDiv');
1546 // win.toggleClass('selected');
1547 var isSelected = win.hasClass('maximized');
1548 if (typeof resizeRestore != 'undefined') { isSelected = resizeRestore;
1549 if ( resizeRestore != isSelected) { win.toggleClass('maximized');
1550 console.log('moo',resizeRestore,isSelected,lt);
1551 return;}
1552 }
1553 // console.log('moo',resizeRestore,isSelected,lt);
1554
1555 if ( !isSelected ) {
1556 // winhei = $(window).height();
1557 postdiv = {h: $('#postDiv').height(), w: $('#postDiv').width(), lt: $('#postDiv').offset()};
1558 win.toggleClass('maximized');
1559 $('#postDiv').draggable( "option", "disabled", true );
1560 $("#postDiv").css({"position": "fixed","top": "0", "bottom": "0","max-height": ""});
1561 $('#postDiv').animate({height: $(window).height()-35, width: '100%', top: 0, left: 0, borderRadius: 0});
1562 } else {
1563 var h = postdiv.h;
1564 var w = postdiv.w;
1565 var lt = postdiv.lt;
1566 if (typeof lt == 'undefined') { return; }
1567 // console.log('moo',resizeRestore,isSelected,lt);
1568
1569 $('#postDiv').css("position", "absolute");
1570 $('#postDiv').css("max-height", "80%");
1571 $('#postDiv').animate({height: h, width: w, top: lt.top, left: lt.left, borderRadius: '25px'});
1572 $('#postDiv').draggable( "option", "disabled", false );
1573 win.toggleClass('maximized');
1574 }
1575}
1576
1577// Cookies
1578function createCookie(name, value, days) {
1579 if (days) {
1580 var date = new Date();
1581 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
1582 var expires = "; expires=" + date.toGMTString();
1583 } else var expires = "";
1584 document.cookie = name + "=" + value + expires + "; path=/; SameSite=Strict ; Secure";
1585}
1586
1587function readCookie(name) {
1588 var nameEQ = name + "=";
1589 var ca = document.cookie.split(';');
1590 for (var i = 0; i < ca.length; i++) {
1591 var c = ca[i];
1592 while (c.charAt(0) == ' ') c = c.substring(1, c.length);
1593 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
1594 }
1595 return null;
1596}
1597
1598function eraseCookie(name) {
1599 createCookie(name, "", -1);
1600}
1601
1602
1603
1604var commsBgInterval = '';
1605var light = "on";
1606
1607function toggleLight() {
1608 if (light == "on") {
1609 $("#bulb").fadeTo(250, 0, function() {
1610 $(this).load(function() {
1611 $(this).fadeTo(250, 1);
1612 });
1613 $('#bulb').attr('src', 'bulb-off.png');
1614 });
1615 $('#nav').animate({
1616 backgroundColor: '#7AB6CA'
1617 }, 1000);
1618 $('h1,h2,h3,h4,h5').animate({
1619 Color: '#3393B2'
1620 }, 1000);
1621 $('.content').animate({
1622 Color: '#3393B2'
1623 }, 1000);
1624 light = "off";
1625 createCookie("light", "off", "365");
1626 } else {
1627 $("#bulb").fadeTo(250, 0, function() {
1628 $(this).load(function() {
1629 $(this).fadeTo(250, 1);
1630 });
1631 $('#bulb').attr('src', 'bulb.png');
1632 });
1633 $('#nav').animate({
1634 backgroundColor: '#ade9fd'
1635 }, 1000);
1636 $('h1,h2,h3,h4,h5').animate({
1637 Color: '#00607f'
1638 }, 1000);
1639 $('.content').animate({
1640 Color: '#00607f'
1641 }, 1000);
1642 light = "on";
1643 createCookie("light", "on", "365");
1644 }
1645}
1646
1647function preload(arrayOfImages) {
1648 $('<img />').attr('src', "loadpic.gif").appendTo('body').css('display', 'none');
1649 $(arrayOfImages).each(function() {
1650 $('<img />').attr('src', this).appendTo('body').css('display', 'none');
1651 });
1652}
1653
1654function JSONparse(str) {
1655 try {
1656 return (JSON.parse(str) && !!str);
1657 } catch (e) {
1658 return str;
1659 }
1660}
1661
1662function prettyDate(pdate) {
1663 return moment(pdate).format('dddd, MMMM Do YYYY, h:mm a');
1664}
1665
1666function niceList(array) {
1667 if (!array || array.length == 0) return "";
1668 var clone = array.slice(0);
1669
1670 return function build() {
1671 if (clone.length == 1) return clone[0];
1672 if (clone.length == 2) return clone[0] + ' and ' + clone[1];
1673 return decodeEntities(clone.shift() + ", " + build());
1674 }();
1675}
1676
1677function getSearchParams(k) {
1678 var p = {};
1679 location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(s, k, v) {
1680 p[k] = v
1681 })
1682 return k ? p[k] : p;
1683}
1684
1685function decodeEntities(encodedString) {
1686 var textArea = document.createElement('textarea');
1687 textArea.innerHTML = encodedString;
1688 return textArea.value;
1689}
1690
1691function scrollToId(eId, container = '#content') {
1692 var myElement = document.getElementById(eId);
1693 var topPos = myElement.offsetTop;
1694 if (eId == 'comms-search') {
1695 topPos = topPos - 50;
1696 }
1697 $(container).animate({
1698 scrollTop: topPos - 90
1699 });
1700}
1701
1702function loadPage(page_url, page_title = siteTitle) {
1703 clearTimeout(autoUpdateList);
1704 expandCats = '0';
1705 updateMode = false;
1706 document.title = siteTitle + ' - Loading...';
1707 if (page_url === 'selector') {
1708 page = $(page_title).val();
1709 page_title = $(page_title).text();
1710 page_url = page;
1711 }
1712 page = page_url;
1713 if (page == 'comms' || page == 'openrp' || page == 'groups' || page == 'events' || page == 'services' || page == 'hiring') {
1714 $('#content').css({
1715 "overflow": "hidden"
1716 });
1717 } else {
1718 $('#content').css({
1719 "overflow-y": "auto"
1720 });
1721 }
1722 if (page != 'news') {
1723 $('#header').animate({
1724 "opacity": "1"
1725 });
1726 $('#footer').animate({
1727 "opacity": "1"
1728 });
1729 }
1730 $.get(page_url, function(data) { // generic ajax call
1731 $('#content').animate({
1732 scrollTop: 0
1733 });
1734 $('#content').fadeOut(500, function() {
1735 $('#content').html(data);
1736 $('#content').fadeIn(500);
1737 }); // generic html update
1738 if (typeof history.pushState !== "undefined") { // can also use modernizr to check if browser supports history
1739 if (pageevent == '') {
1740 var obj = {
1741 url: "?page=" + page_url
1742 };
1743 history.pushState(obj, page_title, "?page=" + page_url);
1744 }
1745 pageevent = '';
1746 }
1747 });
1748 return false; // since doing ajax
1749}
1750
1751
1752
1753$(document).ready(function() {
1754 if (cookiedatacenter != null) {
1755 userdatacenter = cookiedatacenter;
1756 } else if (userdc != '') {
1757 createCookie("datacenter", userdc, "365");
1758 userdatacenter = userdc;
1759 } else {
1760 createCookie("datacenter", "Crystal", "365");
1761 userdatacenter = "Crystal";
1762 }
1763
1764
1765 populatedcs();
1766
1767 setInterval(function() {
1768 updateClock();
1769 }, 1000);
1770
1771 $("#streamframe").draggable({
1772 handle: ".streamDraggableHandle"
1773 });
1774
1775 $( "#postDiv" ).draggable({
1776 handle: ".postdivDraggableHandle"
1777 });
1778
1779 $("#fashionframe").draggable({
1780 handle: ".fashionDraggableHandle"
1781 });
1782
1783 // $("#submitpost").draggable({
1784 // handle: ".postDraggableHandle"
1785 // });
1786
1787 // $("#submitevent").draggable({
1788 // handle: ".eventDraggableHandle"
1789 // });
1790
1791 // $("#submitfc").draggable({
1792 // handle: ".fcDraggableHandle"
1793 // });
1794
1795 favPosts = readCookie("favPosts");
1796 if (favPosts == null) {
1797 favPosts = [];
1798 createCookie('favPosts', JSON.stringify(favPosts));
1799 } else {
1800 favPosts = JSON.parse(favPosts);
1801 }
1802
1803 recentPosts = readCookie("recentPosts");
1804 if (recentPosts == null) {
1805 recentPosts = [];
1806 createCookie('recentPosts', JSON.stringify(recentPosts));
1807 } else {
1808 recentPosts = JSON.parse(recentPosts);
1809 }
1810
1811 refreshList = readCookie("refreshList");
1812 if (refreshList == null) {
1813 refreshList = 0;
1814 createCookie('refreshList', refreshList);
1815 }
1816 // refreshList = 0;
1817 var select = document.getElementById("usertimezone");
1818 for (index in timezones) {
1819 var zonefancy = timezones[index].replace(/\//g, ": ").replace(/_/g, " ");
1820 select.options[select.options.length] = new Option(zonefancy, index);
1821 }
1822
1823
1824 $(function () {
1825 $("#datacenter, #pageSelect, #usertimezone").select2();
1826 });
1827
1828
1829 const format1 = "Y-m-d H:i:s";
1830 const format2 = "YYYY-MM-DD HH:mm:ss";
1831 // var serverTime = new Date(serverTimePHP);
1832 // var clientTime = new Date();
1833 var serverTime = moment(serverTimePHP, format2);
1834 var clientTime = moment(new Date());
1835 //serverTime = moment(serverTime).format(format1);
1836 //clientTime = moment(clientTime).format(format1);
1837
1838 //serverTime = moment(serverTime,'YYYY-MM-dd H:i:s');
1839 // var clientTime = moment.format('YYYY-MM-dd H:i:s');
1840
1841 var timeDifference = moment.duration(serverTime.diff(clientTime));
1842 timeDifference = Math.round(timeDifference.asHours());
1843 // msg("Timezone offset: "+timeDifference);
1844
1845 utimezone = readCookie("timezone");
1846 tz = moment.tz.guess();
1847 // var guessedOffset = timeDifference * -1;
1848 // console.log(tz, guessedOffset,timezone,utimezone);
1849 if (utimezone != null) {
1850 // if (!isNumber(utimezone)) {
1851 tz = moment.tz.guess();
1852 utimezone = getKeyByValue(timezones, tz);
1853 // }
1854 $("#usertimezone").val(utimezone);
1855 timezone = utimezone;
1856 offset = timezone;
1857 timezone = timezones[timezone];
1858 reverseoffset = offset * -1;
1859 createCookie('timezone', utimezone);
1860 } else {
1861 // var guessedOffset = $('#usertimezone option').filter(function () { return $(this).html() == tz; }).val();
1862 tz = moment.tz.guess();
1863 // var guessedOffset = timeDifference * -1;
1864 utimezone = getKeyByValue(timezones, tz);
1865 // console.log(tz, guessedOffset,timezone);
1866 // if (!isNumber(utimezone)) {
1867 // var tz = moment.tz.guess();
1868 // utimezone = getKeyByValue(timezones, tz);
1869 // }
1870 createCookie('timezone', utimezone);
1871 timezone = utimezone;
1872 offset = timezone;
1873 reverseoffset = offset * -1;
1874 timezone = timezones[timezone];
1875 // console.log(tz, guessedOffset,timezone);
1876 $('#usertimezone').val(utimezone);
1877 }
1878
1879 // msg("There was a slight miscalculation with timezone offset. It should be fixed now.<br>Your timezone is "+tz+". If this is incorrect, please let Link know!!");
1880
1881 // ajaxNonFatalError('Timezone Debug Data: '+tz+' '+offset+' '+timezone+' '+utimezone, '', '', true);
1882
1883
1884 zoneAbbr = moment.tz(timezone).format("z");
1885
1886 var clight = readCookie("light");
1887 if (clight != '') {
1888 if (clight == 'off') {
1889 light = 'on';
1890 } else {
1891 light = 'off';
1892 };
1893 toggleLight();
1894 }
1895
1896 // trigger history update
1897 $('.nav').on('click', '.update-content', function() {
1898 document.title = siteTitle + ' - Loading...';
1899 pageevent = '';
1900 var page_url = $(this).attr('href'); // get url to call
1901 page = page_url;
1902 page_title = $(this).attr('data-title'); // set data-title in link
1903 loadPage(page_url, page_title);
1904 });
1905
1906 // capture the back button click
1907 $(window).bind('popstate', function(e) {
1908 var state = e.originalEvent.state;
1909 if (state) {
1910 var page_url = state.url; // state is actually 'obj' in previous function
1911 // run your ajax using page_url as the source url
1912 $.get(page_url, function(data) {
1913 $('#content').html(data);
1914 });
1915 }
1916 });
1917
1918 var cookieUser = readCookie("username");
1919 if (cookieUser != null) {
1920 $('#username').val(cookieUser);
1921 }
1922 // activate tabs
1923 $('#content, #postDiv-body').on('click', '.tabs', function(e) {
1924 name = 'div[name="' + e.target.getAttribute('name') + '"]';
1925 eurl = e.target.getAttribute('eurl');
1926
1927 wrapper = 'div[name="' + e.target.getAttribute('name') + '-wrapper"]';
1928 id = e.target.id;
1929 $(wrapper).animate({
1930 width: "95%"
1931 });
1932 $(wrapper).html("<img src='loadpic.gif' width='20%' class='imgdropshadow'>");
1933
1934 mode = id.substr(id.lastIndexOf('-') + 1);
1935
1936
1937
1938 if (eurl.toString().startsWith('event-') || mode == 'getevent') {
1939 // mode = mode+'event';
1940 eurl = eurl.replace(/^event-/, "");
1941 mode = mode.replace(/tab$/, "event");
1942 // mode = ;
1943 prefix = 'event-';
1944 }
1945 if (eurl.toString().startsWith('group-') || mode == 'getgroup') {
1946 // mode = mode+'group';
1947 eurl = eurl.replace(/^group-/, "");
1948 // mode = mode+"group";
1949 mode = mode.replace(/tab$/, "group");
1950 prefix = 'group-';
1951 }
1952
1953 if (mode.toString().startsWith('post') && prefix != '') {
1954 // mode = mode+'event';
1955 // eurl = eurl.replace(/^event-/, "");
1956 mode = mode.replace(/^post/, "get");
1957 // mode = ;
1958 // prefix = 'event-';
1959 }
1960 // console.log(mode);
1961
1962
1963 // console.log('gm?',getMode, page, mode, name,eurl,wrapper,id);
1964 switch (mode) {
1965 case 'menutab':
1966 mode = 'menu';
1967 break;
1968 case 'sitetab':
1969 mode = 'website';
1970 break;
1971 case 'calurltab':
1972 mode = 'calurl';
1973 break;
1974 case 'posttab':
1975 mode = 'get';
1976 break;
1977 case 'eventtab':
1978 mode = 'event';
1979 break;
1980 case 'employmenttab':
1981 mode = 'employment';
1982 break;
1983 }
1984 getMode = mode;
1985 // console.log('gm?',getMode);
1986 // console.log(eurl,name,mode,'#'+id,'','0', wrapper);
1987 getPost(eurl, name, mode, '#' + id, '', '0', wrapper);
1988 });
1989 if (user == 'Guest') {
1990 $('.captcha').fadeIn(500);
1991 $('#logoutlogin').val("Log In");
1992 $('#logoutlogin').attr("onclick", "location.href = ('./?page=login');");
1993 } else {
1994 $('.captcha').fadeOut(500);
1995 $('#logoutlogin').val("Log Out");
1996 $('#logoutlogin').attr("onclick", "location.href = ('./login-mog.php?mode=logout');");
1997 }
1998
1999 $('#posttimezone').on('change', function() {
2000 posttimezone = $('#posttimezone').val();
2001 postoffset = posttimezone;
2002 posttimezone = timezones[posttimezone];
2003 postreverseoffset = postoffset * -1;
2004 });
2005
2006 $('#eventtimezone').on('change', function() {
2007 eventtimezone = $('#eventtimezone').val();
2008 eventoffset = eventtimezone;
2009 eventtimezone = timezones[eventtimezone];
2010 eventreverseoffset = eventoffset * -1;
2011 });
2012
2013 $('#usertimezone').on('change', function() {
2014 createCookie('timezone', $(this).val(), 365);
2015 timezone = $('#usertimezone').val();
2016 offset = timezone;
2017 timezone = timezones[timezone];
2018 zoneAbbr = moment.tz(timezone).format("z");
2019 reverseoffset = offset * -1;
2020 if (pageevent !== '') {
2021 getPost(event);
2022 } else {
2023 loadPage(page);
2024 }
2025 });
2026
2027 if (domain != 'roleplayfinder.com') {
2028 var ratingMode = readCookie("rating");
2029 if (ratingMode == null) {
2030 ratingMode = 'T';
2031 createCookie('rating', ratingMode);
2032 $('#ratingIcon').attr("src", "teen.png");
2033 msg("ESRB Rating set to Teen by default. Click the ESRB icon on the top left to change rating.");
2034 } else {
2035 $('#ratingIcon').attr("src", "teen.png");
2036 if (ratingMode == 'M') {
2037 $('#ratingIcon').attr("src", "mature.png");
2038 } else {
2039 $('#ratingIcon').attr("src", "teen.png");
2040 }
2041 }
2042 } else {
2043 var ratingMode = 'T';
2044 createCookie('rating', ratingMode);
2045 }
2046
2047 event = window.location.href.split("?", )[1];
2048 if (event === void(0)) {
2049 event = '=';
2050 }
2051 if (event.indexOf('=') == -1) {
2052 pageevent = event;
2053 loadPostDiv(event);
2054 loadPage('comms');
2055 } else if (getSearchParams('page')) {
2056 page = getSearchParams('page');
2057 $('#pageSelect').val(page);
2058 loadPage(page);
2059 } else {
2060 loadPage('comms');
2061 }
2062
2063 introEffects();
2064 $('#content').fadeIn();
2065
2066 function readURL(input) {
2067 if (input.files && input.files[0]) {
2068 var reader = new FileReader();
2069
2070 reader.onload = function(e) {
2071 $("#img").fadeOut(1000, function() {
2072 $('#img').attr('src', e.target.result);
2073 }).fadeIn(1000);
2074 }
2075 reader.readAsDataURL(input.files[0]); // convert to base64 string
2076 }
2077 }
2078
2079 $("#image").change(function() {
2080 readURL(this);
2081 });
2082
2083 if (user != '') {
2084 $(".login-form").fadeOut(500);
2085 loggedIn(user, character, acct);
2086 }
2087
2088 $("#logout-form").on("submit", function(e) {
2089 e.preventDefault();
2090 var form_mode = e.target.id;
2091 // var user = $("#username").val().trim();
2092 $(".login-form").fadeOut(500);
2093 $(".logout-form").fadeOut(500);
2094 $("#loading-img").fadeIn(500);
2095 var formData = new FormData(this);
2096 $.ajax({
2097 type: 'POST',
2098 url: 'login-mog.php',
2099 processData: false,
2100 contentType: false,
2101 data: formData,
2102 success: function(str) {
2103 response = JSON.parse(str);
2104 $("#loading-img").fadeOut(500);
2105 if (response['login'] == 'blocked') {
2106 msg("Account blocked");
2107 // location.reload();
2108 return;
2109 }
2110
2111 if (response['login'] == 'ok') {
2112 delete response.login;
2113 if (response.approved == '0') {
2114 showreg('verify');
2115 return;
2116 }
2117 scout = response.scout;
2118 points = response.points;
2119 loggedIn(user, response.character, response.acct_type);
2120 } else if (response['logout'] == 'ok') {
2121 loggedOut();
2122 // location.reload();
2123 } else {
2124 $(".login-form").fadeIn(500);
2125 msg("Login Error!");
2126 loggedOut();
2127 // location.reload();
2128 }
2129 },
2130 error: function(XMLHttpRequest, textStatus, errorThrown) {
2131 $("." + e.target.id).fadeIn(500);
2132 $("#loading-img").fadeOut(500);
2133 msg("An error occurred processing your request!");
2134 }
2135 });
2136 });
2137
2138 // resetForm();
2139 //msg("Crystal Shouts promotes hate for harrasment and love for our community!<br>Any and all harassment, threats, slander (or libel), or bullying will not be tolerated. Please report all incidences immediately. <br>CS and their partners will not tolerate the suffering<br>or abuse of anyone. If you have any comments or feedback, please contact <b>Link Baudelaire#2052</b>");
2140 // msg("Please excuse the current state of the listings<br>while our dedicated team is working with these dedicated venue owners to assure the highest<br>quality listings and most accurate data. Updated information can be submitted via discord");
2141 // msg("Did you know that <img src='checkmark.png' height='20'> ensures a post is accurate and<br>up-to-date to guarantee the best experience and the most enjoyment?");
2142
2143 //if ( domain == 'roleplayfinder.com' ) {
2144 //msg("RolePlay Finder will no longer host 18+ posts. Please visit <a href='https://www.crystalshouts.com'>Crystal Shouts</a> for 18+ listings. Thank you.");
2145 //}
2146
2147 $(".postdivDraggableHandle, .fashionDraggableHandle, .streamDraggableHandle, .postdivDraggableHandle, .fcDraggableHandle, .eventDraggableHandle").on("mousedown", function() {
2148 $(this).addClass("mouseDown");
2149 }).on("mouseup", function() {
2150 $(this).removeClass("mouseDown");
2151 });
2152
2153 // if ( !commsBgInterval ) {
2154 // changeBackground();
2155 if (domain == 'roleplayfinder.com') {
2156 bgImage = 'rpf.png';
2157 var bgSize = '50% auto';
2158 $('#featuredDiv').css("top", "-144px");;
2159 } else {
2160 bgImage = 'comms-background17.png';
2161 var bgSize = 'cover';
2162 $('#featuredDiv').css("top", "-155px");;
2163 }
2164 document.getElementById("contain").style.backgroundImage = "url(" + bgImage + ")";
2165
2166 setTimeout(function() {
2167 $("#contain").css("background-size", bgSize);
2168 // $("#contain").css("background-height", '50%');
2169 }, 500);
2170 // };
2171
2172 $('#title').on("change paste keyup", function() {
2173 var str = $(this).val();
2174 str = str.replace(/[^a-zA-Z 0-9 -]+/g, '').replace(/\s+/g, '-').toLowerCase();
2175 $('#eurl').val(str);
2176 });
2177
2178 $('#e-title').on("change paste keyup", function() {
2179 var str = $(this).val();
2180 str = str.replace(/[^a-zA-Z 0-9 -]+/g, '').replace(/\s+/g, '-').toLowerCase();
2181 $('#e-eurl').val(str);
2182 });
2183
2184 $('#fc-title').on("change paste keyup", function() {
2185 showImport();
2186 var str = $(this).val();
2187 str = str.replace(/[^a-zA-Z 0-9 -]+/g, '').replace(/\s+/g, '-').toLowerCase();
2188 $('#fc-eurl').val(str);
2189 });
2190
2191 $('#eurl, #e-eurl, #fc-eurl').on("change paste keyup", function() {
2192 var eurlval = this.value;
2193 var patt = /^(\w|\-)+$/;
2194 if (!patt.test(this.value) || eurlval.startsWith('event-') || eurlval.startsWith('group-')) {
2195 $('#eurl').css({
2196 "color": "red",
2197 "border": "2px dotted red"
2198 });
2199 $('#submit_form').prop('disabled', true);
2200 $('#e-eurl').css({
2201 "color": "red",
2202 "border": "2px dotted red"
2203 });
2204 $('#e-submit_form').prop('disabled', true);
2205 $('#fc-eurl').css({
2206 "color": "red",
2207 "border": "2px dotted red"
2208 });
2209 $('#fc-submit_form').prop('disabled', true);
2210 if (eurlval.startsWith('event-')) {
2211 $("eurlcheck, e-eurlcheck, fc-eurlcheck").html("URL cannot begin with 'event-' or 'group-'");
2212 }
2213 } else {
2214 $("eurlcheck, e-eurlcheck").html("");
2215 $('#e-submit_form').prop('disabled', false);
2216 $('#e-eurl').css({
2217 "color": "#5c2713",
2218 "border": "2px solid #948f7c"
2219 });
2220 $('#submit_form').prop('disabled', false);
2221 $('#eurl').css({
2222 "color": "#5c2713",
2223 "border": "2px solid #948f7c"
2224 });
2225 }
2226 });
2227
2228 $(document).keyup(function(e) {
2229 if (e.key === "Escape") {
2230 $('#postDiv').fadeOut(500);
2231 try {
2232 if (!typeof closeWiz != 'undefined') {
2233 closeWiz();
2234 }
2235 } catch (e) {
2236 console.log(e);
2237 }
2238
2239 if (!typeof activeTrid['lasteurl'] != 'undefined') {
2240 collapsePost(activeTrid['lasteurl']);
2241 }
2242 setLocation();
2243 }
2244 });
2245
2246 $("body").on('submit', '#post-form', function(e) {
2247 e.preventDefault();
2248 var dayslist = $("select#dayOpt").val()
2249 $('#submit_form').prop('disabled', true);
2250 $("#loading-img").fadeIn(1500);
2251 var id = $("#id");
2252 var times = {};
2253
2254 if (dayslist != null) {
2255 for (i = 0; i < dayslist.length; i++) {
2256 day = dayslist[i];
2257 otime = $(`#${day}-otime`).val();
2258 ctime = $(`#${day}-ctime`).val();
2259 if (moment.utc(otime, 'hh:mm A')._isValid) {
2260 var otime = moment.utc(otime, 'hh:mm A').add(postreverseoffset, 'hour').format('h:mm A');
2261 }
2262 if (moment.utc(ctime, 'hh:mm A')._isValid) {
2263 var ctime = moment.utc(ctime, 'hh:mm A').add(postreverseoffset, 'hour').format('h:mm A');
2264 }
2265 times[day] = {};
2266 times[day]['otime'] = otime;
2267 times[day]['ctime'] = ctime;
2268 }
2269 }
2270 times = JSON.stringify(times);
2271
2272 if ($("#server").val() == "Anywhere") {
2273 $("#psize").val('');
2274 }
2275
2276 times = times.toString();
2277
2278 var formData = new FormData(this);
2279 var managers = [];
2280
2281 $('.managers').each(function() {
2282 managers.push(this.value);
2283 });
2284 var mode = $("#submit_form").text();
2285 formData.append('day', dayslist);
2286 formData.append('manager', managers);
2287 formData.append('mode', mode);
2288 formData.append('times', times);
2289
2290 $.ajax({
2291 type: "POST",
2292 url: "addpost.php",
2293 data: formData,
2294 processData: false,
2295 contentType: false,
2296 success: function(ndata, status, xdr) {
2297 data = JSON.parse(ndata);
2298 $("#loading-img").fadeOut(1500);
2299 $('#submit_form').prop('disabled', false);
2300 if (data.approved == '0') {
2301 msg("Please verify your account before managing posts!");
2302 showreg('verify');
2303 return;
2304 }
2305 if (data['status'] == '1') {
2306 eurl = $('#eurl').val();
2307 $('#submitpost').fadeOut();
2308 loadPostDiv(eurl);
2309 } else {
2310 ajaxNonFatalError(ndata,status,xhr);
2311 }
2312 },
2313 error: function(XMLHttpRequest, textStatus, errorThrown) {
2314 $("#loading-img").fadeOut(1500);
2315 $('#submit_form').prop('disabled', false);
2316 msg("An error occurred processing your request.");
2317 }
2318 });
2319 });
2320
2321 $("body").on('submit', '#event-form', function(e) {
2322 e.preventDefault();
2323 var dayslist = $("select#e-dayOpt").val()
2324 $('#e-submit_form').prop('disabled', true);
2325 $("#loading-img").fadeIn(1500);
2326 var id = $("#e-id");
2327
2328 if (moment.utc($("#e-otime").val(), 'hh:mm A')._isValid) {
2329 var otime = moment.utc($("#e-otime").val(), 'hh:mm A').add(eventreverseoffset, 'hour').format('h:mm A');
2330 }
2331 if (moment.utc($("#e-ctime").val(), 'hh:mm A')._isValid) {
2332 var ctime = moment.utc($("#e-ctime").val(), 'hh:mm A').add(eventreverseoffset, 'hour').format('h:mm A');
2333 }
2334
2335 $("#e-otime").val(otime);
2336 $("#e-ctime").val(ctime);
2337
2338 var formData = new FormData(this);
2339 var managers = [];
2340
2341 $('.e-managers').each(function() {
2342 managers.push(this.value);
2343 });
2344 var mode = $("#e-submit_form").text();
2345 formData.append('day', dayslist);
2346 formData.append('manager', managers);
2347 formData.append('mode', mode);
2348 $.ajax({
2349 type: "POST",
2350 url: "addevent.php",
2351 data: formData,
2352 processData: false,
2353 contentType: false,
2354 success: function(ndata, status, xhr) {
2355 data = JSON.parse(ndata);
2356 $("#loading-img").fadeOut(1500);
2357 $('#e-submit_form').prop('disabled', false);
2358 if (data.approved == '0') {
2359 msg("Please verify your account before managing events!");
2360 showreg('verify');
2361 return;
2362 }
2363 if (data['status'] == '1') {
2364 eurl = $('#e-eurl').val();
2365 id = data['response'];
2366 $('#submitevent').fadeOut();
2367 loadPostDiv('event-' + eurl);
2368 } else {
2369 ajaxNonFatalError(ndata,status,xhr);
2370 // msg("An error occurred processing your request.");
2371 }
2372 },
2373 error: function(XMLHttpRequest, textStatus, errorThrown) {
2374 $("#loading-img").fadeOut(1500);
2375 $('#e-submit_form').prop('disabled', false);
2376 msg("An error occurred processing your request.");
2377 }
2378 });
2379 });
2380
2381 $(function() {
2382 $('#datacenter > option').hover(function() {
2383 $(this).parent().css({
2384 fontFamily: $(this).val()
2385 })
2386 })
2387 })
2388
2389 $("#FashionIcon").hover(function() {
2390 $(this).css('cursor', 'pointer').attr('title', 'This Week\'s Fashion Report!');
2391 }, function() {
2392 $(this).css('cursor', 'auto');
2393 });
2394
2395 $("body").on('submit', '#alert-form', function(e) {
2396 $("#loading-img").fadeIn(1500);
2397 e.preventDefault();
2398 var formData = new FormData(this);
2399 $.ajax({
2400 type: "POST",
2401 processData: false,
2402 contentType: false,
2403 url: "sendalert.php",
2404 data: formData,
2405 success: function(data) {
2406 if (isJson(data)) {
2407 data = JSON.parse(data);
2408 }
2409 if (data['status'] != '0') {
2410 $("#loading-img").fadeOut(500);
2411 msg("An error occurred processing your request!<br>" + data['msg']);
2412 return;
2413 }
2414 msg("Alert sent!");
2415 $("#sendalert").fadeOut();
2416 $("#loading-img").fadeOut(500);
2417 },
2418 error: function() {
2419 msg("An error occurred processing your request");
2420 $("#loading-img").fadeOut(500);
2421 }
2422 });
2423 });
2424
2425 // $("body").on('submit', '#fc-form', function(e) {
2426 // e.preventDefault();
2427 // $('#fc-submit_form').prop('disabled', true);
2428 // $("#loading-img").fadeIn(1500);
2429 // var id = $("#fc-id").val();
2430 // var apt = $("#fc-apt").val();
2431 // var housing = $("#fc-housing").val();
2432 // var rank = $("#fc-rank").val();
2433 // var recruit = $("#fc-recruit").prop('checked');
2434 // var crest = [];
2435 // crest[0] = $('#fc-crest1').attr('src');
2436 // crest[1] = $('#fc-crest2').attr('src');
2437 // crest[2] = $('#fc-crest3').attr('src');
2438
2439 // var formData = new FormData(this);
2440 // var managers = [];
2441
2442 // $('.fc-managers').each(function() {
2443 // managers.push(this.value);
2444 // });
2445 // var mode = $("#fc-submit_form").text();
2446 // formData.append('manager', managers);
2447 // formData.append('mode', mode);
2448 // formData.append('rank', rank);
2449 // formData.append('crest', crest);
2450 // formData.append('recruit', recruit);
2451 // $.ajax({
2452 // type: "POST",
2453 // url: "addgroup.php",
2454 // data: formData,
2455 // processData: false,
2456 // contentType: false,
2457 // success: function(ndata) {
2458 // data = JSON.parse(ndata);
2459 // $("#loading-img").fadeOut(1500);
2460 // $('#fc-submit_form').prop('disabled', false);
2461 // if (data.approved == '0') {
2462 // msg("Please verify your account before managing events!");
2463 // showreg('verify');
2464 // return;
2465 // }
2466 // if (data['status'] == '1') {
2467 // eurl = $('#fc-eurl').val();
2468 // id = data['response'];
2469 // $('#submitfc').fadeOut();
2470 // loadPostDiv('group-' + eurl);
2471 // } else {
2472 // msg("An error occurred processing your request.");
2473 // }
2474 // },
2475 // error: function(XMLHttpRequest, textStatus, errorThrown) {
2476 // $("#loading-img").fadeOut(1500);
2477 // $('#fc-submit_form').prop('disabled', false);
2478 // msg("An error occurred processing your request.");
2479 // }
2480 // });
2481 // });
2482
2483 // $("#fc-form input").blur(function() {
2484 // var checkValue = $(this).val();
2485 // if (checkValue != '') {
2486 // $(this).css("border", "2px solid #948f7c");
2487 // }
2488 // });
2489
2490});
2491
2492
2493
2494function event_css() {
2495 $('body').animate({
2496 backgroundColor: '#333'
2497 }, 1000);
2498}
2499
2500if (user != "") {
2501 $('.captcha').css({
2502 "display": "none"
2503 });
2504} else {
2505 $('.captcha').css({
2506 "display": "block"
2507 });
2508}
2509
2510$('input[type=radio][name=uploadurl]').change(function() {
2511 if (this.value == 'url') {
2512 $(".filephoto").fadeOut(150, function() {
2513 $("#urlphoto").fadeIn(150);
2514 });
2515 } else if (this.value == 'upload') {
2516 $("#urlphoto").fadeOut(150, function() {
2517 $(".filephoto").fadeIn(150);
2518 });
2519 }
2520});
2521var hrng = 0;
2522
2523function addHiring(position = '', rate = '') {
2524 if (hrng <= 20) {
2525 var div = document.createElement('div');
2526 div.innerHTML = `
2527 <br>
2528 Position: <br>
2529 <input type="text" autocomplete="off" class="hiring" hindex="${hrng}" name="position" value="${position}" id="position${hrng}"><br>
2530 Details:<br>
2531 <textarea rows="4" cols="30" class="hiring" name="rate" hindex="${hrng}" id="rate${hrng}">${rate}</textarea>
2532 <input class="link" type="button" id="add_hiring()" onClick="addHiring()" value="+" />
2533 <input class="link" type="button" value="-" onclick="removeHiring(this)">
2534 `;
2535 hrng++;
2536 if (document.getElementById('hiringMore') != null) {
2537 document.getElementById('hiringMore').appendChild(div);
2538 somethingChangedFunc(true);
2539 populatepositions('position' + hrng);
2540 }
2541 }
2542}
2543
2544function removeHiring(div) {
2545 somethingChangedFunc(true);
2546 document.getElementById('hiringMore').removeChild(div.parentNode);
2547 hrng--;
2548}
2549
2550var mgrs = 1;
2551var emgrs = 1;
2552var fcmgrs = 1;
2553
2554function addManager(value = '', prefix = '') {
2555 if (prefix == 'e-') {
2556 if (emgrs <= 20) {
2557 emgrs++;
2558 somethingChangedFunc(true);
2559 var div = document.createElement('div');
2560 div.innerHTML = `<input type="text" value="${value}" style="width:100px;" class="e-managers" name="manager" id="${prefix}${mgrs}" ><input class="link" type="button" onClick="addManager('', 'e-')" value="+" /><input class="link" type="button" value="-" onclick="removeManager(this, 'e-')">`;
2561 document.getElementById('e-managers').appendChild(div);
2562 }
2563 } else if (prefix == 'fc-') {
2564 if (fcmgrs <= 20) {
2565 fcmgrs++;
2566 somethingChangedFunc(true);
2567 var div = document.createElement('div');
2568 div.innerHTML = `<input type="text" value="${value}" style="width:100px;" class="fc-managers" name="manager" id="${prefix}${mgrs}" ><input class="link" type="button" onClick="addManager('', 'fc-')" value="+" /><input class="link" type="button" value="-" onclick="removeManager(this, 'fc-')">`;
2569 document.getElementById('fc-managers').appendChild(div);
2570 }
2571 } else {
2572 if (mgrs <= 20) {
2573 mgrs++;
2574 somethingChangedFunc(true);
2575 var div = document.createElement('div');
2576 div.innerHTML = `<input type="text" value="${value}" style="width:100px;" class="managers" name="manager" id="${mgrs}" ><input class="link" type="button" onClick="addManager('')" value="+" /><input class="link" type="button" value="-" onclick="removeManager(this)">`;
2577 document.getElementById('managers').appendChild(div);
2578 }
2579 }
2580}
2581
2582function removeManager(div, prefix = '') {
2583 somethingChangedFunc(true);
2584 if (prefix == 'e-') {
2585 document.getElementById('e-managers').removeChild(div.parentNode);
2586 emgrs--;
2587 } else if (prefix == 'fc-') {
2588 document.getElementById('fc-managers').removeChild(div.parentNode);
2589 fcmgrs--;
2590 } else {
2591 document.getElementById('managers').removeChild(div.parentNode);
2592 mgrs--;
2593 }
2594}
2595
2596// function newPost(mode = '') {
2597 // $("#submitpost").fadeIn(250, function() {
2598 // resetForm('');
2599 // });
2600// }
2601
2602// function newEvent() {
2603 // $("#submitevent").fadeIn(250, function() {
2604 // resetForm('e-');
2605 // });
2606// }
2607
2608// function newFc() {
2609 // $("#submitfc").fadeIn(250, function() {
2610 // resetForm('fc-');
2611 // });
2612// }
2613
2614function scrollToObject(id) {
2615 var myElement = document.getElementById(id);
2616 var topPos = myElement.offsetTop;
2617 $('#content').animate({
2618 scrollTop: topPos
2619 });
2620}
2621
2622$("#urlphoto").change(function() {
2623 var url = $("#urlphoto").val();
2624 $('#img').attr('src', url);
2625 $(".preview").fadeIn(500);
2626});
2627
2628function readURL(input, prefix = '') {
2629 if (input.files && input.files[0]) {
2630 var reader = new FileReader();
2631 reader.onload = function(e) {
2632 $('#' + prefix + 'img').attr('src', e.target.result);
2633 $('#' + prefix + 'img').fadeTo(1000, 1);
2634 $('initCropperBtn').fadeIn();
2635 }
2636 $('#' + prefix + 'img').fadeTo(1000, 0, function() {
2637 reader.readAsDataURL(input.files[0]); // convert to base64 string
2638 });
2639 }
2640}
2641
2642function readVid(input, prefix = '') {
2643 var url = youtube_parse(input.value);
2644 $('#' + prefix + 'vid').attr('src', "https://www.youtube.com/embed/" + url);
2645}
2646
2647$("#image").change(function() {
2648 readURL(this);
2649});
2650
2651function resetForm(prefix = '', mode = 'post', service = '') {
2652 $('#post-category').tagEditor('destroy');
2653 $('#' + mode + '-form').trigger('reset');
2654 if (prefix === 'e-') {
2655 $('#inputfile-event').fadeIn();
2656 $(`#e-dc option[value=${userdatacenter}]`).attr('selected', 'selected');
2657 $('#e-dc').trigger('change');
2658 type = 'event';
2659 $('#posteurl').html('<option value="">Do not attach to post</option>');
2660 populatePosteurl();
2661 $('#fceurl').html('<option value="">Do not attach to FC/Group</option>');
2662 populatePosteurl('', 'fc');
2663 jQuery('#datetimepicker').datetimepicker();
2664 jQuery('#edatetimepicker').datetimepicker();
2665 mode = 'event';
2666 } else if (prefix === 'fc-') {
2667 $('#inputfile-fc').fadeIn();
2668 $(`#fc-dc option[value=${userdatacenter}]`).attr('selected', 'selected');
2669 $('#fc-dc').trigger('change');
2670 type = 'fc';
2671 mode = 'fc';
2672 $('#fc-crest1').attr('src', '');
2673 $('#fc-crest1').fadeOut();
2674 $('#fc-crest2').attr('src', '');
2675 $('#fc-crest2').fadeOut();
2676 $('#fc-crest3').attr('src', '');
2677 $('#fc-crest3').fadeOut();
2678 $('#fc-apt').val('');
2679 $('#fc-import').fadeOut();
2680 $('#fc-category').val('');
2681 $('#fc-estate').prop('checked', false);
2682 } else {
2683 type = '';
2684 mode = 'post';
2685 $.ajax({
2686 type: 'POST',
2687 url: 'api.php',
2688 data: {
2689 mode: 'category',
2690 dc: $('#datacenter').val()
2691 },
2692 dataType: 'json',
2693 success: function(data) {
2694 if (typeof data.status != 'undefined' && data.status == '255') {
2695 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
2696 return;
2697 }
2698
2699 // var catlist = data[0]["GROUP_CONCAT(category SEPARATOR ' ')"];
2700 var catlist = data.catlist;
2701
2702 let ucats = '';
2703 if (catlist == null) {
2704 catlist = '';
2705 }
2706
2707 var oldcats = catlist.split(" #").map(Function.prototype.call, String.prototype.trim);
2708 var cats = oldcats.filter(function(v) {
2709 return v !== ''
2710 }).sort();
2711 ucats = [...new Set(cats)];
2712 var ignoredTags = ['erp', 'escorts', 'escort', '18+', '21+'];
2713 for (i = 0, len = ignoredTags.length, tag = ""; i < len; i++) {
2714 var tag = ignoredTags[i];
2715 if (ucats.includes(tag)) {
2716 var index = ucats.indexOf(tag);
2717 ucats.splice(index, 1);
2718 }
2719 }
2720 currentTags = unique(catlist.split(' #'));
2721 currentTags = currentTags.toString().replace("#", "");
2722 currentTags = currentTags.replace(/ #/g, ",").split(',');
2723
2724 if ( prefix == 'group-' ) { currentKeywords = currentTags; }
2725
2726
2727 // console.log(currentTags, currentKeywords);
2728 $('#' + prefix + 'category').tagEditor('destroy');
2729 $('#' + prefix + 'category').tagEditor('destroy');
2730 $('#' + prefix + 'category').prop("disabled", false);
2731 $('#' + prefix + 'category').tagEditor({
2732 autocomplete: {
2733 delay: 0, // show suggestions immediately
2734 source: currentTags,
2735 position: {
2736 collision: 'flip'
2737 } // automatic menu position up/down
2738 },
2739 forceLowercase: true,
2740 placeholder: 'Post tags...'
2741 });
2742 }
2743 });
2744 }
2745 $('#inputfile-post').fadeIn();
2746 $('#' + prefix + 'img').attr("src", "getimage.php?1");
2747 $('#' + prefix + 'managers').text('');
2748 $('#' + prefix + 'id').val('');
2749 $('#' + prefix + 'pictureid').val('');
2750 $('#' + prefix + 'submit_form').val('Submit');
2751 $('#' + prefix + 'submit_form').html('Submit');
2752 $(`#${prefix}dc option[value=${userdatacenter}]`).attr('selected', 'selected');
2753 $('#' + prefix + 'dc').trigger('change');
2754 $('#' + prefix + 'featured').prop("checked", false);
2755 $('#' + prefix + 'listed').prop("checked", true);
2756 $('#' + prefix + 'closed').prop("checked", false);
2757 $('#' + prefix + 'owner').val(user);
2758 if (acct == '2') {
2759 $('#' + prefix + 'owner').fadeIn();
2760 $('#' + prefix + 'owner').val(user);
2761 } else {
2762 $('#' + prefix + 'owner').fadeOut();
2763 }
2764 $('#biweekly').prop("checked", false)
2765 $('#weekly').prop("checked", true);
2766 $('#biweeklystart').fadeOut();
2767 jQuery('#post-datetimepicker').datepicker({
2768 dateonly: true,
2769 format: 'YYYY-MM-DD'
2770 });
2771 $('#e-0').val(character);
2772 $('#fc-0').val(character);
2773 $('#0').val(character);
2774 $('#' + prefix + type + 'timezone').val($('#usertimezone').val());
2775 reverseoffset = offset * -1;
2776}
2777
2778function loadPost(eurl, elem = '', prefix = '') {
2779 if ( eurl.startsWith("group-") ) {
2780 prefix = 'group-';
2781 eurl = eurl.replace('group-', '');
2782 }
2783 if ( eurl.startsWith("event-") ) {
2784 prefix = 'event-';
2785 eurl = eurl.replace('event-', '');
2786 }
2787
2788 $('#postDiv-body').text('');
2789 var id = '';
2790 var bg = '';
2791 savedHtml[prefix + eurl] = $(elem).parent().parent().prop('outerHTML');
2792 id = savedHtmlId[prefix + eurl] = $(elem).parent().parent().attr('id');
2793 idtd = id.replace('tr', 'td');
2794 bg = savedHtmlBg[prefix + eurl] = $(elem).parent().parent().attr('style');
2795 // idtd = $(elem).parent().attr('id');
2796 colspan = 20;
2797 if (prefix == '') {
2798 colspan = 4;
2799 }
2800 activeTrid[eurl] = id;
2801 activeTrid['last'] = id;
2802 activeTrid['lasteurl'] = eurl;
2803
2804 $(`#${id}`).fadeTo(500, 0, function() {
2805 // $(`#${id}`).html(`<td id='${idtd}' colspan='${colspan}' style="border: 0px; width:1200px; "><h1 class="headertitle"><center><img id='loadpicPost' src='loadpic.gif'/></h1></td>`);
2806 $(`#${id}`).html(`<td id='${idtd}' colspan='${colspan}'><h1 class="headertitle"><center><img id='${eurl}-loadpicPost' height="100%" src='loadpic.gif'/></h1></td>`);
2807 $(`#${id}`).css('height', `244px`);
2808 // $(`#${id}`).css('background', `url('getimage.php?banner-${prefix}${eurl}') no-repeat;`);
2809 $(`#${id}`).css('background-size', '100% auto');
2810 $(`#${idtd}`).css('background-color', 'rgba(0, 0, 0, 0)');
2811 $(`#${id}`).css('background-color', 'rgba(0, 0, 0, 0)');
2812 $(`#${id}`).css('background-position', `center;`);
2813 $(`#${idtd}`).css('background', '');
2814
2815
2816 // style="border: 0px; width:1200px;
2817 // background: url('getimage.php?${prefix}${eurl}') no-repeat;
2818 // background-size: 100% auto; background-position: center;"
2819
2820
2821 $(`#${id}`).fadeTo(500, 1, function() {
2822 getPost(prefix + eurl, '#' + idtd);
2823 });
2824 });
2825}
2826
2827function readList(request, target, filter = '', mode = 'list') {
2828 // console.log('readlist',arguments);
2829 var result = "<label for='invert'><input id='invert' type='checkbox' name='invert'> Invert Results</label><br><ul id='tagCategory' class='menuList'>";
2830 var prefix = '';
2831
2832 if (mode == 'category') {
2833 request = mode;
2834 result = result + "<label><li class='reversegradient' name='All Posts'>All | Refresh List<input category style='float:right;' id='AllPosts' checked type='checkbox' name='All Posts'></li></label>";
2835 }
2836
2837 if (mode == 'category-groups') {
2838 request = mode;
2839 prefix = 'group-';
2840 result = result + "<label><li class='reversegradient' name='All Groups'>All | Refresh List<input category style='float:right;' id='AllGroups' checked type='checkbox' name='All Groups'></li></label>";
2841 }
2842
2843 if (mode == 'keywords-groups') {
2844 request = mode;
2845 prefix = 'group-';
2846 // result = result + "<label><li class='reversegradient' name='All Groups'>All | Refresh List<input category style='float:right;' id='AllGroups' checked type='checkbox' name='All Groups'></li></label>";
2847 }
2848
2849 if (mode == 'category-events') {
2850 request = mode;
2851 prefix = 'event-';
2852 result = result + "<label><li class='reversegradient' name='All Events'>All | Refresh List<input category style='float:right;' id='AllEvents' checked type='checkbox' name='All Events'></li></label>";
2853 }
2854
2855 $.ajax({
2856 type: 'POST',
2857 url: 'api.php',
2858 data: {
2859 mode: mode,
2860 request: request,
2861 filter: filter,
2862 dc: $('#datacenter').val()
2863 },
2864 dataType: 'json',
2865 success: function(data) {
2866 if (typeof data.status != 'undefined' && data.status == '255') {
2867 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
2868 return;
2869 }
2870
2871 for (var i in data) {
2872 var row = data[i];
2873 if ((mode == 'list') || (mode == 'categories')) {
2874 var description = 'No Results!';
2875 if (row.description) {
2876 description = truncate(row['description']);
2877 }
2878 var otime = moment.utc(row['otime'], 'hh:mm A').add(offset, 'hour').format('h:mm A');
2879 var ctime = moment.utc(row['ctime'], 'hh:mm A').add(offset, 'hour').format('h:mm A') + " " + timezone;
2880 if (row['day'] == '["Event Only"]' || otime == 'Invalid date') {
2881 var times = '';
2882 } else {
2883 var times = `From ${otime} to ${ctime}`;
2884 }
2885
2886 if (row.datacenter == userdatacenter || row.datacenter == 'Anywhere') {
2887 result = `${result}<li onclick='loadPost("${row['eurl']}")'>
2888 <table width='100%' rules="rows">
2889 <tbody>
2890 <tr class="trbg">
2891 <td width="100px" class="centered">
2892 <center>
2893 <img class='comms-search-results-img imgdropshadowGold' src="getimage.php?${prefix}${row['eurl']}" height='80px'>
2894 </center>
2895 </td>
2896 <td>
2897 <table width='100%' class="search-result-text">
2898 <tbody>
2899 <tr>
2900 <td><center>
2901 <b>${row['title']}</b></center>
2902 </td>
2903 </tr>
2904 <tr>
2905 <td><center>
2906 ${description}<br>
2907 ${row['day']} ${times}</center>
2908 </td>
2909 </tr>
2910 <tr>
2911 <td><center>
2912 ${row['server']}:
2913 ${row['housing']}:
2914 Ward #${row['ward']},
2915 Plot #${row['plot']} near
2916 ${row['aetheryte']}
2917 </center><br>
2918 ${row['psize']}
2919 </td>
2920 </tr>
2921 </tbody>
2922 </table>
2923 </td>
2924 </tr>
2925 </tbody>
2926 </table>`;
2927 }
2928 } else {
2929 let ucats = '';
2930 if (i != 'catlist') {
2931 continue;
2932 }
2933 // console.log(typeof row, typeof data, i);
2934 // if (typeof row ) { row = data; }
2935 row = data;
2936 // console.log(row[i], data[i]);
2937
2938 var catlist = row['catlist'];
2939 if (mode == 'category') {
2940 if (catlist == null) {
2941 catlist = '';
2942 }
2943 var oldcats = catlist.split("#").map(Function.prototype.call, String.prototype.trim);
2944 var cats = oldcats.filter(function(v) {
2945 return v !== ''
2946 }).sort();
2947 ucats = [...new Set(cats)];
2948 var ignoredTags = ['erp', 'escorts', 'escort', '18+', '21+'];
2949 for (i = 0, len = ignoredTags.length, tag = ""; i < len; i++) {
2950 var tag = ignoredTags[i];
2951 if (ucats.includes(tag)) {
2952 var index = ucats.indexOf(tag);
2953 ucats.splice(index, 1);
2954 }
2955 }
2956 }
2957
2958 currentTags = ucats;
2959
2960 if (mode == 'category-groups') {
2961 ucats = unique(catlist.split(','));
2962 // currentKeywords = ucats;
2963 }
2964 if (mode == 'keywords-groups') {
2965 ucats = unique(catlist.split('#'));
2966 currentKeywords = ucats;
2967 }
2968 if (mode == 'category-events') {
2969 ucats = unique(catlist.split(','));
2970 currentTags = ucats;
2971 currenteTags = ucats;
2972 }
2973 var j;
2974 for (j = 0; j < ucats.length; j++) {
2975 result = `${result}
2976 <label>
2977 <li name='${ucats[j]}' categoryli class='gradient'>
2978 ${ucats[j]}
2979 <input style='float:right;display:none;' category type='checkbox' name='${ucats[j]}'>
2980 </li>
2981 </label>`;
2982 }
2983 }
2984 }
2985 if (target) { $(target).html(result + "</ul>"); }
2986 },
2987 error: function(XMLHttpRequest, textStatus, errorThrown) {
2988 $("#loading-img").fadeOut(500);
2989 msg("An error occurred processing your request!");
2990 }
2991 });
2992}
2993
2994function unique(list) {
2995 var result = [];
2996 $.each(list, function(i, e) {
2997 if ($.inArray(e, result) == -1) result.push(e);
2998 });
2999 return result;
3000}
3001
3002function updateClock() {
3003 var currentTime = new Date();
3004 var currentHours = currentTime.getHours();
3005 var currentMinutes = currentTime.getMinutes();
3006 var currentSeconds = currentTime.getSeconds();
3007
3008 // if ( refreshList == 1 && page != 'about' && page != 'groups' && page != 'contact' && page != 'news' ) {
3009 // if ( currentMinutes+'-'+currentSeconds == '1-0' || currentMinutes+'-'+currentSeconds == '31-0' ) {
3010 // var venuePage = page;
3011 // if ( page == 'comms' ) { venuePage = 'venues'; $("#timeWhen").val('today'); }
3012 // if ( page == 'events' ) {
3013 // eventList('', '#comms-search-results', '', page);
3014 // } else if ( page == 'groups' ) {
3015 // groupList('', '#comms-search-results', '', page);
3016 // } else {
3017 // if ( page == 'openrp' ) { venuePage = 'openrp'; }
3018 // if ( page == 'services' ) { venuePage = 'services'; }
3019 // if ( page == 'hiring' ) { venuePage = 'hiring'; }
3020 // venueList('', '#comms-search-results', '', venuePage);
3021 // }
3022 // }
3023 // }
3024
3025 // Pad the minutes and seconds with leading zeros, if required
3026 currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
3027 currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
3028
3029 // Choose either "AM" or "PM" as appropriate
3030 var timeOfDay = (currentHours < 12) ? "AM" : "PM";
3031
3032 // Convert the hours component to 12-hour format if needed
3033 currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;
3034
3035 // Convert an hours component of "0" to "12"
3036 currentHours = (currentHours == 0) ? 12 : currentHours;
3037
3038 var today = new Date();
3039
3040 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
3041 var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
3042
3043 curDay = dayName = days[today.getDay()];
3044 var monthName = months[today.getMonth()];
3045
3046 var date = dayName + ' ' + monthName + ' ' + today.getDate();
3047
3048 // Compose the string for display
3049 if (currentSeconds % 2 == 0)
3050 colon = '<font style="color:#FFDF00">:</font>';
3051 else
3052 colon = '<font style="color:red">:</font>';
3053
3054 var currentTimeString = currentHours + colon + currentMinutes + " " + timeOfDay + " <font size='4' style='color:#fff'>" + date + "</font>";
3055
3056 $("#digitalClock").html(currentTimeString);
3057}
3058
3059
3060readList('category', false, '', 'category');
3061readList('category-events', false, '', 'category-events');
3062readList('keywords-groups', false, '', 'keywords-groups');
3063
3064var clocktype = 'digital';
3065
3066function swapClock() {
3067 if ($('#clock:visible').length == 0) {
3068 var dateNow = new Date();
3069 var seconds = dateNow.getSeconds();
3070 var sdegree = seconds * 6;
3071 var srotate = "rotate(" + sdegree + "deg)";
3072 jQuery("#sec").css({
3073 "-moz-transform": srotate,
3074 "-webkit-transform": srotate
3075 });
3076 var hours = dateNow.getHours();
3077 var mins = dateNow.getMinutes();
3078 var hdegree = hours * 30 + (mins / 2);
3079 var hrotate = "rotate(" + hdegree + "deg)";
3080 jQuery("#hour").css({
3081 "-moz-transform": hrotate,
3082 "-webkit-transform": hrotate
3083 });
3084 var mins = dateNow.getMinutes();
3085 var mdegree = mins * 6;
3086 var mrotate = "rotate(" + mdegree + "deg)";
3087 jQuery("#min").css({
3088 "-moz-transform": mrotate,
3089 "-webkit-transform": mrotate
3090 });
3091 $('#digitalClock').fadeOut(700, function() {
3092 $('#clock').fadeIn(700);
3093 clocktype = 'analog';
3094 });
3095 } else {
3096 $('#clock').fadeOut(700, function() {
3097 updateClock();
3098 $('#digitalClock').fadeIn(700);
3099 clocktype = 'digital';
3100 });
3101 }
3102}
3103
3104var timezones = {
3105 '-7': 'Pacific/Kwajalein',
3106 '-6': 'Pacific/Samoa',
3107 '-5': 'Pacific/Honolulu',
3108 '-4': 'America/Juneau',
3109 '-3': 'America/Los_Angeles',
3110 '-2': 'America/Denver',
3111 '-1': 'America/Mexico_City',
3112 '0': 'America/New_York',
3113 '1': 'America/Caracas',
3114 '1.5': 'America/St_Johns',
3115 '2': 'America/Argentina/Buenos_Aires',
3116 '3': 'Atlantic/Azores',
3117 '4': 'Atlantic/Azores',
3118 '5': 'Europe/London',
3119 '6': 'Europe/Paris',
3120 '7': 'Europe/Helsinki',
3121 '8': 'Europe/Moscow',
3122 '8.5': 'Asia/Tehran',
3123 '9': 'Asia/Baku',
3124 '9.5': 'Asia/Kabul',
3125 '10': 'Asia/Karachi',
3126 '10.5': 'Asia/Calcutta',
3127 '11': 'Asia/Colombo',
3128 '12': 'Asia/Bangkok',
3129 '-12': 'Asia/Singapore',
3130 '-11': 'Asia/Tokyo',
3131 '-10.5': 'Australia/Darwin',
3132 '-10': 'Pacific/Guam',
3133 '-9': 'Asia/Magadan',
3134 '-8': 'Asia/Kamchatka'
3135};
3136
3137function copyToClipboard(text) {
3138 var dummy = document.createElement("textarea");
3139 // to avoid breaking page when copying more words
3140 // cant copy when adding below this code
3141 // dummy.style.display = 'none'
3142 document.body.appendChild(dummy);
3143 //Be careful if you use texarea. setAttribute('value', value), which works with "input" does not work with "textarea". – Eduard
3144 dummy.value = text;
3145 dummy.select();
3146 document.execCommand("copy");
3147 document.body.removeChild(dummy);
3148 msg(text + " copied to clipboard!");
3149}
3150
3151function msg(text, ok = "Ok") {
3152 var close = closeBtn;
3153 if (ok == '') {
3154 close = ''
3155 } else {
3156 close = '<br><input type="button" class="defaultBtn" value="' + ok + '" onclick=\'$("#popup").fadeOut()\'>';
3157 }
3158 $('#popup').css("text-align", "center");
3159 $('#popup').css("width", "");
3160 $('#popup').css("overflow-wrap", "break-word");
3161 $('#popup').css("max-width", "80%");
3162 $("#popup").html(text + close);
3163 $('#popup').fadeIn(500);
3164}
3165
3166function wizardDiv(text) {
3167 $("#wizardDiv").html(text);
3168 $('#wizardDiv').fadeIn(500);
3169}
3170
3171function isNumber(n) {
3172 return !isNaN(parseFloat(n)) && !isNaN(n - 0)
3173}
3174function checkeurl(eurl, prefix = '', id = $('#id').val()) {
3175 if (id == '' || typeof id == 'undefined') {
3176 id = $('#id').val();
3177 }
3178 // console.log('id',id);
3179 if (typeof id == 'undefined') { id = 0; }
3180 if (eurl == '[object HTMLInputElement]') { eurl = eurl.value; }
3181 // eurl = prefix+eurl;
3182 $.ajax({
3183 type: 'POST',
3184 url: 'api.php?'+eurl,
3185 data: {
3186 mode: "checkeurl",
3187 eurl: eurl,
3188 id: id,
3189 prefix: prefix
3190 },
3191 dataType: 'json',
3192 success: function(data) {
3193 if (typeof data.status != 'undefined' && data.status == '255') {
3194 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
3195 return true;
3196 }
3197 if (data.eurl == 1) {
3198 $("eurlcheck").addClass("redFont");
3199 $(eurl).animate({
3200 borderWidth: "2px",
3201 borderColor: "red"
3202 });
3203 somethingChangedFunc(true, 'red');
3204 $("eurlcheck").html("URL is taken. It needs to be unique!");
3205 return true;
3206 } else {
3207 var title = data['title'];
3208 var id = data['id'];
3209 if (id != null || wizId != '') {
3210 $('#wizView').fadeIn();
3211 $('#wizNext').fadeIn();
3212 if (title != null || wizTitle != '') { $('#wizTitle').animate({height: "50px", top: "-52px", border: "1px solid white"}); }
3213 $('.needID').attr('disabled', false).css('cursor', 'pointer');
3214 } else {
3215 $('.needID').attr('disabled', true).css('cursor', 'not-allowed');
3216 }
3217 $("eurlcheck").html("");
3218 $("eurlcheck").removeClass("redFont");
3219 somethingChangedFunc(false, 'red');
3220 $(eurl).animate({
3221 borderWidth: "0px",
3222 borderColor: "#FFDF00"
3223 });
3224 return false;
3225
3226 }
3227 },
3228 error: function() {
3229 console.log("error-125");
3230 return true;
3231 }
3232 });
3233}
3234var unlocksave = true;
3235
3236function checktinyurl(tiny, prefix = '') {
3237 if (!tiny.value) {
3238 return;
3239 } else {
3240 var elem = tiny;
3241 tiny = 'cs'+tiny.value;
3242 }
3243 // var idcheck = $('#'+prefix+'id').val();
3244 $.ajax({
3245 type: 'POST',
3246 url: 'addpost.php',
3247 data: {
3248 mode: "check",
3249 tiny: tiny,
3250 eurl: eurl,
3251 prefix: prefix
3252 },
3253 dataType: 'json',
3254 success: function(data) {
3255 var check = data.check;
3256 somethingChangedFunc(check, 'red');
3257 // if (check) {
3258 // $('#wizSave, #wizSaveValidate').animate({
3259 // backgroundColor: '#CCC'
3260 // });
3261 // } else {
3262 // $('#wizSave, #wizSaveValidate').animate({
3263 // backgroundColor: 'red'
3264 // });
3265 // }
3266
3267 if (check) {
3268 $(elem).animate({
3269 borderColor: "red"
3270 });
3271 $(prefix + "tinycheck").html("URL is taken. Please try another one");
3272 } else {
3273 $(prefix + "tinycheck").removeClass("redFont");
3274 $(elem).animate({
3275 borderColor: "#FFDF00"
3276 });
3277 $(prefix + "tinycheck").html("");
3278 }
3279 },
3280 error: function() {
3281 console.log("error-125");
3282 }
3283 });
3284}
3285
3286function time_convert(numberOfHours) {
3287 numberOfHours = numberOfHours;
3288 var Days = Math.floor(numberOfHours / 24);
3289 var Remainder = numberOfHours % 24;
3290 var Hours = Math.floor(Remainder);
3291 var Minutes = Math.floor(60 * (Remainder - Hours));
3292 var ms = '';
3293 var hs = '';
3294 var ds = '';
3295 if (Days != 1) {
3296 ds = 's';
3297 }
3298 if (Hours != 1) {
3299 hs = 's';
3300 }
3301 if (Minutes != 1) {
3302 ms = 's';
3303 }
3304 return "Opening in " + Days + ` day${ds}, ` + Hours + ` hour${hs}, and ` + Minutes + ` minute${ms}`;
3305}
3306
3307function pad(num, size) {
3308 num = num.toString();
3309 while (num.length < size) num = "0" + num;
3310 return num;
3311}
3312
3313function merge(obj1, obj2) {
3314 var obj3 = {};
3315 for (var attrname in obj1) {
3316 obj3[attrname] = obj1[attrname];
3317 }
3318 for (var attrname in obj2) {
3319 obj3[attrname] = obj2[attrname];
3320 }
3321 return obj3;
3322}
3323
3324function time_convert_until(num) {
3325 num = num * 60;
3326 var hours = Math.floor(num / 60);
3327 var minutes = Math.floor(num % 60);
3328 var ms = '';
3329 var hs = '';
3330 if (hours != 1) {
3331 hs = 's';
3332 }
3333 if (minutes != 1) {
3334 ms = 's';
3335 }
3336 return hours + ` hour${hs} and ` + minutes + " minute" + ms;
3337}
3338
3339function bouncer(arr) {
3340 var notAllowed = ["", false, null, undefined, NaN];
3341 for (i = 0; i < arr.length; i++) {
3342 for (j = 0; j < notAllowed.length; j++) {
3343 arr = arr.filter(function(val) {
3344 return val !== notAllowed[j];
3345 });
3346 }
3347 }
3348 return arr;
3349}
3350
3351
3352function keywordSearch(event) {
3353 $("#venuelist tr").removeClass('SearchFilter');
3354 if ($('#filterDay').val() != '') {
3355 var $Srows = $('.FilterDay').not('.venuelist-caption').not('#venuelist-header-tr');
3356 } else {
3357 var $Srows = $("#venuelist tr").not('.venuelist-caption').not('#venuelist-header-tr');
3358 }
3359 var val = $.trim($(event).val()).replace(/ +/g, ' ').toLowerCase().split(' ');
3360 $Srows.hide().filter(function() {
3361 var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
3362 var matchesSearch = true;
3363 $(val).each(function(index, value) {
3364 matchesSearch = (!matchesSearch) ? false : ~text.indexOf(value);
3365 });
3366 return matchesSearch;
3367 }).show().addClass('SearchFilter');
3368};
3369
3370
3371var origData;
3372var updateMode = false;
3373var trbgList;
3374var latestdate = [];
3375var vIdList = [];
3376
3377// venueList(data, '', '', 'render');
3378function venueList(request, target, filter = '', mode = 'list', prefix = '', upd = updateMode) {
3379 var position = '';
3380 var positions = {};
3381 var rowpositions = [];
3382 var selpos = [];
3383 var onDay = [];
3384 total = 0;
3385 opentoday = 0;
3386 opensoon = 0;
3387 opennow = 0;
3388 var row;
3389 var rows;
3390
3391 if ( !eventArray['populated'] ) {
3392 populateEventeurl('venueArray', 'yesdupes', '', '', venueList, arguments);
3393 // console.log(arguments);
3394 return;
3395 }
3396
3397
3398 if (!updateMode) {
3399 activeTrid = [];
3400 origData;
3401 progressDiv = `
3402 <div class="progress"></div>
3403 <div class="animate-flicker" id="animate-flicker-div">
3404 <br>
3405 <center>
3406 <img src="comms.png" style="float: center;" alt="comms logo" class="imgdropshadow" width="50%" height="auto"><br>
3407 <h1>Loading...</h1>
3408 </div>`;
3409
3410 // $('#comms-search-results').fadeTo(250, 0, function() {
3411 // $('#comms-search-results').html(progressDiv);
3412 // $('#comms-search-results').fadeTo(250, 1);
3413 // });
3414
3415 var thDayColH = '';
3416 if (mode != 'services') {
3417 thDayColH = `<th align="center" class='venuelistclass' id="headerDay" style="text-align: center; white-space: nowrap; max-width:130px;">
3418 <img src="sort.png" height="15" class='imgdropshadow link sort'>
3419 <select class="searchbarselect" id='filterDay' style='color: #ffdf00;display:inline-block' onchange='filterVenueList(1, "filterDay");'>
3420 <option disabled selected>-Day-</option>
3421 <option value=''>Any Day</option>
3422 <option value='today'>Today</option>
3423 <option value='sun'>Sunday</option>
3424 <option value='mon'>Monday</option>
3425 <option value='tue'>Tuesday</option>
3426 <option value='wed'>Wednesday</option>
3427 <option value='thu'>Thursday</option>
3428 <option value='fri'>Friday</option>
3429 <option value='sat'>Saturday</option>
3430 </select>
3431 </th>`;
3432 }
3433
3434 $('.progress').animate({
3435 width: '100%'
3436 }, 250);
3437 $('.progress').fadeIn();
3438 var result = `<center><table id="venuelist" width="600" class="venuetable" border='0'>
3439 <thead>
3440 <tr id='venuelist-header-tr'>
3441 <th class='venuelistclass' align="center" id='venue24' style='min-width: 343px;'>
3442 <img src="sort.png" height="15" class='imgdropshadow link sort'>
3443 <input
3444 class="searchbar" type="text" id="findSearchInput" onkeyup="keywordSearch(this)"
3445 style='width:calc(100% - 70px)' name="findSearchInput"
3446 class='searchMenu' size="30" placeholder="Search Name, Description, and Tags">
3447 <div class="stopprop" id="filterDiv"></div>
3448 <img src="filter.png" height="15" class='imgdropshadow link stopprop' onclick="$('#filterDiv').toggle('slow'); msg('Advanced filtering still in development');">
3449 <img src="search.png" height="15" id="SearchList" class='imgdropshadow link stopprop' onclick="console.log($('#filterDiv').structFilter('val'));">
3450 </th>
3451 ${thDayColH}
3452 <th class='venuelistclass' style='padding-left: 894px'></th>
3453 </tr>
3454 </thead>
3455 `;
3456
3457 var vc = '0';
3458 var uvc = '0';
3459 var verified = '';
3460 var unverified = '';
3461 $("#loading-img").fadeIn(500);
3462 var total = 0;
3463 var today = new Date();
3464 var dayOfWeek = days[today.getDay()].toString().substring(0, 3).toLowerCase();
3465
3466 if (mode == 'recent') {
3467 var request = JSON.stringify(recentPosts);
3468 }
3469 if (mode == 'favPosts') {
3470 var request = JSON.stringify(favPosts);
3471 }
3472 // if ( refreshList == '1' && updateMode == false ) { updateMode = 'next'; }
3473 postData = {
3474 mode: mode,
3475 request: request,
3476 filter: filter,
3477 dc: $('#datacenter').val(),
3478 upd: updateMode,
3479 ids: bouncer(vIdList)
3480 };
3481 // if (updateMode == 'next') { updateMode = false; }
3482 } else {
3483 trbgList = [];
3484 $('.trbg').each(function() {
3485 trbgList.push($(this).attr('pid'));
3486 });
3487
3488 if (updateMode != 'false' && typeof latestdate['venues'] == 'undefined') {
3489 latestdate['venues'] = updateMode;
3490 }
3491 postData.upd = latestdate['venues'];
3492 postData.ids = JSON.stringify(bouncer(vIdList));
3493 }
3494 trbgList = [];
3495 $('.trbg').not('tr[style*="display: none"]').each(function() {
3496 trbgList.push($(this).attr('pid'));
3497 });
3498 clearTimeout(autoUpdateList);
3499
3500 $.ajax({
3501 type: 'POST',
3502 url: 'api.php',
3503 dataType: 'json',
3504 data: postData,
3505 xhr: function() {
3506 var xhr = new window.XMLHttpRequest();
3507 xhr.addEventListener("progress", function(evt) {
3508 if (evt.lengthComputable) {
3509 var percentComplete = evt.loaded / evt.total;
3510 $('.progress').animate({
3511 width: percentComplete * 100 + '%'
3512 });
3513 }
3514 }, false);
3515 return xhr;
3516 },
3517 success: function(data) {
3518 if (typeof data.status != 'undefined' && data.status == '255') {
3519 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
3520 return;
3521 }
3522 if (updateMode) {
3523 if (typeof data.updateids != 'undefined' || typeof data.newids != 'undefined') {
3524 console.log("Server is sending listing updates...", data.updateids, data.newids);
3525 for (var did in data.updateids) {
3526 trbgList[did] = did;
3527 vIdList[did] = did;
3528 }
3529 database = merge(database, data.posts);
3530 data.posts = database;
3531 if (typeof data.latestdate != 'undefined') {
3532 if (typeof latestdate == 'undefined') {
3533 var latestdate = [];
3534 }
3535 var d = new Date(data.latestdate);
3536 d = new Date(d.getTime() + 1000);
3537 updateMode = moment(d).format("YYYY-MM-DD HH:mm:ss");
3538 latestdate.venues = updateMode;
3539 console.log("Listings up to date as of", updateMode);
3540 }
3541 }
3542 }
3543 if (!updateMode) {
3544 if (data.posts) {
3545 database = data.posts;
3546 }
3547 }
3548 var row;
3549 var taggedTitle;
3550 total = 0;
3551 opentoday = 0;
3552 opensoon = 0;
3553 opennow = 0;
3554 hiringCount = '';
3555 var latestdate = {
3556 venues: '0000-00-00 00:00:00'
3557 };
3558 if (typeof data['posts'] != 'undefined') {
3559 data = data['posts'];
3560 }
3561 for (var i in data) {
3562 row = data[i];
3563 if (!row || typeof row == 'undefined') {
3564 continue;
3565 }
3566 var eurl = row.eurl;
3567 var id = row.id;
3568
3569 if (typeof eurl == 'undefined') {
3570 continue;
3571 }
3572 if (!updateMode && id != '' && isNumber(id)) {
3573 vIdList[id] = id;
3574 }
3575 if (updateMode && !trbgList.includes(data[i].id)) {
3576 continue;
3577 }
3578 taggedTitle = '';
3579 if (mode == 'venues') {
3580 if (row['day'] == '["Event Only"]' || row['day'] == '["To be Determined"]' || row['day'] == '' || row['day'] == '["Service"]') {
3581 continue;
3582 }
3583 }
3584 var rating = 'T';
3585 taggedTitle = " (All Ages)";
3586 if (domain == 'roleplayfinder.com') {
3587 taggedTitle = " ";
3588 } else {
3589 if (typeof row['category'] != 'undefined' && row['category'] != null) {
3590 if (row['category'].includes("#escort") || row['category'].includes("#18+") || row['category'].includes("#erp") || row['rating'] == '1') {
3591 taggedTitle = ' (18+ Only)';
3592 rating = 'M';
3593 }
3594 }
3595 if (typeof row['category'] != 'undefined' && row['category'] != null) {
3596 if (row['category'].includes("#21+") || row['rating'] == '2') {
3597 taggedTitle = ' (21+ Only)';
3598 rating = 'M';
3599 }
3600 }
3601 }
3602 if (rating == "M" && domain == 'roleplayfinder.com') {
3603 return;
3604 }
3605 if (row.listed == '1') {
3606 total++;
3607 }
3608
3609 if (row['free'] == '1') {
3610 taggedTitle += ' (No Gil Required)';
3611 }
3612 if (row['lstream'] != '' && row['lstream'] != 'N/A') {
3613 taggedTitle += ' (LiveStream)';
3614 }
3615 if (row['twitter'] != '' && row['twitter'] != 'N/A') {
3616 taggedTitle += ' (Twitter)';
3617 }
3618 if (row['discord'] != '' && row['discord'] != 'N/A') {
3619 taggedTitle += ' (Discord)';
3620 }
3621 if (mode != 'admin') {
3622 if (ratingMode == 'T' && rating == 'M') {
3623 total--;
3624 continue;
3625 }
3626 }
3627 if (row['psize']) {
3628 var psize = "(" + row['psize'] + ")";
3629 } else {
3630 var psize = '';
3631 }
3632 if (row['category']) {
3633 var tags = row.category.replace(/#/g, '', true);
3634 tags = tags.split(" ");
3635 var tagslist = '';
3636 for (var tag in tags) {
3637 var tagName = tags[tag];
3638 tagslist = tagslist + ` <tag class="link white" onclick="$('#timeWhen').val(''); venueList('', '#comms-search-results', '${tagName}', 'categories');">` + tagName + '</tag>';
3639 }
3640 tagslist = "Tags: " + tagslist;
3641 } else {
3642 var tagslist = '';
3643 }
3644
3645 if (row['discord']) {
3646 discord = `<a target="_blank" class="white" href="${row['discord']}">${row['discord']}</a>`;
3647 }
3648 if (row['website']) {
3649 website = `<a target="_blank" class="white" href="${row['website']}">${row['website']}</a>`;
3650 }
3651 if (row['lstream']) {
3652 lstream = `<a target="_blank" class="white" href="${row['lstream']}">${row['lstream']}</a>`;
3653 }
3654
3655 for (var key in row) {
3656 if (!row[key]) {
3657 row[key] = "N/A";
3658 }
3659 }
3660
3661 var rpcal = false;
3662
3663 var linkedEvent = '';
3664 if (row['eventeurl'] != '' && typeof eventArray[row.eventeurl] != 'undefined' ) {
3665 var eventeurl = row['eventeurl'];
3666 var eventeurltitle = eventArray[eventeurl]['title'];
3667 var eventeurldate = eventArray[eventeurl]['date'];
3668 if ( typeof eventeurltitle != 'undefined' ) { linkedEvent = `<linkedEvent style="float: right" >Synced from <eventSpan onclick="loadPostDiv('event-${eventeurl}')" class="link">${eventeurltitle}</eventSpan></linkedEvent>`; }
3669
3670 let result = Object.keys(eventArray).filter(v => v.startsWith(eventeurl));
3671
3672
3673 for (var index in result) {
3674 var key = result[index];
3675 var nowd = moment().format('YYYY-MM-DD');
3676 var nowdt = moment().format('YYYY-MM-DD HH:mm');
3677 var odate = moment(eventArray[key]['date'], 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD');
3678 var odatet = eventArray[key]['date'];
3679 var datediff = moment().diff(moment(odate), 'hours');
3680 if (nowd == odate) { rpcal = true; break; }
3681 }
3682 }
3683
3684 var day = row['day'];
3685 var soonest = 0;
3686 var last = 999;
3687 var otimea = '';
3688 var ctimea = '';
3689 var times = '';
3690 var otime = '';
3691 var ctime = '';
3692 var odate = '';
3693 var cdate = '';
3694 var otime24 = '';
3695 var ctime24 = '';
3696
3697 var oTime = '';
3698
3699 var cTime = '';
3700
3701 var times = decodeEntities(row['times']);
3702 var rawStime = '9999-99-99-99:99';
3703
3704 var today24 = '';
3705 var postDay = '';
3706
3707 if (isJson(times)) {
3708 times = JSON.parse(times);
3709 }
3710 var ctday = [];
3711 var sortdate = '';
3712 var sortdatec = '';
3713 var nextday = 0;
3714 var notclosed = 0;
3715 var fixedopenuntil = 0;
3716 var tclass = 'grey';
3717 var when = '';
3718 var opening = 'nottoday';
3719 var openuntil = 0;
3720 var prevopenuntil = 9999999999;
3721 var timeArray = '';
3722 var sorttime = '';
3723 var prevsorttime = 9999999999;
3724 if (typeof times === 'object') {
3725 for (var day in times) {
3726 otime = day + ' ' + times[day].otime;
3727 ctime = day + ' ' + times[day].ctime;
3728 otime24 = moment(otime, 'dddd hh:mm A').add(offset, 'hours').format('HH:mm');
3729 ctime24 = moment(ctime, 'dddd hh:mm A').add(offset, 'hours').format('HH:mm');
3730 if (otime24 > ctime24) {
3731 nextday = 1;
3732 }
3733 bwodate = odate = moment(otime, 'dddd hh:mm A').add(offset, 'hours');
3734 cdate = moment(ctime, 'dddd hh:mm A').add(offset, 'hours').add(nextday, 'day');
3735
3736 var d = new Date();
3737 var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
3738 var dayName = days[d.getDay()];
3739
3740 if (days.includes(day)) {
3741 if (typeof onDay[day] != 'undefined') {
3742 onDay[day]++;
3743 } else {
3744 onDay[day] = 1;
3745 }
3746 }
3747
3748 otimea = moment(otime, 'dddd hh:mm A').add(offset, 'hours').format('h:mm A');
3749 ctimea = moment(ctime, 'dddd hh:mm A').add(nextday, 'day').add(offset, 'hours').format('h:mm A');
3750
3751 var todayTomorrow = 'Tomorrow';
3752 if (day == dayName) {
3753 todayTomorrow = 'Today';
3754 ctday = [otimea, ctimea];
3755 }
3756
3757
3758 timeArray = timeArray + day + "<br>" + otimea + " - " + ctimea + "<br>";
3759 curdate = moment();
3760 sortdate = moment(otime, 'dddd hh:mm A').add(offset, 'hours').format('YYYY-MM-DD-HH:mm');
3761 sortdatec = moment(ctime, 'dddd hh:mm A').add(offset, 'hours').add(nextday, 'day').format('YYYY-MM-DD-HH:mm');
3762
3763 if (moment().diff(moment(odate), 'hours') > 10) {
3764 var isBiweekly = 1;
3765 if (row.biweekly == '1') {
3766 isBiweekly = 2;
3767 }
3768 odate = moment(odate).add(isBiweekly, 'week');
3769 cdate = moment(cdate).add(isBiweekly, 'week');
3770 sortdate = moment(otime, 'dddd hh:mm A').add(offset, 'hours').add(isBiweekly, 'week').format('YYYY-MM-DD-HH:mm');
3771 sortdatec = moment(ctime, 'dddd hh:mm A').add(offset, 'hours').add(isBiweekly, 'week').add(nextday, 'day').format('YYYY-MM-DD-HH:mm');
3772 }
3773
3774 last = soonest;
3775 soonest = moment().diff(moment(odate), 'hours');
3776
3777 var openingIn = moment.duration(odate.diff(moment())).humanize();
3778 var closingWhen = moment.duration(moment().diff(moment(cdate))).humanize();
3779 var openingInHours = moment.duration(odate.diff(moment())).minutes();
3780 var diffMinutes = moment(odate).diff(moment(), 'minutes');
3781
3782 if (openingIn == 'a day') {
3783 todayTomorrow = '';
3784 }
3785
3786 if (((rpcal == true) || moment().diff(moment(odate), 'hours') > -24 && moment().diff(moment(cdate), 'hours') < 24 && (rawStime > sortdate || day == dayName))) {
3787 rawStime = sortdate;
3788 opening = 'today';
3789 tclass = 'blue';
3790 when = 'Open ' + todayTomorrow + ' In ' + openingIn;
3791
3792 if (moment().diff(moment(odate), 'hours') > -2) {
3793 when = 'Opening In ' + openingIn;
3794 tclass = 'lightviolet';
3795 }
3796 if (moment().diff(moment(odate), 'hours') > -1) {
3797 tclass = 'violet';
3798 }
3799 if (moment().isBetween(odate, cdate)) {
3800 openuntil = moment.duration(cdate.diff(curdate)).asHours();
3801 when = 'Open Now For ' + closingWhen;
3802 tclass = 'green';
3803 }
3804 if (moment(cdate).diff(moment(), 'minutes') < 0) {
3805 when = 'Closed For Today';
3806 tclass = 'grey';
3807 }
3808 }
3809 }
3810
3811 if (rawStime == '9999-99-99-99:99') {
3812 rawStime = sortdate;
3813 }
3814 if (row.day) {
3815 var day = row['day'];
3816 }
3817 if (isJson(day)) {
3818 days = niceList(JSON.parse(day));
3819 }
3820 times = `${days}<br>` + otimea + ' - ' + ctimea + ' ' + zoneAbbr;
3821
3822 if (row.sametime == '0') {
3823 times = timeArray + ' ' + zoneAbbr;
3824 }
3825 }
3826 if (!ctday.length) {
3827 ctday = [otimea, ctimea];
3828 }
3829
3830 if (rawStime == 'Invalid date' || times == 'N/A' || times == 'Anytime' || times == 'Event Only Scheduling') {
3831 otimea = '';
3832 times = '';
3833 ctimea = '';
3834 rawStime = 'D';
3835 }
3836
3837 var eventcount = row['eventcount'];
3838 var events = '';
3839 if (eventcount > 0) {
3840 if (eventcount === "1") {
3841 events = eventcount + " event |";
3842 } else {
3843 events = eventcount + " events |";
3844 }
3845 }
3846 today = new Date();
3847 var isBiweekly = '';
3848 var rec = true;
3849 if (row.biweekly == '1') {
3850 when = "Bi-Weekly Venue " + when;;
3851 days = -1;
3852 var startdate = row.startdate;
3853 while (days < 0) {
3854 var demarcationdate = moment(startdate, 'YYYY-MM-DD').subtract(14, 'd'),
3855 startdate = demarcationdate.format('YYYY-MM-DD');
3856 days = daysBetween(demarcationdate, bwodate),
3857 daystill = 14 - days % 14,
3858 rec = days % 14 == 0;
3859 }
3860 var nextweek = '1';
3861 if (rec || rpcal) {
3862 opening = "today";
3863 nextweek = '0';
3864 } else { if (times != '') {
3865 times = 'Next ' + times;
3866 }
3867 var nextDate = moment(odate).add(nextweek, 'weeks');
3868 nextDate = prettyDate(nextDate);
3869 opening = 'biweekly';
3870 tclass = 'lightblue';
3871 when = 'This bi-weekly venue will be open next ' + nextDate;
3872 }
3873 }
3874
3875 if (row.open == '1') {
3876 times = when = "Open Now";
3877 tclass = 'green';
3878 }
3879
3880 var description = 'No Results!';
3881 var fulldescription = urlify(row.description, '1');
3882 if (row.description) {
3883 var wat = truncate(fulldescription, 150);
3884 const splitLines = str => str.split(/\r?\n/);
3885 wat = splitLines(wat).slice(0, 2).join('<br>');
3886 description = "<pre style='font-size: 13px; margin-left: 15px;'>" + wat + "</pre>";
3887 }
3888
3889 if (row.id == "0") {
3890 result = 'No results found!';
3891 } else {
3892 var pa = 'P' + row.plot;
3893 if (row.ward == 'N/A') {
3894 pa = 'N/A';
3895 ward = '';
3896 } else {
3897 ward = 'W' + row.ward;
3898 }
3899 if (psize == '(Apartment)') {
3900 pa = 'A' + row.apt;
3901 }
3902 if (row.aetheryte != '') {
3903 aetheryte = 'near ' + row.aetheryte;
3904 }
3905 if (row.datacenter == userdatacenter || row.datacenter == 'Anywhere' || acct == '2') {
3906 var goldstar = `<img onclick='favPost("${row.eurl}","add");' id='fav-${row.eurl}' src='emptystar.png' class='link imgdropshadow' height='15px' title='Add Post to Favourites'>`;
3907 var unlisted = '';
3908 if ((mode == 'admin' || mode == 'show') && row['listed'] == '0') {
3909 unlisted = ' <font class="red">Unlisted</font><br>';
3910 }
3911
3912 if (mode == 'show') {
3913 var unapproved = ' <font class="green">Approved</font><br>';
3914 } else {
3915 var unapproved = '';
3916 }
3917 if (row['approved'] == '0' && (mode == 'show' || mode == 'admin')) {
3918 unapproved = ' <font class="red">Pending Approval</font><br>';
3919 }
3920 var deleted = '';
3921 if (mode == 'admin' && row['deleted'] == '1') {
3922 deleted = ' <font class="red">Deleted</font><br>';
3923 }
3924 if (page == 'hiring') {
3925 var item = row;
3926 var rowpositions = [];
3927 if (item.hiring != '' && item.hiring != '{}' && isJson(decodeEntities(item.hiring))) {
3928 var position = JSON.parse(decodeEntities(item.hiring));
3929 var subarray = [];
3930 for (var key in position) {
3931 if (position.hasOwnProperty(key) && position[key] != null && position != "") {
3932 subarray = position[key].position.split(',');;
3933 for (var x in subarray) {
3934 var pos = subarray[x].trim();
3935 if (pos != "") {
3936 pos = capitalizeWords(pos);
3937 var rpos = pos.replace(/\s+/g, '-').toLowerCase();
3938 rowpositions.push(rpos);
3939 if (typeof selpos[rpos] != 'undefined') {
3940 var curnum = selpos[rpos] + 1;
3941 selpos[rpos] = curnum;
3942 } else {
3943 selpos[rpos] = 1;
3944 positions[rpos] = pos;
3945 }
3946 }
3947 }
3948 }
3949 }
3950 }
3951
3952 var rowposition = rowpositions.join(' ');
3953 }
3954 var ver = '0';
3955 if (row.verified != '' && row.limited != '1') {
3956 var sinceVerified = moment.duration(moment().diff(moment(row.verified))).humanize();
3957 var verifiedWhen = `Post verified ${sinceVerified} ago by ${row.verifier}`;
3958 var isVerified = ''; //.substring(0, 5)
3959 if (moment().diff(moment(row.verified), 'days') < 5) {
3960 ver = '1';
3961 rawStime = 'A' + rawStime;
3962 isVerified = '<img src="checkmark.png" style="float: right;" height="25" title="' + verifiedWhen + '">';
3963 } else {
3964 rawStime = 'B' + rawStime;
3965 }
3966 } else {
3967 rawStime = 'B' + rawStime;
3968 }
3969
3970 if (row.limited == '1') {
3971 isVerified = '';
3972 }
3973 var closeduntil = row.closeduntil;
3974 if (closeduntil == '0000-00-00 00:00:00') {
3975 closeduntil = -999;
3976 } else {
3977 closeduntil = moment().diff(moment(closeduntil, 'YYYY-MM-DD HH:mm:ss'), 'seconds');
3978 }
3979
3980 var actuallyClosed = 0;
3981 if (row['closed'] != 0 && closeduntil < 0) {
3982 actuallyClosed = 1;
3983 }
3984
3985 var isclosed = '';
3986 var isvacant = '';
3987 if ((row['vacant'] != 0 || actuallyClosed == 1) && opening != 'nottoday') {
3988 opentoday--;
3989 }
3990 if (actuallyClosed == 1) {
3991 when = "Closed";
3992 rawStime = 'C9999-99-99-99:99';
3993 tclass = 'white';
3994 }
3995 if (row['vacant'] == 1) {
3996 isvacant = '<font size="5" class="red">(Vacant)</font>';
3997 tclass = 'white';
3998 }
3999 if (row['vacant'] == 2) {
4000 isvacant = '<font size="5" class="red">(Unknown Status)</font>';
4001 tclass = 'white';
4002 }
4003 if (favPosts.includes(row['eurl'])) {
4004 goldstar = `<img onclick='favPost("${row.eurl}","del");' id='fav-${row.eurl}' src='goldstar.gif' class='link imgdropshadow' height='15px' title='Remove Post from Favourites'>`;
4005 }
4006 var hiring = '';
4007 if (row.limited == 1) {
4008 rawStime = 'D9999-99-99-99:99';
4009 }
4010
4011 var views = '';
4012 if (scout == '1' || row.owner == '1' || acct == "2") {
4013 views = ' | Views: ' + row.views;
4014 }
4015
4016 var postURL = `https://www.${domain}/?${row.eurl}`
4017 if (row['tinyurl'] != 'N/A' && domain != 'roleplayfinder.com') {
4018 postURL = row.tinyurl;
4019 }
4020
4021 var housing = `${row['housing']} at ${ward} ${pa} ${aetheryte}`;
4022 if (row.housing == 'Other Location') {
4023 housing = row.location;
4024 }
4025 var location = `${row['datacenter']} on ${row['server']} in ${housing}`;
4026
4027 var openrpVenue = '';
4028 var orv = '';
4029 if (row['openrp'] == '1') {
4030 orv = " (OpenRP) ";
4031 openrpVenue = '<tclass class="green">OpenRP Venue</tclass><br>';
4032 }
4033
4034 thDayCol = '';
4035 // if (typeof times != 'undefined') {console.log(, typeof times);}
4036 if (mode != 'services' && typeof row.customtimes != 'undefined' && typeof times != 'undefined') { // cleartext
4037 if (row.customtimes != 'N/A') {
4038 times = row.customtimes;
4039 when = "Custom Times";
4040 } // cleartext
4041 // if (ctday.length) { times = times.replaceAll('%t', `<br>from ${ctday.0} to ${ctday.1} ${zoneAbbr}`);}
4042 if (ctday.length && typeof times != 'undefined') {
4043 times = times.replaceAll('%t', '<br>from ' + ctday[0] + ' to ' + ctday[1] + ' ' + zoneAbbr);
4044 } else {
4045 times = times.replaceAll('%t', '');
4046 }
4047 thDayCol = `<td class="remove_line venuelistclass listTimes" align="center"><rawtime class='cleartext'>${rawStime}</rawtime><font class="${tclass}" size='2'><br>${openrpVenue}${times}</font></td>`;
4048 }
4049 if (row['category'] == 'N/A') {
4050 row['category'] = '';
4051 }
4052
4053 var escapedLocation = decodeEntities(location).replace(/'/g, "\\'");
4054 var escapedTitle = decodeEntities(row['title']).replace(/'/g, "\\'");
4055 if (psize == 'N/A') {
4056 psize = '';
4057 }
4058 if (mode != 'hiring') {
4059 if (row['hiringurl'] != 'N/A') {
4060 hiring = " (Now Hiring)";
4061 hiringCount++
4062 }
4063 } else {
4064 var hurl = row['hiringurl'];
4065 var hiringList = '';
4066 var hiring = decodeEntities(row['hiring']);
4067 if (isJson(hiring)) {
4068 var hiring = JSON.parse(hiring);
4069 var hrngLen = Object.keys(hiring).length - 1;
4070 if (hrngLen > 0) {
4071 hiringList = 'Open positions:<br><p>';
4072 }
4073 for (var key in hiring) {
4074 if (hiring.hasOwnProperty(key) && hiring[key] != null) {
4075 var position = capitalizeWords(hiring[key]['position']);
4076 hiringList += " " + position;
4077 // positionsattr.push(position.replace(/\s+/g, '-').toLowerCase());
4078 if (hiring[key]['rate'] != '') {
4079 hiringList += " - Details: " + hiring[key]['rate'];
4080 }
4081 hiringList += "<br>";
4082 }
4083 }
4084 if (hiringList != '') {
4085 hiringList += "</p><br>";
4086 // positionsattr = positionsattr.join(" ");
4087 description += '<br>' + hiringList + '<a target="_blank" style="text-decoration: underline;" href="' + hurl + '">Application for ' + row.title + '</a><br>';
4088 } else {
4089 description += '<br><a target="_blank" href="' + hurl + '">Application for ' + row.title + '</a><br>';
4090 }
4091 }
4092 }
4093 if (row['public'] != '1' && typeof(row['public']) !== 'undefined' && user != "Guest") {
4094 hiring = hiring + " (Private Listing)";
4095 }
4096
4097 if (opening == 'today' && (tclass == 'blue' || tclass == 'violet' || tclass == 'lightviolet' || tclass == 'green')) {
4098 opentoday++;
4099 }
4100 if (tclass == 'violet' || tclass == "lightviolet") {
4101 opensoon++;
4102 }
4103 if (tclass == 'green' || row.open == '1' || row.openrp == '1') {
4104 opennow++;
4105 }
4106
4107 var id = row['id'];
4108 var trid = `tr-${row['id']}`;
4109
4110 var preveurl = row.eurl;
4111 var nprefix = '';
4112 if (eurl.toString().startsWith('event-')) {
4113 eurl = eurl.replace(/^event-/, "");
4114 nprefix = 'event-';
4115 }
4116 if (eurl.toString().startsWith('group-')) {
4117 eurl = eurl.replace(/^group-/, "");
4118 nprefix = 'group-';
4119 }
4120 date = row.date;
4121 if (latestdate['venues'] < date) {
4122 latestdate['venues'] = date;
4123 }
4124 var postType = '';
4125 if (nprefix == 'group-') {
4126 postType = '[Group] ';
4127 var listingresult = processEvent(row, nprefix, postType);
4128 row.eurl = preveurl;
4129 } else if (nprefix == 'event-') {
4130 postType = '[Event] ';
4131 var listingresult = processEvent(row, nprefix, postType);
4132 row.eurl = preveurl;
4133 } else {
4134 // background: url('getimage.php?banner-${prefix}${row["eurl"]}') no-repeat;
4135 // background-size: 894px auto; background-position: right;
4136
4137
4138 // if (rpcal) { rpcal = 'RPCal Opn'; } else { rpcal = 'RPCal nOpn'; }
4139 var listingresult = `
4140 <tr id="${prefix}tr-${row['id']}" positions="${rowposition}" pid="${row['id']}" eurl="${row['eurl']}" tclass='${tclass}' class="trbg" opening='${opening}'
4141 style="height: 134px;
4142 background: url(getimage.php?banner-${prefix}${row["eurl"]}) right center / 894px auto no-repeat rgba(0, 0, 0, 0);">
4143 <td id="${prefix}td-${row['id']}" class="remove_line venuelistclass" colspan="1" style="min-width: 370px;">${unapproved}${unlisted}${deleted}${goldstar}<b class='link' style="text-decoration: underline;" onclick="resizeWindow('1'); loadPost('${row['eurl']}',this)">
4144 ${row['title']}</b> <img src='link.png' height='15px' class="link" alt="Copy Post Link" onclick="copyToClipboard('${postURL}');"> ${isvacant} ${isVerified}<font size="1" class="tags psize">${psize}</font>
4145 <br><b><font size="1.5" class="${tclass}"><tclasstag listingid="${id}" class="${tclass}">${when}</tclasstag> | ${orv} ${taggedTitle} ${hiring} ${isclosed} ${views}</font></b><br><desc class='grey' title="${fulldescription}">${description}</desc>
4146 ${tagslist}
4147 <br><font size="1.5">Location: ${location}</font> <img src='link.png' height='8px' width="8px" class="link" alt="Copy Link" onclick="copyToClipboard('` + escapedTitle + ` on ` + escapedLocation + `');"><br>${linkedEvent}
4148 </td>
4149 ${thDayCol}
4150 <td class="gold_line venuelistclass tdbgimg" align="center">
4151 </td>
4152 </tr>`;
4153 }
4154 if (updateMode) {
4155 if (activeTrid[eurl] == trid) {
4156 savedHtml[prefix + eurl] = listingresult;
4157 } else {
4158 $('#' + trid).prop('outerHTML', listingresult);
4159 }
4160 var parentElem = $('#' + trid).parent().attr('id');
4161 if (parentElem == 'tbodyB' && isVerified != '') {
4162 if (activeTrid.last == trid && $('#' + trid).visible()) {
4163 $('#tbodyA').append($('#' + trid));
4164 scrollToBannerId(trid);
4165 } else {
4166 $('#tbodyA').append($('#' + trid));
4167 }
4168 }
4169 if (parentElem == 'tbodyA' && isVerified == '') {
4170 if (activeTrid.last == trid && $('#' + trid).visible()) {
4171 $('#tbodyB').append($('#' + trid));
4172 scrollToBannerId(trid);
4173 } else {
4174 $('#tbodyB').append($('#' + trid));
4175 }
4176 }
4177 continue;
4178 } else {
4179 if (ver == '1') {
4180 vc = '1';
4181 verified = `${verified}${listingresult}`;
4182 } else {
4183 uvc = '1';
4184 unverified = `${unverified}${listingresult}`;
4185 }
4186 }
4187 }
4188 }
4189 }
4190 if (!updateMode) {
4191 result = `${result}
4192 <tr class="venuelist-caption" style="display:none;">
4193 <td bgcolor="#595a5d" class="gold_line venuelistclass" style="line-height:10px;text-align:center;" colspan=4>
4194 <h2>Confirmed Listings</h2>
4195 </td>
4196 </tr>
4197 <tbody id='tbodyA'>${verified}</tbody>
4198 <tr class="venuelist-caption" style="display:none;">
4199 <td bgcolor="#595a5d" class="gold_line venuelistclass" style="line-height:10px;text-align:center" colspan=4>
4200 <h2>Unconfirmed Listings</h2>
4201 </td>
4202 </tr>
4203 <tbody id='tbodyB'>${unverified}</tbody></table></center>`;
4204 $(target).fadeTo(500, 0, function() {
4205 $(target).html(result);
4206 if (hiringCount != '') {
4207 $("#hiringtotal").html("Hiring Now (" + hiringCount + ")");
4208 } else {
4209 $("#hiringtotal").html("Hiring Now");
4210 }
4211 if (vc == '0' || uvc == '0') {
4212 $('.venuelist-caption').fadeOut();
4213 } else {
4214 $('.venuelist-caption').fadeIn();
4215 }
4216 $(target).fadeTo(1000, 1);
4217 total = $('[opening]').length;
4218 opentoday = $('[opening="today"]').length;
4219 opensoon = $('[tclass$="violet"]').length;
4220 opennow = $('[tclass="green"]').length;
4221 $("#opentotal").html("All Times (" + total + ")");
4222 $("#opentoday").html("Today (" + opentoday + ")");
4223 $("#opensoon").html("Soon (" + opensoon + ")");
4224 $("#opennow").html("Now (" + opennow + ")");
4225 $('#venuelist').fadeIn();
4226 $('#timeWhen').trigger('change');
4227 $("#loading-img").fadeOut(500);
4228 $(`#filterDay option:contains('Any Day')`).html("Any Day (" + total + ")");
4229 $(`#filterDay option:contains('Today')`).html("Today (" + opentoday + ")");
4230 days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
4231 days.forEach(function(day) {
4232 if (typeof onDay[day] == 'undefined') {
4233 onDay[day] = 0;
4234 }
4235 $(`#filterDay option:contains(${day})`).html(day + " (" + onDay[day] + ")");
4236 });
4237 $("#filterDiv").structFilter({
4238 buttonLabels: true,
4239 submitButton: true,
4240 fields: [{
4241 id: "title",
4242 type: "text",
4243 label: "Title"
4244 }, {
4245 id: "description",
4246 type: "text",
4247 label: "Description"
4248 }, {
4249 id: "tags",
4250 type: "text",
4251 label: "Tags"
4252 }, {
4253 id: "twitter",
4254 type: "boolean",
4255 label: "Has Twitter"
4256 }, {
4257 id: "twitch",
4258 type: "boolean",
4259 label: "Live Strem"
4260 }, {
4261 id: "free",
4262 type: "boolean",
4263 label: "Gil Free"
4264 }, {
4265 id: "confirmed",
4266 type: "boolean",
4267 label: "Is Confirmed"
4268 }, {
4269 id: "dc",
4270 type: "list",
4271 label: "Datacenter",
4272 list: [{
4273 id: "crystal",
4274 label: "Crystal"
4275 }, {
4276 id: "primal",
4277 label: "Primal"
4278 }, {
4279 id: "aether",
4280 label: "Aether"
4281 }]
4282 }, {
4283 id: "housing",
4284 type: "list",
4285 label: "Housing",
4286 list: [{
4287 id: "goblet",
4288 label: "The Goblet"
4289 }, {
4290 id: "mist",
4291 label: "Mist"
4292 }, {
4293 id: "lavender",
4294 label: "The Lavender Beds"
4295 }, {
4296 id: "shirogane",
4297 label: "Shirogane"
4298 }]
4299 }]
4300 });
4301 });
4302 }
4303
4304 if (page == 'hiring') {
4305 var select = document.getElementById("positions");
4306 for (var i in positions) {
4307 var opt = positions[i];
4308 var el = document.createElement("option");
4309
4310 el.textContent = '(' + selpos[i] + ') ' + opt;
4311 el.value = i;
4312 select.appendChild(el);
4313 }
4314 }
4315
4316 if (refreshList == '1') {
4317 if (latestdate['venues'] != '' && typeof latestdate['venues'] != 'undefined') {
4318 updateMode = latestdate['venues'];
4319 } else {
4320 updateMode = "next";
4321 }
4322 console.log('Sleeping for a minute before auto-updating.');
4323 autoUpdateList = setTimeout(function() {
4324 venueList(request, target);
4325 }, 60000);
4326 }
4327 // $("#filterDiv").on("submit.search", function(event){
4328 // });
4329 }
4330 });
4331}
4332
4333var autoupdatelist = '0';
4334var autoUpdateList;
4335//capitalize all words of a string.
4336function capitalizeWords(string) {
4337 return string.replace(/(?:^|\s)\S/g, function(a) {
4338 return a.toUpperCase();
4339 });
4340};
4341var mode = '';
4342function processEvent(row, prefix = '', type = "Event ") {
4343 // if (typeof data.status != 'undefined' && data.status == '255') { msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", ''); return; }
4344 // var total = 0;
4345 // var row = data[i];
4346 // mode = mode+'event';
4347 if (row['eurl'].toString().startsWith('event-')) {
4348 row['eurl'] = row['eurl'].replace(/^event-/, "");
4349 type = "[Event] ";
4350 }
4351
4352 if (row['eurl'].toString().startsWith('group-')) {
4353 row['eurl'] = row['eurl'].replace(/^group-/, "");
4354 type = "[Group] ";
4355 }
4356
4357 if (row['psize']) {
4358 row['psize'] = "(" + row['psize'] + ")";
4359 }
4360 var rating = 'T';
4361 if (typeof row['keywords'] != 'undefined' && row['keywords'].includes("21+")) {
4362 rating = 'M';
4363 }
4364 if (typeof row['keywords'] != 'undefined' && row['keywords'].includes("18+")) {
4365 rating = 'M';
4366 }
4367 if (mode != 'admin') {
4368 if (ratingMode == 'T' && rating == 'M') {
4369 return false;
4370 }
4371 }
4372 if (row['keywords']) {
4373 row['keywords'] = "Keywords: <i class='tags'>" + row['keywords'] + "</i>";
4374 }
4375 if (row['discord']) {
4376 row['discord'] = `<a target="_blank" href="${row['discord']}">${row['discord']}</a>`;
4377 }
4378 if (row['website']) {
4379 row['website'] = `<a target="_blank" href="${row['website']}">${row['website']}</a>`;
4380 }
4381 if (row.date == '1970-01-01 00:00:00' || row.date == null) {
4382 var pdate = row.hours;
4383 row.date = null;
4384 }
4385 if (row.date != null) {
4386 if (row.date == row.edate || row.edate == null || row.edate == '1970-01-01 00:00:00' || row.edate == '') {
4387 var pdate = prettyDate(row.date) + " " + timezone;
4388 } else {
4389 var pdate = prettyDate(row.date) + "<br>to<br>" + prettyDate(row.edate) + "<br>" + timezone;
4390 }
4391 } else {
4392 pdate = '';
4393 }
4394
4395 for (var key in row) {
4396 if (!row[key]) {
4397 row[key] = "N/A";
4398 }
4399 }
4400
4401 if (typeof row["eventfccount"] === 'undefined') {
4402 row["eventfccount"] = 0;
4403 }
4404 if (typeof row["eventcount"] === 'undefined') {
4405 row["eventcount"] = 0;
4406 }
4407 var eventcount = parseFloat(row["eventfccount"]) + parseFloat(row["eventcount"]);
4408
4409 var events = '';
4410
4411 if (eventcount > 0) {
4412 if (eventcount === 1) {
4413 events = eventcount + " event |";
4414 } else {
4415 events = eventcount + " events |";
4416 }
4417 }
4418
4419 var description = 'No Results!';
4420 if (row.description) {
4421 description = truncate(row['description'], 150);
4422 }
4423
4424 var tclass = 'white';
4425
4426 if (row.edate === '1970-01-01 00:00:00') {
4427 row.edate = row.date;
4428 }
4429
4430 var todaysdate = moment().format('YYYYMMDD');
4431 var todaysdatetime = moment().format('YYYYMMDDHHmm');
4432 var todaysdatetimesoon = moment().add(2, 'hours').format('YYYYMMDDHHmm');
4433
4434 var justdate = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDD');
4435 var justedate = moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDD');
4436 var justdatetime = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDDHHmm');
4437 var justedatetime = moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDDHHmm');
4438
4439 // total++;
4440 when = 'nottoday';
4441 tclass = 'white';
4442 if (todaysdate >= justdate && todaysdate <= justedate) {
4443 tclass = 'blue';
4444 when = 'today';
4445 opentoday++;
4446 var sorttime = '';
4447 if (moment.utc(row['date'], 'hh:mm A')._isValid && moment.utc(row['edate'], 'hh:mm A')._isValid) {
4448 otime = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').format('HH:mm');
4449 ctime = moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss').format('HH:mm');
4450 sorttime = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').format('HH:mm');
4451 curtime = today.toLocaleTimeString();
4452 soontime = otime;
4453 if (todaysdatetimesoon >= justdatetime) {
4454 when = 'soon';
4455 tclass = 'lightviolet';
4456 opensoon++;
4457 }
4458 // if ( isOpen(otime, ctime, 'America/New_York') == 'open' || isSoon(curtime, soontime, '1')) {
4459 // tclass = 'violet';
4460 // }
4461 if (todaysdatetime >= justdatetime && todaysdatetime <= justedatetime) {
4462 when = 'now';
4463 tclass = 'green';
4464 opensoon--;
4465 opennow++;
4466 }
4467 if (todaysdatetime > justedatetime) {
4468 when = 'closed';
4469 tclass = 'grey';
4470 opensoon--;
4471 total--;
4472 }
4473 }
4474 }
4475
4476 if (row['id'] != 0) {
4477 var housing = `${row['housing']} at ${ward} ${pa} ${aetheryte}`;
4478 if (row.housing == 'Other Location') {
4479 housing = row.location;
4480 }
4481 var location = `${row['datacenter']} on ${row['server']} in ${housing}`;
4482
4483 var pa = 'P' + row.plot;
4484 if (row.apt != 'N/A') {
4485 pa = 'A' + row.apt;
4486 }
4487 if (row.ward == 'N/A') {
4488 pa = 'N/A';
4489 } else {
4490 row.ward = 'W' + row.ward;
4491 }
4492 var unlisted = '';
4493 if (mode == 'eventadmin' && row['listed'] == '0') {
4494 unlisted = ' <font class="red">Unlisted</font><br>';
4495 }
4496 var category = ''
4497 if (row.category != 'N/A') {
4498 category = 'Category: ' + row.category + ' | ';
4499 }
4500 if (typeof row['keywords'] != 'undefined') {
4501 if (row['keywords'].includes("#escort") || row['keywords'].includes("#18+") ||
4502 row['keywords'].includes("#erp")) {
4503 row['title'] += " (18+ Only)";
4504 }
4505 }
4506 return `<tr id="${prefix}tr-${row['id']}" colspan='1' eurl="${row.eurl}" tclass="${tclass}" opening="${when}" class="trbg" style="height: 134px; background: url('getimage.php?banner-${prefix}${row["eurl"]}') no-repeat;
4507 background-size: 894px auto;
4508 background-position: right;">
4509 <td class="remove_line venuelistclass" colspan="1">${unlisted}<b class='link' onclick="loadPost('${row['eurl']}',this,'${prefix}')">${type}${row['title']}</b><font size="2" class="tags psize">${row['psize']}</font><br>${description}<br><font size="2" class="tags">${category} ${row['keywords']}</font></td>
4510 <td class="remove_line venuelistclass listTimes" align="center"><font font-size="20" class="${tclass}">${pdate}</font></td>
4511 <td class="remove_line venuelistclass" align="center"></td>
4512 </tr>`;
4513
4514 // <td class="remove_line venuelistclass" align="center">${row['server']}</td>
4515 // <td class="remove_line venuelistclass" align="center">${row['housing']}</td>
4516 // <td class="remove_line venuelistclass" align="center">${row['ward']}</td>
4517 // <td class="remove_line venuelistclass" align="center">${pa}</td>
4518 // <td class="remove_line venuelistclass" align="center">${row['aetheryte']}</td>
4519 // <td class="remove_line venuelistclass">${row['discord']}</td>
4520 // <td class="remove_line venuelistclass">${row['website']}</td>
4521 }
4522}
4523
4524
4525function groupList(request, target, filter = '', mode = 'grouplist') {
4526 total = 0;
4527 opentoday = 0;
4528 opensoon = 0;
4529 opennow = 0;
4530
4531 // <th align="center" class="venuelistclass" style='min-width: 600px;'><input size="70"
4532 // class="searchbar" type="text" id="findSearchInput"
4533 // name="findSearchInput" style='width:calc(100% - 55px)'
4534 // class='searchMenu' size="40" placeholder="Search Name, Description, and Keywords. Or click to sort by Name">
4535 // <img src="search.png" height="15" class='imgdropshadow link' onclick="filterVenueList(0, 'findSearchInput')">
4536 // </th>
4537
4538
4539
4540 var result = `<table id="grouplist" width="100%" class="grouptable" border='0'>
4541 <thead>
4542 <tr id='venuelist-header-tr'>
4543 <th class='venuelistclass' align="center" id='venue24' style='min-width: 343px;'>
4544 <img src="sort.png" height="15" class='imgdropshadow link'>
4545 <input
4546 class="stopprop searchbar" type="text" id="findSearchInput"
4547 style='width:calc(100% - 70px)' name="findSearchInput"
4548 class='searchMenu' size="30" placeholder="Search Name, Description, and Tags">
4549 <div class="stopprop" id="filterDiv"></div>
4550 <img src="filter.png" height="15" class='imgdropshadow link stopprop' onclick="$('#filterDiv').toggle('slow'); msg('Advanced filtering still in development');">
4551 <img src="search.png" height="15" class='imgdropshadow link stopprop' onclick="console.log($('#filterDiv').structFilter('val'));filterVenueList(0, 'findSearchInput')">
4552 </th>
4553 <th align="center" class="venuelistclass" style="white-space: nowrap; padding-left: 15px; padding-right: 15px;">Recruitment</th>
4554 <th class='venuelistclass' style='padding-left: 894px'></th>
4555 </tr>
4556 </thead><tbody>
4557 `;
4558
4559
4560
4561 // <thead>
4562 // <tr class="venuelist-header-tr">
4563
4564 // <th class='venuelistclass' align="center" id='venue24' style='min-width: 343px;'>
4565 // <img src="sort.png" height="15" class='imgdropshadow link'>
4566 // <input
4567 // class="stopprop searchbar" type="text" id="findSearchInput"
4568 // style='width:calc(100% - 70px)' name="findSearchInput"
4569 // class='searchMenu' size="30" placeholder="Search Name, Description, and Tags">
4570 // <div class="stopprop" id="filterDiv"></div>
4571 // <img src="filter.png" height="15" class='imgdropshadow link stopprop' onclick="$('#filterDiv').toggle('slow'); msg('Advanced filtering still in development');">
4572 // <img src="search.png" height="15" class='imgdropshadow link stopprop' onclick="console.log($('#filterDiv').structFilter('val'));filterVenueList(0, 'findSearchInput')">
4573 // </th>
4574
4575 // <th align="center" class="venuelistclass" style="white-space: nowrap; padding-left: 15px; padding-right: 15px;">Recruitment</th>
4576 // <th align="center" class="venuelistclass">Rank</th>
4577 // <th align="center" class="venuelistclass" style="white-space: nowrap; padding-left: 15px; padding-right: 15px;">Datacenter</th>
4578 // <th align="center" class="venuelistclass">Server</th>
4579 // <th align="center" class="venuelistclass">Housing</th>
4580 // <th align="center" class="venuelistclass">Ward</th>
4581 // <th align="center" class="venuelistclass">Plot/Apt</th>
4582 // <th align="center" class="venuelistclass">Aetheryte</th>
4583 // <th class="venuelistclass">Discord</th>
4584 // <th class="venuelistclass">Website</th>
4585 // </tr>
4586 // </thead>
4587 // <tbody>
4588 // `;
4589 $("#loading-img").fadeIn(500);
4590 // console.log(mode);
4591 $.ajax({
4592 type: 'POST',
4593 url: 'api.php',
4594 data: {
4595 mode: mode,
4596 request: request,
4597 filter: filter,
4598 dc: userdatacenter
4599 },
4600 dataType: 'json',
4601 xhr: function() {
4602 var xhr = new window.XMLHttpRequest();
4603 xhr.addEventListener("progress", function(evt) {
4604 if (evt.lengthComputable) {
4605 var percentComplete = evt.loaded / evt.total;
4606 $('.progress').animate({
4607 width: percentComplete * 100 + '%'
4608 });
4609 }
4610 }, false);
4611 return xhr;
4612 },
4613 success: function(data) {
4614 if (typeof data.status != 'undefined' && data.status == '255') {
4615 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
4616 return;
4617 }
4618
4619 data = data['posts'];
4620 for (var i in data) {
4621 var row = data[i];
4622 if (row['psize']) {
4623 psize = "(" + row['psize'] + ")";
4624 } else { psize = ''; }
4625 var rating = 'T';
4626 if (typeof row['keywords'] != 'undefined' && row['keywords'].includes("18+")) {
4627 rating = 'M';
4628 }
4629 if (typeof row['keywords'] != 'undefined' && row['keywords'].includes("21+")) {
4630 rating = 'M';
4631 }
4632 if (mode != 'admin') {
4633 if (ratingMode == 'T' && rating == 'M') {
4634 continue;
4635 }
4636 }
4637 if (row['keywords']) {
4638 row['keywords'] = "Keywords: <i class='tags'>" + row['keywords'] + "</i>";
4639 }
4640 if (row['discord']) {
4641 row['discord'] = `<a target="_blank" href="${row['discord']}">${row['discord']}</a>`;
4642 }
4643 if (row['website']) {
4644 row['website'] = `<a target="_blank" href="${row['website']}">${row['website']}</a>`;
4645 }
4646 for (var key in row) {
4647 if (!row[key]) {
4648 row[key] = "N/A";
4649 }
4650 }
4651 if (typeof row["eventfccount"] === 'undefined') {
4652 row["eventfccount"] = 0;
4653 }
4654 if (typeof row["eventcount"] === 'undefined') {
4655 row["eventcount"] = 0;
4656 }
4657 var eventcount = parseFloat(row["eventfccount"]) + parseFloat(row["eventcount"]);
4658 var events = '';
4659 if (eventcount > 0) {
4660 if (eventcount === 1) {
4661 events = eventcount + " event |";
4662 } else {
4663 events = eventcount + " events |";
4664 }
4665 }
4666 var fulldescription = '';
4667 var description = 'No Results!';
4668 if (row.description) {
4669 fulldescription = row['description'];
4670 description = urlify(truncate(row['description'],280));
4671 }
4672 var recruit = "";
4673 var tclass = "violet";
4674 if (row.recruit == 'true') {
4675 recruit = "Open";
4676 tclass = 'green';
4677 }
4678 if (row['id'] != 0) {
4679 var pa = 'P' + row.plot;
4680 if (row.apt != 'N/A') {
4681 pa = 'A' + row.apt;
4682 }
4683 if (row.ward == '' || row.ward == 'N/A') {
4684 pa = 'N/A';
4685 } else {
4686 ward = 'W' + row.ward;
4687 }
4688 var escapedTitle = decodeEntities(row['title']).replace(/'/g, "\\'");
4689 var tag = '';
4690 if (row['tag'] == '' || row['tag'] == 'N/A') {
4691 tag = '';
4692 } else {
4693 tag = '<font size="3" class="white"> << ' + row['tag'] + ' >> </font>';
4694 }
4695
4696 var housing = `${row['housing']} at ${ward} ${pa} ${row['aetheryte']}`;
4697 if (row.housing == 'Other Location') {
4698 housing = row.location;
4699 }
4700 var location = `${row['datacenter']} on ${row['server']} in ${housing}`;
4701
4702 var escapedLocation = decodeEntities(location).replace(/'/g, "\\'");
4703
4704 var prefix = "group-";
4705
4706 var postURL = `https://www.${domain}/?${prefix}${row.eurl}`;
4707 if (row['tinyurl'] != '' && typeof row.tinyurl != 'undefined') {
4708 postURL = row.tinyurl;
4709 }
4710
4711 result = `${result}
4712 <tr id="group-tr-${row['id']}" pid="${row['id']}" eurl="${row['eurl']}" class="trbg"
4713 style="height: 134px;
4714 background: url('getimage.php?banner-${prefix}${row["eurl"]}') no-repeat;
4715 background-size: 894px auto; background-position: right;">
4716
4717 <td id="${prefix}td-${row['id']}" class="remove_line venuelistclass" colspan="1" style="min-width: 370px;">
4718 <b class='link' style="text-decoration: underline;" onclick="loadPost('${row['eurl']}',this,'group-')">
4719 ${row['title']}</b> <img src='link.png' height='15px' class="link" alt="Copy Post Link" onclick="copyToClipboard('${postURL}');"> ${tag}<font size="1" class="tags psize">${psize}</font><br>
4720 <desc class='grey' title="${fulldescription}">${description}</desc><br>
4721 ${row['keywords']}<br>
4722 <font size="1.5">Location: ${location}</font> <img src='link.png' height='8px' width="8px" class="link" alt="Copy Link" onclick="copyToClipboard('` + escapedTitle + ` on ` + escapedLocation + `');">
4723 </td>
4724
4725 <td class="remove_line listTimes" align="center"><font class="${tclass}">${recruit}</font></td>
4726 <td class="gold_line venuelistclass tdbgimg" align="center"></td>
4727 </tr>`;
4728
4729 // result = `${result}
4730 // <tr id="group-tr-${row['id']}" class="trbg" style="background: url('getimage.php?group-${row["eurl"]}') right bottom no-repeat; background-position: center; background-size: cover;">
4731 // <td class="remove_line" colspan='1'><b class='link' onclick="loadPost('${row['eurl']}', this, 'group-')">${row['title']}</b><font size="2" class="tags psize">${row['psize']}</font><br>${description}<br>${events} <font size="2" class="tags">${row['keywords']}</font></td>
4732 // <td class="remove_line" align="center"><font class="${tclass}">${recruit}</font></td>
4733 // <td class="remove_line" align="center">${row['rank']}</td>
4734 // <td class="remove_line" align="center">${row['datacenter']}</td>
4735 // <td class="remove_line" align="center">${row['server']}</td>
4736 // <td class="remove_line" align="center">${row['housing']}</td>
4737 // <td class="remove_line" align="center">${row['ward']}</td>
4738 // <td class="remove_line" align="center">${pa}</td>
4739 // <td class="remove_line" align="center">${row['aetheryte']}</td>
4740 // <td class="remove_line">${row['discord']}</td>
4741 // <td class="remove_line">${row['website']}</td>
4742 // </tr>`;
4743 } else {
4744 result = "No results found!";
4745 }
4746 }
4747 result = `${result}</tbody></table>`;
4748 $(target).html(result);
4749 total = $('[opening]').length;
4750 opentoday = $('[opening="today"]').length;
4751 opensoon = $('[tclass$="violet"]').length;
4752 opennow = $('[tclass="green"]').length;
4753 $("#opentotal").html("All Times (" + total + ")");
4754 $("#opentoday").html("Today (" + opentoday + ")");
4755 $("#opensoon").html("Soon (" + opensoon + ")");
4756 $("#opennow").html("Now (" + opennow + ")");
4757 $('#venuelist').fadeIn();
4758 $('#timeWhen').trigger('change');
4759 $("#loading-img").fadeOut(500);
4760 $(`#filterDay option:contains('Any Day')`).html("Any Day (" + total + ")");
4761 $(`#filterDay option:contains('Today')`).html("Today (" + opentoday + ")");
4762 $("#loading-img").fadeOut(500);
4763 }
4764 });
4765}
4766
4767function unique(list) {
4768 var result = [];
4769 $.each(list, function(i, e) {
4770 if ($.inArray(e, result) == -1) result.push(e);
4771 });
4772 return result;
4773}
4774
4775function replaceText() {
4776
4777 $("tbody").find("span.highlight").remove();
4778
4779 var searchword = $("#findSearchInput").val();
4780// console.log(searchword);
4781 var custfilter = new RegExp(searchword, "ig");
4782 var repstr = "<span class='highlight'>" + searchword + "</span>";
4783
4784 if (searchword != "") {
4785 $('tbody').each(function() {
4786 $(this).html($(this).html().replace(custfilter, repstr));
4787 })
4788 }
4789}
4790
4791var when = '';
4792
4793function eventList(request, target, filter = '', mode = 'eventlist') {
4794 var result = `<table id="eventlist" width="100%" class="eventtable" border='0'>
4795 <thead>
4796 <tr id='venuelist-header-tr' class='venuelist-header-tr'>
4797 <th class='venuelistclass' align="center" id='venue24' style='min-width: 343px; opacity: 0.9'>
4798 <img src="sort.png" onclick="$('#venue24').trigger('click');" height="15" style="float: left;padding-top: 5px;" class='imgdropshadow link sort'>
4799 <input
4800 class="stopprop searchbar" type="text" id="findSearchInput"
4801 style='width:calc(100% - 70px)' name="findSearchInput"
4802 class='searchMenu' size="30" placeholder="Search Name, Description, and Tags">
4803 <div class="stopprop" id="filterDiv"></div>
4804 <img src="filter.png" height="15" class='imgdropshadow link stopprop' onclick="$('#filterDiv').toggle('slow'); msg('Advanced filtering still in development');">
4805 <img src="search.png" height="15" class='imgdropshadow link stopprop' onclick="console.log($('#filterDiv').structFilter('val'));filterVenueList(0, 'findSearchInput')">
4806 </th>
4807 <th align="center" class='venuelistclass' id="headerDay" style="opacity:0.9;white-space: nowrap; max-width:130px;">
4808 <img src="sort.png" onclick="$('#headerDay').trigger('click');" height="15" style="float: left;padding-top: 5px;" class='imgdropshadow link sort'>
4809 <select class="searchbarselect" id='filterDay' style='color: #ffdf00;display:inline-block' onchange='filterVenueList(1, "filterDay");'>
4810 <option disabled selected>-Day-</option>
4811 <option value=''>Any Day</option>
4812 <option value='today'>Today</option>
4813 <option value='sun'>Sunday</option>
4814 <option value='mon'>Monday</option>
4815 <option value='tue'>Tuesday</option>
4816 <option value='wed'>Wednesday</option>
4817 <option value='thu'>Thursday</option>
4818 <option value='fri'>Friday</option>
4819 <option value='sat'>Saturday</option>
4820 </select>
4821 </th>
4822 <th class='venuelistclass tdbgimg' style='padding-left: 894px'></th>
4823 </tr>
4824 </thead><tbody>
4825 `;
4826
4827 // <select class="searchbarselect" id='filterDay' style='color: #ffdf00;display:inline-block' onchange='filterVenueList(1, "filterDay"); $("#findSearchInput").trigger("click");'>
4828
4829
4830 // var result = `<table id="eventlist" width="100%" class="eventtable" border='0'>
4831 // <thead>
4832 // <tr class="venuelist-header-tr">
4833 // <th class='venuelistclass' align="center" id='venue24' style='min-width: 343px;'>
4834 // <img src="sort.png" height="15" class='imgdropshadow link'>
4835 // <input
4836 // class="stopprop searchbar" type="text" id="findSearchInput"
4837 // style='width:calc(100% - 70px)' name="findSearchInput"
4838 // class='searchMenu' size="30" placeholder="Search Name, Description, and Tags">
4839 // <div class="stopprop" id="filterDiv"></div>
4840 // <img src="filter.png" height="15" class='imgdropshadow link stopprop' onclick="$('#filterDiv').toggle('slow'); msg('Advanced filtering still in development');">
4841 // <img src="search.png" height="15" class='imgdropshadow link stopprop' onclick="console.log($('#filterDiv').structFilter('val'));filterVenueList(0, 'findSearchInput')">
4842 // </th>
4843 // <th class="venuelistclass" align="center" style="white-space: nowrap; padding-left: 70px; padding-right: 70px;">Date</th>
4844 // <th class="venuelistclass" align="center" style="white-space: nowrap; padding-left: 15px; padding-right: 15px;">Datacenter</th>
4845 // <th class="venuelistclass" align="center">Server</th>
4846 // <th class="venuelistclass" align="center">Housing</th>
4847 // <th class="venuelistclass" align="center">Ward</th>
4848 // <th class="venuelistclass" align="center">Plot/Apt</th>
4849 // <th class="venuelistclass" align="center">Aetheryte</th>
4850 // <th class="venuelistclass">Discord</th>
4851 // <th class="venuelistclass">Website</th>
4852 // </tr>
4853 // </thead>
4854 // <tbody>
4855 // `;
4856 $("#loading-img").fadeIn(500);
4857 $.ajax({
4858 type: 'POST',
4859 url: 'api.php',
4860 data: {
4861 mode: mode,
4862 request: request,
4863 filter: filter,
4864 dc: userdatacenter
4865 },
4866 dataType: 'json',
4867 xhr: function() {
4868 var xhr = new window.XMLHttpRequest();
4869 xhr.addEventListener("progress", function(evt) {
4870 if (evt.lengthComputable) {
4871 var percentComplete = evt.loaded / evt.total;
4872 $('.progress').animate({
4873 width: percentComplete * 100 + '%'
4874 });
4875 }
4876 }, false);
4877 return xhr;
4878 },
4879 success: function(data) {
4880 if (typeof data.status != 'undefined' && data.status == '255') {
4881 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
4882 return;
4883 }
4884 data = data['posts'];
4885
4886 var total = 0;
4887 var opentoday = 0;
4888 var opensoon = 0;
4889 var opennow = 0;
4890 var onDay = [];
4891 for (var i in data) {
4892 var row = data[i];
4893 if (row['psize']) {
4894 row['psize'] = "(" + row['psize'] + ")";
4895 }
4896 var rating = 'T';
4897 if (typeof row['keywords'] != 'undefined' && row['keywords'].includes("21+")) {
4898 rating = 'M';
4899 }
4900 if (typeof row['keywords'] != 'undefined' && row['keywords'].includes("18+")) {
4901 rating = 'M';
4902 }
4903 if (mode != 'admin') {
4904 if (ratingMode == 'T' && rating == 'M') {
4905 continue;
4906 }
4907 }
4908 if (row['keywords']) {
4909 row['keywords'] = "Keywords: <i class='tags'>" + row['keywords'] + "</i>";
4910 }
4911 if (row['discord']) {
4912 row['discord'] = `<a target="_blank" href="${row['discord']}">${row['discord']}</a>`;
4913 }
4914 if (row['website']) {
4915 row['website'] = `<a target="_blank" href="${row['website']}">${row['website']}</a>`;
4916 }
4917 if (row.date == '1970-01-01 00:00:00' || row.date == null) {
4918 var pdate = row.hours;
4919 row.date = null;
4920 }
4921 if (row.date != null) {
4922 if (row.date == row.edate || row.edate == null || row.edate == '1970-01-01 00:00:00' || row.edate == '') {
4923 var pdate = prettyDate(row.date) + " " + timezone;
4924 } else {
4925 var pdate = prettyDate(row.date) + "<br>to<br>" + prettyDate(row.edate) + "<br>" + timezone;
4926 }
4927 } else {
4928 pdate = '';
4929 }
4930
4931
4932 for (var key in row) {
4933 if (!row[key]) {
4934 row[key] = "N/A";
4935 }
4936 }
4937
4938 if (typeof row["eventfccount"] === 'undefined') {
4939 row["eventfccount"] = 0;
4940 }
4941 if (typeof row["eventcount"] === 'undefined') {
4942 row["eventcount"] = 0;
4943 }
4944 var eventcount = parseFloat(row["eventfccount"]) + parseFloat(row["eventcount"]);
4945
4946 var events = '';
4947
4948 if (eventcount > 0) {
4949 if (eventcount === 1) {
4950 events = eventcount + " event |";
4951 } else {
4952 events = eventcount + " events |";
4953 }
4954 }
4955
4956 var description = 'No Results!';
4957 if (row.description) {
4958 description = truncate(row['description'], 150);
4959 }
4960
4961 var tclass = 'white';
4962
4963 if (row.edate === '1970-01-01 00:00:00') {
4964 row.edate = row.date;
4965 }
4966
4967 var todaysdate = moment().format('YYYYMMDD');
4968 var todaysdatetime = moment().format('YYYYMMDDHHmm');
4969 var todaysdatetimesoon = moment().add(2, 'hours').format('YYYYMMDDHHmm');
4970
4971 var day = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('dddd');
4972 // console.log(day);
4973 if (days.includes(day)) {
4974 if (typeof onDay[day] != 'undefined') {
4975 onDay[day]++;
4976 } else {
4977 onDay[day] = 1;
4978 }
4979 }
4980
4981
4982
4983 var justdate = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDD');
4984 var justedate = moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDD');
4985 var justdatetime = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDDHHmm');
4986 var justedatetime = moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss').add(offset, 'hours').format('YYYYMMDDHHmm');
4987
4988 total++;
4989 when = 'nottoday';
4990 tclass = 'white';
4991 if (todaysdate >= justdate && todaysdate <= justedate) {
4992 tclass = 'blue';
4993 when = 'today';
4994 opentoday++;
4995 var rawtime = '';
4996 var sorttime = '';
4997 if (moment.utc(row['date'], 'hh:mm A')._isValid && moment.utc(row['edate'], 'hh:mm A')._isValid) {
4998 rawtime = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').format('YYYYMMDDHHmmss');
4999 otime = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').format('HH:mm');
5000 ctime = moment.utc(row['edate'], 'YYYY-MM-DD HH:mm:ss').format('HH:mm');
5001 sorttime = moment.utc(row['date'], 'YYYY-MM-DD HH:mm:ss').format('HH:mm');
5002 curtime = today.toLocaleTimeString();
5003 soontime = otime;
5004 if (todaysdatetimesoon >= justdatetime) {
5005 when = 'soon';
5006 tclass = 'lightviolet';
5007 opensoon++;
5008 rawtime='2'+rawtime;
5009 }
5010 // if ( isOpen(otime, ctime, 'America/New_York') == 'open' || isSoon(curtime, soontime, '1')) {
5011 // tclass = 'violet';
5012 // }
5013 if (todaysdatetime >= justdatetime && todaysdatetime <= justedatetime) {
5014 when = 'now';
5015 tclass = 'green';
5016 opensoon--;
5017 opennow++;
5018 rawtime='1'+rawtime;
5019 }
5020 if (todaysdatetime > justedatetime) {
5021 when = 'closed';
5022 tclass = 'grey';
5023 opensoon--;
5024 total--;
5025 rawtime='3'+rawtime;
5026
5027 }
5028 }
5029 }
5030
5031 if (row['id'] != 0) {
5032
5033 var pa = 'P' + row.plot;
5034 if (row.apt != 'N/A') {
5035 pa = 'A' + row.apt;
5036 }
5037 if (row.ward == 'N/A') {
5038 pa = 'N/A';
5039 } else {
5040 row.ward = 'W' + row.ward;
5041 }
5042 var unlisted = '';
5043 if (mode == 'eventadmin' && row['listed'] == '0') {
5044 unlisted = ' <font class="red">Unlisted</font><br>';
5045 }
5046 var category = ''
5047 if (row.category != 'N/A') {
5048 category = 'Category: ' + row.category + '<br> ';
5049 }
5050 if (typeof row['keywords'] != 'undefined') {
5051 if (row['keywords'].includes("#escort") || row['keywords'].includes("#18+") ||
5052 row['keywords'].includes("#erp")) {
5053 row['title'] += " (18+ Only)";
5054 }
5055
5056 // result = `${result}<tr id="event-tr-${row['id']}" colspan='1' eurl="${row.eurl}" tclass="${tclass}" opening="${when}" class="trbg" style="height: 134px; background: url('getimage.php?banner-${prefix}${row["eurl"]}') no-repeat;
5057 }
5058 result = `${result}
5059 <tr id="event-tr-${row['id']}" eurl="${row.eurl}" tclass="${tclass}" opening="${when}" class="trbg" style="height: 134px; background: url('getimage.php?banner-event-${row["eurl"]}') no-repeat;
5060 background-size: 894px auto;
5061 background-position: right;">
5062 <td class="remove_line venuelistclass" colspan="1">${unlisted}<b class='link' onclick="loadPost('${row['eurl']}',this,'event-')">${row['title']}</b><font size="2" class="tags psize">${row['psize']}</font><br>${description}<br><font size="2" class="tags">${category} ${row['keywords']}</font></td>
5063 <td class="remove_line venuelistclass listTimes num" style="text-align: center"><rawtime class="cleartext">${rawtime}<br></rawtime><font font-size="20" class="${tclass}">${pdate}</font></td>
5064 <td class="remove_line venuelistclass tdbgimg" align="center"></td>
5065 </tr>`;
5066 // result = `${result}
5067 // <tr id="event-tr-${row['id']}" eurl="${row.eurl}" tclass="${tclass}" opening="${when}" class="trbg" style="background: url('getimage.php?banner-event-${row["eurl"]}') no-repeat center right;">
5068 // <td class="remove_line venuelistclass" colspan='1'>${unlisted}<b class='link' onclick="loadPost('${row['eurl']}',this,'event-')">${row['title']}</b><font size="2" class="tags psize">${row['psize']}</font><br>${description}<br><font size="2" class="tags">${category} ${row['keywords']}</font></td>
5069 // <td class="remove_line venuelistclass" align="center"><font font-size="20" class="${tclass}">${pdate}</font></td>
5070 // <td class="remove_line venuelistclass" align="center">${row['datacenter']}</td>
5071 // <td class="remove_line venuelistclass" align="center">${row['server']}</td>
5072 // <td class="remove_line venuelistclass" align="center">${row['housing']}</td>
5073 // <td class="remove_line venuelistclass" align="center">${row['ward']}</td>
5074 // <td class="remove_line venuelistclass" align="center">${pa}</td>
5075 // <td class="remove_line venuelistclass" align="center">${row['aetheryte']}</td>
5076 // <td class="remove_line venuelistclass">${row['discord']}</td>
5077 // <td class="remove_line venuelistclass">${row['website']}</td>
5078 // </tr>`;
5079 } else {
5080 result = "No results found!";
5081 }
5082 }
5083 result = `${result}</tbody></table>`;
5084 $(target).html(result);
5085 if (opensoon < 0) {
5086 opensoon = 0;
5087 }
5088 $("#opentotal").html("All Times (" + total + ")");
5089 $("#opentoday").html("Today (" + opentoday + ")");
5090 $("#opensoon").html("Soon (" + opensoon + ")");
5091 $("#opennow").html("Now (" + opennow + ")");
5092 if (opentoday > 0) {
5093 $('#timeWhen').val('today');
5094 }
5095 $("#timeWhen").trigger("change");
5096
5097 $(`#filterDay option:contains('Any Day')`).html("Any Day (" + total + ")");
5098 $(`#filterDay option:contains('Today')`).html("Today (" + opentoday + ")");
5099 days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
5100 days.forEach(function(day) {
5101 if (typeof onDay[day] == 'undefined') {
5102 onDay[day] = 0;
5103 }
5104 // console.log(day, onDay[day]);
5105 $(`#filterDay option:contains(${day})`).html(day + " (" + onDay[day] + ")");
5106 });
5107
5108 scrollToBanner('eventlist');
5109
5110 $("#loading-img").fadeOut(500);
5111 }
5112 });
5113}
5114
5115function sortTable(id = 'venuelist', cellnum = 0) {
5116 var tbl = document.getElementById(id).tBodies[0];
5117 var store = [];
5118 for (var i = 0, len = tbl.rows.length; i < len; i++) {
5119 var row = tbl.rows[i];
5120 var sortnr = parseFloat(row.cells[0].textContent || row.cells[0].innerText);
5121 if (!isNaN(sortnr)) store.push([sortnr, row]);
5122 }
5123 store.sort(function(x, y) {
5124 return x[0] - y[0];
5125 });
5126 for (var i = 0, len = store.length; i < len; i++) {
5127 tbl.appendChild(store[i][1]);
5128 }
5129 store = null;
5130}
5131
5132function scrollToBanner(id = 'venuelist') {
5133 var rowpos = $(`#${id} tr[tclass='green']`).position();
5134 if (typeof rowpos == 'undefined') {
5135 var rowpos = $(`#${id} tr[tclass='violet']`).position();
5136 }
5137 if (typeof rowpos == 'undefined') {
5138 var rowpos = $(`#${id} tr[tclass='lightviolet']`).position();
5139 }
5140 if (typeof rowpos == 'undefined') {
5141 var rowpos = $(`#${id} tr[tclass='blue']`).position();
5142 }
5143 if (typeof rowpos == 'undefined') {
5144 return;
5145 }
5146 $('#comms-search-results').animate({
5147 scrollTop: rowpos.top - 200
5148 });
5149}
5150
5151function scrollToBannerId(id) {
5152 var rowpos = $(`#${id}`).position();
5153 if (typeof rowpos == 'undefined') {
5154 return;
5155 }
5156 $('#comms-search-results').animate({
5157 scrollTop: rowpos.top
5158 });
5159}
5160
5161function OrderBy(a, b, n) {
5162 if (n) return a - b;
5163 if (a < b) return -1;
5164 if (a > b) return 1;
5165 return 0;
5166}
5167
5168function filterVenueList(index = 2, input) {
5169 if (index == '1' && input == null) {
5170 return;
5171 }
5172 if (index == '0' && input == null) {
5173 input = 'findSearchInput';
5174 }
5175 var input, filter, table, tr, td, i, txtValue;
5176 input = document.getElementById(input);
5177 if (input == null) {
5178 return;
5179 }
5180 filter = input.value.toLowerCase();
5181 if (index == '1' && filter == 'today') {
5182 $('#timeWhen').val('today');
5183 $('#timeWhen').trigger('change');
5184 return;
5185 }
5186 if (index == '1' && filter == '') {
5187 $('#timeWhen').val('');
5188 // $('#timeWhen').trigger('change');
5189 }
5190 table = document.getElementById("venuelist");
5191 if (!table) {
5192 table = document.getElementById("grouplist");
5193 }
5194 if (!table) {
5195 table = document.getElementById("eventlist");
5196 }
5197 if (!table) {
5198 return;
5199 }
5200 tr = table.getElementsByTagName("tr");
5201 for (i = 0; i < tr.length; i++) {
5202 td = tr[i].getElementsByTagName("td")[index];
5203 var trElem = tr[i].id;
5204 var trElemClass = tr[i].className;
5205 if (td) {
5206 var dayFilter = '';
5207 if (index == 1) {
5208 dayFilter = td.textContent;
5209 }
5210 txtValue = td.textContent || td.innerText;
5211 if (txtValue.toLowerCase().indexOf(filter) > -1 || dayFilter === 'Anytime' || dayFilter == '0') {
5212 //tr[i].style.display = "";
5213 if ($('#findSearchInput').val() != '') {
5214 $(`#${trElem}`).addClass('FilterDay');
5215 $(`#${trElem}.SearchFilter`).fadeIn();
5216 } else {
5217 $(`#${trElem}`).addClass('FilterDay').fadeIn();
5218 }
5219 } else {
5220 if (trElem != 'venuelist-header-tr' || trElemClass != 'venuelist-caption') {
5221 $(`#${trElem}`).removeClass('FilterDay').fadeOut();
5222 // if ($('#findSearchInput').val() == '') {
5223 // $(`#${trElem}`).not('.SearchFilter').fadeOut();
5224 // }
5225 }
5226 //$('#tr-logout-form').css({display: ""});
5227 }
5228 }
5229 }
5230 if (index == 0 && input == '') {
5231 $('#timeWhen').trigger("change");
5232 }
5233 if ($('#findSearchInput').val() != '') {
5234 $('#findSearchInput').trigger("keyup");
5235 }
5236}
5237
5238function mainPicture(id, mode = "", eurl = "") {
5239 $("#loading-img").fadeIn(500);
5240 if (mode == 'events' || mode == 'event' || mode == 'showevents' || mode == 'getevent' || mode == 'postevent') {
5241 $("#e-" + id).attr("src", "getimage.php?event-" + eurl);
5242 } else {
5243 $.ajax({
5244 type: 'POST',
5245 url: 'api.php',
5246 data: {
5247 mode: 'mainPicture',
5248 id: id
5249 },
5250 dataType: 'json',
5251 success: function(data) {
5252 if (typeof data.status != 'undefined' && data.status == '255') {
5253 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
5254 return;
5255 }
5256
5257 if (mode == 'bg') {
5258 var pid = data[0]['id'];
5259 $("#tr-" + id).css('background', 'url(getimage.php?' + eurl + ') no-repeat; background-position: center; background-size: cover;');
5260 } else {
5261 $("#p-" + id).attr("src", "getimage.php?" + data[0]['id']);
5262 }
5263 $("#loading-img").fadeOut(500);
5264 }
5265 });
5266 }
5267}
5268
5269function allPictures(eurl, target = "#wizard", title = '') {
5270 var title = $('#title-' + eurl).text();
5271 var gallery = `
5272 <div class="noborder window-body" style="size: 25px; display: inline-block; height: 10%;">
5273 <h3>${title} Media Gallery</h3>
5274 <br>`;
5275 $("#loading-img").fadeIn(500);
5276 $.ajax({
5277 type: 'POST',
5278 url: 'api.php',
5279 data: {
5280 mode: 'pictures',
5281 eurl: eurl
5282 },
5283 dataType: 'json',
5284 success: function(data) {
5285 if (typeof data.status != 'undefined' && data.status == '255') {
5286 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
5287 return;
5288 }
5289
5290 for (i in data) {
5291 row = data[i];
5292 index = eval(i) + 1;
5293 if (row.type == 'video') {
5294 gallery = `${gallery}
5295 <iframe name="vid" class="vid imgdropshadowGold imgdropshadow" src="https://www.youtube-nocookie.com/embed/${row.image}" allow="accelerometer; clipboard-write; encrypted-media; gyroscope;" allowfullscreen="" style="display: inline;" frameborder="0"></iframe>
5296 <br>`;
5297 } else {
5298 gallery = `${gallery}
5299 <img src='getimage.php?${row.id}' width="100%" class='imgdropshadowGold imgdropshadow'>
5300 <br>`;
5301 }
5302 }
5303 gallery = `${gallery}</div>`;
5304 $(target).animate({
5305 width: '80%'
5306 });
5307 $(target).html(gallery);
5308 $(target).fadeIn();
5309 $("#loading-img").fadeOut(500);
5310 }
5311 });
5312 // }
5313}
5314
5315var arCrop = 16 / 9;
5316
5317function abortAdd(prefix) {
5318 var add = `<br><img src='addmedia.png' width="50%" class='imgdropshadowGold imgdropshadow' onclick="addMedia('${wizEurl}','${prefix}');">`;
5319 $('#addMedia').html(add);
5320}
5321
5322var cropper;
5323var bannerMode = 0;
5324
5325function reinitCrop() {
5326 var ar = 16 / 9;
5327 bannerMode = 0;
5328 var previewElem = '';
5329 if ($('#bannerAR').is(':checked')) {
5330 bannerMode = 1;
5331 ar = arCrop;
5332 //previewElem = $('.bannerSample');
5333 } else {
5334 ar = 16 / 9;
5335 }
5336 ar = Number(ar);
5337
5338 cropper.destroy();
5339 const image = document.getElementById('addimg');
5340 cropper = new Cropper(image, {
5341 aspectRatio: ar,
5342 preview: previewElem,
5343 crop(event) {
5344 cropper.getCroppedCanvas().toBlob(function(blob) {
5345 var uri = cropper.getCroppedCanvas().toDataURL("image/png", 0.7);
5346 if (bannerMode == 1) {
5347 $('#samplePostRow').css("background-image", "url(" + uri + ")");
5348 }
5349 $('#addpicpasted').val(uri);
5350 });
5351 },
5352 });
5353}
5354
5355var cropper;
5356
5357function initCropper() {
5358 if (typeof cropper != 'undefined') {
5359 cropper.destroy();
5360 $('#initCropperBtn').val('Crop Mode');
5361 return;
5362 }
5363 var ar = 16 / 9;
5364 bannerMode = 0;
5365 var previewElem = '';
5366 ar = Number(ar);
5367 const image = document.getElementById('addimg');
5368 cropper = new Cropper(image, {
5369 aspectRatio: ar,
5370 crop(event) {
5371 cropper.getCroppedCanvas().toBlob(function(blob) {
5372 var uri = cropper.getCroppedCanvas().toDataURL("image/png", 0.7);
5373 $('#addpicpasted').val(uri);
5374 $('#initCropperBtn').val('Disable Crop Mode');
5375 $('bannerCrop').fadeIn();
5376 });
5377 },
5378 });
5379}
5380
5381function addMedia(eurl, prefix = '', ar = 16 / 9) {
5382 if (cropper) {
5383 cropper.destroy();
5384 }
5385 if (typeof wizEurl == 'undefined' || eurl != '') {
5386 wizEurl = eurl;
5387 }
5388 var addForm = `
5389 <form id="addMediaForm" action="">
5390 <input type="hidden" name="eurl" value="${eurl}">
5391 <input type="hidden" name="mode" value="add">
5392 <input type="hidden" id="addpicpasted" name="pasted" value="">
5393 <input type="hidden" name="prefix" value="${prefix}">
5394 <input type="radio" name="vidpic" checked value="pic" id="addPicture">Picture</input>
5395 <input type="radio" name="vidpic" value="vid" id="addVideo">Video</input>
5396 <br>
5397 <input type="text" class="vidInput" onchange="readVid(this, 'add');" name="vid" style="display:none;" placeholder="https://www.youtube.com/watch?v=X5zyMLqYFr8">
5398 <input type="file" id="addMediaPic" name="pic" onchange="readURL(this,'add');"><br>
5399 <input type="text" id="uploadUrl">
5400 <input type="button" id="initCropperBtn" class="defaultBtn" style="display: none;" value="Crop Mode" onclick="initCropper(cropper);">
5401 <bannerCrop style="display: none;"><input type="checkbox" id="bannerAR" name="isbanner" onchange="reinitCrop(cropper);">Banner Crop Mode<br></bannerCrop>
5402 </form>
5403 <br>Or paste a copied image here<br>
5404 <center>
5405 <div width="100%" style="width: '100%';">
5406 <img src='getimage.php?0' id="addimg" name="pic" class="imgdropshadowGold imgdropshadow">
5407 </div>
5408 </center><br>
5409 <iframe name="vid" id="addvid" class="vid imgdropshadowGold imgdropshadow" src="https://www.youtube-nocookie.com/embed/X5zyMLqYFr8" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br>
5410 <button class="defaultBtn" onclick="addvidpic('${wizEurl}','${prefix}')">Add</button>
5411 <button class="defaultBtn" onclick="abortAdd('${prefix}')">Cancel</button>`;
5412
5413 $('#addMedia').html(addForm);
5414
5415 document.onpaste = function(event) {
5416 var items = (event.clipboardData || event.originalEvent.clipboardData).items;
5417 for (index in items) {
5418 var item = items[index];
5419 if (item.kind === 'file') {
5420 var blob = item.getAsFile();
5421 var reader = new FileReader();
5422 reader.onload = function(event) {
5423 $('#addimg').attr('src', event.target.result);
5424 $('#addpicpasted').val(event.target.result);
5425 // $('initCropperBtn').fadeIn();
5426 ar = 16 / 9;
5427 $('#initCropperBtn').fadeIn();
5428 }
5429 reader.readAsDataURL(blob);
5430 }
5431 }
5432 }
5433
5434 $("#addMediaForm").submit(function(e) {
5435 return false;
5436 });
5437 $('input[type=radio][name=vidpic]').change(function() {
5438 if (this.value == 'vid') {
5439 $('[name=pic]').fadeOut(function() {
5440 $('[name=vid]').fadeIn();
5441 });
5442 } else if (this.value == 'pic') {
5443 $('[name=vid]').fadeOut(function() {
5444 $('[name=pic]').fadeIn();
5445 });
5446 }
5447 });
5448}
5449
5450function addvidpic(eurl, prefix = '') {
5451 var vidpic = $('input[name=vidpic]:checked').val();
5452 $('[name=vid]').val(youtube_parse($('[name=vid]').val()));
5453 $("#loading-img").fadeIn(500);
5454 var form = $('#addMediaForm')[0]; // You need to use standard javascript object here
5455 var formData = new FormData(form);
5456 $.ajax({
5457 type: 'POST',
5458 url: 'addphoto.php',
5459 data: formData,
5460 dataType: 'json',
5461 success: function(data) {
5462 var prefix = '';
5463 var results = data;
5464 if (results["status"] == "1") {
5465 msg("An error occurred processing your request - 212");
5466 $("#loading-img").fadeOut(500);
5467 return;
5468 }
5469 prefix = results["prefix"];
5470 var realprefix = prefix;
5471 if (prefix == 'fc-') {
5472 realprefix = 'group-';
5473 }
5474 if (realprefix == 'event-') {
5475 prefix = 'e-';
5476 }
5477
5478 editPictures(wizEurl, '#wizard', '', realprefix);
5479 $("#loading-img").fadeOut(500);
5480 },
5481 error: function(e) {
5482 console.log(e);
5483 msg("An error occurred processing your request - 221");
5484 $("#loading-img").fadeOut(500);
5485 },
5486 contentType: false,
5487 processData: false
5488 });
5489}
5490
5491function editPictures(eurl, target = "#wizard", title = '', prefix = '') {
5492
5493 // console.log(arguments);
5494 // var closegroup = '';
5495 // if (prefix == 'group-') {
5496 // closegroup = `<button class="defaultBtn" onclick='$("#gallery").fadeOut()' >Close</button>`
5497 // }
5498 var gallery = `
5499 <div class="noborder title" style="size: 25px; display: inline-block;">
5500 ${title} Media Gallery
5501 </div>`;
5502 gallery = `${gallery}<center><div id="addMedia" style="width: '50%';">
5503 <br><img src='addmedia.png' width="25%" class='imgdropshadowGold imgdropshadow' onclick="addMedia('${eurl}','${prefix}',${arCrop});">
5504 </div></center><br> <banner><center><h2>Loading sample banner...</h2></center></banner>`;
5505 $("#loading-img").fadeIn(500);
5506 if (eurl != '') {
5507 $.ajax({
5508 type: 'POST',
5509 url: 'api.php',
5510 data: {
5511 mode: 'pictures',
5512 eurl: prefix + eurl,
5513 banner: '1'
5514 },
5515 dataType: 'json',
5516 success: function(data) {
5517 if (typeof data.status != 'undefined' && data.status == '255') {
5518 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
5519 return;
5520 }
5521
5522 for (i in data) {
5523 if (!isNumber(i)) {
5524 continue;
5525 }
5526 row = data[i];
5527 index = eval(i) + 1;
5528 if (row.prefix == '') {
5529 gallery = `${gallery}`;
5530 }
5531
5532 if (typeof row.id != 'undefined') {
5533 var bgpic = '';
5534 if (row.type == 'video') {
5535 var type = 'video';
5536 gallery = `${gallery}
5537 <iframe name="vid" class="vid imgdropshadowGold imgdropshadow" src="https://www.youtube-nocookie.com/embed/${row.image}" allow="accelerometer; clipboard-write; encrypted-media; gyroscope;" allowfullscreen="" style="display: inline;" frameborder="0"></iframe>
5538 <br>`;
5539 } else {
5540 var bselected = '';
5541 if (row['hidden'] == 1) {
5542 bselected = 'checked';
5543 }
5544 var type = 'picture';
5545 // var bypasscache = '.'+Math.floor((Math.random() * 100000) + 1);
5546 var bypasscache = '';
5547 gallery = `${gallery}
5548 <img src='getimage.php?${row.id}${bypasscache}' width="100%" class='imgdropshadowGold imgdropshadow'>
5549 <br>`;
5550 var bgpic = `<input type="checkbox" ${bselected} onchange='modPic("bg","${row.id}","","${row.eurl}","${prefix}");' id="bg-${row.id}">
5551 Hide Image on Post `;
5552
5553 var bselected = '';
5554 if (row['banner'] == 1) {
5555 bselected = 'checked';
5556 }
5557
5558 var bgpic = `${bgpic}<input type="radio" ${bselected} name='banner-${row.eurl}' onchange='modPic("banner","${row.id}","","${row.eurl}","${prefix}");' id="bg-${row.id}">
5559 Use Image as Banner `;
5560 }
5561 var mselected = '';
5562 if (row['main'] == 1) {
5563 var mselected = 'checked';
5564 }
5565 gallery = `${gallery}
5566 ${bgpic}<input type="radio" ${mselected} onchange='modPic("main","${row.id}","${type}","${prefix}");' name="main${type}">Set as main ${type} <button class="defaultBtn" onclick='modPic("remove","${row.id}","","${prefix}");'>
5567 Remove Media</button><br><br>
5568 `;
5569 }
5570 }
5571 var mode = 'get'+prefix.replace(/-/g, "");
5572 $(target).html(gallery);
5573 $(target).fadeIn();
5574 $.ajax({
5575 type: 'POST',
5576 url: 'api.php',
5577 data: {
5578 mode: mode,
5579 id: eurl,
5580 eurl: eurl
5581 },
5582 dataType: 'json',
5583 success: function(data) {
5584 if (typeof data.status != 'undefined' && data.status == '255') {
5585 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
5586 return;
5587 }
5588
5589 for (i in data) {
5590 if (!isNumber(i)) {
5591 continue;
5592 }
5593 row = data[i];
5594 index = eval(i) + 1;
5595
5596 if (typeof row.id != 'undefined') {
5597 var when = 'placeholder';
5598 var pa = 'Plot ' + row.plot;
5599 if (row.ward != '') {
5600 row.ward = `Ward ${row['ward']}`;
5601 } else {
5602 row.ward = '';
5603 }
5604 if (row.psize == 'Apartment') {
5605 pa = 'Apt ' + row.apt;
5606 }
5607 if (row.plot == '' && row.apt == '') {
5608 pa = '';
5609 }
5610 var tclass = 'green';
5611 var pdate = 'Open now for 2 hours and 31 minutes';
5612 var when = 'Friday and Saturday<br>8:00 PM - 11:00 PM';
5613
5614 var description = 'No Results!';
5615 if (row.description) {
5616 description = truncate(row['description']);
5617 }
5618
5619 // console.log(row.category);
5620 // var tagslist = '';
5621 if (row['category']) {
5622 var tags = row.category.replace(/#/g, '', true);
5623 tags = tags.split(" ");
5624 var tagslist = '';
5625 for (var tag in tags) {
5626 var tagName = tags[tag];
5627 tagslist = tagslist + ` <tag class="link white" onclick="$('#timeWhen').val(''); venueList('', '#comms-search-results', '${tagName}', 'categories');">` + tagName + '</tag>';
5628 }
5629 tagslist = "Tags: " + tagslist;
5630 } else {
5631 var tagslist = '';
5632 }
5633 // console.log(tagslist);
5634
5635 var bypasscache = Math.floor((Math.random() * 100000) + 1);
5636 var banner = `<div width='1655'><table id="samplevenue" width="1654" class="venuetable" border='0' background-color="white" style="color: white;">
5637 <thead>
5638 <tr>
5639 <th align="center" id='venue24sample' class='venuelistclass' style="min-width: 100%"><input size="70"
5640 class="searchbar" type="text" id="findSearchInputSample"
5641 name="findSearchInput" class='searchMenu' style='width:calc(100% - 55px)'
5642 placeholder="Search Name, Description, and Tags. Or click to sort by Name">
5643 <img src="search.png" height="15" class='imgdropshadow link' onclick="filterVenueList(0, 'findSearchInput')">
5644 </th>
5645 <th align="center" id="demoheaderDay" class='venuelistclass' style="white-space: nowrap; padding-right: 40px; padding-left: 40px;">
5646 <select class="searchbar" id='demofilterDay' style='display:inline-block'>
5647 <option disabled selected>-Day-</option>
5648 <option value=''>Any Day</option>
5649 <option value='today'>Today</option>
5650 <option value='sun'>Sunday</option>
5651 <option value='mon'>Monday</option>
5652 <option value='tue'>Tuesday</option>
5653 <option value='wed'>Wednesday</option>
5654 <option value='thu'>Thursday</option>
5655 <option value='fri'>Friday</option>
5656 <option value='sat'>Saturday</option>
5657 </select>
5658 </th>
5659 <th align="center" class='venuelistclass' style="white-space: nowrap; padding-left: 894px;"></th>
5660 </tr>
5661 </thead>
5662 <tbody>
5663 <tr id="samplePostRow" opening="${when}" class="samplePostRowImg bannerSample trbg">
5664 <td class="remove_line" colspan='1'><b>${row['title']}</b><font size="2" class="tags psize">${row['psize']}</font><br><font font-size="20" class="${tclass}">${pdate}</font><br>${description}<br> <font size="2" class="tags">${row['category']}</font></td>
5665 <td class="remove_line" align="center"><font font-size="20" class="${tclass}">${when}</font></td>
5666 <td class="remove_line" align="center" height="134" style="height:134; background: url('getimage.php?banner-${row["eurl"]}.${bypasscache}') no-repeat center; background-size: 100% auto; background-position: center"></td>
5667 </tr></tbody></table></div>Banner Dimensions & Ratio: <rowdimensions></rowdimensions><br><br>`;
5668 }
5669 }
5670 $('banner').html(banner);
5671 var w = 894; //$('#samplePostRow').width();
5672 // var h = $('#samplePostRow').height();
5673 // if (h == null) { h = 200;}
5674 var h = 134;
5675 var r = gcd(w, h);
5676 var ar = w / r + ":" + h / r;
5677 arCrop = (w / r) / (h / r);
5678 var dims = w + 'x' + h + ' | ' + ar;
5679
5680 $('rowdimensions').html(dims)
5681 $("#loading-img").fadeOut(500);
5682 }
5683 });
5684 $("#loading-img").fadeOut(500);
5685 }
5686 });
5687 } else {
5688 msg("Please specify a Title/Post URL on form before adding photos to the gallery!");
5689 $("#loading-img").fadeOut(500);
5690 }
5691}
5692
5693String.fromHtmlEntities = function(string) {
5694 return (string + "").replace(/&#\d+;/gm, function(s) {
5695 return String.fromCharCode(s.match(/\d+/gm)[0]);
5696 })
5697};
5698
5699$.datetimepicker.setDateFormatter('moment');
5700
5701var dayslist = [];
5702var daysAndTimes = '';
5703var oTime = '';
5704var cTime = '';
5705var day = '';
5706
5707function daysOpen(pTimes) {
5708 var actualDayCount = 0;
5709 dayslist = $("select#dayOpt").val();
5710 daysAndTimes = '';
5711 if (dayslist == null) {
5712 daysAndTimes = '';
5713 }
5714 var count = 0;
5715 $("#days").html('');
5716 var allTimes = '';
5717 if (pTimes != '') {
5718 pTimes = JSON.parse(postTimes);
5719 }
5720 for (i in dayslist) {
5721 day = dayslist[i];
5722 if (day == 'Service' || day == 'To be Determined' || day == 'Event Only' || day == 'Popup Venue' || day == 'Anytime') {
5723 continue;
5724 }
5725 actualDayCount++;
5726 oTime = '';
5727 cTime = '';
5728 if (pTimes != '' && typeof pTimes[day] != 'undefined') {
5729 oTime = pTimes[day]['otime'];
5730 cTime = pTimes[day]['ctime'];
5731 // console.log(day, pTimes[day], oTime);
5732 if (moment.utc(oTime, 'hh:mm A')._isValid) {
5733 oTime = moment.utc(oTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
5734 }
5735 if (moment.utc(cTime, 'hh:mm A')._isValid) {
5736 cTime = moment.utc(cTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
5737 }
5738 }
5739 // console.log(day, pTimes[day], oTime);
5740 var updateTimes = '';
5741 if (count == 0) {
5742 var onkeyup = `onchange="fillTimes()"`;
5743 updateTimes = `fillTimes()`;
5744 }
5745 daysAndTimes = `<tr><td>${day}:</td><td>From <input value="${oTime}" type="text" style="width: 80px;" class="times" id="${day}-otime" name="otime" placeholder="9:00AM" ${onkeyup} onchange=" somethingChangedFunc(true); $('#wizSave').animate({backgroundColor: '#FFDF00'});">
5746 to <input type="text" value="${cTime}" style="width: 80px;" class="times" id="${day}-ctime" name="ctime" placeholder="5:30PM" ${onkeyup} onchange="somethingChangedFunc(true); $('#wizSave').animate({backgroundColor: '#FFDF00'});"></td></tr> `;
5747 count++;
5748 $("#days").append(daysAndTimes);
5749 jQuery(function() {
5750 jQuery(`#${day}-otime`).datetimepicker({
5751 format: 'h:mm A',
5752 formatTime: "h:mm A",
5753 // inline:true,
5754 parentID: "#timepickerdiv",
5755 theme: 'dark',
5756 // validateOnBlur: false,
5757 step: 15,
5758 // hours12: true,
5759 onShow: function(ct) {
5760 this.setOptions({
5761 maxTime: jQuery(`#${day}-ctime`).val() ? jQuery(`#${day}-ctime`).val() : false
5762 })
5763 },
5764 onSelectTime: function(ct) {
5765 fillTimes();
5766 },
5767 onChangeDateTime: function(ct) {
5768 somethingChangedFunc(true);
5769 },
5770 datepicker: false
5771 });
5772 jQuery(`#${day}-ctime`).datetimepicker({
5773 format: 'h:mm A',
5774 formatTime: 'h:mm A',
5775 parentID: "#timepickerdiv",
5776 theme: 'dark',
5777 // validateOnBlur: false,
5778 step: 15,
5779 onShow: function(ct) {
5780 this.setOptions({
5781 minTime: jQuery(`#${day}-otime`).val() ? jQuery(`#${day}-otime`).val() : false
5782 })
5783 },
5784 onSelectTime: function(ct) {
5785 fillTimes();
5786 },
5787 onChangeDateTime: function(ct) {
5788 somethingChangedFunc(true);
5789 $('#wizSave').animate({
5790 backgroundColor: '#FFDF00'
5791 });
5792 },
5793 datepicker: false
5794 });
5795 });
5796 }
5797 if (actualDayCount > 1) {
5798 $("#days").prepend(`Time is same for all days open: <input type="checkbox" id="timeSame" checked name="timeSame" onchange="fillTimes(this);"><br>`);
5799 }
5800}
5801
5802function fillTimes() {
5803 somethingChangedFunc(true);
5804 var input = $('#timeSame');
5805 checkState = input.checked;
5806 daysAndTimes = '';
5807 var disabled = checkState;
5808 if (typeof input[0] != 'undefined') {
5809 checkState = input[0].checked;
5810 }
5811 if (!checkState && typeof disabled == 'undefined') {
5812 $('.times').prop("disabled", false);
5813 return;
5814 }
5815 dayslist = $("select#dayOpt").val();
5816 day = dayslist[0];
5817 var Sotime = $(`#${day}-otime`).val();
5818 var Sctime = $(`#${day}-ctime`).val();
5819 for (i = 1; i < dayslist.length; i++) {
5820 day = dayslist[i];
5821 $(`#${day}-otime`).val(Sotime);
5822 $(`#${day}-ctime`).val(Sctime);
5823 $(`#${day}-otime`).prop("disabled", true);
5824 $(`#${day}-ctime`).prop("disabled", true);
5825 }
5826}
5827
5828
5829function setpostdc(prefix = '') {
5830 var dclist = '';
5831 switch ($("select#" + prefix + "dc").val()) {
5832 case "Crystal":
5833 dclist = `
5834 <option value="">N/A</option>
5835 <option value="Balmung">Balmung</option>
5836 <option value="Brynhildr">Brynhildr</option>
5837 <option value="Coeurl">Coeurl</option>
5838 <option value="Diabolos">Diabolos</option>
5839 <option value="Goblin">Goblin</option>
5840 <option value="Mateus">Mateus</option>
5841 <option value="Malboro">Malboro</option>
5842 <option value="Zalera">Zalera</option>
5843 `;
5844 break;
5845 case "Primal":
5846 dclist = `
5847 <option value="">N/A</option>
5848 <option value="Behemoth">Behemoth</option>
5849 <option value="Excalibur">Excalibur</option>
5850 <option value="Exodus">Exodus</option>
5851 <option value="Famfrit">Famfrit</option>
5852 <option value="Hyperion">Hyperion</option>
5853 <option value="Lamia">Lamia</option>
5854 <option value="Leviathan">Leviathan</option>
5855 <option value="Ultros">Ultros</option>
5856 `;
5857 break;
5858 case "Chaos":
5859 dclist = `
5860 <option value="">N/A</option>
5861 <option value="Cerberus">Cerberus</option>
5862 <option value="Louisoix">Louisoix</option>
5863 <option value="Moogle">Moogle</option>
5864 <option value="Omega">Omega</option>
5865 <option value="Ragnarok">Ragnarok</option>
5866 <option value="Spriggan">Spriggan</option>
5867 `;
5868 break;
5869 case "Light":
5870 dclist = `
5871 <option value="">N/A</option>
5872 <option value="Lich">Lich</option>
5873 <option value="Odin">Odin</option>
5874 <option value="Phoenix">Phoenix</option>
5875 <option value="Shiva">Shiva</option>
5876 <option value="Twintania">Twintania</option>
5877 <option value="Zodiark">Zodiark</option>
5878 `;
5879 break;
5880 case "Elemental":
5881 dclist = `
5882 <option value="">N/A</option>
5883 <option value="Aegis">Aegis</option>
5884 <option value="Atomos">Atomos</option>
5885 <option value="Carbuncle">Carbuncle</option>
5886 <option value="Garuda">Garuda</option>
5887 <option value="Gungnir">Gungnir</option>
5888 <option value="Kujata">Kujata</option>
5889 <option value="Ramuh">Ramuh</option>
5890 <option value="Tonberry">Tonberry</option>
5891 <option value="Typhon">Typhon</option>
5892 <option value="Unicorn">Unicorn</option>
5893 `;
5894 break;
5895 case "Gaia":
5896 dclist = `
5897 <option value="">N/A</option>
5898 <option value="Alexander">Alexander</option>
5899 <option value="Bahamut">Bahamut</option>
5900 <option value="Durandal">Durandal</option>
5901 <option value="Fenrir">Fenrir</option>
5902 <option value="Ifrit">Ifrit</option>
5903 <option value="Ridill">Ridill</option>
5904 <option value="Tiamat">Tiamat</option>
5905 <option value="Ultima">Ultima</option>
5906 <option value="Valefor">Valefor</option>
5907 <option value="Yojimbo">Yojimbo</option>
5908 <option value="Zeromus">Zeromus</option>
5909 `;
5910 break;
5911 case "Mana":
5912 dclist = `
5913 <option value="">N/A</option>
5914 <option value="Anima">Anima</option>
5915 <option value="Asura">Asura</option>
5916 <option value="Belias">Belias</option>
5917 <option value="Chocobo">Chocobo</option>
5918 <option value="Hades">Hades</option>
5919 <option value="Ixion">Ixion</option>
5920 <option value="Mandragora">Mandragora</option>
5921 <option value="Masamune">Masamune</option>
5922 <option value="Pandemonium">Pandemonium</option>
5923 <option value="Shinryu">Shinryu</option>
5924 <option value="Titan">Titan</option>
5925 `;
5926 break;
5927 case "Aether":
5928 dclist = `
5929 <option value="">N/A</option>
5930 <option value="Adamantoise">Adamantoise</option>
5931 <option value="Cactuar">Cactuar</option>
5932 <option value="Faerie">Faerie</option>
5933 <option value="Gilgamesh">Gilgamesh</option>
5934 <option value="Jenova">Jenova</option>
5935 <option value="Midgardsormr">Midgardsormr</option>
5936 <option value="Sargatanas">Sargatanas</option>
5937 <option value="Siren">Siren</option>
5938 `;
5939 break;
5940 }
5941 if (dclist) {
5942 $('#' + prefix + 'server').html(dclist);
5943 }
5944}
5945
5946function setaetheryte(prefix = '') {
5947 var aetherlist = '';
5948 $("#location").fadeOut();
5949 $("#housingloc").fadeIn();
5950 switch ($("select#" + prefix + "housing").val()) {
5951 case "Other Location":
5952 $("#housingloc").fadeOut();
5953 $("#location").fadeIn();
5954 break;
5955 case "The Goblet":
5956 aetherlist = `
5957 <option value="">N/A</option>
5958 <option value="Goblet Exchange">Goblet Exchange</option>
5959 <option value="Goblet Northeast">Goblet Northeast</option>
5960 <option value="Goblet West">Goblet West</option>
5961 <option value="Goblet Southeast">Goblet Southeast</option>
5962 <option value="Goblet North">Goblet North</option>
5963 <option value="Goblet East">Goblet East</option>
5964 <option value="The Brimming Heart">The Brimming Heart</option>
5965 <option value="The Sultana's Breath">The Sultana's Breath</option>
5966 <option value="Goblet Exchange Sub">Goblet Exchange Sub</option>
5967 <option value="Goblet Southeast Sub">Goblet Southeast Sub</option>
5968 <option value="Goblet North Sub">Goblet North Sub</option>
5969 <option value="The Brimming Heart Sub">The Brimming Heart Sub</option>
5970 <option value="Goblet Southwest Sub">Goblet Southwest Sub</option>
5971 <option value="Goblet East Sub">Goblet East Sub</option>
5972 <option value="Goblet South Sub">Goblet South Sub</option>
5973 <option value="The Sultana's Breath Sub">The Sultana's Breath Sub</option>
5974 `;
5975 break;
5976 case "Mist":
5977 aetherlist = `
5978 <option value="">N/A</option>
5979 <option value="Mistgate Square">Mistgate Square</option>
5980 <option value="Mist West">Mist West</option>
5981 <option value="Mist Northeast">Mist Northeast</option>
5982 <option value="Seagaze Markets">Seagaze Markets</option>
5983 <option value="Mist Southeast">Mist Southeast</option>
5984 <option value="Mist South (Docks)">Mist South (Docks)</option>
5985 <option value="Mist East">Mist East</option>
5986 <option value="The Topmast">The Topmast</option>
5987 <option value="Mistgate Square Sub">Mistgate Square Sub</option>
5988 <option value="Mist Northeast Sub">Mist Northeast Sub</option>
5989 <option value="Mist Southeast Sub">Mist Southeast Sub</option>
5990 <option value="Seagaze Markets Sub">Seagaze Markets Sub</option>
5991 <option value="Mist Southwest Sub">Mist Southwest Sub</option>
5992 <option value="Mist Northwest Sub">Mist Northwest Sub</option>
5993 <option value="Central Mist Sub">Central Mist Sub</option>
5994 <option value="The Topmast Sub">The Topmast Sub</option>
5995 `;
5996 break;
5997 case "The Lavender Beds":
5998 aetherlist = `
5999 <option value="">N/A</option>
6000 <option value="Amethyst Shallows">Amethyst Shallows</option>
6001 <option value="Dappled Stalls">Dappled Stalls</option>
6002 <option value="Lavender Northwest">Lavender Northwest</option>
6003 <option value="Wildflower Stalls">Wildflower Stalls</option>
6004 <option value="Lavender Southeast">Lavender Southeast</option>
6005 <option value="Lavender Southwest">Lavender Southwest</option>
6006 <option value="Lavender East">Lavender East</option>
6007 <option value="Lily Hills">Lily Hills</option>
6008 <option value="Dappled Stalls Sub">Dappled Stalls Sub</option>
6009 <option value="Lavender Northeast Sub">Lavender Northeast Sub</option>
6010 <option value="Wildflower Stalls Sub">Wildflower Stalls Sub</option>
6011 <option value="Lavender Southwest Sub">Lavender Southwest Sub</option>
6012 <option value="Lavender Northwest Sub">Lavender Northwest Sub</option>
6013 <option value="Lavender South Sub">Lavender South Sub</option>
6014 <option value="Amethyst Shallows Sub">Amethyst Shallows Sub</option>
6015 <option value="Lily Hills Sub">Lily Hills Sub</option>
6016 `;
6017 break;
6018 case "Shirogane":
6019 aetherlist = `
6020 <option value="">N/A</option>
6021 <option value="Akanegumo Bridge">Akanegumo Bridge</option>
6022 <option value="Northwestern Shirogane">Northwestern Shirogane</option>
6023 <option value="Western Shirogane">Western Shirogane</option>
6024 <option value="Kobai Goten">Kobai Goten</option>
6025 <option value="Northeastern Shirogane">Northeastern Shirogane</option>
6026 <option value="Southwestern Shirogane">Southwestern Shirogane</option>
6027 <option value="Southern Shirogane">Southern Shirogane</option>
6028 <option value="Southeastern Shirogane">Southeastern Shirogane</option>
6029 <option value="Akanegumo Bridge Sub">Akanegumo Bridge Sub</option>
6030 <option value="Eastern Shirogane Sub">Eastern Shirogane Sub</option>
6031 <option value="Northeastern Shirogane Sub">Northeastern Shirogane Sub</option>
6032 <option value="Kobai Goten Sub">Kobai Goten Sub</option>
6033 <option value="Southern Shirogane Sub">Southern Shirogane Sub</option>
6034 <option value="Northern Shirogane Sub">Northern Shirogane Sub</option>
6035 <option value="Western Shirogane Sub">Western Shirogane Sub</option>
6036 <option value="Southwestern Shirogane Sub">Southwestern Shirogane Sub</option>
6037 `;
6038 break;
6039 }
6040 if (aetherlist) {
6041 $('#' + prefix + 'aetheryte').html(aetherlist);
6042 }
6043}
6044
6045function wpaSelect(e = '') {
6046 switch ($("select#" + e + "psize").val()) {
6047 case "Small":
6048 case "Medium":
6049 case "Large":
6050 $('.apt').fadeOut(function() {
6051 $('.plot').fadeIn();
6052 });
6053 break;
6054 case "Apartment":
6055 $('.plot').fadeOut(function() {
6056 $('.apt').fadeIn();
6057 });
6058 break;
6059 }
6060}
6061
6062String.prototype.trunc =
6063 function(n) {
6064 return this.substr(0, n - 1) + (this.length > n ? '…' : '');
6065 };
6066
6067function truncate(str, n = 70) {
6068 if (str == null) {
6069 return;
6070 }
6071 return (str.length > n) ? str.substr(0, n - 1) + '…' : str;
6072};
6073
6074function youtube_parse(url) {
6075 var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
6076 var match = url.match(regExp);
6077 return (match && match[7].length == 11) ? match[7] : false;
6078}
6079
6080var posteurl = '';
6081
6082function populatePosteurl(posteurl = '', prefix = '') {
6083 var postresults = [];
6084 var posts = '';
6085 postresults["return"] = '';
6086 $.ajax({
6087 type: 'POST',
6088 url: 'api.php',
6089 data: {
6090 mode: 'listpost' + prefix
6091 },
6092 dataType: 'json',
6093 success: function(postresults) {
6094 if (typeof postresults.status != 'undefined' && postresults.status == '255') {
6095 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6096 return;
6097 }
6098
6099 if (postresults["return"] == "1") {
6100 return;
6101 }
6102 for (i in postresults) {
6103 row = postresults[i];
6104 posts = `${posts}<option value="${row.eurl}">${row.title}</option>`;
6105 }
6106 $('#post' + prefix + 'eurl').append(posts);
6107 $('#post' + prefix + 'eurl').val(posteurl);
6108 }
6109 });
6110}
6111
6112// var posteurl = '';
6113function populateCategory(posteurl = '', prefix = '') {
6114 var catresults = [];
6115 var cats = '';
6116 catresults["return"] = '';
6117 $.ajax({
6118 type: 'POST',
6119 url: 'api.php',
6120 data: {
6121 mode: 'category' + prefix
6122 },
6123 dataType: 'json',
6124 success: function(data) {
6125 if (typeof data.status != 'undefined' && data.status == '255') {
6126 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6127 return;
6128 }
6129
6130 if (data["return"] == "1") {
6131 return;
6132 }
6133 data = data.catlist.split(',');
6134 for (i in data) {
6135 // console.log(row, data, i);
6136 row = data[i];
6137 cats = `${cats}<option value="${row}">${row}</option>`;
6138 }
6139 $('.categories' + prefix).append(cats);
6140 $('.categories' + prefix).val(posteurl);
6141 var usedNames = {};
6142 $("select#e-category > option").each(function() {
6143 if (usedNames[this.text]) {
6144 $(this).remove();
6145 } else {
6146 usedNames[this.text] = this.value;
6147 }
6148 });
6149 }
6150 });
6151}
6152var wizEeurl;
6153
6154String.prototype.nthLastIndexOf = function(searchString, n){
6155 var url = this;
6156 if(url === null) {
6157 return -1;
6158 }
6159 if(!n || isNaN(n) || n <= 1){
6160 return url.lastIndexOf(searchString);
6161 }
6162 n--;
6163 return url.lastIndexOf(searchString, url.nthLastIndexOf(searchString, n) - 1);
6164}
6165
6166function populateEventeurl(eventeurl = '', nodupes = 'nodupes', eurl = '', prefix = '', callback = '', args = '') {
6167 // console.log(callback, args);
6168 $("#loading-img").fadeIn(500);
6169 var eventresults = [];
6170 var events = '';
6171
6172 if (wizId == '') {
6173 $('#eventeurl').html('<option value="">Save your post before linking to an event</option>');
6174 }
6175
6176 var nottaken = 0;
6177 var venueArray = 0;
6178 if ( eventeurl == 'venueArray' ) { eventeurl = ''; venueArray = 1; nottaken = 2 } else { nottaken = 1; }
6179
6180 // console.log(eventeurl, nodupes, eurl);
6181 eventresults["return"] = '';
6182 $.ajax({
6183 type: 'POST',
6184 url: 'api.php',
6185 data: {
6186 mode: 'listevent' + prefix,
6187 eurl: eurl,
6188 nottaken: nottaken
6189 },
6190 dataType: 'json',
6191 success: function(eventresults) {
6192 $("#loading-img").fadeOut(500);
6193 if (typeof eventresults.status != 'undefined' && eventresults.status == '255') {
6194 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6195 return;
6196 }
6197 //eventArray = {};
6198 var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
6199
6200 if (eventresults["return"] == "1") {
6201 return;
6202 }
6203 if ( callback == '' ) { $('#eventeurl').html('<option value="">Do not attach to event</option>');}
6204 for (i in eventresults) {
6205 if (!isNumber(i)) {
6206 continue;
6207 }
6208 row = eventresults[i];
6209 eeurl = row.eurl;
6210 // var dupe = 0;
6211 var n = eeurl.split('-');
6212 var result = n[ n.length - 2 ];
6213 // if (days.includes(result)) { dupe = 1;}
6214 var resulttwo = n[ n.length - 1 ];
6215 // if (days.includes(resulttwo)) { dupe = 1;}
6216 if ((days.includes(result) || days.includes(resulttwo) )&& nodupes != 'yesdupes' ) {
6217 continue;
6218 }
6219
6220 if ( venueArray == 1 ) {
6221 eventArray[row.eurl] = {};
6222 eventArray[row.eurl]['title'] = row.title;
6223 eventArray[row.eurl]['date'] = row.date;
6224 continue;
6225 }
6226
6227 events = `${events}<option value="${row.eurl}">${row.title}</option>`;
6228 // console.log(eventeurl, eeurl);
6229 if (eventeurl == eeurl) {
6230 var feurl = row['eurl'];
6231 $('#ee-photo').attr('src', 'getimage.php/?event-' + feurl);
6232 var fields = ["datacenter", "server", "housing", "ward", "plot", "apt", "aetheryte", "psize", "location", "website", "rating", "category", "schedule", "manager"];
6233 for (var field in fields) {
6234 field = fields[field];
6235 // console.log(field, typeof row[field]);
6236 // data = row[field];
6237 if (field != 'schedule' && (row[field] == '' || typeof row[field] == 'object')) {
6238 $('#event-' + field).next().css("font-style", "italic").css("color", "grey");
6239 // console.log($('#event-'+field).next());
6240 // $('#event-'+field).parent('td').css( "background-color", "grey" );
6241 } else {
6242 if (field == 'schedule') {
6243 // row['times'] = '{"Tuesday":{"otime":"10:00 PM","ctime":"12:00 AM"}}';
6244 // row['times'] = '{"Monday":{"otime":"7:00 PM","ctime":"11:00 PM"},"Friday":{"otime":"7:00 PM","ctime":"11:00 PM"}}';
6245 row.sametime = '0';
6246
6247 var times = decodeEntities(row['times']);
6248
6249 var allTimes = [];
6250 if (isJson(times)) {
6251 times = JSON.parse(times);
6252 // console.log(times);
6253 // timesBlock:
6254 if (row.sametime != '1') {
6255 for (var i in times) {
6256 Day = times[i];
6257 dayName = i;
6258 oTime = Day['0'];
6259 cTime = Day['1'];
6260 if (moment.utc(oTime, 'hh:mm A')._isValid) {
6261 var oTime = moment.utc(oTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
6262 }
6263 if (moment.utc(cTime, 'hh:mm A')._isValid) {
6264 var cTime = moment.utc(cTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
6265 }
6266 if (dayName == today) {
6267 ctday = [oTime, cTime];
6268 }
6269
6270 var biweekly = 'On';
6271 if (row.biweekly == '2') {
6272 biweekly = 'Monthly on';
6273 }
6274 if (row.biweekly == '1') {
6275 biweekly = 'On every other';
6276 }
6277
6278 allTimes.push(`${biweekly} ${dayName} from ${oTime} to ${cTime} ${zoneAbbr}`);
6279 }
6280 } else if (isJson(row.day)) {
6281 Day = times[JSON.parse(row.day)[0]];
6282 // if ( typeof Day == 'undefined' ) { break timesBlock;}
6283 dayName = i;
6284 oTime = Day['0'];
6285 cTime = Day['1'];
6286 // ctday = [oTime, cTime];
6287 // console.log(ctday)
6288
6289 if (moment.utc(oTime, 'hh:mm A')._isValid) {
6290 var oTime = moment.utc(oTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
6291 }
6292 if (moment.utc(cTime, 'hh:mm A')._isValid) {
6293 var cTime = moment.utc(cTime, 'hh:mm A').add(offset, 'hour').format('h:mm A');
6294 }
6295 var biweekly = 'On';
6296 // if ( row.biweekly == '2' ) { biweekly = 'Monthly on'; }
6297 // if ( row.biweekly == '1' ) { biweekly = 'On every other'; }
6298
6299 // var niceDay = niceList(JSON.parse(row.day));
6300 allTimes.push(`${biweekly} ${niceDay} from ${oTime} to ${cTime} ${zoneAbbr}`);
6301 }
6302 }
6303 // 7 of 9
6304 row['schedule'] = niceList(allTimes);
6305 }
6306 if (field == 'rating') {
6307 switch (row[field]) {
6308 case '0':
6309 row[field] = "All Ages";
6310 break;
6311 case '1':
6312 row[field] = "18+";
6313 break;
6314 case '2':
6315 row[field] = "21+";
6316 break;
6317 default:
6318 row[field] = 'N/A';
6319 }
6320 }
6321 if (field == 'manager') {
6322 row.manager = niceList(JSON.parse(row.manager));
6323 }
6324 if (field == 'website') {
6325 row.website = urlify(row.website);
6326 }
6327 $('#ee-' + field).html(row[field]);
6328 // console.log(field,row[field]);
6329 }
6330 }
6331 }
6332 }
6333
6334 if ( venueArray == 1 ) {
6335 eventArray['populated'] = true;
6336 // console.log(callback);
6337 if ( callback != '' ) {
6338 callback(args[0],args[1],args[2],args[3]);
6339 return;
6340 } else {
6341 return eventArray;
6342 }
6343 }
6344
6345 $('#event' + prefix + 'eurl').append(events);
6346 $('#event' + prefix + 'eurl').val(eventeurl);
6347 if (eventeurl != '' && $('#event' + prefix + 'eurl').val() != eventeurl) {
6348 events = `<option value="${eventeurl}">Currently linked event not found in Events!</option>`;
6349 $('#event' + prefix + 'eurl').append(events);
6350 $('#event' + prefix + 'eurl').val(eventeurl);
6351 }
6352 // console.log('ffsync', $('#eventeurl').val(), eventeurl, wizMode);
6353 if (eventeurl != '') {
6354 wizEeurl = eventeurl;
6355 }
6356 $(function () {
6357 $("#eventeurl").select2();
6358 });
6359 if ($('#eventeurl').val() == '' || typeof $('#eventeurl').val() == 'undefined' || wizMode == 'sync') {
6360 $('ffxivrp').fadeOut();
6361 } else {
6362 $('ffxivrp').fadeIn();
6363 }
6364 }
6365 });
6366}
6367
6368function calendar(eurl, calid = '') {
6369 if (calid != '') {
6370 $("#dialog-confirm").attr("title", "Calendar Entry");
6371 $("#dialog-confirm").html('Calendar entry exists.<br>Would you like to:');
6372 $("#dialog-confirm").dialog({
6373 resizable: false,
6374 height: "auto",
6375 width: 700,
6376 modal: true,
6377 dialogClass: 'dialogWindow',
6378 buttons: {
6379 "Update Calendar?": function() {
6380 $(this).dialog("close");
6381 $("#loading-img").fadeIn(500);
6382 $.ajax({
6383 type: "POST",
6384 url: "cal.php",
6385 data: {
6386 eurl: eurl
6387 },
6388 success: function(data) {
6389 if (data != '0') {
6390 $("#loading-img").fadeOut(500);
6391 msg("An error occurred processing your request! - 7<br>" + data);
6392 return;
6393 }
6394 msg("Calendar updated!");
6395 loadPage('submit');
6396 $("#loading-img").fadeOut(500);
6397 },
6398 error: function() {
6399 msg("An error occurred processing your request - 71");
6400 $("#loading-img").fadeOut(500);
6401 }
6402 });
6403 },
6404 "Remove from Calendar?": function() {
6405 $(this).dialog("close");
6406 $("#loading-img").fadeIn(500);
6407 $.ajax({
6408 type: "POST",
6409 url: "cal.php",
6410 data: {
6411 eurl: eurl,
6412 mode: "delete"
6413 },
6414 success: function(data) {
6415 if (data != '0') {
6416 $("#loading-img").fadeOut(500);
6417 msg("An error occurred processing your request! - 8<br>" + data);
6418 return;
6419 }
6420 msg("Calendar entry removed!");
6421 loadPage('submit');
6422 $("#loading-img").fadeOut(500);
6423 },
6424 error: function() {
6425 msg("An error occurred processing your request - 81");
6426 $("#loading-img").fadeOut(500);
6427 }
6428 });
6429 },
6430 Cancel: function() {
6431 $(this).dialog("close");
6432 }
6433 }
6434 });
6435 } else {
6436 $("#dialog-confirm").attr("title", "Calendar Entry");
6437 $("#dialog-confirm").html('Post is not on calendar.<br>Would you like to:');
6438 $("#dialog-confirm").dialog({
6439 resizable: false,
6440 height: "auto",
6441 width: 400,
6442 modal: true,
6443 dialogClass: 'dialogWindow',
6444 buttons: {
6445 "Add to Calendar?": function() {
6446 $(this).dialog("close");
6447 $("#loading-img").fadeIn(500);
6448 $.ajax({
6449 type: "POST",
6450 url: "cal.php",
6451 data: {
6452 eurl: eurl
6453 },
6454 success: function(data) {
6455 if (data != '0') {
6456 $("#loading-img").fadeOut(500);
6457 msg("An error occurred processing your request!<br>" + data);
6458 return;
6459 }
6460 msg("Calendar updated!");
6461 loadPage('submit');
6462 $("#loading-img").fadeOut(500);
6463 },
6464 error: function() {
6465 msg("An error occurred processing your request");
6466 $("#loading-img").fadeOut(500);
6467 }
6468 });
6469 },
6470 Cancel: function() {
6471 $(this).dialog("close");
6472 }
6473 }
6474 });
6475 }
6476}
6477
6478function autocomplete(inp, arr) {
6479 /*the autocomplete function takes two arguments,
6480 the text field element and an array of possible autocompleted values:*/
6481 var currentFocus;
6482 /*execute a function when someone writes in the text field:*/
6483 inp.addEventListener("input", function(e) {
6484 var a, b, i, val = this.value;
6485 /*close any already open lists of autocompleted values*/
6486 closeAllLists();
6487 if (!val) {
6488 return false;
6489 }
6490 currentFocus = -1;
6491 /*create a DIV element that will contain the items (values):*/
6492 a = document.createElement("DIV");
6493 a.setAttribute("id", this.id + "autocomplete-list");
6494 a.setAttribute("class", "autocomplete-items");
6495 /*append the DIV element as a child of the autocomplete container:*/
6496 this.parentNode.appendChild(a);
6497 /*for each item in the array...*/
6498 for (i = 0; i < arr.length; i++) {
6499 /*check if the item starts with the same letters as the text field value:*/
6500 if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
6501 /*create a DIV element for each matching element:*/
6502 b = document.createElement("DIV");
6503 /*make the matching letters bold:*/
6504 b.innerHTML = "<strong>" + arr[i].substr(0, val.length) + "</strong>";
6505 b.innerHTML += arr[i].substr(val.length);
6506 /*insert a input field that will hold the current array item's value:*/
6507 b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
6508 /*execute a function when someone clicks on the item value (DIV element):*/
6509 b.addEventListener("click", function(e) {
6510 /*insert the value for the autocomplete text field:*/
6511 inp.value = this.getElementsByTagName("input")[0].value;
6512 /*close the list of autocompleted values,
6513 (or any other open lists of autocompleted values:*/
6514 closeAllLists();
6515 });
6516 a.appendChild(b);
6517 }
6518 }
6519 });
6520 /*execute a function presses a key on the keyboard:*/
6521 inp.addEventListener("keydown", function(e) {
6522 var x = document.getElementById(this.id + "autocomplete-list");
6523 if (x) x = x.getElementsByTagName("div");
6524 if (e.keyCode == 40) {
6525 /*If the arrow DOWN key is pressed,
6526 increase the currentFocus variable:*/
6527 currentFocus++;
6528 /*and and make the current item more visible:*/
6529 addActive(x);
6530 } else if (e.keyCode == 38) { //up
6531 /*If the arrow UP key is pressed,
6532 decrease the currentFocus variable:*/
6533 currentFocus--;
6534 /*and and make the current item more visible:*/
6535 addActive(x);
6536 } else if (e.keyCode == 13) {
6537 /*If the ENTER key is pressed, prevent the form from being submitted,*/
6538 e.preventDefault();
6539 if (currentFocus > -1) {
6540 /*and simulate a click on the "active" item:*/
6541 if (x) x[currentFocus].click();
6542 }
6543 }
6544 });
6545
6546 function addActive(x) {
6547 /*a function to classify an item as "active":*/
6548 if (!x) return false;
6549 /*start by removing the "active" class on all items:*/
6550 removeActive(x);
6551 if (currentFocus >= x.length) currentFocus = 0;
6552 if (currentFocus < 0) currentFocus = (x.length - 1);
6553 /*add class "autocomplete-active":*/
6554 x[currentFocus].classList.add("autocomplete-active");
6555 }
6556
6557 function removeActive(x) {
6558 /*a function to remove the "active" class from all autocomplete items:*/
6559 for (var i = 0; i < x.length; i++) {
6560 x[i].classList.remove("autocomplete-active");
6561 }
6562 }
6563
6564 function closeAllLists(elmnt) {
6565 /*close all autocomplete lists in the document,
6566 except the one passed as an argument:*/
6567 var x = document.getElementsByClassName("autocomplete-items");
6568 for (var i = 0; i < x.length; i++) {
6569 if (elmnt != x[i] && elmnt != inp) {
6570 x[i].parentNode.removeChild(x[i]);
6571 }
6572 }
6573 }
6574 /*execute a function when someone clicks in the document:*/
6575 document.addEventListener("click", function(e) {
6576 closeAllLists(e.target);
6577 });
6578}
6579
6580function autoFillIn(prefix = '') {
6581 var fc = '';
6582 if (prefix === 'group') {
6583 fc = 'fc';
6584 }
6585 var eurl = $('#post' + fc + 'eurl').val();
6586 $("#dialog-confirm").attr("title", "Autofill");
6587 $("#dialog-confirm").html('Would you like to autofill?');
6588 $("#dialog-confirm").dialog({
6589 resizable: false,
6590 height: "auto",
6591 width: 400,
6592 modal: true,
6593 dialogClass: 'dialogWindow',
6594 buttons: {
6595 "Yes": function() {
6596 $(this).dialog("close");
6597 $("#loading-img").fadeIn(500);
6598 $.ajax({
6599 type: "POST",
6600 url: "api.php",
6601 data: {
6602 mode: "get" + prefix,
6603 id: eurl
6604 },
6605 success: function(data) {
6606 if (typeof data.status != 'undefined' && data.status == '255') {
6607 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6608 return;
6609 }
6610
6611 var row = JSON.parse(data)[0];
6612 var server = row['server'];
6613 var ward = row['ward'];
6614 var psize = row['psize'];
6615 var manager = row['manager'];
6616 var housing = row['housing'];
6617 var posteurl = row['posteurl'];
6618 var plot = row['plot'];
6619 var apt = row['apt'];
6620 $('#e-server').val(server);
6621 $('#e-housing').val(housing);
6622 $('#e-ward').val(ward);
6623 $('#e-plot').val(plot);
6624 $('#e-apt').val(apt);
6625 $('#e-psize').val(psize);
6626 mgrs = 1;
6627 if (isJson(manager)) {
6628 manager = JSON.parse(manager);
6629 $('#e-0').val(manager.shift());
6630 manager.forEach(function(item) {
6631 addManager(item, 'e-');
6632 });
6633 } else {
6634 $('#e-0').val(manager);
6635 }
6636
6637 $("#loading-img").fadeOut(500);
6638 },
6639 error: function() {
6640 msg("An error occurred processing your request");
6641 $("#loading-img").fadeOut(500);
6642 }
6643 });
6644 },
6645 Cancel: function() {
6646 $(this).dialog("close");
6647 }
6648 }
6649 });
6650}
6651
6652function deletePost(eurl, title, prefix = '') {
6653 $("#dialog-confirm").attr("title", title);
6654 $("#dialog-confirm").html('Are you sure you want to delete ' + title + '? This action cannot be undone!');
6655 $("#dialog-confirm").dialog({
6656 resizable: false,
6657 height: "auto",
6658 width: "auto",
6659 modal: true,
6660 buttons: {
6661 "Yes": function() {
6662 $(this).dialog("close");
6663 $("#loading-img").fadeIn(500);
6664 $.ajax({
6665 type: "POST",
6666 url: "api.php",
6667 data: {
6668 mode: "delete",
6669 eurl: prefix + eurl
6670 },
6671 success: function(data) {
6672 if (typeof data.status != 'undefined' && data.status == '255') {
6673 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6674 return;
6675 }
6676
6677 if (data == '1') {
6678 $("#loading-img").fadeOut(500);
6679 msg("An error occurred processing your request!<br>" + data);
6680 return;
6681 }
6682 msg("Post deleted!");
6683 if ($('#postDiv').is(":visible")) {
6684 $('#postDiv').fadeOut();
6685 } else {
6686 collapsePost(data);
6687 $( `tr[eurl='${eurl}']` )
6688 $( `tr[eurl='${eurl}']` ).fadeOut(1500, function(){
6689 $( `tr[eurl='${eurl}']` ).remove();
6690 })
6691
6692 }
6693 $("#loading-img").fadeOut(500);
6694 },
6695 error: function() {
6696 msg("An error occurred processing your request");
6697 $("#loading-img").fadeOut(500);
6698 }
6699 });
6700 },
6701 Cancel: function() {
6702 $(this).dialog("close");
6703 }
6704 }
6705 });
6706}
6707
6708function modPic(mode, id, type = '', eurl = '', prefix = '') {
6709 if (mode == 'remove') {
6710 $.ajax({
6711 type: "POST",
6712 url: "api.php",
6713 data: {
6714 mode: "deletePic",
6715 id: id,
6716 prefix: prefix
6717 },
6718 success: function(data) {
6719 if (typeof data.status != 'undefined' && data.status == '255') {
6720 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6721 return;
6722 }
6723
6724 if (data == '1') {
6725 $("#loading-img").fadeOut(500);
6726 msg("An error occurred processing your request!<br>return: " + data);
6727 return;
6728 }
6729 var prefix = data;
6730 var realprefix = prefix;
6731 if (prefix == 'fc-') {
6732 realprefix = 'group-';
6733 }
6734 if (prefix == 'e-') {
6735 realprefix = 'event-';
6736 }
6737 msg("Media deleted!");
6738 editPictures(wizEurl, '#wizard', $('#' + prefix + 'title').val(), realprefix);
6739 $("#loading-img").fadeOut(500);
6740 },
6741 error: function() {
6742 msg("An error occurred processing your request");
6743 $("#loading-img").fadeOut(500);
6744 }
6745 });
6746 }
6747 if (mode == 'bg') {
6748 var checked = '0';
6749 if (document.getElementById('bg-' + id).checked) {
6750 checked = '1';
6751 }
6752 $.ajax({
6753 type: "POST",
6754 url: "api.php",
6755 data: {
6756 mode: "bgPic",
6757 id: id,
6758 checked: checked,
6759 prefix: prefix
6760 },
6761 success: function(data) {
6762 if (typeof data.status != 'undefined' && data.status == '255') {
6763 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6764 return;
6765 }
6766
6767 if (data != '0') {
6768 $("#loading-img").fadeOut(500);
6769 msg("An error occurred processing your request!<br>" + data);
6770 return;
6771 }
6772 msg("Media updated!");
6773 $("#loading-img").fadeOut(500);
6774 },
6775 error: function() {
6776 msg("An error occurred processing your request");
6777 $("#loading-img").fadeOut(500);
6778 }
6779 });
6780 }
6781 if (mode == 'main') {
6782 msg('Processing...', '');
6783 $.ajax({
6784 type: "POST",
6785 url: "api.php",
6786 data: {
6787 mode: "mainPic",
6788 id: id,
6789 type: type,
6790 prefix: prefix
6791 },
6792 success: function(data) {
6793 if (typeof data.status != 'undefined' && data.status == '255') {
6794 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6795 return;
6796 }
6797
6798 if (data == '1') {
6799 $("#loading-img").fadeOut(500);
6800 msg("An error occurred processing your request!<br>" + data);
6801 return;
6802 }
6803 msg("Media updated!");
6804 $("#loading-img").fadeOut(500);
6805 },
6806 error: function() {
6807 msg("An error occurred processing your request");
6808 $("#loading-img").fadeOut(500);
6809 }
6810 });
6811 }
6812
6813 if (mode == 'banner') {
6814 msg('Processing...', '');
6815 $.ajax({
6816 type: "POST",
6817 url: "api.php",
6818 data: {
6819 mode: "bannerPic",
6820 id: id,
6821 type: type,
6822 prefix: prefix
6823 },
6824 success: function(data) {
6825 if (typeof data.status != 'undefined' && data.status == '255') {
6826 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
6827 return;
6828 }
6829
6830 if (data == '1') {
6831 $("#loading-img").fadeOut(500);
6832 msg("An error occurred processing your request!<br>" + data);
6833 return;
6834 }
6835 var prefix = data;
6836 var realprefix = prefix;
6837 // if (prefix == 'fc-') {
6838 // realprefix = 'group-';
6839 // }
6840 // if (prefix == 'e-') {
6841 // realprefix = 'event-';
6842 // }
6843 msg("Media updated!");
6844 editPictures(wizEurl, '#wizard','',prefix);
6845 $("#loading-img").fadeOut(500);
6846 },
6847 error: function() {
6848 msg("An error occurred processing your request");
6849 $("#loading-img").fadeOut(500);
6850 }
6851 });
6852 }
6853}
6854
6855var slideIndex = [];
6856
6857function plusSlides(n, eurl) {
6858 showSlides(slideIndex[eurl] += n, eurl);
6859}
6860
6861function currentSlide(n, eurl) {
6862 showSlides(slideIndex[eurl] = n, eurl);
6863}
6864
6865function showSlides(n, eurl) {
6866
6867
6868 var i;
6869 var slides = document.getElementsByName("ss-" + eurl);
6870 if (n > slides.length) {
6871 slideIndex[eurl] = 1
6872 }
6873 if (n < 1) {
6874 slideIndex[eurl] = slides.length
6875 }
6876 for (i = 0; i < slides.length; i++) {
6877 $(slides[i]).fadeOut();
6878 }
6879 if (typeof slides[slideIndex[eurl] - 1] != 'undefined') {
6880 $(slides[slideIndex[eurl] - 1]).fadeIn();
6881 } else {
6882 $(`#slideshow-container-${eurl}`).html(`<img src='getimage.php?1' width="100%" class='imgrounded imgborder imgdropshadow'>`);
6883 $(`#ss-nav-${eurl}`).fadeOut();
6884 }
6885}
6886
6887function lodeLink(character = $('#UMcharacter').val(), userServer = $('#um-server').val()) {
6888 $("#loading-img").fadeIn(500);
6889 msg("Searching...", '');
6890 $.get("https://xivapi.com/character/search", {
6891 name: character,
6892 server: userServer
6893 })
6894 .done(function(data) {
6895 $("#loading-img").fadeOut(500);
6896 var results = data["Results"];
6897 if (results.length == 0) {
6898 msg("No results found!");
6899 } else {
6900 var output = '<select class="event-info black lodeResults" id="lodeResults">';
6901 for (var i in results) {
6902 var result = results[i];
6903 var id = result['ID'];
6904 var name = result['Name'];
6905 var server = result['Server'];
6906 output = `${output}<option value="${id}">${name} (${server})</option>`;
6907 }
6908 output = `${output}</select><input type="button" class="defaultBtn" value="Import" onclick="importLodeID();"><input type="button" value="Cancel" class='defaultBtn' onclick="$('.lodelinkSearch').fadeOut()">`;
6909 }
6910 $('#popup').html(output);
6911 $('#popup').addClass("lodelinkSearch");
6912 $('#popup').fadeIn();
6913 }).fail(function(data) {
6914 var data = data['responseJSON'];
6915 $("#loading-img").fadeOut(500);
6916 msg('Error ' + data['ExCode'] + ': ' + data['Message']);
6917 });
6918}
6919
6920function importLodeID() {
6921 lodeid = $('#lodeResults').val();
6922 // $.getJSON("https://xivapi.com/character/"+lodeid, function (data, textStatus, jqXHR){
6923 // avatar = data['Character']['Avatar'];
6924 // bio = data['Character']['Bio'];
6925 // $('#avatar').attr("src", avatar);
6926 // });
6927
6928 $.ajax({
6929 type: "POST",
6930 url: "user.php",
6931 data: {
6932 lodeid: lodeid
6933 },
6934 success: function(data) {
6935 if (data.status == 0) {
6936 $("#lodeLink").html(`<td>Linked to Lodestone</td><td>${lodeid}<input type="hidden" value="${lodeid}" name="lodeid"></td>`);
6937 $('#avatar').attr("src", data.avatar);
6938 } else {
6939 msg("Error verifying your code!");
6940 }
6941 // msg("Lodestone ID imported. Click Apply to save data");
6942 },
6943 dataType: "json"
6944 });
6945}
6946
6947function autofillGroup(category, server, title,lodeid) {
6948 // msg("Lodestone API access unavailable");
6949 // return;
6950 if (category == '' || server == '' || title == '' || lodeid != '0') { return; }
6951
6952 var pcategory = category;
6953 // var category = $('#category').val();
6954 // var server = $('#server').val();
6955 // var name = $('#title').val();
6956
6957 switch (category) {
6958 case "Free Company":
6959 category = 'freecompany';
6960 break;
6961 case "PVP Team":
6962 category = 'pvpteam';
6963 break;
6964 case "Linkshell":
6965 category = 'linkshell';
6966 break;
6967 }
6968
6969 if (category == pcategory) { return; }
6970
6971 $("#loading-img").fadeIn(500);
6972 $('#lodeid').html("<option disabled value=''>Loading results...</option>");
6973
6974 // msg("Loading results...", '');
6975 $.get("https://xivapi.com/" + category + "/search", {
6976 name: title,
6977 server: server
6978 })
6979 .done(function(data) {
6980 $("#loading-img").fadeOut(500);
6981 var results = data["Results"];
6982 if (results.length == 0) {
6983 output="<option disabled value=''>No Results Found</option>";
6984 $('#popup').fadeOut();
6985 } else {
6986 var output = '<option disabled value="">Select your group</option>';
6987 for (var i in results) {
6988 var result = results[i];
6989 var id = result['ID'];
6990 var name = result['Name'];
6991 var server = result['Server'];
6992 output = `${output}<option value="${id}">${name} (${server})</option>`;
6993 }
6994 // output = `${output}`;
6995 }
6996 $('#lodeid').html(output);
6997 $('#popup').fadeOut();
6998 $('#lodeImport').fadeIn();
6999 }).fail(function(data) {
7000 var data = data['responseJSON'];
7001 $("#loading-img").fadeOut(500);
7002 msg('Error ' + data['ExCode'] + ': ' + data['Message']);
7003 });
7004}
7005
7006function showImport(category,title) {
7007 // var category = $('#category').val();
7008 // var name = $('#fc-title').val();
7009 if (title != '') {
7010 switch (category) {
7011 case 'Free Company':
7012 $('#fc-option').fadeIn();
7013 $('import').fadeIn();
7014 break;
7015 case 'Linkshell':
7016 $('#fc-option').fadeOut();
7017 $('import').fadeIn();
7018 break;
7019 case 'PVP Team':
7020 $('#fc-option').fadeOut();
7021 $('import').fadeIn();
7022 break;
7023 default:
7024 $('#fc-option').fadeOut();
7025 $('import').fadeOut();
7026 break;
7027 }
7028 }
7029}
7030
7031function importFromLode(category,lodeid = 0) {
7032 return false;
7033 var id = $("#lodeResults").val();
7034 $("#loading-img").fadeIn(500);
7035 msg("Importing...", '');
7036 $.get("https://xivapi.com/" + category + "/" + id, {
7037 extended: 1
7038 })
7039 .done(function(data) {
7040 $("#loading-img").fadeOut(500);
7041 $("#popup").fadeOut();
7042 if (category == 'character') {
7043 var lodeid = row['ID'];
7044 $("#lodeLink").html(`<td>Linked to Lodestone</td><td><input type="text" name="lodeid" id="lodeid" disabled value="${lodeid}"></td>`);
7045 } else {
7046 var row = data['FreeCompany'];
7047 var server = row['Server'];
7048 var tag = row['Tag'];
7049 var crest1 = row['Crest'][0];
7050 var crest2 = row['Crest'][1];
7051 var crest3 = row['Crest'][2];
7052 var title = row['Name'];
7053 var rank = row['Rank'];
7054 var housing = row['Estate'];
7055 var plot = housing['Plot'];
7056 if (row['Recruitment'] === "Open") {
7057 $('#fc-recruit').prop("checked", true);
7058 } else {
7059 $('#fc-recruit').prop("checked", false);
7060 }
7061 if (plot === null) {
7062 $('#fc-estate').prop("checked", false);
7063 $('fc-where').fadeOut();
7064 } else {
7065 $('#fc-estate').prop("checked", true);
7066 $('fc-where').fadeIn();
7067 var location = plot.split(",");
7068 var plot = location[0].split(" ")[1];
7069 var ward = location[1].split(" ")[1];
7070 var psize = location[2].split("(")[1].split(")")[0].trim();
7071 var housing = location[2].split("(")[0].trim();
7072 if (housing == 'The Mist') {
7073 housing = 'Mist';
7074 }
7075 }
7076 $('#fc-crest1').attr('src', crest1);
7077 $('#fc-crest1').fadeIn();
7078 $('#fc-crest2').attr('src', crest2);
7079 $('#fc-crest2').fadeIn();
7080 $('#fc-crest3').attr('src', crest3);
7081 $('#fc-crest3').fadeIn();
7082 $('#fc-title').val(title);
7083 $('#fc-title').trigger('change');
7084 $('#fc-eurl').trigger('change');
7085 $('#fc-server').val(server);
7086 $('#fc-housing').val(housing);
7087 $('#fc-rank').val(rank);
7088 $('#fc-tag').val(tag);
7089 $('#fc-plot').val(plot);
7090 $('#fc-psize').val(psize);
7091 $('#fc-ward').val(ward);
7092 }
7093 });
7094}
7095var postTimes = '';
7096
7097function resizeInput() {
7098 $(this).attr('size', $(this).val().length);
7099}
7100
7101function posts(mode = '', eurl = '', data = '') {
7102 var jsonData = {};
7103 jsonData["mode"] = mode;
7104 jsonData["eurl"] = eurl;
7105 jsonData["data"] = data;
7106
7107 $.ajax({
7108 type: 'POST',
7109 url: 'api.php',
7110 data: jsonData,
7111 dataType: 'json',
7112 success: function(rows) {
7113 if (typeof rows.status != 'undefined' && rows.status == '255') {
7114 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
7115 return;
7116 }
7117 rows = rows.posts;
7118 for (var i in rows) {
7119 if (!isNumber(i)) {
7120 continue;
7121 }
7122 var row = rows[i];
7123 var id = row['id'];
7124 wizId = id;
7125 if (id) {
7126 $('#wizView').color('green');
7127 } else {
7128 $('#wizView').color('grey');
7129 }
7130 var day = row['day'];
7131 var limited = row['limited'];
7132 var title = decodeEntities(row['title']);
7133 var escapedTitle = row['title'].replace(/'/g, "\\'");
7134 var eurl = row['eurl'];
7135 curWizEurl = eurl;
7136 var category = row['category'];
7137 var calid = row['calid'];
7138 if (typeof calid == null) {
7139 calid = '';
7140 }
7141 var psize = row['psize'];
7142 var rating = row['rating'];
7143 var free = row['free'];
7144 var rent = row['rent'];
7145 var row_public = row['public'];
7146 var newcomers = row['newcomers'];
7147 var ffxivrpfields = row['ffxivrpfields'];
7148 var hiringurl = row['hiringurl'];
7149 var eventurl = row['eventurl'];
7150 var eventeurl = row['eventeurl'];
7151 populateEventeurl(eventeurl, 'nodupes', eurl);
7152 var owner = row['owner'];
7153 var dc = row['datacenter'];
7154 populatedcs('#dc', dc);
7155 var startdate = row['startdate'];
7156 if (moment.utc(row['otime'], 'hh:mm A')._isValid) {
7157 var otime = moment.utc(row['otime'], 'hh:mm A').add(offset, 'hour').format('h:mm A');
7158 }
7159 if (moment.utc(row['ctime'], 'hh:mm A')._isValid) {
7160 var ctime = moment.utc(row['ctime'], 'hh:mm A').add(offset, 'hour').format('h:mm A');
7161 }
7162 var website = row['website'];
7163 var menu = row['menu'];
7164 var calurl = row['calurl'];
7165 var gcid = row['gcid'];
7166 var discord = row['discord'];
7167 var twitter = row['twitter'];
7168 var lstream = row['lstream'];
7169 var description = decodeEntities(row['description']);
7170 var note = decodeEntities(row['note']);
7171 var shoutmsg = decodeEntities(row['shoutmsg']);
7172 var notedate = row['notedate'];
7173 var closeduntil = row['closeduntil'];
7174 var closedmsg = decodeEntities(row['closedmsg']);
7175 var manager = decodeEntities(row['manager']);
7176 var server = row['server'];
7177 var ward = row['ward'];
7178 var featured = row['featured'];
7179 var plot = row['plot'];
7180 var apt = row['apt'];
7181 var customtimes = row['customtimes'];
7182 var ownerName = row['ownerName'];
7183 var housing = decodeEntities(row['housing']);
7184 var aetheryte = decodeEntities(row['aetheryte']);
7185 var isapproved = '';
7186 if (isJson(day)) {
7187 day = JSON.parse(day);
7188 } else {
7189 var day = '["' + day + '"]';
7190 }
7191 if (isJson(manager)) {
7192 manager = JSON.parse(manager);
7193 } else {
7194 manager = decodeEntities(manager);
7195 }
7196
7197 if (mode == 'edit') {
7198 $("#submitpost").fadeOut(500);
7199 $('#inputfile-post').fadeOut();
7200 $("#dc").val(dc).trigger('change');
7201 $('#id').val(id);
7202 $("#dayOpt").val(day); //.trigger('change');
7203
7204 postTimes = decodeEntities(row['times']);
7205
7206 daysOpen(postTimes);
7207
7208 $('#eventeurl').html('<option value="">Loading events...</option>');
7209
7210 $('#dayOpt').change(function() {
7211 somethingChangedFunc(true);
7212 $('#wizSave').animate({
7213 backgroundColor: '#FFDF00'
7214 });
7215 });
7216
7217 $('#title').val(title);
7218 wizTitle = title;
7219 $('#wizTitle').html(`<h1>${title}</h1>`);
7220 if (domain != 'roleplayfinder.com' && row.tinyurl != '' && row.tinyurl.includes('rpxiv.online')) {
7221 $('#tinyurl').attr('href', row.tinyurl);
7222
7223 var tinyurl = row['tinyurl'].split('cs');
7224 var tiny = `<a href='${row.tinyurl}' id='tinyurl' class='form-control eurl link' target="_blank" name='tinyurl'>`+tinyurl[0]+`cs</a><input type='text' name='customtiny' id='customtiny' onchange="checktinyurl(this};" value="`+tinyurl[1]+`">`;
7225 $('tinyurl').html(tiny);
7226 } else if (domain != 'roleplayfinder.com' && row.tinyurl != '') {
7227 $('tinyurl').html(`<a href='${row.tinyurl}' id='tinyurl' class='form-control eurl link' target="_blank" name='tinyurl'>${row.tinyurl}</a>`);
7228 }
7229 if (calurl != 'N/A' && calurl != '') {
7230 if (gcid == '1') {
7231 $('gcid').html("<input type='hidden' name='gcid' value='LINKED'>Linked! <sync class='link'>Sync Now</sync>");
7232 } else if (gcid == '2') {
7233 $('gcid').html(`Linkup Error. Could not determine CalendarID!
7234 <input type='text' name='gcid' placeholder='You can manually specify the GcID here'>`);
7235 } else {
7236 $('gcid').text("Unlinked");
7237 }
7238 }
7239 $('#eurl').val(eurl);
7240 $('#calurl').val(calurl);
7241 $('#cureurl').val(eurl);
7242 $('#otime').val(otime);
7243 $('#ctime').val(ctime);
7244 $('#customtimes').val(customtimes);
7245 $('#posttimezone').val($('#usertimezone').val());
7246 $('#description').val(description);
7247 $('#closedmsg').val(closedmsg);
7248 $('#psize').val(psize);
7249 $('#note').val(note);
7250 $('#location').val(row.location);
7251 $('#shoutmsg').val(shoutmsg);
7252 $('#hiringurl').val(hiringurl);
7253 wpaSelect();
7254 $('#eventurl').val(eventurl);
7255
7256 if (notedate != '0000-00-00') {
7257 notedate = moment(notedate, "YYYY-MM-DD").format("MM/DD/YYYY");
7258 }
7259 $('#notedate').val(notedate);
7260 jQuery('#notedate').datepicker({
7261 format: 'YYYY-MM-DD',
7262 defaultValue: date
7263 });
7264 if (closeduntil != '0000-00-00 00:00:00') {
7265 closeduntil = moment(closeduntil, "YYYY-MM-DD HH:mm:ss").format("MM/DD/YYYY hh:mm A");
7266 }
7267 $('#closeduntil').val(closeduntil);
7268 jQuery('#closeduntil').datetimepicker({
7269 allowBlank: true,
7270 parentID: '#timepickerdiv',
7271 theme: "dark",
7272 validateOnBlur: false,
7273 step: 15,
7274 format: 'MM/DD/Y h:mm A',
7275 formatTime: "h:mm A",
7276 onShow: function() {
7277 $('#timepickerdiv').fadeIn();
7278 },
7279 onClose: function() {
7280 $('#timepickerdiv').fadeOut();
7281 },
7282 formatDate: "m/d/Y"
7283 });
7284
7285 if (row['sametime'] == 1) {
7286 $('#timeSame').prop("checked", true);
7287 $('#timeSame').trigger('change');
7288 } else {
7289 $('#timeSame').prop("checked", false);
7290 }
7291
7292 $('#regentinyurl').prop('checked', false);
7293
7294 $('#timeSame').change(function() {
7295 somethingChangedFunc(true);
7296 $('#wizSave').animate({
7297 backgroundColor: '#FFDF00'
7298 });
7299 });
7300
7301 if (row['openrp'] == 1) {
7302 $('#openrp').prop("checked", true);
7303 } else {
7304 $('#openrp').prop("checked", false);
7305 }
7306
7307 if (row['free'] == 1) {
7308 $('#free').prop("checked", true);
7309 } else {
7310 $('#free').prop("checked", false);
7311 }
7312
7313 if (row['public'] == 1) {
7314 $('#public').prop("checked", true);
7315 } else {
7316 $('#public').prop("checked", false);
7317 }
7318
7319 if (row['rent'] == 1) {
7320 $('#rent').prop("checked", true);
7321 } else {
7322 $('#rent').prop("checked", false);
7323 }
7324
7325 $('#rpt1').prop("checked", false);
7326 if (row['newcomers'] != '') {
7327 var rpt = row['newcomers'];
7328 $('#rpt'+rpt).prop("checked", true);
7329 } else {
7330 $('#rpt0').val("0");
7331 }
7332
7333 $('#rating0').prop("checked", true);
7334 if (row['rating'] != 0) {
7335 $('#rating' + row['rating']).prop("checked", true);
7336 }
7337
7338 var hiring = decodeEntities(row['hiring']);
7339 if (isJson(hiring)) {
7340 hiring = JSON.parse(hiring);
7341 // console.log(hiring);
7342 }
7343 if (ffxivrpfields != '' && isJson(ffxivrpfields)) {
7344 ffxivrpfields = JSON.parse(ffxivrpfields);
7345 for (var key in ffxivrpfields) {
7346 if (ffxivrpfields[key] == 1) {
7347 $('#event-' + key).prop("checked", true);
7348 } else {
7349 $('#event-' + key).prop("checked", false);
7350 }
7351 }
7352 if ($('.ffxivlocation:checked').length == $('.ffxivlocation').length) {
7353 $('#event-alllocation').prop("checked", true);
7354 } else {
7355 $('#event-alllocation').prop("checked", false);
7356 }
7357 }
7358
7359 $(".ffxivlocation").change(function() {
7360 if ($('.ffxivlocation:checked').length == $('.ffxivlocation').length) {
7361 $('#event-alllocation').prop("checked", true);
7362 } else {
7363 $('#event-alllocation').prop("checked", false);
7364 }
7365 });
7366
7367 if (row['closed'] != 0) {
7368 $('#closed').prop("checked", true);
7369 setClosed();
7370 $('#closedType' + row['closed']).prop("checked", true);
7371 } else {
7372 $('#closed').prop("checked", false);
7373 setClosed();
7374 }
7375 if (row['listed'] == 1) {
7376 $('#listed').prop("checked", true);
7377 } else {
7378 $('#listed').prop("checked", false);
7379 }
7380 if (row['approved'] == 1) {
7381 $('#approved').prop("checked", true);
7382 } else {
7383 $('#approved').prop("checked", false);
7384 }
7385 $('#weekly').prop("checked", true);
7386 if (row['biweekly'] == 1) {
7387 $('#biweekly').prop("checked", true);
7388 startdate = moment(startdate, 'YYYY-MM-DD').format('MM/DD/YYYY');
7389 $('#post-datetimepicker').val(startdate);
7390 $('#biweeklystart').fadeIn();
7391 jQuery('#post-datetimepicker').datepicker({
7392 dateonly: true,
7393 format: 'YYYY-MM-DD'
7394 });
7395 }
7396 if (row['biweekly'] == 2) {
7397 $('#monthly').prop("checked", true);
7398 startdate = moment(startdate, 'YYYY-MM-DD').format('MM/DD/YYYY');
7399 $('#post-datetimepicker').val(startdate);
7400 $('#biweeklystart').fadeIn();
7401 jQuery('#post-datetimepicker').datepicker({
7402 dateonly: true,
7403 format: 'YYYY-MM-DD'
7404 });
7405 }
7406 $('#server').val(server);
7407 $('#ward').val(ward);
7408 $('#plot').val(plot);
7409 $('#apt').val(apt);
7410
7411 if (category != null) {
7412 category = unique(category.split(' #'));
7413 category = category.toString().replace("#", "");
7414 category = category.replace(/ #/g, ",").split(',');
7415 } else {
7416 category = '';
7417 }
7418 // console.log(currentTags, currentKeywords);
7419
7420 $('#post-category').tagEditor('destroy');
7421 $("#post-category").prop("disabled", false);
7422 $('#post-category').tagEditor({
7423 autocomplete: {
7424 delay: 0, // show suggestions immediately
7425 source: currentTags,
7426 position: {
7427 collision: 'flip'
7428 } // automatic menu position up/down
7429 },
7430 onChange: function(field, editor, tags) {
7431 somethingChangedFunc(true);
7432 $('#wizSave, #wizSaveValidate').color('yellow');
7433 },
7434 initialTags: category,
7435 forceLowercase: true,
7436 placeholder: 'Post tags...'
7437 });
7438
7439 $('#housing').val(housing);
7440 setaetheryte();
7441 $('#website').val(website);
7442 $('#menu').val(menu);
7443 $('#discord').val(discord);
7444 $('#twitter').val(twitter);
7445 $('#lstream').val(lstream);
7446 $('#aetheryte').val(aetheryte);
7447 $('#submit_form').text("Update");
7448 $('#clear').text("Cancel");
7449 $("#img").attr("src", "getimage.php?" + eurl);
7450 $('#pictureid').val(row['pictureid']);
7451
7452 if (acct == '2') {
7453 if (row['ownerName'] == 'undefined') {
7454 row['ownerName'] = user;
7455 }
7456 $('#owner').val(row['ownerName']);
7457 if (row['featured'] == 1) {
7458 $('#featured').prop("checked", true);
7459 } else {
7460 $('#featured').prop("checked", false);
7461 }
7462 if (row['limited'] == 1) {
7463 $('#wizSaveValidate').remove();
7464 $('#limited').prop("checked", true);
7465 } else {
7466 $('#limited').prop("checked", false);
7467 }
7468 $('#vacant1, #vacant2').prop("checked", false);
7469 if (row['vacant'] != 0) {
7470 var vacant = row['vacant'];
7471 $('#vacant'+vacant).prop("checked", true);
7472 } else {
7473 $('#vacant0').val("0");
7474 }
7475 // if (row['vacant'] == 1) {
7476 // $('#vacant').prop("checked", true);
7477 // } else {
7478 // $('#vacant').prop("checked", false);
7479 // }
7480 }
7481
7482 $('#dc, #server, #aetheryte, #housing').change(function() {
7483 somethingChangedFunc(true);
7484 $('#wizSave').animate({
7485 backgroundColor: '#FFDF00'
7486 });
7487 });
7488
7489 somethingChangedFunc(false);
7490 $('#wizSave').animate({
7491 backgroundColor: '#CCC'
7492 });
7493
7494 if (calid == null) {
7495 calid = '';
7496 }
7497 if (calid.length != 0) {
7498 $("#calendar").prop("checked", true);
7499 }
7500
7501 hrng = 0;
7502 var hrngLen = Object.keys(hiring).length - 1;
7503 $("#hiringMore").html('');
7504 if (hrngLen > 0) {
7505 for (var hrng in hiring) {
7506 if (hiring.hasOwnProperty(hrng) && hiring[hrng] != null) {
7507 addHiring(hiring[hrng]['position'], hiring[hrng]['rate']);
7508 }
7509 }
7510 }
7511 checkWizEurl(eurl);
7512
7513 mgrs = 1;
7514 if (isJson(manager)) {
7515 $('#0').val(manager.shift());
7516 manager.forEach(function(item) {
7517 addManager(decodeEntities(item));
7518 });
7519 } else {
7520 $('#0').val(manager);
7521 }
7522 $("#submitpost").fadeIn(1500);
7523 }
7524 if ((mode == 'show') || (mode == '')) {
7525 if (owner == '1' || acct == "2") {
7526 var manage = `<span class='icon link'><img src='edit.png' onclick='postWizard("${eurl}");' alt='Edit Post'></span><span class='icon link'><img src='delete.png' alt='Delete Event'></span>`;
7527 } else {
7528 var manage = "";
7529 }
7530 $('#posts').append("<div class='event-wrapper' id='event-" + id + "'>" + isapproved + "<br><div class='event-title'><a href='./?page=events&eventid=" + id + "'>" + title + " <img src='link.png' height='30px'></a>" + manage + "</div><br><div id='wrapper'><div class='event-photo left'><center><img src='getimage.php?" + photo + "' width='100%'></center></div><div class='event-info right'>When: <p>" + prettyDate(date) + "<br>Time Zone: " + timezone + "</p><br>Where: <p>" + location + "</p><br>Details: <p>" + description + "</p><br>Event Manager(s): <p>" + niceList(manager) + "</p></div></div></div>");
7531 }
7532 }
7533 }
7534 });
7535}
7536
7537function groups(mode = '', eurl = '', data = '') {
7538 var jsonData = {};
7539 mode = 'group-'+mode;
7540 jsonData["mode"] = mode;
7541 jsonData["id"] = eurl;
7542 jsonData["eurl"] = eurl;
7543 jsonData["data"] = data;
7544 $.ajax({
7545 type: 'POST',
7546 url: 'api.php',
7547 data: jsonData,
7548 dataType: 'json',
7549 // processData: false,
7550 success: function(rows) {
7551 // if (!rows) { return; }
7552 if (typeof rows.message != 'undefined') {
7553 console.log(rows.message);
7554 $('#popup').fadeOut();
7555 $("#loading-img").fadeOut(500);
7556 // checkWizEurl();
7557 return;
7558 }
7559 if (typeof rows.status != 'undefined' && rows.status == '255') {
7560 msg("Login session expired! Click <a href='./?page=refreshlogin'>here</a> to refresh your login session.", '');
7561 return;
7562 }
7563
7564 rows = rows.posts;
7565 for (var i in rows) {
7566 if (!isNumber(i)) {
7567 continue;
7568 }
7569 var row = rows[i];
7570 var id = row['id'];
7571 $('#id').val(id);
7572 wizId = id;
7573 if (id) {
7574 $('#wizView').color('green');
7575 } else {
7576 $('#wizView').color('grey');
7577 }
7578 var title = decodeEntities(row['title']);
7579 var escapedTitle = row['title'].replace(/'/g, "\\'");
7580 var eurl = row['eurl'];
7581 var lodeid = row['lodeid'];
7582 curWizEurl = eurl;
7583 var dc = row['datacenter'];
7584 var tag = decodeEntities(row['tag']);
7585 var eurl = row['eurl'];
7586 var category = row['category'];
7587 var keywords = row['keywords'];
7588 var psize = row['psize'];
7589 var owner = row['owner'];
7590 var isPublic = row['public'];
7591 var rank = row['rank'];
7592 var website = row['website'];
7593 var discord = row['discord'];
7594 var description = decodeEntities(row['description']);
7595 var manager = row['manager'];
7596 var server = row['server'];
7597 var ward = row['ward'];
7598 var plot = row['plot'];
7599 var keywords = row['keywords'];
7600 var apt = row['apt'];
7601 if (typeof row.crest != 'undefined' ) {
7602 row['crest'] = row['crest'].replace(/(?:\\(.))/g, '$1');
7603 if (isJson(row['crest'])) {
7604 row['crest'] = JSON.parse(decodeEntities(row['crest']));
7605 }
7606 var crest1 = row['crest'][0];
7607 var crest2 = row['crest'][1];
7608 var crest3 = row['crest'][2];
7609 }
7610 var housing = decodeEntities(row['housing']);
7611 var aetheryte = decodeEntities(row['aetheryte']);
7612 var isapproved = '';
7613 if (isJson(manager)) {
7614 var manager = JSON.parse(manager);
7615 }
7616
7617 if (mode == 'group-edit') {
7618 // $("#submitfc").fadeOut(500);
7619
7620 if (row['recruit'] === "true") {
7621 $('#recruit').prop("checked", true);
7622 } else {
7623 $('#recruit').prop("checked", false);
7624 }
7625 if (row['public'] == "1") {
7626 $('#public').prop("checked", true);
7627 } else {
7628 $('#public').prop("checked", false);
7629 }
7630 if (row['plot'] === null || row['plot'] === '') {
7631 $('#estate').prop("checked", false);
7632 $('#where').fadeOut();
7633 } else {
7634 $('#estate').prop("checked", true);
7635 $('#where').fadeIn();
7636 }
7637 // $('##inputfile-fc').fadeOut();
7638
7639 if (wizMode == 'who' ) { autofillGroup(category,server,title,lodeid);}
7640 $('#crest1').attr('src', crest1);
7641 $('#crest1').fadeIn();
7642 $('#crest2').attr('src', crest2);
7643 $('#crest2').fadeIn();
7644 $('#crest3').attr('src', crest3);
7645 $('#crest3').fadeIn();
7646 // checkeurl(eurl,'group-');
7647 // console.log(dc);
7648 $('#dc').val(dc);
7649 $('#dc').trigger('change');
7650 $('#rank').val(rank);
7651 $('#title').val(title);
7652 $('#title').keyup(resizeInput).each(resizeInput);
7653 $('#rpt1').prop("checked", false);
7654 if (row['newcomers'] != '') {
7655 var rpt = row['newcomers'];
7656 $('#rpt'+rpt).prop("checked", true);
7657 } else {
7658 $('#rpt0').val("0");
7659 }
7660 if ( tag != '' ) { $('#tag').text("<<"+tag+">>"); }
7661 $('#eurl').val(eurl);
7662 $('#cureurl').val(eurl);
7663 $('#description').val(description);
7664 $('#keywords').val(keywords);
7665
7666
7667 if (keywords != null) {
7668 keywords = unique(keywords.split(' #'));
7669 keywords = keywords.toString().replace("#", "");
7670 keywords = keywords.replace(/ #/g, ",").split(',');
7671 } else {
7672 keywords = '';
7673 }
7674 // console.log(currentTags, currentKeywords);
7675
7676 $('#keywords').tagEditor('destroy');
7677 $("#keywords").prop("disabled", false);
7678 $('#keywords').tagEditor({
7679 autocomplete: {
7680 delay: 0, // show suggestions immediately
7681 source: currentKeywords,
7682 position: {
7683 collision: 'flip'
7684 } // automatic menu position up/down
7685 },
7686 onChange: function(field, editor, tags) {
7687 somethingChangedFunc(true);
7688 $('#wizSave, #wizSaveValidate').color('yellow');
7689 },
7690 initialTags: keywords,
7691 forceLowercase: true,
7692 placeholder: 'Group tags...'
7693 });
7694 $('#eventurl').val(row.eventurl);
7695
7696 if (row['listed'] == 1) {
7697 $('#listed').prop("checked", true);
7698 } else {
7699 $('#listed').prop("checked", false);
7700 }
7701 if (acct == 2) {
7702 if (row['approved'] == 1) {
7703 $('#approved').prop("checked", true);
7704 } else {
7705 $('#approved').prop("checked", false);
7706 }
7707 if (row['ownerName'] == 'undefined') {
7708 row['ownerName'] = user;
7709 }
7710 $('#owner').val(row['ownerName']);
7711 }
7712
7713
7714 $('#psize').val(psize);
7715 $('#server').val(server);
7716 $('#ward').val(ward);
7717 $('#plot').val(plot);
7718 $('#apt').val(apt);
7719 $('#category').val(category);
7720 $('#housing').val(housing);
7721 showImport(category, title);
7722 setaetheryte();
7723 $('#website').val(website);
7724 $('#discord').val(discord);
7725 $('#aetheryte').val(aetheryte);
7726 // $('#submit_form').text("Update");
7727 // $('#clear').text("Cancel");
7728 // $("img").attr("src", "getimage.php?group-" + eurl);
7729 // $('#pictureid').val(row['pictureid']);
7730 // console.log('checkwiz',eurl, id);
7731 mgrs = 1;
7732 if (isJson(manager)) {
7733 $('#0').val(manager.shift());
7734 manager.forEach(function(item) {
7735 addManager(decodeEntities(item));
7736 });
7737 } else {
7738 $('#0').val(decodeEntities(manager));
7739 }
7740 // $("#submitfc").fadeIn(1500);
7741 }
7742 // if ((mode == 'show') || (mode == '')) {
7743 // if (owner == '1' || acct == "2") {
7744 // var manage = "<span class='icon link'><img src='edit.png' onclick=\"posts('edit','" + id + "');\" alt='Edit Post'></span><span class='icon link'><img src='delete.png' alt='Delete Event'></span>";
7745 // } else {
7746 // var manage = "";
7747 // }
7748 // $('#groups').append("<div class='event-wrapper' id='event-" + id + "'>" + isapproved + "<br><div class='event-title'><a href='./?page=events&eventid=" + id + "'>" + title + " <img src='link.png' height='30px'></a>" + manage + "</div><br><div id='wrapper'><div class='event-photo left'><center><img src='getimage.php?" + photo + "' width='100%'></center></div><div class='event-info right'>When: <p>" + prettyDate(date) + "<br>Time Zone: " + timezone + "</p><br>Where: <p>" + location + "</p><br>Details: <p>" + description + "</p><br>Event Manager(s): <p>" + niceList(manager) + "</p></div></div></div>");
7749 // }
7750 }
7751 checkWizEurl(curWizEurl, 'group-', wizId);
7752 }
7753 });
7754}
7755
7756var dateFormat = function() {
7757 var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
7758 timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
7759 timezoneClip = /[^-+\dA-Z]/g,
7760 pad = function(val, len) {
7761 val = String(val);
7762 len = len || 2;
7763 while (val.length < len) val = "0" + val;
7764 return val;
7765 };
7766
7767 // Regexes and supporting functions are cached through closure
7768 return function(date, mask, utc) {
7769 var dF = dateFormat;
7770
7771 // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
7772 if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
7773 mask = date;
7774 date = undefined;
7775 }
7776
7777 // Passing date through Date applies Date.parse, if necessary
7778 date = date ? new Date(date) : new Date;
7779 if (isNaN(date)) throw SyntaxError("invalid date");
7780
7781 mask = String(dF.masks[mask] || mask || dF.masks["default"]);
7782
7783 // Allow setting the utc argument via the mask
7784 if (mask.slice(0, 4) == "UTC:") {
7785 mask = mask.slice(4);
7786 utc = true;
7787 }
7788
7789 var _ = utc ? "getUTC" : "get",
7790 d = date[_ + "Date"](),
7791 D = date[_ + "Day"](),
7792 m = date[_ + "Month"](),
7793 y = date[_ + "FullYear"](),
7794 H = date[_ + "Hours"](),
7795 M = date[_ + "Minutes"](),
7796 s = date[_ + "Seconds"](),
7797 L = date[_ + "Milliseconds"](),
7798 o = utc ? 0 : date.getTimezoneOffset(),
7799 flags = {
7800 d: d,
7801 dd: pad(d),
7802 ddd: dF.i18n.dayNames[D],
7803 dddd: dF.i18n.dayNames[D + 7],
7804 m: m + 1,
7805 mm: pad(m + 1),
7806 mmm: dF.i18n.monthNames[m],
7807 mmmm: dF.i18n.monthNames[m + 12],
7808 yy: String(y).slice(2),
7809 yyyy: y,
7810 h: H % 12 || 12,
7811 hh: pad(H % 12 || 12),
7812 H: H,
7813 HH: pad(H),
7814 M: M,
7815 MM: pad(M),
7816 s: s,
7817 ss: pad(s),
7818 l: pad(L, 3),
7819 L: pad(L > 99 ? Math.round(L / 10) : L),
7820 t: H < 12 ? "a" : "p",
7821 tt: H < 12 ? "am" : "pm",
7822 T: H < 12 ? "A" : "P",
7823 TT: H < 12 ? "AM" : "PM",
7824 Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
7825 o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
7826 S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
7827 };
7828
7829 return mask.replace(token, function($0) {
7830 return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
7831 });
7832 };
7833}();
7834
7835// Some common format strings
7836dateFormat.masks = {
7837 "default": "ddd mmm dd yyyy HH:MM:ss",
7838 shortDate: "m/d/yy",
7839 mediumDate: "mmm d, yyyy",
7840 longDate: "mmmm d, yyyy",
7841 fullDate: "dddd, mmmm d, yyyy",
7842 shortTime: "h:MM TT",
7843 mediumTime: "h:MM:ss TT",
7844 longTime: "h:MM:ss TT Z",
7845 isoDate: "yyyy-mm-dd",
7846 isoTime: "HH:MM:ss",
7847 isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
7848 isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
7849};
7850
7851// Internationalization strings
7852dateFormat.i18n = {
7853 dayNames: [
7854 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
7855 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
7856 ],
7857 monthNames: [
7858 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
7859 "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
7860 ]
7861};
7862
7863// For convenience...
7864Date.prototype.format = function(mask, utc) {
7865 return dateFormat(this, mask, utc);
7866};
7867
7868function events(mode = '', id = '', data = '') {
7869 var jsonData = {};
7870 mode = 'event-' + mode;
7871 jsonData["mode"] = mode;
7872 jsonData["id"] = id;
7873 jsonData["eurl"] = id;
7874 jsonData["data"] = data;
7875
7876 $.ajax({
7877 type: 'POST',
7878 url: 'api.php',
7879 data: jsonData,
7880 dataType: 'json',
7881 success: function(rows) {
7882 rows = rows.posts;
7883 for (var i in rows) {
7884 var row = rows[i];
7885 var id = row['id'];
7886 var date = row['date'];
7887 var edate = row['edate'];
7888 var calid = row['calid'];
7889 var hours = row['hours'];
7890 var title = decodeEntities(row['title']);
7891 var eurl = row['eurl'];
7892 var tinyurl = row['tinyurl'];
7893 var category = row['category'];
7894 var keywords = row['keywords'];
7895 var psize = row['psize'];
7896 var owner = row['owner'];
7897 var website = row['website'];
7898 var discord = row['discord'];
7899 var lstream = row['lstream'];
7900 var description = decodeEntities(row['description']);
7901 var manager = row['manager'];
7902 var server = row['server'];
7903 var ward = row['ward'];
7904 var posteurl = row['posteurl'];
7905 var postfceurl = row['postfceurl'];
7906 var plot = row['plot'];
7907 var apt = row['apt'];
7908 var dc = row['datacenter'];
7909 var housing = decodeEntities(row['housing']);
7910 var aetheryte = decodeEntities(row['aetheryte']);
7911 var isapproved = '';
7912 if (isJson(manager)) {
7913 var manager = JSON.parse(manager);
7914 } else {
7915 manager = decodeEntities(manager);
7916 }
7917
7918 if (mode == 'event-edit') {
7919 $('#posteurl').html('<option value="">Do not attach to post</option>');
7920 populatePosteurl(posteurl);
7921 populatePosteurl(postfceurl, 'fc');
7922 $("#submitevent").fadeOut(500);
7923 $('#inputfile-event').fadeOut();
7924 $('#e-id').val(id);
7925 $('#e-title').val(title);
7926 $('#e-eurl').val(eurl);
7927 $('#e-tinyurl').html(tinyurl);
7928 $('#e-tinyurl').attr('href', tinyurl);
7929 $('#e-cureurl').val(eurl);
7930 $('#e-hours').val(hours);
7931 date = moment(date, "YYYY-MM-DD HH:mm:ss").format('Y-m-d hh:mm A');
7932 edate = moment(edate, "YYYY-MM-DD HH:mm:ss").format('Y-m-d hh:mm A');
7933 jQuery(function() {
7934 jQuery('#datetimepicker').datetimepicker({
7935 format: 'Y-m-d h:mm A',
7936 formatTime: "h:mm A",
7937 inline: true,
7938 theme: 'dark',
7939 validateOnBlur: false,
7940 step: 15,
7941 value: date,
7942 onShow: function(ct) {
7943 this.setOptions({
7944 maxDate: jQuery('#edatetimepicker').val() ? jQuery('#edatetimepicker').val() : false
7945 })
7946 },
7947 timepicker: true
7948 });
7949 jQuery('#edatetimepicker').datetimepicker({
7950 format: 'Y-m-d h:mm A',
7951 formatTime: "h:mm A",
7952 inline: true,
7953 theme: 'dark',
7954 validateOnBlur: false,
7955 step: 15,
7956 value: edate,
7957 onShow: function(ct) {
7958 this.setOptions({
7959 minDate: jQuery('#datetimepicker').val() ? jQuery('#datetimepicker').val() : false
7960 })
7961 },
7962 timepicker: true
7963 });
7964 });
7965
7966 populateCategory(category, "-events");
7967 $('#eventtimezone').val($('#usertimezone').val());
7968 $("#e-dc").val(dc).trigger('change');
7969 $('#e-description').val(description);
7970 $('#e-psize').val(psize);
7971 $('#e-ward').val(ward);
7972 $('#e-plot').val(plot);
7973 $('#e-apt').val(apt);
7974 $('#e-dc').val(dc);
7975 $('#e-eventurl').val(row.eventurl);
7976 $('#e-dc').trigger('change');
7977 $('#e-server').val(server);
7978 $('#e-category').val(category);
7979 $('#e-keywords').val(keywords);
7980 $('#e-housing').val(housing);
7981 setaetheryte('e-');
7982 $('#e-website').val(website);
7983 $('#e-discord').val(discord);
7984 $('#e-lstream').val(lstream);
7985 $('#e-aetheryte').val(aetheryte);
7986 $('#e-submit_form').text("Update");
7987 $('#e-clear').text("Cancel");
7988 $("#e-img").attr("src", "getimage.php?event-" + eurl);
7989 $('#e-pictureid').val(row['pictureid']);
7990
7991 if (acct == '2' || scout != '0') {
7992 if (row['ownerName'] == 'undefined' || row['ownerName'] == '') {
7993 row['ownerName'] = user;
7994 }
7995 $('#e-owner').val(row['ownerName']);
7996 if (row['featured'] == 1) {
7997 $('#e-featured').prop("checked", true);
7998 } else {
7999 $('#e-featured').prop("checked", false);
8000 }
8001 }
8002
8003 if (row['listed'] == 1) {
8004 $('#e-listed').prop("checked", true);
8005 } else {
8006 $('#e-listed').prop("checked", false);
8007 }
8008
8009 if (row['closed'] == 1) {
8010 $('#e-closed').prop("checked", true);
8011 } else {
8012 $('#e-closed').prop("checked", false);
8013 }
8014
8015 if (row['free'] == 1) {
8016 $('#e-free').prop("checked", true);
8017 } else {
8018 $('#e-free').prop("checked", false);
8019 }
8020
8021 if (row['recurring'] == 1) {
8022 $('#e-recurring').prop("checked", true);
8023 } else {
8024 $('#e-recurring').prop("checked", false);
8025 }
8026
8027 if (keywords != null) {
8028 keywords = unique(keywords.split(' #'));
8029 keywords = keywords.toString().replace("#", "");
8030 keywords = keywords.replace(/ #/g, ",").split(',');
8031 } else {
8032 keywords = '';
8033 }
8034 // console.log(currentTags, currentKeywords);
8035
8036 $('#e-keywords').tagEditor('destroy');
8037 $("#e-keywords").prop("disabled", false);
8038 $('#e-keywords').tagEditor({
8039 autocomplete: {
8040 delay: 0, // show suggestions immediately
8041 source: currentKeywords,
8042 position: {
8043 collision: 'flip'
8044 } // automatic menu position up/down
8045 },
8046 initialTags: keywords,
8047 forceLowercase: true,
8048 placeholder: 'Post tags...'
8049 });
8050
8051 $('#e-rating' + row.rating).prop("checked", true);
8052
8053 if (calid == null) {
8054 calid = '';
8055 }
8056
8057 if (calid.length != 0) {
8058 $("#e-calendar").prop("checked", true);
8059 }
8060
8061 mgrs = 1;
8062 if (isJson(manager)) {
8063 $('#e-0').val(manager.shift());
8064 manager.forEach(function(item) {
8065 addManager(decodeEntities(item), 'e-');
8066 });
8067 } else {
8068 $('#e-0').val(decodeEntities(manager));
8069 }
8070 // $("#submitevent").fadeIn(1500, function() {
8071 // jQuery('#datetimepicker').datetimepicker();
8072 // jQuery('#edatetimepicker').datetimepicker();
8073 // });
8074 }
8075 // following block is obsolete probably
8076 if ((mode == 'event-show') || (mode == '')) {
8077 if (owner == '1' || acct == "2") {
8078 var manage = "<span class='icon link'><img src='edit.png' onclick=\"posts('edit','" + id + "');\" alt='Edit Post'></span><span class='icon link'><img src='delete.png' alt='Delete Event'></span>";
8079 } else {
8080 var manage = "";
8081 }
8082 // following line is afaik obsolete
8083 $('#events').append("<div class='event-wrapper' id='event-" + id + "'>" + isapproved + "<br><div class='event-title'><a href='./?page=events&eventid=" + id + "'>" + title + " <img src='link.png' height='30px'></a>" + manage + "</div><br><div id='wrapper'><div class='event-photo left'><center><img src='getimage.php?" + photo + "' width='100%'></center></div><div class='event-info right'>When: <p>" + prettyDate(date) + "<br>Time Zone: " + timezone + "</p><br>Where: <p>" + location + "</p><br>Details: <p>" + description + "</p><br>Event Manager(s): <p>" + niceList(manager) + "</p></div></div></div>");
8084 }
8085 }
8086 }
8087 });
8088}
8089
8090function alertPost(eurl, title) {
8091 $("#sendalert").attr("title", "Send alert regarding " + title);
8092 $("sendalert-buttons").html(`
8093 <input type="hidden" value="${eurl}" name="eurl">
8094 <input type="submit" class="defaultBtn" value="Submit Alert" width="10px">
8095 <input type="button" class="defaultBtn" value="Close" onclick=\'$("#sendalert").fadeOut()\'>`);
8096 $("#sendalert").fadeIn();
8097}
8098
8099var aapmsg = 0;
8100var wizard = {};
8101
8102function postWizard(eurl, prefix = '', mode = 'who', title = '') {
8103
8104 if (user == 'Guest') {
8105 msg("You must be logged in to create a post");
8106 return;
8107 }
8108 if (user == '' || acct == '0') {
8109 msg('Your account must be validated to perform this action');
8110 return;
8111 }
8112 if (registered == '0') {
8113 msg('Feature is currently unavailable. Please contact an Admin for further details.');
8114 return;
8115 }
8116
8117 if (autoapprove != '1') {
8118 msg("Note: Keep in mind that all post changes must be approved by a CS Admin before the post can<br>be relisted so make sure to have an Admin on standby if the post needs to be listed asap!");
8119 aapmsg = 1;
8120 }
8121 wizard['eurl'] = eurl;
8122 wizard['title'] = title;
8123 wizard['mode'] = mode;
8124
8125 if (typeof eurl != 'undefined') {
8126 msg("Loading wizard...", '');
8127 $.ajax({
8128 url: prefix + "wizard",
8129 type: "get", //send it through get method
8130 success: function(response) {
8131 wizardDiv(response, '');
8132 },
8133 error: function(xhr) {
8134 msg("An error occurred processing your request");
8135 $("#loading-img").fadeOut(500);
8136 }
8137 });
8138 return;
8139 }
8140
8141
8142 $("#dialog-confirm").attr("title", "Create Listing");
8143 $("#dialog-confirm").html('What type of listing would you like to create?');
8144 $("#dialog-confirm").dialog({
8145 resizable: false,
8146 height: "auto",
8147 width: "auto",
8148 modal: true,
8149 buttons: {
8150 "Venue/Service Post": function() {
8151 msg("Loading wizard...", '');
8152 $(this).dialog("close");
8153 $.ajax({
8154 url: "wizard",
8155 type: "get", //send it through get method
8156 success: function(response) {
8157 wizardDiv(response, '');
8158 },
8159 error: function(xhr) {
8160 msg("An error occurred processing your request");
8161 $("#loading-img").fadeOut(500);
8162 }
8163 });
8164 },
8165 "Event Post": function() {
8166 $(this).dialog("close");
8167 msg("Loading wizard...", '');
8168 $.ajax({
8169 url: "event-wizard",
8170 type: "get", //send it through get method
8171 success: function(response) {
8172 wizardDiv(response, '');
8173 },
8174 error: function(xhr) {
8175 msg("An error occurred processing your request");
8176 $("#loading-img").fadeOut(500);
8177 }
8178 });
8179 },
8180 "Group or FC Post (Beta)": function() {
8181 $(this).dialog("close");
8182 // newFc();
8183 // return;
8184 msg("Loading wizard...", '');
8185 $.ajax({
8186 url: "group-wizard",
8187 type: "get", //send it through get method
8188 success: function(response) {
8189 wizardDiv(response, '');
8190 },
8191 error: function(xhr) {
8192 msg("An error occurred processing your request");
8193 $("#loading-img").fadeOut(500);
8194 }
8195 });
8196 }
8197 }
8198 });
8199}
8200
8201function shout(eurl) {
8202 $("#dialog-confirm").attr("title", "Announce listing on Discord");
8203 $("#dialog-confirm").html('Would you like to send a shout on Discord for your post?');
8204 $("#dialog-confirm").dialog({
8205 resizable: false,
8206 height: "auto",
8207 width: "auto",
8208 modal: true,
8209 buttons: {
8210 "Shout it!": function() {
8211 $("#loading-img").fadeIn(500);
8212 $(this).dialog("close");
8213 $.ajax({
8214 type: 'POST',
8215 url: 'shoutbot.php',
8216 data: {
8217 eurl: eurl
8218 },
8219 dataType: 'json',
8220 success: function(rows) {
8221 if (rows == '0') {
8222 $('#shoutBtn-' + eurl).fadeOut();
8223 msg("Post announced on Discord! Please only do this once a week at most!");
8224 $("#loading-img").fadeOut(500);
8225 } else {
8226 msg("An error occurred processing your request");
8227 $("#loading-img").fadeOut(500);
8228 }
8229 },
8230 error: function() {
8231 msg("An error occurred processing your request");
8232 $("#loading-img").fadeOut(500);
8233 }
8234 });
8235 },
8236 "Cancel": function() {
8237 $(this).dialog("close");
8238 }
8239 }
8240 });
8241}
8242
8243function boost(eurl) {
8244 // msg("Feature coming soon!");
8245 // return true;
8246
8247 $("#dialog-confirm").attr("title", "Boost Venue");
8248 $("#dialog-confirm").html("If your venue isn't getting enough traffic, you can apply to have your post boosted.<br>A representative will visit your venue during it's regular hours<br>and determine if you qualify for a boost promotion!");
8249 $("#dialog-confirm").dialog({
8250 resizable: false,
8251 height: "auto",
8252 width: "auto",
8253 modal: true,
8254 buttons: {
8255 "Apply for Boost": function() {
8256 $("#loading-img").fadeIn(500);
8257 $(this).dialog("close");
8258 $.ajax({
8259 type: 'POST',
8260 url: 'boost.php',
8261 data: {
8262 eurl: eurl
8263 },
8264 dataType: 'json',
8265 success: function(rows) {
8266 if (rows == '0') {
8267 msg("Post submitted for Boost approval. A representative will contact you as soon as possible!");
8268 $("#loading-img").fadeOut(500);
8269 } else {
8270 msg("An error occurred processing your request");
8271 $("#loading-img").fadeOut(500);
8272 }
8273 },
8274 error: function() {
8275 msg("An error occurred processing your request");
8276 $("#loading-img").fadeOut(500);
8277 }
8278 });
8279 },
8280 "Cancel": function() {
8281 $(this).dialog("close");
8282 }
8283 }
8284 });
8285}
8286
8287function loadPostDiv(eurl) {
8288 $("#postDiv-body").html(`
8289 <center>
8290 <br/>
8291 <img id='${eurl}-loadpicPost' src='loadpic.gif' height="20%" style="padding-top:20%;"/>
8292 </center>
8293 `);
8294 $("#postDiv").fadeIn(500);
8295 $("#postDiv").animate({
8296 width: '60%',
8297 height: '70%'
8298 });
8299 $("#contain").prepend($("#postDiv"));
8300 // $("#postDiv").css({"position": "fixed !important","top": "auto !important", "bottom": "0 !important"});
8301
8302 // $("#postDiv").resizable({
8303 // containment: "#content"
8304 // });
8305 getPost(eurl, '#postDiv-body');
8306}
8307
8308function getLocation(prefix = '') {
8309 var plot = $('#' + prefix + 'plot').val();
8310 var housing = $('#' + prefix + 'housing').val();
8311 if (plot == '' || housing == '') {
8312 return;
8313 }
8314 $('#' + prefix + 'aetheryte').val('');
8315 $('#' + prefix + 'psize').val('');
8316 $("#loading-img").fadeIn(500);
8317 $.ajax({
8318 type: 'POST',
8319 url: 'api.php',
8320 data: {
8321 mode: 'getLocation',
8322 plot: plot,
8323 housing: housing,
8324 prefix: prefix
8325 },
8326 dataType: 'json',
8327 success: function(data) {
8328 var prefix = data['prefix'];
8329 var aetheryte = '';
8330 var psize = '';
8331 for (var i in data) {
8332 if (!isNumber(i)) {
8333 continue;
8334 }
8335 if (data[i]['psize'] == "Apartment") {
8336 continue;
8337 }
8338 if (data[i]['psize'] != '') {
8339 $('#' + prefix + 'psize').val(data[i]['psize']);
8340 }
8341
8342 if (data[i]['aetheryte'] != '') {
8343 $('#' + prefix + 'aetheryte').val(decodeEntities(data[i]['aetheryte']));
8344 }
8345 }
8346 $("#loading-img").fadeOut(500);
8347 },
8348 error: function() {
8349 msg("An error occurred processing your request");
8350 $("#loading-img").fadeOut(500);
8351 }
8352 });
8353}
8354
8355function setDatacenter(object) {
8356 userdatacenter = $(object).val();
8357 createCookie("datacenter", userdatacenter, "365");
8358 loadPage(page);
8359}
8360
8361if (domain == 'roleplayfinder.com') {
8362 ratingMode = 'T';
8363 createCookie('rating', ratingMode);
8364}
8365
8366function setRatingMode() {
8367 if (domain == 'roleplayfinder.com') {
8368 ratingMode = 'T';
8369 createCookie('rating', ratingMode);
8370 return;
8371 }
8372 $("#dialog-confirm").attr("title", "Unlock Mature Content");
8373 $("#dialog-confirm").html('We at Crystal Shouts strive to provide the best RP experience possible<br>by ensuring what you see is what you get. We strive to personally<br>evaluate every venue we post and guarantee the highest quality, and of<br>course, the safest experience possible. However, it\'s not<br>always possible to keep track of every venue. If you are<br>over 18 years old, understand this, and take full responsibility<br>for your experience then click "I Agree" to fully unlock all content<br>including 18+ content. Otherwise, press "Cancel".');
8374 $("#dialog-confirm").dialog({
8375 resizable: false,
8376 height: "auto",
8377 width: "auto",
8378 modal: true,
8379 buttons: {
8380 "I Agree": function() {
8381 $(this).dialog("close");
8382 ratingMode = 'M';
8383 createCookie('rating', ratingMode);
8384 msg("Rating set to 'M' for mature.");
8385 $('#ratingIcon').attr("src", "mature.png");
8386 loadPage(page);
8387 },
8388 "Cancel": function() {
8389 $(this).dialog("close");
8390 ratingMode = 'T';
8391 createCookie('rating', ratingMode);
8392 msg("Rating set to 'T' for teen.");
8393 $('#ratingIcon').attr("src", "teen.png");
8394 loadPage(page);
8395 }
8396 }
8397 });
8398}
8399
8400function showstream(url) {
8401 $('#streamframe').fadeIn();
8402 var strippedurl = url.replace('https://', '').replace('https://', '').replace('/', '%2F');
8403 $.ajax({
8404 url: "https://textance.herokuapp.com/title/" + strippedurl,
8405 complete: function(data) {
8406 frameTitle = data.responseText;
8407 $('#streamframeTitle').html(`${frameTitle}<img class="link submitCloseBtn" src="close.png" alt="Close" onclick="$('#streamframeBody').text(''); $('#streamframe').fadeOut(500);" style="float:right; margin:5px;" height="25px">
8408 <img class="link submitCloseBtn" src="minimize.png" alt="Minimize" onclick="minimizeWin('#streamframe');" style="float:right; margin:0px;" height="35px">`);
8409 }
8410 });
8411
8412 if (url.includes("www.twitch.tv")) {
8413 var TwitchID = url.split('/');
8414 TwitchID = TwitchID.pop() || TwitchID.pop();
8415 var options = {
8416 width: '100%',
8417 height: '100%',
8418 channel: TwitchID,
8419 };
8420 var player = new Twitch.Player("streamframeBody", options);
8421 player.setVolume(1);
8422 } else {
8423 var framebodyheight = $('#streamframeBody').outerHeight();
8424 framehtml = `<iframe id='framestreamIframe' height="${framebodyheight}" width="100%" border="0" src="${url}"></iframe>`;
8425 $('#streamframeBody').html(framehtml);
8426 }
8427}
8428
8429function minimizeWin(div) {
8430 $(div).fadeTo(500, 0, function() {
8431 $(div).css("z-index", "-500");
8432 $(div).animate({
8433 bottom: '-500px'
8434 });
8435 });
8436 $("streamwin").html(frameTitle);
8437}
8438
8439function isOpen(openTime, closeTime, timezone) {
8440 const now = moment.tz(timezone);
8441 const date = now.format("YYYY-MM-DD");
8442 const storeOpenTime = moment.tz(date + ' ' + openTime, "YYYY-MM-DD h:mmA", timezone);
8443 const storeCloseTime = moment.tz(date + ' ' + closeTime, "YYYY-MM-DD h:mmA", timezone);
8444 let check;
8445 if (storeCloseTime.isBefore(storeOpenTime)) {
8446 // Handle ranges that span over midnight
8447 check = now.isAfter(storeOpenTime) || now.isBefore(storeCloseTime);
8448 } else {
8449 // Normal range check using an inclusive start time and exclusive end time
8450 check = now.isBetween(storeOpenTime, storeCloseTime, null, '[)');
8451 }
8452 return check ? "open" : "closed";
8453}
8454
8455function isSoon(curtime, otime, soon = '2') {
8456 // start time and end time
8457 var startTime = moment(curtime, "HH:mm:ss a");
8458 var endTime = moment(otime, "HH:mm:ss a");
8459
8460 // calculate total duration
8461 var duration = moment.duration(endTime.diff(startTime));
8462
8463 // duration in hours
8464 var hours = parseInt(duration.asHours());
8465
8466 // duration in minutes
8467 if (hours < 0) {
8468 hours = 99999999;
8469 }
8470 return hours < soon;
8471}
8472
8473function showFashionReport() {
8474 $.getJSON("results.json", function(json) {
8475 $('#fashionframeTitleText').html('Fashion Report for week of ' + json.date);
8476 $('#fashionframeBody').html('<img src="' + json.url + '" width="100%">');
8477 $('#fashionframe').fadeIn();
8478 });
8479}
8480
8481function treatAsUTC(date) {
8482 var result = new Date(date);
8483 result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
8484 return result;
8485}
8486
8487function daysBetween(startDate, endDate) {
8488 var millisecondsPerDay = 24 * 60 * 60 * 1000;
8489 return Math.floor((treatAsUTC(endDate) - treatAsUTC(startDate)) / millisecondsPerDay);
8490}
8491
8492function questionPost(eurl, title) {
8493 $("#dialog-confirm").attr("title", `Mark ${title} as Closed or Vacant`);
8494 $("#dialog-confirm").html('You can let us know if you visit a venue that is vacant (no staff) during it\'s hours<br>of operation so we can mark it as closed. Your feedback is invaluable and, of course, anonymous!');
8495 $("#dialog-confirm").dialog({
8496 resizable: false,
8497 height: "auto",
8498 width: "auto",
8499 modal: true,
8500 buttons: {
8501 "Mark Closed": function() {
8502 $("#loading-img").fadeIn(500);
8503 $(this).dialog("close");
8504 $.ajax({
8505 type: 'POST',
8506 url: 'questionbot.php',
8507 data: {
8508 eurl: eurl
8509 },
8510 dataType: 'json',
8511 success: function(rows) {
8512 if (rows == '0') {
8513 $('#shoutBtn-' + eurl).fadeOut();
8514 msg("Venue alert sent to scouts! We will verify this venue as soon as we can. Thank you!");
8515 $("#loading-img").fadeOut(500);
8516 } else {
8517 msg("An error occurred processing your request");
8518 $("#loading-img").fadeOut(500);
8519 }
8520 },
8521 error: function() {
8522 msg("An error occurred processing your request");
8523 $("#loading-img").fadeOut(500);
8524 }
8525 });
8526 },
8527 "Cancel": function() {
8528 $(this).dialog("close");
8529 }
8530 }
8531 });
8532}
8533
8534function setLocation() {
8535 document.title = page_title;
8536 var obj = {
8537 url: "?page=" + page
8538 };
8539 history.pushState(obj, page_title, "?page=" + page);
8540}
8541
8542function favPost(eurl, mode) {
8543 if (mode == 'add') {
8544 favPosts.push(eurl);
8545 $(`#fav-${eurl}`).attr('src', 'goldstar.gif');
8546 $(`#fav-${eurl}`).attr('title', 'Remove Post from Favourites');
8547 $(`#fav-${eurl}`).attr('onclick', `favPost("${eurl}","del")`);
8548 }
8549 if (mode == 'del') {
8550 favPosts = favPosts.filter(e => e !== eurl); // will return ['A', 'C']
8551 $(`#fav-${eurl}`).attr('src', 'emptystar.png');
8552 $(`#fav-${eurl}`).attr('title', 'Add Post to Favourites');
8553 $(`#fav-${eurl}`).attr('onclick', `favPost("${eurl}","add")`);
8554 }
8555 createCookie('favPosts', JSON.stringify(favPosts));
8556}
8557
8558function verifyPost(eurl, title) {
8559 $("#dialog-confirm").attr("title", "Mark Post as Verified Active for " + title);
8560 $("#dialog-confirm").html('If you have visited the location or otherwise verified the venue is active');
8561 $("#dialog-confirm").dialog({
8562 resizable: false,
8563 height: "auto",
8564 width: "auto",
8565 modal: true,
8566 buttons: {
8567 "Mark Active": function() {
8568 $("#loading-img").fadeIn(500);
8569 $(this).dialog("close");
8570 $.ajax({
8571 type: 'POST',
8572 url: 'verify.php',
8573 data: {
8574 eurl: eurl,
8575 mode: 'verify'
8576 },
8577 dataType: 'json',
8578 success: function(rows) {
8579 if (rows == '2') {
8580 msg("Venue can only be tagged every 24 hours!");
8581 $("#loading-img").fadeOut(500);
8582 return;
8583 }
8584 if (typeof rows.posts != 'undefined') {
8585 msg("Venue tagged active!");
8586 var id = rows['id'];
8587 var trid = `tr-${id}`;
8588 var parentElem = $('#' + trid).parent().attr('id');
8589 if (parentElem == 'tbodyB') {
8590 $('#tbodyA').append($('#' + trid));
8591 $('#timeWhen').trigger('change');
8592 $('#headerDay').removeClass('selected');
8593 $('#headerDay').trigger('click');
8594 scrollToBannerId(trid);
8595 }
8596 $("#loading-img").fadeOut(500);
8597 } else {
8598 msg("An error occurred processing your request");
8599 $("#loading-img").fadeOut(500);
8600 }
8601 },
8602 error: function() {
8603 msg("An error occurred processing your request");
8604 $("#loading-img").fadeOut(500);
8605 }
8606 });
8607 },
8608 "Cancel": function() {
8609 $(this).dialog("close");
8610 }
8611 }
8612 });
8613}
8614
8615function showGuide(outputid = '') {
8616 var guideOutput = `
8617 <center>
8618 <h1>Site Usage Guide</h1>
8619 Note: user registration is only required to create, manage, or scout posts<br>
8620 </center>
8621 <font size="5">
8622 <br>
8623 <center>
8624 <h3>Patrons Guide</h3>
8625 </center>
8626 <b>Housing Locations:</b><br>
8627 The Goblet - Ul'dah - Western Thanalan ( 27.8, 26.1 )<br>
8628 Lavender Beds - New Gridania - Ferry Skipper, Central Shroud ( 25.4, 27.9 )<br>
8629 Mist - Limsa - Lower La Noscea ( 33.4, 19.2 )<br>
8630 Shirogane - Kugane ( 8.6, 10.0 )<br>
8631 <br>
8632 <b>Terms:</b><br>
8633 OOC: Out of Character/RP<br>
8634 IC: In Character/RP<br>
8635 <br>
8636 <b>Player Status Icon:</b><br>
8637 <img src="owner.png" height="20px">: Owner<br>
8638 <img src="meld.png" height="20px">: Staff/Owner/Manager<br>
8639 <img src="greentag.png" height="20px">: Pay-to-Interact RP Staff<br>
8640 <img src="rp.png" height="20px">: IC Patron<br>
8641 (No Tag/Sprout): Newcomer or Observer<br>
8642 <br>
8643 <b>General Venue Rules:</b><br>
8644 • Hide your weapons, sheilds, minions, and pets (unless otherwise stated at venue)<br>
8645 • Try to refrain from running/sprinting or using actions/spells inside the venue<br>
8646 • Usually shout and yell are reserved for staff usage to help coordinate events<br>
8647 • Negativity never helps anyone. Disruptive behavior will lead to being reported/banned<br>
8648 • Issues and complaints can always be taken to a venue owner or staff<br>
8649 • For cases involving the owner or staff, please don't hesitate to contact a CS scout<br>
8650 • Have fun!!<br>
8651 <br>
8652 <b>Use dropdown lists to choose category and datacenter:</b><br><br>
8653 <center><img src='dropdown.png' class="imgborder imgdropshadow"></center><br>
8654 <b>Listings:</b><br>
8655 • (18+/21+ Only): You <i>must</i> be of age to attend the venue. No exceptions<br>
8656 • (Free): You don't need to spend OOC gil to participate in the<br>
8657 venue or event but tips are appreciated<br>
8658 • (Closed): Venue is closed. Details can be found in venue description<br>
8659 regarding the closure<br>
8660 • (Open RP): Venue is always open for anyone to come and use the space for their own<br>
8661 RP. Some ORP venues also have a schedule for when staff will be available as well.<br>
8662 <img src="checkmark.png" height="20px">: Venue verified within the last 5 days<br>
8663 <img src="x.png" height="20px">: Post validation expired. Post information may be out of date<br>
8664 <img src="emptystar.png" height="20px">: Add post to your bookmark list<br>
8665 <img src="goldstar.gif" height="20px">: Post is in your bookmark list<br>
8666 <br>
8667 <b>Posts:</b><br>
8668 <img src="link.png" height="20px">: Copy post information to clipboard!<br>
8669 <img src="checkmark.png" height="20px">: Mark Venue as active<br>
8670 <img src="question.png" height="20px">: Alert scouts if a venue is closed when marked open on the list<br>
8671 <img src="alert.png" height="20px">: Send an alert to the scouts about an error found in a post<br>
8672 <br>
8673 <center>
8674 <h3>Listers Guide</h3>
8675 </center>
8676 <img src="edit.png" height="20px">: Edit your post<br>
8677 <img src="shout.png" height="20px">: Send a shout about your post to partner discord servers<br>
8678 <img src="cal.png" height="20px">: Sync post with google calendar (Currently in redevelopment)<br>
8679 <img src="opensign.png" height="20px">: Popup mode to mark post open regardless of times set for post<br>
8680 <img src="delete.png" height="20px">: Delete listing (This action cannot be undone!)<br>
8681 <img src="powerup.png" height="20px">: Request post boost<br>
8682 <br>
8683 <b>Select Service or Performer in the post editor if your post is as such:</b><br><br>
8684 <center><img src='services.png' class="imgborder imgdropshadow"></center><br>
8685 <br>
8686 <center>
8687 <h3>Scouts Guide</h3>
8688 </center>
8689 <img src="checkmark.png" height="20px">: Mark Venue as active<br>
8690 </font>
8691 <center>${closeBtn}</center>`;
8692
8693 if (outputid != '') {
8694 $(outputid).html(guideOutput);
8695 } else {
8696 msg(guideOutput, "");
8697 $('#popup').css("text-align", "left");
8698 $('#popup').css("padding", "15px");
8699 }
8700}
8701
8702function twitterfy(url) {
8703 return `<center><a class="twitter-timeline" href="${url}?ref_src=twsrc%5Etfw" width='1200px'></a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>`;
8704}
8705
8706function makeid(length) {
8707 var result = '';
8708 var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
8709 var charactersLength = characters.length;
8710 for (var i = 0; i < length; i++) {
8711 result += characters.charAt(Math.floor(Math.random() *
8712 charactersLength));
8713 }
8714 return result;
8715}
8716
8717var userServer = '';
8718
8719function userManager() {
8720 if (registered == '0' || user == 'Guest') {
8721 msg('Feature is currently unavailable.');
8722 $("#loading-img, #popup").fadeOut(500);
8723 return;
8724 }
8725 $.ajax({
8726 type: 'POST',
8727 url: 'user.php',
8728 data: {
8729 mode: 'userData'
8730 },
8731 dataType: 'json',
8732 success: function(row) {
8733 if (row != false) {
8734 points = row['points'];
8735 datacenter = row['dc'];
8736 var defaulteurl = row['defaulteurl'];
8737 var defaultprofile = row['defaultprofile'];
8738 lodeid = row['lodeid'];
8739 userServer = world = row['homeworld'];
8740 did = row['did'];
8741 timezone = row['timezone'];
8742 verify = row['verify'];
8743 character = row['character'];
8744 discordh = row['discord'];
8745 var acctType = 'User';
8746 var discord = '';
8747 if (acct == '0') {
8748 acctType = `<unverified class="link" onclick="showreg('verify');">Unverified User</unverified>`;
8749 }
8750 if (did != '0') {
8751 discord = did;
8752 } else {
8753 discord = "No DiscordID Linked";
8754 }
8755 var scoutMgr = '';
8756 if (acct == '2') {
8757 acctType = 'Admin';
8758 scoutMgr = `<input type="text" name="addscout" id="addscout">
8759 <input type="button" class="defaultBtn" value="Add Scout Leader">`;
8760 }
8761 if (scout == '1') {
8762 acctType += ' & Scout';
8763 scoutMgr = `Points: ${points}<br>`;
8764 }
8765 if (scout == '2') {
8766 acctType += ' & Scout Leader';
8767 scoutMgr += `<br>Points: ${points}<br>`;
8768 scoutMgr += `<input type="text" name="addscout" id="addscout">
8769 <input type="button" class="defaultBtn" value="Add Scout">`;
8770 }
8771 var avatar = 'blank_avatar.png';
8772 if (lodeid == '0') {
8773 lodeid = `<tr id="lodeLink"><td>Not linked to Lodestone</td><td><input class="defaultBtn" type="button" name="lodelink" style="display:none" id="lodelinkButton" value="Link Character" onclick="lodeLink();"><input type="hidden" value="0" name="lodeid"></td></tr>`;
8774 } else {
8775 $('#avatar').attr("src", "comms.gif");
8776 $.getJSON("https://xivapi.com/character/" + lodeid, function(data, textStatus, jqXHR) {
8777 avatar = data['Character']['Avatar'];
8778 $('#avatar').attr("src", avatar);
8779 });
8780 lodeid = `<tr><td>Lodestone ID:</td><td>${lodeid}<input type="hidden" value="${lodeid}" name="lodeid"></td></tr>`;
8781 }
8782
8783 var disableautologin = `<input type="button" class="defaultBtn" value="Disable Auto-Login" onclick="eraseCookie('autoLogin');$(this).fadeOut();msg('AutoLogin turned off.');"><br>`;
8784 if (readCookie('autoLogin') == null) {
8785 disableautologin = '';
8786 }
8787 // <input type="text" name="character" id="UMcharacter" value="${character}" onchange="lodeLinkCheck();">
8788 // <select class="black" id="defaulteurl" name="defaulteurl">
8789 var usermgr = `${acctType}<br>
8790 <form id="saveUserData">
8791 <input type="hidden" value="saveUserData" name="mode">
8792 ${scoutMgr}<br>
8793 <img id="avatar" src='${avatar}' width="50%"><br>
8794 <center>Default Listing (When using CrystalBot):<br>
8795
8796 <div id="defaulteurl"></div>
8797 <br>${disableautologin}
8798 </center>
8799 <br>
8800 <table>
8801 <tr><td style="min-width: 150px;">Username:</td><td>${user}</td></tr>
8802 <tr><td>Current Active Character:</td><td>${character}<input type="hidden" name="defaultprofile" id="defaultprofile" value="${defaultprofile}"></td></tr>
8803 <tr><td>Characters:</td><td><div id="UMcharacter"></div></td></tr>
8804 <tr><td>Discord Handle:</td><td><input type="text" name="discord" id="UMdiscord" value="${discordh}"></td></tr>
8805 <tr><td>DiscordID:</td><td>${discord}</td></tr>
8806 <tr><td>Default Timezone:</td><td><select id="UMtimezone" name="timezone" placeholder="Time Zone" class="dropdown" required></select></td></tr>
8807 </table>
8808 <br>Fill out the next three fields<br>to update your password<br> or leave blank to keep<br>password the same<br><br>
8809 <table>
8810 <tr><td style="min-width: 150px;">Current Password:</td><td><input type="password" name="curpassword" id="curpassword"></td></tr>
8811 <tr><td>New Password:</td><td><input type="password" name="newpassword" id="newpassword"></td></tr>
8812 <tr><td>Confirm Password:</td><td><input type="password" name="confirmpassword" id="confirmpassword"></td></tr>
8813 </table>
8814 </form>
8815 Please contact an administrator<br>if you need to update your e-mail address.<br><br>
8816 <input type="button" value="Apply" class="defaultBtn" onclick="saveUserData();"> ${closeBtn}<br><br>
8817 `;
8818
8819 var chareditor = `
8820 ${lodeid}
8821 <tr><td>Datacenter</td><td>
8822 <select name="dc" id="um-dc" class='dropdown' onchange="setpostdc('um-');">
8823 <option value="" disabled>-North America-</option>
8824 <option value="Aether">Aether</option>
8825 <option selected value="Crystal">Crystal</option>
8826 <option value="Primal">Primal</option>
8827 <option value="" disabled>-Europe-</option>
8828 <option value="Chaos">Chaos</option>
8829 <option value="Light">Light</option>
8830 <option value="" disabled>-Japan-</option>
8831 <option value="Elemental">Elemental</option>
8832 <option value="Gaia">Gaia</option>
8833 <option value="Mana">Mana</option>
8834 </select>
8835 </td></tr>
8836
8837 <tr><td>Home World</td><td>
8838 <select name="homeworld" id="um-server" class='black' placeholder="Server" onchange="lodeLinkCheck();">
8839 <option value="">N/A</option>
8840 <option value="Balmung">Balmung</option>
8841 <option value="Brynhildr">Brynhildr</option>
8842 <option value="Coeurl">Coeurl</option>
8843 <option value="Diabolos">Diabolos</option>
8844 <option value="Goblin">Goblin</option>
8845 <option value="Malboro">Malboro</option>
8846 <option value="Mateus">Mateus</option>
8847 <option value="Zalera">Zalera</option>
8848 </select>
8849 </td></tr>`;
8850
8851 $('#userManager').html(usermgr);
8852 $('#userManager').fadeIn();
8853 $("#loading-img, #popup").fadeOut(500);
8854 $('#um-dc').val(datacenter);
8855 setpostdc('um-');
8856 $('#um-server').val(world);
8857 lodeLinkCheck();
8858
8859 $.ajax({
8860 type: 'POST',
8861 url: 'api.php',
8862 data: {
8863 mode: 'show',
8864 submode: 'dd'
8865 },
8866 dataType: 'json',
8867 success: function(ddDataShow) {
8868 if (ddDataShow != false) {
8869 $('#defaulteurl').ddslick({
8870 data: ddDataShow,
8871 width: 300,
8872 imagePosition: "left",
8873 selectText: "Select default listing",
8874 onSelected: function(data) {
8875 }
8876 });
8877 $("#defaulteurl input.dd-selected-value").attr('name', "defaulteurl");
8878 }
8879 $("#loading-img").fadeOut(500);
8880 },
8881 error: function() {
8882 $("#loading-img").fadeOut(500);
8883 }
8884 });
8885
8886 var select = document.getElementById("UMtimezone");
8887 for (index in timezones) {
8888 var zonefancy = timezones[index].replace(/\//g, ": ").replace(/_/g, " ");
8889 select.options[select.options.length] = new Option(zonefancy, timezones[index]);
8890 }
8891 if (typeof timezone == 'undefined' || timezone == '') {
8892 timezone = timezones[$('#usertimezone option:selected').val()];
8893 }
8894 $('#UMtimezone').val(timezone);
8895 $.ajax({
8896 type: 'POST',
8897 url: 'user.php',
8898 data: {
8899 mode: 'profileData',
8900 submode: 'dd'
8901 },
8902 dataType: 'json',
8903 success: function(ddData) {
8904 if (ddData != false) {
8905 $('#UMcharacter').ddslick({
8906 data: ddData,
8907 width: 300,
8908 imagePosition: "left",
8909 selectText: "Manage character profile",
8910 onSelected: function(data) {
8911 if (data["selectedData"]["value"] == 'new') {
8912 msg('Feature coming soon!');
8913 }
8914 }
8915 });
8916 $("#UMcharacter input.dd-selected-value").attr('name', "character");
8917 } else {
8918 msg("An error occurred processing server response");
8919 $("#loading-img").fadeOut(500);
8920 }
8921 },
8922 error: function() {
8923 msg("An error occurred processing your request");
8924 $("#loading-img").fadeOut(500);
8925 }
8926 });
8927 } else {
8928 msg("An error occurred processing server response");
8929 $("#loading-img").fadeOut(500);
8930 }
8931 },
8932 error: function() {
8933 msg("An error occurred processing your request");
8934 $("#loading-img").fadeOut(500);
8935 }
8936 });
8937}
8938
8939function lodeLinkCheck() {
8940 if ($('#um-server').val() != '' && $('#UMcharacter').val() != '') {
8941 $('#lodelinkButton').fadeIn();
8942 } else {
8943 $('#lodelinkButton').fadeOut();
8944 }
8945}
8946
8947function verifyDid() {
8948 $.ajax({
8949 type: 'POST',
8950 url: 'user.php',
8951 data: {
8952 mode: 'verifyDid'
8953 },
8954 dataType: 'json',
8955 success: function(rows) {
8956 if (rows == '1') {
8957 msg("Discord account linked to CS account!");
8958 $("#loading-img").fadeOut(500);
8959 userManager();
8960 } else {
8961 msg("An error occurred processing your request");
8962 $("#loading-img").fadeOut(500);
8963 }
8964 },
8965 error: function() {
8966 msg("An error occurred processing your request");
8967 $("#loading-img").fadeOut(500);
8968 }
8969 });
8970}
8971
8972function saveUserData() {
8973 var form = $('#saveUserData')[0]; // You need to use standard javascript object here
8974 var formData = new FormData(form);
8975 $.ajax({
8976 type: 'POST',
8977 url: 'user.php',
8978 data: formData,
8979 dataType: 'json',
8980 contentType: false,
8981 processData: false,
8982 success: function(rows) {
8983 if (rows == '1') {
8984 character = $('#UMcharacter').val();
8985 msg("User information updated!");
8986 $("#loading-img").fadeOut(500);
8987 userManager();
8988 } else {
8989 msg("An error occurred processing your request");
8990 $("#loading-img").fadeOut(500);
8991 }
8992 },
8993 error: function() {
8994 msg("An error occurred processing your request");
8995 $("#loading-img").fadeOut(500);
8996 }
8997 });
8998}
8999
9000function toggleOpen(eurl) {
9001 $("#dialog-confirm").attr("title", "Popup Mode - Toggle Open/Closed Status");
9002 $("#dialog-confirm").html('This will set your post as open regardless of the times posted on the<br>post. Click this icon again once the popup event is over to set the<br>post back to automatic.');
9003 $("#dialog-confirm").dialog({
9004 resizable: false,
9005 height: "auto",
9006 width: "auto",
9007 modal: true,
9008 buttons: {
9009 "Toggle Open": function() {
9010 $("#loading-img").fadeIn(500);
9011 $(this).dialog("close");
9012 $.ajax({
9013 type: 'POST',
9014 url: 'api.php',
9015 data: {
9016 eurl: eurl,
9017 mode: 'toggleOpen'
9018 },
9019 dataType: 'json',
9020 success: function(rows) {
9021 if (rows == '1') {
9022 msg("Venue toggled to open!");
9023 $("#loading-img").fadeOut(500);
9024 return;
9025 }
9026 if (rows == '0') {
9027 msg("Venue toggled to closed/listed times!");
9028 $("#loading-img").fadeOut(500);
9029 } else {
9030 msg("An error occurred processing your request");
9031 $("#loading-img").fadeOut(500);
9032 }
9033 },
9034 error: function() {
9035 msg("An error occurred processing your request");
9036 $("#loading-img").fadeOut(500);
9037 }
9038 });
9039 },
9040 "Cancel": function() {
9041 $(this).dialog("close");
9042 }
9043 }
9044 });
9045}
9046var expandCats = '0';
9047var widthCats = '';
9048var widthResults = '';
9049
9050function toggleCats() {
9051 if (expandCats == '1') {
9052 expandCats = '0';
9053 widthCats = $('#comms-search-filter').width();
9054 // widthResults = $('#comms-search-results').width();
9055 $('#comms-search-filter').animate({
9056 width: '0'
9057 });
9058 // $('#comms-search-results').animate({width: '99%'});
9059 $('#expander').animate({
9060 left: '-25px'
9061 });
9062 } else {
9063 expandCats = '1';
9064 $('#expander').animate({
9065 left: '170px'
9066 });
9067 $('#comms-search-filter').animate({
9068 width: "170px"
9069 });
9070 // $('#comms-search-results').animate({width: widthResults});
9071 }
9072}
9073
9074if (acct == '2') {
9075 var needsApproval = [];
9076 $.ajax({
9077 type: 'POST',
9078 url: 'api.php',
9079 data: {
9080 mode: 'unapproved'
9081 },
9082 dataType: 'json',
9083 success: function(rows) {
9084 if (!rows) {
9085 return;
9086 }
9087 if (rows['posts'] == undefined) {
9088 return;
9089 }
9090 rows = rows['posts'];
9091 var post = '';
9092 rows.forEach(function(item, index) {
9093 if (rows[index].eurl == undefined) {
9094 return;
9095 }
9096 // post = '<br><b class="link" onclick="loadPostDiv(\''+rows[index].eurl+'\');">'+rows[index].title+'</b>';
9097 post = '<br><b class="link" onclick="postWizard(\'' + rows[index].eurl + '\', \'\', \'advanced\');">' + rows[index].title + '</b>';
9098 needsApproval.push(post);
9099 });
9100 needsApproval = niceList(needsApproval);
9101 if (needsApproval != '') {
9102 msg('The following listings need approval: ' + needsApproval);
9103 }
9104 $("#loading-img").fadeOut(500);
9105 },
9106 error: function() {
9107 $("#loading-img").fadeOut(500);
9108 }
9109 });
9110}
9111
9112var featured;
9113
9114$.ajax({
9115 type: 'POST',
9116 url: 'api.php',
9117 data: {
9118 mode: 'featured'
9119 },
9120 dataType: 'json',
9121 success: function(rows) {
9122 rows = rows['posts'];
9123 if (rows) {
9124 featured = rows;
9125 $.ajax({
9126 type: 'POST',
9127 url: 'api.php',
9128 data: {
9129 mode: 'events-featured'
9130 },
9131 dataType: 'json',
9132 success: function(rows) {
9133 rows = rows['posts']
9134 if (rows) {
9135 rows.forEach(function(item, index) {
9136 var neweurl = 'event-' + item.eurl;
9137 rows[index].eurl = neweurl;
9138 });
9139 featured.push.apply(featured, rows);
9140 $("#loading-img").fadeOut(500);
9141 } else {
9142 $("#loading-img").fadeOut(500);
9143 }
9144 },
9145 error: function() {
9146 $("#loading-img").fadeOut(500);
9147 }
9148 });
9149 $("#loading-img").fadeOut(500);
9150 } else {
9151 $("#loading-img").fadeOut(500);
9152 }
9153 },
9154 error: function() {
9155 $("#loading-img").fadeOut(500);
9156 }
9157});
9158
9159function featuredClick() {
9160 loadPostDiv(featuredEurl);
9161}
9162
9163var featuredEurl = 0;
9164var featuredId = 0;
9165var featuredIdOld;
9166
9167function featuredRotate() {
9168 return;
9169 if (featured.length == 1) {
9170 return;
9171 }
9172
9173 featuredId = Math.floor(Math.random() * featured.length) + 1;
9174 var featRow = featured[featuredId];
9175
9176 while (typeof featRow == "undefined" || featuredId == featuredIdOld) {
9177 featuredId = Math.floor(Math.random() * featured.length) + 1;
9178 featRow = featured[featuredId];
9179 }
9180 featuredIdOld = featuredId;
9181
9182 $('#featuredDiv').fadeTo("slow", 0, function() {
9183 $('#featuredDiv').html('');
9184 featuredEurl = featRow.eurl;
9185 featRow.description = truncate(featRow.description, 110);
9186 var featuredPost = `<div id="featuredPost" style="background-color: rgba(0,0,0,0.7); opacity: 0; padding; 15px; padding-top: 10px; font-size: 15px; line-height: 20px; width:100%;height:70px;color: #FFDF00;">
9187 ${featRow.title}<br>
9188 <p><font class='event-info featuredDivFont' style="font-size: 15px; padding-top: 15px; padding-left: 15px; padding-right: 15px; line-height: 15px; text-shadow: -1px 1px 0 #000, 1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000, 0px 0px 15px #FFF;">${featRow.description}</font></p>
9189 </div>`;
9190 $('#featuredDiv').css("background-image", `url('getimage.php?banner-${featRow.eurl}')`);
9191 $('#featuredDiv').fadeTo(3000, 1, function() {
9192 $('#featuredDiv').html(featuredPost);
9193 $('#featuredPost').fadeTo("slow", 1);
9194 });
9195 });
9196}
9197// if (headerwidth > 1500) {
9198// $('#featuredDiv').fadeIn();
9199// if (typeof featuredInterval == "undefined") {
9200// featuredInterval = setInterval(function(){ featuredRotate(); }, 10000);
9201// }
9202// } else {
9203// if (typeof featuredInterval != "undefined") {
9204// clearInterval(featuredInterval); featuredInterval = undefined;
9205$('#featuredDiv').fadeOut();
9206// }
9207// }
9208
9209// $(window).resize(function (){
9210// headerwidth = $(window).width();
9211// if (headerwidth > 1500) {
9212// $('#featuredDiv').fadeIn();
9213// if (typeof featuredInterval == "undefined") {
9214// featuredInterval = setInterval(function(){ featuredRotate(); }, 10000);
9215// }
9216// } else {
9217// if (typeof featuredInterval != "undefined") {
9218// clearInterval(featuredInterval); featuredInterval = undefined;
9219// $('#featuredDiv').fadeOut();
9220// }
9221// }
9222// });
9223
9224function filldefaulteurl(selected) {
9225 $.ajax({
9226 type: 'POST',
9227 url: 'api.php',
9228 data: {
9229 mode: 'show',
9230 submode: 'dd'
9231 },
9232 dataType: 'json',
9233 success: function(rows) {
9234 $("#loading-img").fadeOut(500);
9235 },
9236 error: function() {
9237 $("#loading-img").fadeOut(500);
9238 }
9239 });
9240}
9241
9242function syncpost(eurl, eeurl) {
9243 wizMode = "sync";
9244 $('#wizard').fadeTo(1000, 0, function() {
9245 $('#wizard').html("<iframe height='100%' width='100%' classe='syncframe' id='syncPost'></iframe>");
9246 $('#wizard').fadeTo(750, 1);
9247 document.getElementById('syncPost').src = "./ffxivrp.php?eurl=" + encodeURIComponent(eurl) + "&eeurl=" + encodeURIComponent(eeurl);
9248 window.addEventListener('message', function(event) {
9249 // console.log(event);
9250 if (event.origin === origin) {
9251 if (event.data.message == '0') {
9252 msg("Sync completed successfully!");
9253 switchStep("who");
9254 } else {
9255 msg("Sync encountered an error!");
9256 switchStep("who");
9257 }
9258 } else {
9259 msg("Sync process has finished.");
9260 switchStep("who");
9261 }
9262 }, false);
9263 });
9264}
9265
9266
9267
9268// row.forEach(function (item, index) {
9269// });
9270var wizPositions = [];
9271
9272function populatepositions(target) {
9273 if (!wizPositions.length) {
9274 $.ajax({
9275 type: 'POST',
9276 url: 'api.php',
9277 data: {
9278 mode: 'positions'
9279 },
9280 dataType: 'json',
9281 success: function(rows) {
9282 var positions = [];
9283 for (row in rows) {
9284 if (!isNumber(row)) {
9285 continue;
9286 }
9287 var item = rows[row];
9288 if (item.hiring != '' && item.hiring != '{}' && isJson(decodeEntities(item.hiring))) {
9289 var position = JSON.parse(decodeEntities(item.hiring));
9290 var subarray = [];
9291 for (var key in position) {
9292 if (position.hasOwnProperty(key) && position[key] != null && position != "") {
9293 subarray = position[key].position.split(',');;
9294 for (var x in subarray) {
9295 var pos = subarray[x].trim();
9296 if (pos != "") {
9297 pos = capitalizeWords(pos);
9298 if (!positions.includes(pos)) {
9299 positions.push(pos);
9300 }
9301 }
9302 }
9303 }
9304 }
9305 }
9306 }
9307 wizPositions = positions;
9308 // autocomplete(document.getElementById(target), wizPositions);
9309 }
9310 });
9311 } else {
9312 // autocomplete(document.getElementById(target), wizPositions);
9313 }
9314}
9315$('#usertimezone').val("Eastern");
9316
9317var faded = 0;
9318
9319function hover(element) {
9320 $('img', element).attr('src', 'quest_icon_hover.png');
9321 $('img', element).css({
9322 'filter': 'drop-shadow(0px 0px 5px #000)'
9323 });
9324}
9325
9326function unhover(element) {
9327 $('img', element).attr('src', 'quest_icon.png');
9328 $('img', element).css({
9329 'filter': 'drop-shadow(0px 0px 2px #000)'
9330 });
9331}
9332
9333var imagesArray = [
9334 "comms-background17.png",
9335 "rpf.png"
9336 //"getimage.php?crystal-shouts"
9337];
9338preload(imagesArray);
9339preload([
9340 "getimage.php?crystal-shouts",
9341 "getimage.php?0",
9342 "getimage.php?",
9343 'quest_icon_hover.png',
9344 "comms.png",
9345 'comms.gif',
9346 'loading.gif',
9347 'search.png',
9348 'addmedia.png'
9349]);
9350var imageIndex = 0;
9351
9352function changeBackground(bgElement = "contain") {
9353 var index = Math.floor(Math.random() * imagesArray.length);
9354 if (!$("#" + bgElement).length) {
9355 clearInterval(commsBgInterval);
9356 }
9357 document.getElementById(bgElement).style.backgroundImage = "url(" + imagesArray[index] + ")";
9358}
9359
9360function introEffects() {
9361 $("#header").animate({
9362 top: 0,
9363 }, 1500, function() {
9364 headerwidth = $("#header").width();
9365 });
9366 $("#footer").animate({
9367 bottom: 0,
9368 }, 1500, );
9369}
9370
9371function loggedIn(luser, character, lacct = '1') {
9372 var characterListings;
9373 $('.restricted').fadeIn(500);
9374 $('.captcha').fadeOut(500);
9375 $('#captcha').fadeOut(500);
9376 $('#e-captcha').fadeOut(500);
9377 $('#fc-captcha').fadeOut(500);
9378 if (character == '') {
9379 characterListings = '{Character Name Not Specified}';
9380 } else if (user != 'Guest') {
9381 var characterListings = character.split(' ')[0] + "'s Posts";
9382 }
9383 if (avatar != '') {
9384 $('#avatar-img').attr('src', avatar).fadeIn();
9385 } else {
9386 $('#avatar').fadeOut();
9387 }
9388 $(".logout-form ").fadeIn(500);
9389 acct = lacct;
9390 user = luser;
9391 // console.log(discordUser);
9392 if (discordUser != '0' && discordUser != '') {
9393 createCookie("autoLogin", 'discord-user', "365");
9394 }
9395 if (user != "Guest" && discordUser == '0') {
9396 createCookie("username", user, "365");
9397 } else if (user == "Guest") {
9398 $('#usermanager-img').fadeOut();
9399 //$('#logoutlogin').css('top','0');
9400 //$('#username-span').attr('onclick', '').removeClass('logout-form-username link').css('cursor','default').css('top','0'); -->
9401 characterListings = 'Guest';
9402 }
9403 $("#username-span").html(characterListings);
9404 if (lacct == "2") {
9405 $('.admin').fadeIn(500);
9406 }
9407}
9408
9409function loggedOut() {
9410 var cookieUser = readCookie("username");
9411 if (cookieUser != null) {
9412 $('#username').val(cookieUser);
9413 }
9414 user = '';
9415 playerdata = '';
9416 $('.admin').fadeOut(500);
9417 $('#avatar-img').fadeOut();
9418 $('.user-form').css('top', '0px');
9419 $('#fc-captcha').fadeIn(500);
9420 $('#e-captcha').fadeIn(500);
9421 $('#captcha').fadeIn(500);
9422 $('.captcha').fadeIn(500);
9423 $(".logout-form-username").text();
9424 $(".login-form").fadeIn(500);
9425 $('.restricted').fadeOut(500);
9426}