Fixed JavaScript "space-infix-ops" violations.
This commit is contained in:
parent
ec6563f585
commit
efc144aba0
|
@ -36,10 +36,7 @@
|
||||||
],
|
],
|
||||||
"space-before-blocks": [2, "always"],
|
"space-before-blocks": [2, "always"],
|
||||||
"space-before-function-paren": [2, {"anonymous": "never", "named": "never"}],
|
"space-before-function-paren": [2, {"anonymous": "never", "named": "never"}],
|
||||||
"space-infix-ops": [
|
"space-infix-ops": [2, {"int32Hint": false}],
|
||||||
1,
|
|
||||||
{"int32Hint": false}
|
|
||||||
],
|
|
||||||
"strict": [1, "function"]
|
"strict": [1, "function"]
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
|
|
|
@ -49,7 +49,7 @@ var SelectBox = {
|
||||||
}
|
}
|
||||||
var j = SelectBox.cache[id].length - 1;
|
var j = SelectBox.cache[id].length - 1;
|
||||||
for (i = delete_index; i < j; i++) {
|
for (i = delete_index; i < j; i++) {
|
||||||
SelectBox.cache[id][i] = SelectBox.cache[id][i+1];
|
SelectBox.cache[id][i] = SelectBox.cache[id][i + 1];
|
||||||
}
|
}
|
||||||
SelectBox.cache[id].length--;
|
SelectBox.cache[id].length--;
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,7 +24,7 @@ Requires core.js, SelectBox.js and addevent.js.
|
||||||
from_box.className = 'filtered';
|
from_box.className = 'filtered';
|
||||||
|
|
||||||
var ps = from_box.parentNode.getElementsByTagName('p');
|
var ps = from_box.parentNode.getElementsByTagName('p');
|
||||||
for (var i=0; i<ps.length; i++) {
|
for (var i = 0; i < ps.length; i++) {
|
||||||
if (ps[i].className.indexOf("info") !== -1) {
|
if (ps[i].className.indexOf("info") !== -1) {
|
||||||
// Remove <p class="info">, because it just gets in the way.
|
// Remove <p class="info">, because it just gets in the way.
|
||||||
from_box.parentNode.removeChild(ps[i]);
|
from_box.parentNode.removeChild(ps[i]);
|
||||||
|
|
|
@ -25,7 +25,7 @@ var DateTimeShortcuts = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputs = document.getElementsByTagName('input');
|
var inputs = document.getElementsByTagName('input');
|
||||||
for (var i=0; i<inputs.length; i++) {
|
for (var i = 0; i < inputs.length; i++) {
|
||||||
var inp = inputs[i];
|
var inp = inputs[i];
|
||||||
if (inp.getAttribute('type') === 'text' && inp.className.match(/vTimeField/)) {
|
if (inp.getAttribute('type') === 'text' && inp.className.match(/vTimeField/)) {
|
||||||
DateTimeShortcuts.addClock(inp);
|
DateTimeShortcuts.addClock(inp);
|
||||||
|
@ -161,8 +161,8 @@ var DateTimeShortcuts = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openClock: function(num) {
|
openClock: function(num) {
|
||||||
var clock_box = document.getElementById(DateTimeShortcuts.clockDivName+num);
|
var clock_box = document.getElementById(DateTimeShortcuts.clockDivName + num);
|
||||||
var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName+num);
|
var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName + num);
|
||||||
|
|
||||||
// Recalculate the clockbox position
|
// Recalculate the clockbox position
|
||||||
// is it left-to-right or right-to-left layout ?
|
// is it left-to-right or right-to-left layout ?
|
||||||
|
@ -252,9 +252,9 @@ var DateTimeShortcuts = {
|
||||||
|
|
||||||
// next-prev links
|
// next-prev links
|
||||||
var cal_nav = quickElement('div', cal_box);
|
var cal_nav = quickElement('div', cal_box);
|
||||||
var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', 'javascript:DateTimeShortcuts.drawPrev('+num+');');
|
var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', 'javascript:DateTimeShortcuts.drawPrev(' + num + ');');
|
||||||
cal_nav_prev.className = 'calendarnav-previous';
|
cal_nav_prev.className = 'calendarnav-previous';
|
||||||
var cal_nav_next = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNext('+num+');');
|
var cal_nav_next = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNext(' + num + ');');
|
||||||
cal_nav_next.className = 'calendarnav-next';
|
cal_nav_next.className = 'calendarnav-next';
|
||||||
|
|
||||||
// main box
|
// main box
|
||||||
|
@ -285,8 +285,8 @@ var DateTimeShortcuts = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openCalendar: function(num) {
|
openCalendar: function(num) {
|
||||||
var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num);
|
var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1 + num);
|
||||||
var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName+num);
|
var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName + num);
|
||||||
var inp = DateTimeShortcuts.calendarInputs[num];
|
var inp = DateTimeShortcuts.calendarInputs[num];
|
||||||
|
|
||||||
// Determine if the current value in the input has a valid date.
|
// Determine if the current value in the input has a valid date.
|
||||||
|
@ -320,7 +320,7 @@ var DateTimeShortcuts = {
|
||||||
addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
||||||
},
|
},
|
||||||
dismissCalendar: function(num) {
|
dismissCalendar: function(num) {
|
||||||
document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';
|
document.getElementById(DateTimeShortcuts.calendarDivName1 + num).style.display = 'none';
|
||||||
removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
||||||
},
|
},
|
||||||
drawPrev: function(num) {
|
drawPrev: function(num) {
|
||||||
|
|
|
@ -10,17 +10,17 @@ var CalendarNamespace = {
|
||||||
daysOfWeek: gettext('S M T W T F S').split(' '),
|
daysOfWeek: gettext('S M T W T F S').split(' '),
|
||||||
firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')),
|
firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')),
|
||||||
isLeapYear: function(year) {
|
isLeapYear: function(year) {
|
||||||
return (((year % 4)===0) && ((year % 100)!==0) || ((year % 400)===0));
|
return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0));
|
||||||
},
|
},
|
||||||
getDaysInMonth: function(month, year) {
|
getDaysInMonth: function(month, year) {
|
||||||
var days;
|
var days;
|
||||||
if (month===1 || month===3 || month===5 || month===7 || month===8 || month===10 || month===12) {
|
if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) {
|
||||||
days = 31;
|
days = 31;
|
||||||
}
|
}
|
||||||
else if (month===4 || month===6 || month===9 || month===11) {
|
else if (month === 4 || month === 6 || month === 9 || month === 11) {
|
||||||
days = 30;
|
days = 30;
|
||||||
}
|
}
|
||||||
else if (month===2 && CalendarNamespace.isLeapYear(year)) {
|
else if (month === 2 && CalendarNamespace.isLeapYear(year)) {
|
||||||
days = 29;
|
days = 29;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -31,7 +31,7 @@ var CalendarNamespace = {
|
||||||
draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999
|
draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
var todayDay = today.getDate();
|
var todayDay = today.getDate();
|
||||||
var todayMonth = today.getMonth()+1;
|
var todayMonth = today.getMonth() + 1;
|
||||||
var todayYear = today.getFullYear();
|
var todayYear = today.getFullYear();
|
||||||
var todayClass = '';
|
var todayClass = '';
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ var CalendarNamespace = {
|
||||||
// zone.
|
// zone.
|
||||||
var isSelectedMonth = false;
|
var isSelectedMonth = false;
|
||||||
if (typeof selected !== 'undefined') {
|
if (typeof selected !== 'undefined') {
|
||||||
isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth()+1) === month);
|
isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth() + 1) === month);
|
||||||
}
|
}
|
||||||
|
|
||||||
month = parseInt(month);
|
month = parseInt(month);
|
||||||
|
@ -56,7 +56,7 @@ var CalendarNamespace = {
|
||||||
var calDiv = document.getElementById(div_id);
|
var calDiv = document.getElementById(div_id);
|
||||||
removeChildren(calDiv);
|
removeChildren(calDiv);
|
||||||
var calTable = document.createElement('table');
|
var calTable = document.createElement('table');
|
||||||
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month-1] + ' ' + year);
|
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month - 1] + ' ' + year);
|
||||||
var tableBody = quickElement('tbody', calTable);
|
var tableBody = quickElement('tbody', calTable);
|
||||||
|
|
||||||
// Draw days-of-week header
|
// Draw days-of-week header
|
||||||
|
@ -65,7 +65,7 @@ var CalendarNamespace = {
|
||||||
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
|
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var startingPos = new Date(year, month-1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
|
var startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
|
||||||
var days = CalendarNamespace.getDaysInMonth(month, year);
|
var days = CalendarNamespace.getDaysInMonth(month, year);
|
||||||
|
|
||||||
var _cell;
|
var _cell;
|
||||||
|
@ -80,13 +80,13 @@ var CalendarNamespace = {
|
||||||
// Draw days of month
|
// Draw days of month
|
||||||
var currentDay = 1;
|
var currentDay = 1;
|
||||||
for (i = startingPos; currentDay <= days; i++) {
|
for (i = startingPos; currentDay <= days; i++) {
|
||||||
if (i%7 === 0 && currentDay !== 1) {
|
if (i % 7 === 0 && currentDay !== 1) {
|
||||||
tableRow = quickElement('tr', tableBody);
|
tableRow = quickElement('tr', tableBody);
|
||||||
}
|
}
|
||||||
if ((currentDay===todayDay) && (month===todayMonth) && (year===todayYear)) {
|
if ((currentDay === todayDay) && (month === todayMonth) && (year === todayYear)) {
|
||||||
todayClass='today';
|
todayClass = 'today';
|
||||||
} else {
|
} else {
|
||||||
todayClass='';
|
todayClass = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// use UTC function; see above for explanation.
|
// use UTC function; see above for explanation.
|
||||||
|
@ -99,7 +99,7 @@ var CalendarNamespace = {
|
||||||
|
|
||||||
var cell = quickElement('td', tableRow, '', 'class', todayClass);
|
var cell = quickElement('td', tableRow, '', 'class', todayClass);
|
||||||
|
|
||||||
quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');
|
quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '(' + year + ',' + month + ',' + currentDay + '));');
|
||||||
currentDay++;
|
currentDay++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// Don't hide if fields in this fieldset have errors
|
// Don't hide if fields in this fieldset have errors
|
||||||
if ($(elem).find("div.errors").length === 0) {
|
if ($(elem).find("div.errors").length === 0) {
|
||||||
$(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
|
$(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
|
||||||
i +'" class="collapse-toggle" href="#">' + gettext("Show") +
|
i + '" class="collapse-toggle" href="#">' + gettext("Show") +
|
||||||
'</a>)');
|
'</a>)');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Core javascript helper functions
|
// Core javascript helper functions
|
||||||
|
|
||||||
// basic browser identification & version
|
// basic browser identification & version
|
||||||
var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion);
|
var isOpera = (navigator.userAgent.indexOf("Opera") >= 0) && parseFloat(navigator.appVersion);
|
||||||
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
|
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
|
||||||
|
|
||||||
// Cross-browser event handlers.
|
// Cross-browser event handlers.
|
||||||
|
@ -48,7 +48,7 @@ function quickElement() {
|
||||||
}
|
}
|
||||||
var len = arguments.length;
|
var len = arguments.length;
|
||||||
for (var i = 3; i < len; i += 2) {
|
for (var i = 3; i < len; i += 2) {
|
||||||
obj.setAttribute(arguments[i], arguments[i+1]);
|
obj.setAttribute(arguments[i], arguments[i + 1]);
|
||||||
}
|
}
|
||||||
arguments[1].appendChild(obj);
|
arguments[1].appendChild(obj);
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -132,12 +132,12 @@ Date.prototype.getTwelveHours = function() {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return hours <= 12 ? hours : hours-12;
|
return hours <= 12 ? hours : hours - 12;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Date.prototype.getTwoDigitMonth = function() {
|
Date.prototype.getTwoDigitMonth = function() {
|
||||||
return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1);
|
return (this.getMonth() < 9) ? '0' + (this.getMonth() + 1) : (this.getMonth() + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
Date.prototype.getTwoDigitDate = function() {
|
Date.prototype.getTwoDigitDate = function() {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").prop("autocomplete", "off");
|
var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").prop("autocomplete", "off");
|
||||||
// only show the add button if we are allowed to add more items,
|
// only show the add button if we are allowed to add more items,
|
||||||
// note that max_num = None translates to a blank string.
|
// note that max_num = None translates to a blank string.
|
||||||
var showAddButton = maxForms.val() === '' || (maxForms.val()-totalForms.val()) > 0;
|
var showAddButton = maxForms.val() === '' || (maxForms.val() - totalForms.val()) > 0;
|
||||||
$this.each(function(i) {
|
$this.each(function(i) {
|
||||||
$(this).not("." + options.emptyCssClass).addClass(options.formCssClass);
|
$(this).not("." + options.emptyCssClass).addClass(options.formCssClass);
|
||||||
});
|
});
|
||||||
|
@ -66,11 +66,11 @@
|
||||||
if (row.is("tr")) {
|
if (row.is("tr")) {
|
||||||
// If the forms are laid out in table rows, insert
|
// If the forms are laid out in table rows, insert
|
||||||
// the remove button into the last table cell:
|
// the remove button into the last table cell:
|
||||||
row.children(":last").append('<div><a class="' + options.deleteCssClass +'" href="javascript:void(0)">' + options.deleteText + "</a></div>");
|
row.children(":last").append('<div><a class="' + options.deleteCssClass + '" href="javascript:void(0)">' + options.deleteText + "</a></div>");
|
||||||
} else if (row.is("ul") || row.is("ol")) {
|
} else if (row.is("ul") || row.is("ol")) {
|
||||||
// If they're laid out as an ordered/unordered list,
|
// If they're laid out as an ordered/unordered list,
|
||||||
// insert an <li> after the last list item:
|
// insert an <li> after the last list item:
|
||||||
row.append('<li><a class="' + options.deleteCssClass +'" href="javascript:void(0)">' + options.deleteText + "</a></li>");
|
row.append('<li><a class="' + options.deleteCssClass + '" href="javascript:void(0)">' + options.deleteText + "</a></li>");
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, just insert the remove button as the
|
// Otherwise, just insert the remove button as the
|
||||||
// last child element of the form's container:
|
// last child element of the form's container:
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
$(totalForms).val(parseInt(totalForms.val(), 10) + 1);
|
$(totalForms).val(parseInt(totalForms.val(), 10) + 1);
|
||||||
nextIndex += 1;
|
nextIndex += 1;
|
||||||
// Hide add button in case we've hit the max, except we want to add infinitely
|
// Hide add button in case we've hit the max, except we want to add infinitely
|
||||||
if ((maxForms.val() !== '') && (maxForms.val()-totalForms.val()) <= 0) {
|
if ((maxForms.val() !== '') && (maxForms.val() - totalForms.val()) <= 0) {
|
||||||
addButton.parent().hide();
|
addButton.parent().hide();
|
||||||
}
|
}
|
||||||
// The delete button of each row triggers a bunch of other things
|
// The delete button of each row triggers a bunch of other things
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
var forms = $("." + options.formCssClass);
|
var forms = $("." + options.formCssClass);
|
||||||
$("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length);
|
$("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length);
|
||||||
// Show add button again once we drop below max
|
// Show add button again once we drop below max
|
||||||
if ((maxForms.val() === '') || (maxForms.val()-forms.length) > 0) {
|
if ((maxForms.val() === '') || (maxForms.val() - forms.length) > 0) {
|
||||||
addButton.parent().show();
|
addButton.parent().show();
|
||||||
}
|
}
|
||||||
// Also, update names and ids for all remaining form controls
|
// Also, update names and ids for all remaining form controls
|
||||||
|
@ -112,8 +112,7 @@
|
||||||
var updateElementCallback = function() {
|
var updateElementCallback = function() {
|
||||||
updateElementIndex(this, options.prefix, i);
|
updateElementIndex(this, options.prefix, i);
|
||||||
};
|
};
|
||||||
for (i=0, formCount=forms.length; i<formCount; i++)
|
for (i = 0, formCount = forms.length; i < formCount; i++) {
|
||||||
{
|
|
||||||
updateElementIndex($(forms).get(i), options.prefix, i);
|
updateElementIndex($(forms).get(i), options.prefix, i);
|
||||||
$(forms.get(i)).find("*").each(updateElementCallback);
|
$(forms.get(i)).find("*").each(updateElementCallback);
|
||||||
}
|
}
|
||||||
|
@ -164,11 +163,11 @@
|
||||||
if (typeof SelectFilter !== 'undefined') {
|
if (typeof SelectFilter !== 'undefined') {
|
||||||
$('.selectfilter').each(function(index, value) {
|
$('.selectfilter').each(function(index, value) {
|
||||||
var namearr = value.name.split('-');
|
var namearr = value.name.split('-');
|
||||||
SelectFilter.init(value.id, namearr[namearr.length-1], false);
|
SelectFilter.init(value.id, namearr[namearr.length - 1], false);
|
||||||
});
|
});
|
||||||
$('.selectfilterstacked').each(function(index, value) {
|
$('.selectfilterstacked').each(function(index, value) {
|
||||||
var namearr = value.name.split('-');
|
var namearr = value.name.split('-');
|
||||||
SelectFilter.init(value.id, namearr[namearr.length-1], true);
|
SelectFilter.init(value.id, namearr[namearr.length - 1], true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -230,11 +229,11 @@
|
||||||
if (typeof SelectFilter !== "undefined") {
|
if (typeof SelectFilter !== "undefined") {
|
||||||
$(".selectfilter").each(function(index, value) {
|
$(".selectfilter").each(function(index, value) {
|
||||||
var namearr = value.name.split('-');
|
var namearr = value.name.split('-');
|
||||||
SelectFilter.init(value.id, namearr[namearr.length-1], false);
|
SelectFilter.init(value.id, namearr[namearr.length - 1], false);
|
||||||
});
|
});
|
||||||
$(".selectfilterstacked").each(function(index, value) {
|
$(".selectfilterstacked").each(function(index, value) {
|
||||||
var namearr = value.name.split('-');
|
var namearr = value.name.split('-');
|
||||||
SelectFilter.init(value.id, namearr[namearr.length-1], true);
|
SelectFilter.init(value.id, namearr[namearr.length - 1], true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,7 +112,7 @@ var Downcoder = {
|
||||||
}
|
}
|
||||||
Downcoder.map = {};
|
Downcoder.map = {};
|
||||||
Downcoder.chars = [];
|
Downcoder.chars = [];
|
||||||
for (var i=0; i<ALL_DOWNCODE_MAPS.length; i++) {
|
for (var i = 0; i < ALL_DOWNCODE_MAPS.length; i++) {
|
||||||
var lookup = ALL_DOWNCODE_MAPS[i];
|
var lookup = ALL_DOWNCODE_MAPS[i];
|
||||||
for (var c in lookup) {
|
for (var c in lookup) {
|
||||||
if (lookup.hasOwnProperty(c)) {
|
if (lookup.hasOwnProperty(c)) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
OpenLayers.Util.properFeatures = function(features, geom_type) {
|
OpenLayers.Util.properFeatures = function(features, geom_type) {
|
||||||
if (features.constructor === Array) {
|
if (features.constructor === Array) {
|
||||||
var geoms = [];
|
var geoms = [];
|
||||||
for (var i=0; i<features.length; i++) {
|
for (var i = 0; i < features.length; i++) {
|
||||||
geoms.push(features[i].geometry);
|
geoms.push(features[i].geometry);
|
||||||
}
|
}
|
||||||
var geom = new geom_type(geoms);
|
var geom = new geom_type(geoms);
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
var point;
|
var point;
|
||||||
var points = OpenLayers.String.trim(str).split(this.regExes.justComma);
|
var points = OpenLayers.String.trim(str).split(this.regExes.justComma);
|
||||||
var components = [];
|
var components = [];
|
||||||
for(var i=0, len=points.length; i<len; ++i) {
|
for(var i = 0, len = points.length; i < len; ++i) {
|
||||||
point = points[i].replace(this.regExes.trimParens, '$1');
|
point = points[i].replace(this.regExes.trimParens, '$1');
|
||||||
components.push(this.parse.point.apply(this, [point]).geometry);
|
components.push(this.parse.point.apply(this, [point]).geometry);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
'linestring': function(str) {
|
'linestring': function(str) {
|
||||||
var points = OpenLayers.String.trim(str).split(',');
|
var points = OpenLayers.String.trim(str).split(',');
|
||||||
var components = [];
|
var components = [];
|
||||||
for(var i=0, len=points.length; i<len; ++i) {
|
for(var i = 0, len = points.length; i < len; ++i) {
|
||||||
components.push(this.parse.point.apply(this, [points[i]]).geometry);
|
components.push(this.parse.point.apply(this, [points[i]]).geometry);
|
||||||
}
|
}
|
||||||
return new OpenLayers.Feature.Vector(
|
return new OpenLayers.Feature.Vector(
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
var line;
|
var line;
|
||||||
var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma);
|
var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma);
|
||||||
var components = [];
|
var components = [];
|
||||||
for(var i=0, len=lines.length; i<len; ++i) {
|
for(var i = 0, len = lines.length; i < len; ++i) {
|
||||||
line = lines[i].replace(this.regExes.trimParens, '$1');
|
line = lines[i].replace(this.regExes.trimParens, '$1');
|
||||||
components.push(this.parse.linestring.apply(this, [line]).geometry);
|
components.push(this.parse.linestring.apply(this, [line]).geometry);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
var ring, linestring, linearring;
|
var ring, linestring, linearring;
|
||||||
var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma);
|
var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma);
|
||||||
var components = [];
|
var components = [];
|
||||||
for(var i=0, len=rings.length; i<len; ++i) {
|
for(var i = 0, len = rings.length; i < len; ++i) {
|
||||||
ring = rings[i].replace(this.regExes.trimParens, '$1');
|
ring = rings[i].replace(this.regExes.trimParens, '$1');
|
||||||
linestring = this.parse.linestring.apply(this, [ring]).geometry;
|
linestring = this.parse.linestring.apply(this, [ring]).geometry;
|
||||||
linearring = new OpenLayers.Geometry.LinearRing(linestring.components);
|
linearring = new OpenLayers.Geometry.LinearRing(linestring.components);
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
var polygon;
|
var polygon;
|
||||||
var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma);
|
var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma);
|
||||||
var components = [];
|
var components = [];
|
||||||
for(var i=0, len=polygons.length; i<len; ++i) {
|
for(var i = 0, len = polygons.length; i < len; ++i) {
|
||||||
polygon = polygons[i].replace(this.regExes.trimParens, '$1');
|
polygon = polygons[i].replace(this.regExes.trimParens, '$1');
|
||||||
components.push(this.parse.polygon.apply(this, [polygon]).geometry);
|
components.push(this.parse.polygon.apply(this, [polygon]).geometry);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
str = str.replace(/,\s*([A-Za-z])/g, '|$1');
|
str = str.replace(/,\s*([A-Za-z])/g, '|$1');
|
||||||
var wktArray = OpenLayers.String.trim(str).split('|');
|
var wktArray = OpenLayers.String.trim(str).split('|');
|
||||||
var components = [];
|
var components = [];
|
||||||
for(var i=0, len=wktArray.length; i<len; ++i) {
|
for(var i = 0, len = wktArray.length; i < len; ++i) {
|
||||||
components.push(OpenLayers.Format.WKT.prototype.read.apply(this, [wktArray[i]]));
|
components.push(OpenLayers.Format.WKT.prototype.read.apply(this, [wktArray[i]]));
|
||||||
}
|
}
|
||||||
return components;
|
return components;
|
||||||
|
@ -145,8 +145,8 @@
|
||||||
if (isCollection) {
|
if (isCollection) {
|
||||||
collection = features.geometry.components;
|
collection = features.geometry.components;
|
||||||
pieces.push('GEOMETRYCOLLECTION(');
|
pieces.push('GEOMETRYCOLLECTION(');
|
||||||
for (var i=0, len=collection.length; i<len; ++i) {
|
for (var i = 0, len = collection.length; i < len; ++i) {
|
||||||
if (i>0) {
|
if (i > 0) {
|
||||||
pieces.push(',');
|
pieces.push(',');
|
||||||
}
|
}
|
||||||
pieces.push(this.extractGeometry(collection[i]));
|
pieces.push(this.extractGeometry(collection[i]));
|
||||||
|
@ -220,7 +220,7 @@
|
||||||
var feat = OpenLayers.Util.properFeatures(this.read_wkt(wkt), this.options.geom_type);
|
var feat = OpenLayers.Util.properFeatures(this.read_wkt(wkt), this.options.geom_type);
|
||||||
this.write_wkt(feat);
|
this.write_wkt(feat);
|
||||||
if (this.options.is_collection) {
|
if (this.options.is_collection) {
|
||||||
for (var i=0; i<this.num_geom; i++) {
|
for (var i = 0; i < this.num_geom; i++) {
|
||||||
this.layers.vector.addFeatures([new OpenLayers.Feature.Vector(feat.geometry.components[i].clone())]);
|
this.layers.vector.addFeatures([new OpenLayers.Feature.Vector(feat.geometry.components[i].clone())]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -298,7 +298,7 @@
|
||||||
MapWidget.prototype.add_wkt = function(event) {
|
MapWidget.prototype.add_wkt = function(event) {
|
||||||
if (this.options.is_collection) {
|
if (this.options.is_collection) {
|
||||||
var feat = new OpenLayers.Feature.Vector(new this.options.geom_type());
|
var feat = new OpenLayers.Feature.Vector(new this.options.geom_type());
|
||||||
for (var i=0; i<this.layers.vector.features.length; i++) {
|
for (var i = 0; i < this.layers.vector.features.length; i++) {
|
||||||
feat.geometry.addComponents([this.layers.vector.features[i].geometry]);
|
feat.geometry.addComponents([this.layers.vector.features[i].geometry]);
|
||||||
}
|
}
|
||||||
this.write_wkt(feat);
|
this.write_wkt(feat);
|
||||||
|
@ -319,7 +319,7 @@
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
var feat = new OpenLayers.Feature.Vector(new this.options.geom_type());
|
var feat = new OpenLayers.Feature.Vector(new this.options.geom_type());
|
||||||
for (var i=0; i<this.num_geom; i++) {
|
for (var i = 0; i < this.num_geom; i++) {
|
||||||
feat.geometry.addComponents([this.layers.vector.features[i].geometry]);
|
feat.geometry.addComponents([this.layers.vector.features[i].geometry]);
|
||||||
}
|
}
|
||||||
this.write_wkt(feat);
|
this.write_wkt(feat);
|
||||||
|
|
Loading…
Reference in New Issue