placing movie clips around a 24hr clock face (as2) - time management - actionscript-2

I am currently working on a project to plot the activities of my day out by placing them around a 24 hr clock face. the final out come of this is a time management app that allows you to find spaces in your day that could be used more proficiently; however; I have hit a bit of a snafu and that is assigning each movie clip (each of which represents an activity) to its correct place of on the clock face.
I am using an XML file to pull the times from and the calculation of the angle where the movie clip should be placed on the clock is done in relation to a central movie clip.
for (i = 0; i < TimeSheet.length; i++) {
var counter = i + 1;
sortXML(TimeSheet);
}
}
};
function sortXML(TimeSheet){
var activity = TimeSheet[i].firstChild.nodeValue;
var description = TimeSheet[i].firstChild.nextSibling.childNodes;
var HrStart = TimeSheet[i].firstChild.nextSibling.nextSibling.childNodes;
var MinStart = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.childNodes;
var HrEnd = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var MinEnd = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var place = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var creativity = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var usefulness = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var enjoyment = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var focus = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
category = TimeSheet[i].nodeName;
HourStart = parseInt(HrStart, 10);
MinuteStart = parseInt(MinStart, 10);
HourEnd = parseInt(HrEnd, 10);
MinuteEnd = parseInt(MinEnd, 10);
Creativity = parseInt(creativity, 10);
Focus = parseInt(focus, 10);
Usefulness = parseInt(usefulness, 10)
var TimeSpent = ((HourEnd*60)+MinuteEnd) - ((HourStart*60)+MinuteStart) ;
//var ActivityMinutes = (HourStart*60)+MinuteStart;
var TimeStart = (HourStart*60)+MinuteStart;
var BobPlacement = ((TimeStart/1440)*360) // where the bob gets blaced on the circle
//var BobPlacement = (360/1440)*TimeStart;
//var radius = 150 + Usefulness;
var radius = 200 + (Usefulness/2);
var xcenter = _root.bobCentral._x;
var ycenter = _root.bobCentral._y;
var degree = (BobPlacement + 180)*-1;;
var radian;
radian = (degree/180)*Math.PI;
newBob._x = xcenter+Math.cos(radian)*radius;
newBob._y = ycenter-Math.sin(radian)*radius;
/*trace("-----------------------------------");
trace("category = "+category);
trace("activity = " + activity);
trace("Description = " + description);
trace("time start = " + HourStart + ":" + MinuteStart);
trace("time end = " + HourEnd + ":" + MinuteEnd);
trace("Duration of activity = "+TimeSpent);
trace("place = "+ place);
trace("creativity = "+ creativity);
trace("usefulness = "+ usefulness);
trace("enjoyment = "+ enjoyment);
trace("focus = "+ focus);
trace("Time Started = "+ TimeStart);
trace("palce on circle = "+ BobPlacement);
*/
dupeMC(TimeSheet, category, activity, description, HourStart, MinuteStart, TimeSpent, Creativity, Focus, Usefulness);
}
function dupeMC(TimeSheet, category, activity, description, HourStart, MinuteStart, TimeSpent, Creativity, Focus, Usefulness){
bob.duplicateMovieClip("bob"+i, i);
newBob = eval("bob"+i);
Any help would be much appreciated
I apologies in advance if the way I have put this question forward is confusing in any way.

Related

GOOGLE SHEET TELEGRAM character % or $

Telegram Bot API with Google Sheets I HAVE PROBLEM IN CODE
when run telegram bot and press on show last expenses
if i put in chart in google sheet bot stack and never show result
here is the code below
var expenseSheet = SpreadsheetApp.openById(ssId);
var expenses = [];
var expensesSheet = expenseSheet.getSheetByName("Requests");
var lr = expensesSheet.getDataRange().getLastRow();
var counter = 0;
for (var i = lr; i > 1; i--)
{
var date = expensesSheet.getRange(i, 1).getValue();
date = Date.parse(date);
date = new Date(date).toLocaleDateString(locale, {timeZone: timeZone});
var description = expensesSheet.getRange(i, 2).getValue();
var cost = expensesSheet.getRange(i, 3).getValue();
var category = expensesSheet.getRange(i, 4).getValue();
var detalis = expensesSheet.getRange(i, 5).getValue();
var status = expensesSheet.getRange(i, 9).getValue();
var ticketid = expensesSheet.getRange(i,10).getValue();
expenses.push("\n---------\n"
+ "šŸ—“ļø Date: <b>" + date
+ "</b>\nšŸ“‹ Category: <b>" + category
+ "</b>\nšŸ”Ž Description: <b>" + description
+ "</b>\n Value: <b>& " + cost
+ "</b>\nšŸ•µ Details: <b>" + detalis
+ "</b>\nšŸ•µ Ticket ID: <b>" + ticketid
+ "</b>\nšŸ“Š status: <b>" + status+"</b>");
counter++;
if (counter >= 1)
break;

How to Convert Geohash to Geometry in BigQuery?

PostGIS has this function ST_GeomFromGeoHash to get the bounding box geometry of the geohash area (https://postgis.net/docs/ST_GeomFromGeoHash.html), but it has not been ported to BigQuery yet. Is there any workaround?
I've implemented the following BigQuery UDF that converts a geohash of arbitrary precision to a bounding box geometry:
CREATE OR REPLACE FUNCTION dataset.geohash_to_bbox(geohash STRING)
RETURNS STRING
LANGUAGE js AS """
var BASE32_CODES = "0123456789bcdefghjkmnpqrstuvwxyz";
var BASE32_CODES_DICT = {};
for (var i = 0; i < BASE32_CODES.length; i++) {
BASE32_CODES_DICT[BASE32_CODES.charAt(i)] = i;
}
var ENCODE_AUTO = 'auto';
var MIN_LAT = -90;
var MAX_LAT = 90;
var MIN_LON = -180;
var MAX_LON = 180;
var decode_bbox = function (hash_string) {
var isLon = true,
maxLat = MAX_LAT,
minLat = MIN_LAT,
maxLon = MAX_LON,
minLon = MIN_LON,
mid;
var hashValue = 0;
for (var i = 0, l = hash_string.length; i < l; i++) {
var code = hash_string[i].toLowerCase();
hashValue = BASE32_CODES_DICT[code];
for (var bits = 4; bits >= 0; bits--) {
var bit = (hashValue >> bits) & 1;
if (isLon) {
mid = (maxLon + minLon) / 2;
if (bit === 1) {
minLon = mid;
} else {
maxLon = mid;
}
} else {
mid = (maxLat + minLat) / 2;
if (bit === 1) {
minLat = mid;
} else {
maxLat = mid;
}
}
isLon = !isLon;
}
}
return "POLYGON (( " + minLon + " " + minLat + ", " + maxLon + " " + minLat + ", " + maxLon + " " + maxLat + ", " + minLon + " " + maxLat + ", " + minLon + " " + minLat + "))";
};
return decode_bbox(geohash);
""";
Example usage:
select <dataset>.geohash_to_geom("ttnfv2u");
>> POLYGON((77.2119140625 28.6083984375, 77.2119140625 28.65234375, 77.255859375 28.65234375, 77.255859375 28.6083984375, 77.2119140625 28.6083984375))
BigQuery has ST_GEOGPOINTFROMGEOHASH which returns the central point. There is currently no function that returns the box though. The UDF in another answer is often a reasonable workaround, but you should be aware of its usage limitation.
GeoHash normally represents a rectangle on a flat 2D map. BigQuery works with Geography, with geodesic edges, so an edge between two points with same latitude does not follow the parallel, but being geodesic line is a shorter route closer to the pole. So the BigQuery polygon is a bit different from 2D box. You can often ignore the differences, but it might give you wrong results depending on how you use this polygon.

Set resolution when exporting artboards to PNG using script

Sorry that this is so similar to a recent post but I can't find the solution anywhere. I have created a simple script that loops through each artboard in an open illustrator document and exports it as a separate PNG file. All is working well except that I want to set the resolution to 150 dpi and not the default 72 dpi, for production reasons. This is an option that you can set when exporting manually to PNG but I don't seem to be able to set it in the PNG options in the code, although the script runs without errors it ignores the resolution setting. Could someone let me know how to do this, many thanks. Code as follows:
var doc = app.activeDocument;;//Gets the active document
var fileName = doc.name.slice(0, 9);//Gets the G Number
var numArtboards = doc.artboards.length;//returns the number of artboards in the document
var filePath = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/');
var options = new ExportOptionsPNG24();
for (var i = 0; i < numArtboards; i++ ) {
doc.artboards.setActiveArtboardIndex( i );
options.artBoardClipping = true;
options.matte = false;
options.horizontalScale = 100;
options.verticalScale = 100;
options.transparency = true;
var artboardName = doc.artboards[i].name;
//$.writeln("artboardName= ", artboardName);
var destFile = new File(filePath + "/" + fileName + " " + artboardName + ".png");
//$.writeln("destFile= ",destFile);
doc.exportFile(destFile,ExportType.PNG24,options);
}
After doing some digging I've found that if you use imageCapture you can set the resolutuion. So new script below. thanks to CarlosCanto for providing this link via the Adobe Forum https://forums.adobe.com/message/9075307#9075307
var doc = app.activeDocument;;//Gets the active document
var fileName = doc.name.slice(0, 9);//Gets the G Number
var numArtboards = doc.artboards.length;//returns the number of artboards in the document
var filePath = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/');
var options = new ImageCaptureOptions();
for (var i = 0; i < numArtboards; i++) {
doc.artboards.setActiveArtboardIndex(i);
var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];
options.artBoardClipping = true;
options.resolution = 150;
options.antiAliasing = true;
options.matte = false;
options.horizontalScale = 100;
options.verticalScale = 100;
options.transparency = true;
var artboardName = doc.artboards[i].name;
var destFile = new File(filePath + "/" + fileName + " " + artboardName + ".png");
doc.imageCapture(destFile, activeAB.artboardRect, options);
}

Line break in date axis with amcharts

As you can see here http://allopensensors.com/profile/andreas/
the date on x-axis is nonreadable. I'd like to add a line break. How can i solve this?
AmCharts.ready(function () {
// SERIAL CHART
chart = new AmCharts.AmSerialChart();
chart.pathToImages = "http://allopensensors.com/amcharts/images/";
chart.dataProvider = chartData;
chart.marginLeft = 10;
chart.categoryField = "year";
chart.dataDateFormat = "YYYY-MM-DD JJ:NN:SS";
// listen for "dataUpdated" event (fired when chart is inited) and call zoomChart method when it happens
chart.addListener("dataUpdated", zoomChart);
// AXES
// category
var categoryAxis = chart.categoryAxis;
// categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
categoryAxis.minPeriod = "200"; // our data is yearly, so we set minPeriod to YYYY
categoryAxis.dashLength = 3;
categoryAxis.minorGridEnabled = true;
categoryAxis.minorGridAlpha = 0.1;
// value
var valueAxis = new AmCharts.ValueAxis();
valueAxis.axisAlpha = 0;
valueAxis.inside = true;
valueAxis.dashLength = 3;
chart.addValueAxis(valueAxis);
// GRAPH
graph = new AmCharts.AmGraph();
graph.type = "smoothedLine"; // this line makes the graph smoothed line.
graph.lineColor = "#d1655d";
graph.negativeLineColor = "#637bb6"; // this line makes the graph to change color when it drops below 0
graph.bullet = "round";
graph.bulletSize = 8;
graph.bulletBorderColor = "#FFFFFF";
graph.bulletBorderAlpha = 1;
graph.bulletBorderThickness = 2;
graph.lineThickness = 2;
graph.valueField = "value";
graph.balloonText = "[[category]]<br><b><span style='font-size:14px;'>[[value]]</span></b>";
chart.addGraph(graph);
// CURSOR
var chartCursor = new AmCharts.ChartCursor();
chartCursor.cursorAlpha = 0;
chartCursor.cursorPosition = "mouse";
chartCursor.categoryBalloonDateFormat = "JJ:NN:SS";
chart.addChartCursor(chartCursor);
// SCROLLBAR
var chartScrollbar = new AmCharts.ChartScrollbar();
chart.addChartScrollbar(chartScrollbar);
chart.creditsPosition = "bottom-right";
// WRITE
chart.write("chartdiv");
});
// this method is called when chart is first inited as we listen for "dataUpdated" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
// chart.zoomToDates(new Date(1972, 0), new Date(2200, 0));
chart.zoomToIndexes(chartData.length - 40, chartData.length - 1);
}
To make it readable, you can rotate the labels with custom angle. Try categoryAxis.labelRotation : 45
For Reference: http://www.amcharts.com/demos/column-with-rotated-series/
Hope it helps!

Refreshing view panel from dojo widget

Got this code from #MichaelSaiz and altered it slightly, and the calendar widget looks/works great with the Calendar.css that comes with dojo 1.5.x on the Domino server.
However, I need to refresh a Calendar view when the user clicks on a date, and although fields are being refreshed OK, the view is behaving strangely, and I can't see why?
XSP.addOnLoad(function(){
dojo.require("dojox.widget.Calendar");
dojo.require("dojo.date","dijit.registry");
dojo.require("dojo.date.locale");
dojo.require("dijit.Calendar");
dojo.ready(function(){
// create the Calendar:
var selectedDate = null;
var calendar_body = new dojox.widget.Calendar({
value: new Date(),
onValueSelected: function(date){calendarDateClicked(date);
}
}, "calendar_body");
//create Click action
function calendarDateClicked(date){
var d = new Date(date);
var month = '' + (d.getMonth() + 1);
var day = '' + d.getDate();
var year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
var dateString = [day,month,year].join("/");
var y = dojo.date.locale.format(d, {datePattern:"dd/MM/yyyy", selector: 'date'});
//dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = dateString
dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = y;
dojo.byId('#{id:calDate}').value = y;
//dojo.byId('#{id:calDate}').value = dateString;
XSP.partialRefreshGet("#{id:dayPanel1}",{});//Post Value to server
}
});
});
This fires when the user clicks the calendar and it updates a field (calDate) and then updates the viewPanel (dayPanel1).
The view is filtered based on a calDate field which clicking on the calendar sets.
Any ideas how I can get the view refreshed when the user clicks on the calendar? Seems basic but it's driving me nuts!!
Graeme
The date format was incorrect (as #MichaelSaiz surmised). Got it sorted now.
XSP.addOnLoad(function(){
dojo.require("dojox.widget.Calendar");
dojo.require("dojo.date","dijit.registry");
dojo.require("dojo.date.locale");
dojo.require("dijit.Calendar");
dojo.ready(function(){
// create the Calendar:
var selectedDate = null;
var calendar_body = new dojox.widget.Calendar({
value: new Date(),
onValueSelected: function(date){calendarDateClicked(date);
}
}, "calendar_body");
//Set month in correct format
function setMonth(month){
switch(month)
{
case 1:
month = "Jan";
break;
case 2:
month = "Feb";
break;
}
return month;
}
//create Click action
function calendarDateClicked(date){
var d = new Date(date);
var month = (d.getMonth() + 1);
month = setMonth(month);
var day = '' + d.getDate() + ",";
var year = d.getFullYear();
//if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
var dateString = [month,day,year].join(" ");
//var y = dojo.date.locale.format(d, {datePattern:"dd/MM/yyyy", selector: 'date'});
dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = dateString
//dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = y;
//dojo.byId('#{id:calDate}').value = y;
dojo.byId('#{id:calDate}').value = dateString;
XSP.partialRefreshPost("#{id:mainPanel}",{});//Post Value to server
}
});
});