Time tracking parser - javascript

Moving on from the usual image processing script: I'm thinking of writing a Photoshop time tracking script that will log the filename, directory & time a file is created saved and closed. This is relatively easy with the Scripts Events manager.
The clever bit is writing a second script to parse this information so I clearly see what project I was working on on what day and for how long. The first part can be identified by files saved in certain directories. What's the best way forward to process the various time codes (created, saved & closed) to help me easily see the time tracked on a project?
Is this a trivial thing to do or am I opening a metaphorical can of worms here? Are there any standardised algorithms that may be of use to me?

If I understand correctly.. what you want is Logging..
A logging configuration will mainly consists of four parts.
Loggers
Handlers
Filters
Formatters
In short, a logger is mechanism for writing logs.. Each message that is written to a log is called a log record. A log record can contain metadata, and other informations to describes the event that is being logged. Theres also log level stuff which isnt important here..
After a log record has been recorded it is sent to a handler.
Handler : The handler is the engine that determines what happens to each message in a logger. It describes a particular logging behavior, such as writing a message to the screen, to a file etc.
Filters :
Self-explanatory. You can create filters to only view a specific criteria.
Formatters :
Same as the name says.. Formatting records in more readable way , List, Table , Graph.
Thats just a basic overview of the logging system.
As for your case, you mention that you can already use the exsisting tool to log the events. All you need to do is make a handler, that will interpret those logs and save in a file which can be parsed by the script engine.. csv, json
Something like :
projects : [ { "name" : "foo", " creation": "date",
"events" : [ {"action":"file-created", "timestamp":"date", " file":"sample"}]
},
"name":" bar".....
You need to tailor it to your needs.. Depending on your data and what you wanna do with it you need represent in the best way you can think of.
Then all thats is left to show the desired data in a way you want.. Thats a lot of scripting :0

Related

Why would initially requested HTML be different than what is shown to the user and in inspect element?

There seems to be something fundamental here i'm missing and I'd like to get it cleared up so sorry if this seems low level.
As an example, I would like to grab the shipping information from a specific tracked package on UPS's website (i.e. Shipment status, expected date info like that). So, I look at their URL format and insert my tracking number where applicable. In the network section of my browsers development tools I see an initial request that returns a bunch of HTML, however, this HTML looks vastly different than what I'm seeing on my end as a user as well as what is shown in inspect element.
Essentially what I'm asking is, why would this returned HTML be different? and what would be the best way of getting the "correct" html when i'm technically getting back the same HTML my browser is using initially when I load up the website myself? In this case I'm using XMLHttpRequest.
image that shows what's visible to the user and what's returned
Here you can see how different the two are, not just due to CSS. In this case the returned html is missing all tracking and shipping info.
Any additional resources would be helpful :)

console.log to a custom category

I have a requirement to display all the logs with a tag (say TelemetryLogs) to a group, so that I can see all the network calls flow in a single view.
The requirement is to see the Network Calls in a grouped view - say a table with key-name , key-type and log-object.
The immediate suggestion that we gave to business is that we would log to console with a prefix and allow them to filter using a filter-expression.
Eg: console.log(``Telemetry %s %s %o``, "name", "type", { someobject: 'someval' })
But they want the group to appear as a sub-group under one-of the categories in chrome (pic below). Apparently, they plan to roll out similar groups and dont want to remember a list of expression, to filter out what they want.
I then realized stackoverflow is the right place to check if this is possible, if not possible, what other grouped display options would help us achieve a similar expectation.
Note: Background of the use-case is that during our pair-programming, sometimes we end up business analyst sitting next to us. One of them realized if they had a consolidated-running-view of the telemetry data during development, it would help him/her catch early issues...
there is no way to create sub groups in the console current API standard that appear in the developer tools panel - there are group related functions that can group multiple log statements under one statement but thats not what you want, anyway here are two options that came to my mind
structure you log messages in a way that they can be easily filtered using the built in filter for logs maybe something of the following nature (groupId - logType - message) (Anyway it is always better to have a structure for logs)
The developer tools are part of the page, and they can have custom extended functionalities, you can create an extension that adds subgroups to that panel, along with the functionality you need, or you can add a tab of your own to filter that logs (its easier that what it looks)
Anyway one important thing to note, is that if logs are important to you then they should be sent to an external service that ensures no data is lost, and enables advanced load and extract functionalities on the logs. And anyway logs on the client side in the console are only useful for development, so is it worth it ?

Sharepoint - How to: dynamic Url for Note on Noteboard

I'm quite new to SharePoint (about 1 week into it actually) and I'm attempting to mirror certain functionality that my company has with other products. Currently I'm working on how to duplicate the tasking environment in Box.com. Essentially it's just an email link that goes to a webpage where users can view an image and comments related to that image side by side.
I can dynamically load the image based on url parameters using just Javascript so that part is not a problem. As far as the comments part goes I've been trying to use a Noteboard WebPart, and then my desire is to have the "Url for Note" property to change dependent on the same URL parameter. I've looked over the Javascript Object Model and Class Library on MSDN but the hierarchy seems to stop at WebPart so I'm not finding anything that will allow me to update the Url for Note property.
I've read comments saying that there's a lot of exploration involved with this so I've tried the following:
-loading the javascript files into VisualStudio to use intellisense for looking up functions and properties in the SP.js files.
-console.log() on: WebPartDefinitionCollection, WebPartDefinition, WebPart, and methods .get_objectData(), get_properties() on all the previous
-embedding script in the "Builder" on the Url for Note property (where it says "click to use Builder" - I'm still not sure what more this offers than just a bigger textbox to put in the URL path)
I'm certain I've missed something obvious here but am gaining information very slowly now that I've exhausted the usual suspects. I very much appreciate any more resources or information anyone has and am willing to accept that I may be approaching this incorrectly if someone has accomplished this before.
Normally I'd keep going through whatever info I could find but I'm currently on a trial period and start school back up again soon so I won't have as much time with it. Apologies if this seems impatient, I'm just not sure where else to look at the moment.
Did you check out the API libraries like SPServices or SharepointPlus? They could help you doing what you want...
For example with SharepointPlus you could:
Create a Sharepoint List with a "Note" column and whatever you need to record
When the user goes to the page with the image you just show a TEXTAREA input with a SAVE button
When the user hits the SAVE button it will save the Note to the related list using $SP().list("Your list").add()
And you can easily retrieve the information (to show them to the user if he goes back to the page) with $SP().list("Your list").get()
If I understood your problem, that way it may be easier for you to deal with a customized page :-)

How to synchronize Google Calendar & Spreadsheet with Script

I am trying to create a Google Apps Script that keeps a Google Calendar and a "master spreadsheet" on Drive synchronized -- is this possible? I found these two posts:
http://blog.ouseful.info/2010/03/04/maintaining-google-calendars-from-a-google-spreadsheet/
http://blog.ouseful.info/2010/03/05/grabbing-google-calendar-event-details-into-a-spreadsheet/
I'm quite sure this could be done using a lot of if statements and logic, but maybe there's a simpler way?
I ended up just providing the following simple script. All that was really necessary was adding events based on two columns, and this would've taken too long to develop.
function onOpen() {
//spawns a menu with a button that triggers AddToCal
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Add event to calendar",
functionName : "AddToCal"
}];
sheet.addMenu("Data To Calendar Plugin", entries);
};
function AddToCal(){
//get the current row
var ss = SpreadsheetApp.getActiveSpreadsheet();
var cell = ss.getActiveCell();
var R = cell.getRow();
//grab values for current row to pass to calendar event
var date_of_event = ss.getRange('G'+R).getValue();
var date = new Date(date_of_event);
var event_title = ss.getRange('A'+R).getValue();
//access the calendar
var cal = CalendarApp.getCalendarById('[IDREMOVED]');
cal.createAllDayEvent(event_title,date);
ss.toast("Event added to " + cal.getName());
}
Yes, it's possible to write a two-way event synchronization script, but it isn't going to be simple. Those two posts you refer have parts that could be reused, but they are quite elementary compared to the challenges you'll face with actual synchronization. You may want to read over Using Google Apps Script for a event booking system which does create calendar entries based on a spreadsheet (but doesn't do on-going synchronization). I've done some debugging of that script in past.
Synchronization would need to support:
Creation of events in either location
Modification of event details in either location (although you could opt to consider only a subset of event details for simplification)
Deletion of events in either location
Recurrence, e.g. CalendarEvent.getEventSeries() handling (or choose to avoid)
This is pseudo-code that you could start with:
Open Calendar, Read Calendar events into calArray (will all attributes you care for)
Open Spreadsheet, Read Spreadsheet events into sheetArray
For each event in calArray:
Search for calEvent in sheetArray.
If found, compare lastUpdated values.
If equal, do nothing
Otherwise copy most recently updated to least recently updated
Continue with next event
If not found then copy calEvent to new sheetEvent, including lastUpdated value.
Continue with next event
For each event in the sheetArray (...that hasn't been handled yet)
Similar logic above.
Write updated sheetArray to spreadsheet.
Write updated calEvents to calendar API (see note 1 below)
Notes:
All updates to calEvents could be made to array and written to calendar API immediately, as an alternative to a bulk update. This would eliminate the need to track the changes locally, although it would be a good idea to touch the lastUpdated value.
You will want to use CalendarEvent.getLastUpdated() when reading calEvents, and store a similar value in your spreadsheet (tied to an onEdit trigger) to facilitate comparisons.
It would simplify comparisons to record CalendarEvent.getId() against events in the spreadsheet. You also have CalendarEvent.setTag(key,value) that could be used to record custom metadata into the calendar, for instance to indicate events that originated or have been synchronized with your spreadsheet. (These tags are not accessible through the GCal UI, so would only be accessible via script.)
You should think about the range of dates or number of events you want to deal with, and limit the scope of the script. If you don't, you are sure to run into execution time limits in real operation.
Some Calendar Event characteristics don't lend themselves to easy expression in a spreadsheet, for instance:
Guest list
Reminder list
As mentioned (thanks Henrique) in the other post I've spent some time - it was actually what brought me to GAS originally - on data exchange between spreadsheets and calendars mainly because people I worked with where used to organize their time schedule (for a highschool) in spreadsheets and I had to take care of the transition to Google Calendars.
After some time though it appeared that the online Calendar interface is far more effective to create events so they don't use the sheet to Calendar scripts anymore !!
On the other hand, the printing and presentation options in GCal are very limited so the other direction is still very useful and we use it all the time !
I know this will seem to be out of subject regarding the original question and maybe too anecdotic but I just wanted to point out that you should thoroughly think about what you really need before reinventing the wheel... As Mogsdad mentioned, some events parameter are not easily described in spreadsheet logic and finally it could become a lot more complicated to use than the original tool.
The only really useful tool I developed using bidirectional data transfer is a 'batch modification tool" when I need to delete or edit a big number of similar events.
For example if we need to change a teacher's name for some reason all along the year I import all the events for a number of class, replace the name in the spreadsheet and update back the class calendar... it takes me 5 minutes and is very easy but these are very specific use cases and I'm not sure it is very common.
Anyway I wouldn't call that "synchronization" since it only takes some events some time and changes them... I've never attempted to keep a spreadsheet up to date with a calendar, from my experience calendars are pretty reliable and I consider them as the original data source. As I already said, we import data in spreadsheets every week just for printing and local archiving.
Sorry for this long and a bit vague comment (that was way too long to fit in a normal 500 chrs comment ;-)
No there isn't. And although a lot of issues regarding Apps Script Calendar Service has been solved (timezones, all day events, queries and so on), it's still a fairly complex task.
I know Serge, the top contributor here in SO on #google-apps-script tag, has developed quite some scripts involving the Calendar Service.
But I don't know of anyway that made a two-way update between a calendar and a spreadsheet. It should be a hard one. If you ever do, please be kind to share :)
I wrote a script that synchronizes between GCalendar and a GSheet. You may be able to use it as is, or can certainly borrow ideas from it. There are separate commands for copying events each way: https://github.com/Davepar/gcalendarsync

Generate an HTML table from a Word Document

I'm putting together a simple website for our department. I'd like to include one of the references that we use often on the main page, a word document that contains a priority list for outstanding work. This document is generated by another department and located on a shared drive. The info is not in a table, but uses a fairly consisten format for displaying info.
Ex: (the info is actually formatted like this)
--------------
Item Title
--------------
Tracker#: 12345-0012 Due; 01/01/12
Description...
My ultimate goal is to have a table on the main page that contains the various items in the priority list. I would like a mechanism that automatically checks the word docs about once an hour, parses the document, generates a table from the info in the doc, and updates the main page accordingly.
I've never done anything like this and have no idea where to start or if what I'm asking is even possible. I'm not in IT and do not have the ability to use ASP or PHP at the moment. So I'd like to avoid server-side scripting if possible, but I may be able to work something out if absolutely necessary.
Thanks
I know how to do this in java.. you can use the docx4j library.. Without that it would be difficult. Can't the team that create the doc store the file as a flat file as well maybe?
One possible solution is to save document as html (using automation - create Word.Application object, call Open, SaveAs) and serve it directly or inside frame.

Categories

Resources