Skip to content

Commit

Permalink
prepositions are no more needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and eungjun-yi committed Nov 3, 2012
1 parent 85fd66e commit f9cc517
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions js/cal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,54 @@ var updatePreview = function(data) {
}
}

var getEmails = function(string) {
return string.match(/[^\s]+@[^\s]+/g);
}

var getDate = function(string) {
var dates = [];
var getDate2 = function(str) {
var match = str.match(/\s+/);
if (match) {
getDate2(str.substring(match.index + 1).trim());
}
while(str) {
date = Date.create(str.trim(), 'ko')
if (date && date != 'Invalid Date') {
dates[str.length] = [date, str];
}
str = str.substring(0, str.lastIndexOf(' '));
}
}

getDate2(string);

return dates.pop();
}

var update = function() {
var source = $('#event').val();
var result = getDate(source);
if (result) {
var date = result[0];
var origin = result[1];
source = source.replace(origin, '');
}
if (date && date != 'Invalid Date') {
data['date'] = date;
}
emails = getEmails(source);
if (emails) {
for (var i = 0; i < emails.length; i++) {
source = source.replace(emails[i], '');
}
}
data['emails'] = emails;
data['summary'] = source;
updatePreview(data);
}

var update2 = function() {
source = $('#event').val();

var phrases = [];
Expand Down

0 comments on commit f9cc517

Please sign in to comment.