mirror of
https://github.com/django/django.git
synced 2025-06-07 20:49:11 +00:00
Fixed JavaScript "strict" violations.
This commit is contained in:
parent
3c0770f23d
commit
fbb4f0797c
@ -1,5 +1,7 @@
|
||||
/*eslint no-cond-assign:1*/
|
||||
var SelectBox = {
|
||||
(function() {
|
||||
'use strict';
|
||||
var SelectBox = {
|
||||
cache: {},
|
||||
init: function(id) {
|
||||
var box = document.getElementById(id);
|
||||
@ -114,4 +116,6 @@ var SelectBox = {
|
||||
box.options[i].selected = 'selected';
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
window.SelectBox = SelectBox;
|
||||
})();
|
||||
|
@ -5,6 +5,7 @@ SelectFilter2 - Turns a multiple-select box into a filter interface.
|
||||
Requires core.js, SelectBox.js and addevent.js.
|
||||
*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
function findForm(node) {
|
||||
// returns the node of the form containing the given node
|
||||
if (node.tagName.toLowerCase() !== 'form') {
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*global _actions_icnt, gettext, interpolate, ngettext*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
var lastChecked;
|
||||
|
||||
$.fn.actions = function(opts) {
|
||||
|
@ -2,8 +2,9 @@
|
||||
// Inserts shortcut buttons after all of the following:
|
||||
// <input type="text" class="vDateField">
|
||||
// <input type="text" class="vTimeField">
|
||||
|
||||
var DateTimeShortcuts = {
|
||||
(function() {
|
||||
'use strict';
|
||||
var DateTimeShortcuts = {
|
||||
calendars: [],
|
||||
calendarInputs: [],
|
||||
clockInputs: [],
|
||||
@ -356,6 +357,8 @@ var DateTimeShortcuts = {
|
||||
DateTimeShortcuts.calendarInputs[num].focus();
|
||||
DateTimeShortcuts.dismissCalendar(num);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
addEvent(window, 'load', DateTimeShortcuts.init);
|
||||
addEvent(window, 'load', DateTimeShortcuts.init);
|
||||
window.DateTimeShortcuts = DateTimeShortcuts;
|
||||
})();
|
||||
|
@ -2,7 +2,10 @@
|
||||
// Handles related-objects functionality: lookup link for raw_id_fields
|
||||
// and Add Another links.
|
||||
|
||||
function html_unescape(text) {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
function html_unescape(text) {
|
||||
// Unescape a string that was escaped using django.utils.html.escape.
|
||||
text = text.replace(/</g, '<');
|
||||
text = text.replace(/>/g, '>');
|
||||
@ -10,25 +13,25 @@ function html_unescape(text) {
|
||||
text = text.replace(/'/g, "'");
|
||||
text = text.replace(/&/g, '&');
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
// IE doesn't accept periods or dashes in the window name, but the element IDs
|
||||
// we use to generate popup window names may contain them, therefore we map them
|
||||
// to allowed characters in a reversible way so that we can locate the correct
|
||||
// element when the popup window is dismissed.
|
||||
function id_to_windowname(text) {
|
||||
// IE doesn't accept periods or dashes in the window name, but the element IDs
|
||||
// we use to generate popup window names may contain them, therefore we map them
|
||||
// to allowed characters in a reversible way so that we can locate the correct
|
||||
// element when the popup window is dismissed.
|
||||
function id_to_windowname(text) {
|
||||
text = text.replace(/\./g, '__dot__');
|
||||
text = text.replace(/\-/g, '__dash__');
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
function windowname_to_id(text) {
|
||||
function windowname_to_id(text) {
|
||||
text = text.replace(/__dot__/g, '.');
|
||||
text = text.replace(/__dash__/g, '-');
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
|
||||
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
|
||||
var name = triggeringLink.id.replace(name_regexp, '');
|
||||
name = id_to_windowname(name);
|
||||
var href = triggeringLink.href;
|
||||
@ -42,13 +45,13 @@ function showAdminPopup(triggeringLink, name_regexp, add_popup) {
|
||||
var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
|
||||
win.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function showRelatedObjectLookupPopup(triggeringLink) {
|
||||
function showRelatedObjectLookupPopup(triggeringLink) {
|
||||
return showAdminPopup(triggeringLink, /^lookup_/, true);
|
||||
}
|
||||
}
|
||||
|
||||
function dismissRelatedLookupPopup(win, chosenId) {
|
||||
function dismissRelatedLookupPopup(win, chosenId) {
|
||||
var name = windowname_to_id(win.name);
|
||||
var elem = document.getElementById(name);
|
||||
if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
|
||||
@ -57,13 +60,13 @@ function dismissRelatedLookupPopup(win, chosenId) {
|
||||
document.getElementById(name).value = chosenId;
|
||||
}
|
||||
win.close();
|
||||
}
|
||||
}
|
||||
|
||||
function showRelatedObjectPopup(triggeringLink) {
|
||||
function showRelatedObjectPopup(triggeringLink) {
|
||||
return showAdminPopup(triggeringLink, /^(change|add|delete)_/, false);
|
||||
}
|
||||
}
|
||||
|
||||
function updateRelatedObjectLinks(triggeringLink) {
|
||||
function updateRelatedObjectLinks(triggeringLink) {
|
||||
var $this = django.jQuery(triggeringLink);
|
||||
var siblings = $this.nextAll('.change-related, .delete-related');
|
||||
if (!siblings.length) {
|
||||
@ -78,9 +81,9 @@ function updateRelatedObjectLinks(triggeringLink) {
|
||||
} else {
|
||||
siblings.removeAttr('href');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
|
||||
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
|
||||
// newId and newRepr are expected to have previously been escaped by
|
||||
// django.utils.html.escape.
|
||||
newId = html_unescape(newId);
|
||||
@ -107,9 +110,9 @@ function dismissAddRelatedObjectPopup(win, newId, newRepr) {
|
||||
SelectBox.redisplay(toId);
|
||||
}
|
||||
win.close();
|
||||
}
|
||||
}
|
||||
|
||||
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
|
||||
function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
|
||||
objId = html_unescape(objId);
|
||||
newRepr = html_unescape(newRepr);
|
||||
var id = windowname_to_id(win.name).replace(/^edit_/, '');
|
||||
@ -122,9 +125,9 @@ function dismissChangeRelatedObjectPopup(win, objId, newRepr, newId) {
|
||||
}
|
||||
});
|
||||
win.close();
|
||||
}
|
||||
}
|
||||
|
||||
function dismissDeleteRelatedObjectPopup(win, objId) {
|
||||
function dismissDeleteRelatedObjectPopup(win, objId) {
|
||||
objId = html_unescape(objId);
|
||||
var id = windowname_to_id(win.name).replace(/^delete_/, '');
|
||||
var selectsSelector = interpolate('#%s, #%s_from, #%s_to', [id, id, id]);
|
||||
@ -135,8 +138,23 @@ function dismissDeleteRelatedObjectPopup(win, objId) {
|
||||
}
|
||||
}).trigger('change');
|
||||
win.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Kept for backward compatibility
|
||||
var showAddAnotherPopup = showRelatedObjectPopup;
|
||||
var dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
|
||||
// Global for testing purposes
|
||||
window.html_unescape = html_unescape;
|
||||
window.id_to_windowname = id_to_windowname;
|
||||
window.windowname_to_id = windowname_to_id;
|
||||
|
||||
window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup;
|
||||
window.dismissRelatedLookupPopup = dismissRelatedLookupPopup;
|
||||
window.showRelatedObjectPopup = showRelatedObjectPopup;
|
||||
window.updateRelatedObjectLinks = updateRelatedObjectLinks;
|
||||
window.dismissAddRelatedObjectPopup = dismissAddRelatedObjectPopup;
|
||||
window.dismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup;
|
||||
window.dismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup;
|
||||
|
||||
// Kept for backward compatibility
|
||||
window.showAddAnotherPopup = showRelatedObjectPopup;
|
||||
window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
|
||||
|
||||
})();
|
||||
|
@ -4,8 +4,10 @@ calendar.js - Calendar functions by Adrian Holovaty
|
||||
depends on core.js for utility functions like removeChildren or quickElement
|
||||
*/
|
||||
|
||||
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
|
||||
var CalendarNamespace = {
|
||||
(function() {
|
||||
'use strict';
|
||||
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
|
||||
var CalendarNamespace = {
|
||||
monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
|
||||
daysOfWeek: gettext('S M T W T F S').split(' '),
|
||||
firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')),
|
||||
@ -111,10 +113,10 @@ var CalendarNamespace = {
|
||||
|
||||
calDiv.appendChild(calTable);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Calendar -- A calendar instance
|
||||
function Calendar(div_id, callback, selected) {
|
||||
// Calendar -- A calendar instance
|
||||
function Calendar(div_id, callback, selected) {
|
||||
// div_id (string) is the ID of the element in which the calendar will
|
||||
// be displayed
|
||||
// callback (string) is the name of a JavaScript function that will be
|
||||
@ -128,8 +130,8 @@ function Calendar(div_id, callback, selected) {
|
||||
if (typeof selected !== 'undefined') {
|
||||
this.selected = selected;
|
||||
}
|
||||
}
|
||||
Calendar.prototype = {
|
||||
}
|
||||
Calendar.prototype = {
|
||||
drawCurrent: function() {
|
||||
CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback, this.selected);
|
||||
},
|
||||
@ -171,4 +173,6 @@ Calendar.prototype = {
|
||||
this.currentYear++;
|
||||
this.drawCurrent();
|
||||
}
|
||||
};
|
||||
};
|
||||
window.Calendar = Calendar;
|
||||
})();
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*global gettext*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
$(document).ready(function() {
|
||||
// Add anchor tag for Show/Hide link
|
||||
$("fieldset.collapse").each(function(i, elem) {
|
||||
|
@ -6,6 +6,7 @@ var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.spl
|
||||
|
||||
// Cross-browser event handlers.
|
||||
function addEvent(obj, evType, fn) {
|
||||
'use strict';
|
||||
if (obj.addEventListener) {
|
||||
obj.addEventListener(evType, fn, false);
|
||||
return true;
|
||||
@ -18,6 +19,7 @@ function addEvent(obj, evType, fn) {
|
||||
}
|
||||
|
||||
function removeEvent(obj, evType, fn) {
|
||||
'use strict';
|
||||
if (obj.removeEventListener) {
|
||||
obj.removeEventListener(evType, fn, false);
|
||||
return true;
|
||||
@ -30,6 +32,7 @@ function removeEvent(obj, evType, fn) {
|
||||
}
|
||||
|
||||
function cancelEventPropagation(e) {
|
||||
'use strict';
|
||||
if (!e) {
|
||||
e = window.event;
|
||||
}
|
||||
@ -41,6 +44,7 @@ function cancelEventPropagation(e) {
|
||||
|
||||
// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
|
||||
function quickElement() {
|
||||
'use strict';
|
||||
var obj = document.createElement(arguments[0]);
|
||||
if (arguments[2]) {
|
||||
var textNode = document.createTextNode(arguments[2]);
|
||||
@ -56,6 +60,7 @@ function quickElement() {
|
||||
|
||||
// "a" is reference to an object
|
||||
function removeChildren(a) {
|
||||
'use strict';
|
||||
while (a.hasChildNodes()) {
|
||||
a.removeChild(a.lastChild);
|
||||
}
|
||||
@ -89,6 +94,7 @@ if (!xmlhttp && typeof XMLHttpRequest !== 'undefined') {
|
||||
// See http://www.quirksmode.org/js/findpos.html
|
||||
// ----------------------------------------------------------------------------
|
||||
function findPosX(obj) {
|
||||
'use strict';
|
||||
var curleft = 0;
|
||||
if (obj.offsetParent) {
|
||||
while (obj.offsetParent) {
|
||||
@ -106,6 +112,7 @@ function findPosX(obj) {
|
||||
}
|
||||
|
||||
function findPosY(obj) {
|
||||
'use strict';
|
||||
var curtop = 0;
|
||||
if (obj.offsetParent) {
|
||||
while (obj.offsetParent) {
|
||||
@ -125,8 +132,9 @@ function findPosY(obj) {
|
||||
//-----------------------------------------------------------------------------
|
||||
// Date object extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Date.prototype.getTwelveHours = function() {
|
||||
(function() {
|
||||
'use strict';
|
||||
Date.prototype.getTwelveHours = function() {
|
||||
var hours = this.getHours();
|
||||
if (hours === 0) {
|
||||
return 12;
|
||||
@ -134,41 +142,41 @@ Date.prototype.getTwelveHours = function() {
|
||||
else {
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.getTwoDigitDate = function() {
|
||||
Date.prototype.getTwoDigitDate = function() {
|
||||
return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.getTwoDigitTwelveHour = function() {
|
||||
Date.prototype.getTwoDigitTwelveHour = function() {
|
||||
return (this.getTwelveHours() < 10) ? '0' + this.getTwelveHours() : this.getTwelveHours();
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.getTwoDigitHour = function() {
|
||||
Date.prototype.getTwoDigitHour = function() {
|
||||
return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.getTwoDigitMinute = function() {
|
||||
Date.prototype.getTwoDigitMinute = function() {
|
||||
return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.getTwoDigitSecond = function() {
|
||||
Date.prototype.getTwoDigitSecond = function() {
|
||||
return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.getHourMinute = function() {
|
||||
Date.prototype.getHourMinute = function() {
|
||||
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.getHourMinuteSecond = function() {
|
||||
Date.prototype.getHourMinuteSecond = function() {
|
||||
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
|
||||
};
|
||||
};
|
||||
|
||||
Date.prototype.strftime = function(format) {
|
||||
Date.prototype.strftime = function(format) {
|
||||
var fields = {
|
||||
c: this.toString(),
|
||||
d: this.getTwoDigitDate(),
|
||||
@ -197,20 +205,20 @@ Date.prototype.strftime = function(format) {
|
||||
++i;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// String object extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
String.prototype.pad_left = function(pad_length, pad_string) {
|
||||
String.prototype.pad_left = function(pad_length, pad_string) {
|
||||
var new_string = this;
|
||||
for (var i = 0; new_string.length < pad_length; i++) {
|
||||
new_string = pad_string + new_string;
|
||||
}
|
||||
return new_string;
|
||||
};
|
||||
};
|
||||
|
||||
String.prototype.strptime = function(format) {
|
||||
String.prototype.strptime = function(format) {
|
||||
var split_format = format.split(/[.\-/]/);
|
||||
var date = this.split(/[.\-/]/);
|
||||
var i = 0;
|
||||
@ -233,12 +241,14 @@ String.prototype.strptime = function(format) {
|
||||
++i;
|
||||
}
|
||||
return new Date(year, month, day);
|
||||
};
|
||||
};
|
||||
|
||||
})();
|
||||
// ----------------------------------------------------------------------------
|
||||
// Get the computed style for and element
|
||||
// ----------------------------------------------------------------------------
|
||||
function getStyle(oElm, strCssRule) {
|
||||
'use strict';
|
||||
var strValue = "";
|
||||
if(document.defaultView && document.defaultView.getComputedStyle) {
|
||||
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
|
||||
|
@ -16,6 +16,7 @@
|
||||
* See: http://www.opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
$.fn.formset = function(opts) {
|
||||
var options = $.extend({}, $.fn.formset.defaults, opts);
|
||||
var $this = $(this);
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*global URLify*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
$.fn.prepopulate = function(dependencies, maxLength, allowUnicode) {
|
||||
/*
|
||||
Depends on urlify.js
|
||||
|
@ -1,4 +1,6 @@
|
||||
var timeParsePatterns = [
|
||||
(function() {
|
||||
'use strict';
|
||||
var timeParsePatterns = [
|
||||
// 9
|
||||
{
|
||||
re: /^\d{1,2}$/i,
|
||||
@ -86,9 +88,9 @@ var timeParsePatterns = [
|
||||
return '00:00';
|
||||
}
|
||||
}
|
||||
];
|
||||
];
|
||||
|
||||
function parseTimeString(s) {
|
||||
function parseTimeString(s) {
|
||||
for (var i = 0; i < timeParsePatterns.length; i++) {
|
||||
var re = timeParsePatterns[i].re;
|
||||
var handler = timeParsePatterns[i].handler;
|
||||
@ -98,4 +100,7 @@ function parseTimeString(s) {
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
window.parseTimeString = parseTimeString;
|
||||
})();
|
||||
|
@ -1,5 +1,8 @@
|
||||
/*global XRegExp*/
|
||||
var LATIN_MAP = {
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var LATIN_MAP = {
|
||||
'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE',
|
||||
'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I',
|
||||
'Î': 'I', 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O',
|
||||
@ -10,11 +13,11 @@ var LATIN_MAP = {
|
||||
'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o',
|
||||
'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u',
|
||||
'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y'
|
||||
};
|
||||
var LATIN_SYMBOLS_MAP = {
|
||||
};
|
||||
var LATIN_SYMBOLS_MAP = {
|
||||
'©': '(c)'
|
||||
};
|
||||
var GREEK_MAP = {
|
||||
};
|
||||
var GREEK_MAP = {
|
||||
'α': 'a', 'β': 'b', 'γ': 'g', 'δ': 'd', 'ε': 'e', 'ζ': 'z', 'η': 'h',
|
||||
'θ': '8', 'ι': 'i', 'κ': 'k', 'λ': 'l', 'μ': 'm', 'ν': 'n', 'ξ': '3',
|
||||
'ο': 'o', 'π': 'p', 'ρ': 'r', 'σ': 's', 'τ': 't', 'υ': 'y', 'φ': 'f',
|
||||
@ -25,16 +28,16 @@ var GREEK_MAP = {
|
||||
'Ξ': '3', 'Ο': 'O', 'Π': 'P', 'Ρ': 'R', 'Σ': 'S', 'Τ': 'T', 'Υ': 'Y',
|
||||
'Φ': 'F', 'Χ': 'X', 'Ψ': 'PS', 'Ω': 'W', 'Ά': 'A', 'Έ': 'E', 'Ί': 'I',
|
||||
'Ό': 'O', 'Ύ': 'Y', 'Ή': 'H', 'Ώ': 'W', 'Ϊ': 'I', 'Ϋ': 'Y'
|
||||
};
|
||||
var TURKISH_MAP = {
|
||||
};
|
||||
var TURKISH_MAP = {
|
||||
'ş': 's', 'Ş': 'S', 'ı': 'i', 'İ': 'I', 'ç': 'c', 'Ç': 'C', 'ü': 'u',
|
||||
'Ü': 'U', 'ö': 'o', 'Ö': 'O', 'ğ': 'g', 'Ğ': 'G'
|
||||
};
|
||||
var ROMANIAN_MAP = {
|
||||
};
|
||||
var ROMANIAN_MAP = {
|
||||
'ă': 'a', 'î': 'i', 'ș': 's', 'ț': 't', 'â': 'a',
|
||||
'Ă': 'A', 'Î': 'I', 'Ș': 'S', 'Ț': 'T', 'Â': 'A'
|
||||
};
|
||||
var RUSSIAN_MAP = {
|
||||
};
|
||||
var RUSSIAN_MAP = {
|
||||
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo',
|
||||
'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm',
|
||||
'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
|
||||
@ -45,50 +48,51 @@ var RUSSIAN_MAP = {
|
||||
'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U',
|
||||
'Ф': 'F', 'Х': 'H', 'Ц': 'C', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Sh', 'Ъ': '',
|
||||
'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya'
|
||||
};
|
||||
var UKRAINIAN_MAP = {
|
||||
'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G', 'є': 'ye', 'і': 'i', 'ї': 'yi',
|
||||
'ґ': 'g'
|
||||
};
|
||||
var CZECH_MAP = {
|
||||
};
|
||||
var UKRAINIAN_MAP = {
|
||||
'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G', 'є': 'ye', 'і': 'i',
|
||||
'ї': 'yi', 'ґ': 'g'
|
||||
};
|
||||
var CZECH_MAP = {
|
||||
'č': 'c', 'ď': 'd', 'ě': 'e', 'ň': 'n', 'ř': 'r', 'š': 's', 'ť': 't',
|
||||
'ů': 'u', 'ž': 'z', 'Č': 'C', 'Ď': 'D', 'Ě': 'E', 'Ň': 'N', 'Ř': 'R',
|
||||
'Š': 'S', 'Ť': 'T', 'Ů': 'U', 'Ž': 'Z'
|
||||
};
|
||||
var POLISH_MAP = {
|
||||
};
|
||||
var POLISH_MAP = {
|
||||
'ą': 'a', 'ć': 'c', 'ę': 'e', 'ł': 'l', 'ń': 'n', 'ó': 'o', 'ś': 's',
|
||||
'ź': 'z', 'ż': 'z',
|
||||
'Ą': 'A', 'Ć': 'C', 'Ę': 'E', 'Ł': 'L', 'Ń': 'N', 'Ó': 'O', 'Ś': 'S',
|
||||
'Ź': 'Z', 'Ż': 'Z'
|
||||
};
|
||||
var LATVIAN_MAP = {
|
||||
};
|
||||
var LATVIAN_MAP = {
|
||||
'ā': 'a', 'č': 'c', 'ē': 'e', 'ģ': 'g', 'ī': 'i', 'ķ': 'k', 'ļ': 'l',
|
||||
'ņ': 'n', 'š': 's', 'ū': 'u', 'ž': 'z',
|
||||
'Ā': 'A', 'Č': 'C', 'Ē': 'E', 'Ģ': 'G', 'Ī': 'I', 'Ķ': 'K', 'Ļ': 'L',
|
||||
'Ņ': 'N', 'Š': 'S', 'Ū': 'U', 'Ž': 'Z'
|
||||
};
|
||||
var ARABIC_MAP = {
|
||||
};
|
||||
var ARABIC_MAP = {
|
||||
'أ': 'a', 'ب': 'b', 'ت': 't', 'ث': 'th', 'ج': 'g', 'ح': 'h', 'خ': 'kh', 'د': 'd',
|
||||
'ذ': 'th', 'ر': 'r', 'ز': 'z', 'س': 's', 'ش': 'sh', 'ص': 's', 'ض': 'd', 'ط': 't',
|
||||
'ظ': 'th', 'ع': 'aa', 'غ': 'gh', 'ف': 'f', 'ق': 'k', 'ك': 'k', 'ل': 'l', 'م': 'm',
|
||||
'ن': 'n', 'ه': 'h', 'و': 'o', 'ي': 'y'
|
||||
};
|
||||
var LITHUANIAN_MAP = {
|
||||
};
|
||||
var LITHUANIAN_MAP = {
|
||||
'ą': 'a', 'č': 'c', 'ę': 'e', 'ė': 'e', 'į': 'i', 'š': 's', 'ų': 'u',
|
||||
'ū': 'u', 'ž': 'z',
|
||||
'Ą': 'A', 'Č': 'C', 'Ę': 'E', 'Ė': 'E', 'Į': 'I', 'Š': 'S', 'Ų': 'U',
|
||||
'Ū': 'U', 'Ž': 'Z'
|
||||
};
|
||||
var SERBIAN_MAP = {
|
||||
'ђ': 'dj', 'ј': 'j', 'љ': 'lj', 'њ': 'nj', 'ћ': 'c', 'џ': 'dz', 'đ': 'dj',
|
||||
'Ђ': 'Dj', 'Ј': 'j', 'Љ': 'Lj', 'Њ': 'Nj', 'Ћ': 'C', 'Џ': 'Dz', 'Đ': 'Dj'
|
||||
};
|
||||
var AZERBAIJANI_MAP = {
|
||||
};
|
||||
var SERBIAN_MAP = {
|
||||
'ђ': 'dj', 'ј': 'j', 'љ': 'lj', 'њ': 'nj', 'ћ': 'c', 'џ': 'dz',
|
||||
'đ': 'dj', 'Ђ': 'Dj', 'Ј': 'j', 'Љ': 'Lj', 'Њ': 'Nj', 'Ћ': 'C',
|
||||
'Џ': 'Dz', 'Đ': 'Dj'
|
||||
};
|
||||
var AZERBAIJANI_MAP = {
|
||||
'ç': 'c', 'ə': 'e', 'ğ': 'g', 'ı': 'i', 'ö': 'o', 'ş': 's', 'ü': 'u',
|
||||
'Ç': 'C', 'Ə': 'E', 'Ğ': 'G', 'İ': 'I', 'Ö': 'O', 'Ş': 'S', 'Ü': 'U'
|
||||
};
|
||||
};
|
||||
|
||||
var ALL_DOWNCODE_MAPS = [
|
||||
var ALL_DOWNCODE_MAPS = [
|
||||
LATIN_MAP,
|
||||
LATIN_SYMBOLS_MAP,
|
||||
GREEK_MAP,
|
||||
@ -103,9 +107,9 @@ var ALL_DOWNCODE_MAPS = [
|
||||
LITHUANIAN_MAP,
|
||||
SERBIAN_MAP,
|
||||
AZERBAIJANI_MAP
|
||||
];
|
||||
];
|
||||
|
||||
var Downcoder = {
|
||||
var Downcoder = {
|
||||
'Initialize': function() {
|
||||
if (Downcoder.map) { // already made
|
||||
return;
|
||||
@ -127,17 +131,17 @@ var Downcoder = {
|
||||
}
|
||||
Downcoder.regex = new RegExp(Downcoder.chars.join('|'), 'g');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function downcode(slug) {
|
||||
function downcode(slug) {
|
||||
Downcoder.Initialize();
|
||||
return slug.replace(Downcoder.regex, function(m) {
|
||||
return Downcoder.map[m];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function URLify(s, num_chars, allowUnicode) {
|
||||
function URLify(s, num_chars, allowUnicode) {
|
||||
// changes, e.g., "Petty theft" to "petty_theft"
|
||||
// remove all these words from the string before urlifying
|
||||
if (!allowUnicode) {
|
||||
@ -162,4 +166,6 @@ function URLify(s, num_chars, allowUnicode) {
|
||||
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
|
||||
s = s.toLowerCase(); // convert to lowercase
|
||||
return s.substring(0, num_chars);// trim to first num_chars chars
|
||||
}
|
||||
}
|
||||
window.URLify = URLify;
|
||||
})();
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*global OpenLayers*/
|
||||
(function() {
|
||||
'use strict';
|
||||
/**
|
||||
* Transforms an array of features to a single feature with the merged
|
||||
* geometry of geom_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user