Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFlorian Staudacher <florian_staudacher@yahoo.de>2014-09-12 05:18:34 +0400
committerFlorian Staudacher <florian_staudacher@yahoo.de>2014-09-15 03:37:23 +0400
commit10609c3692475087aec689075b7374e0f6863b00 (patch)
tree9a6164d9cda9b79f8e2fc1d0094b716c9f4984be /app
parentbe86014540cf9e0e00e83c6a964ac343f112f7f4 (diff)
fix jasmine and add some specs for direction detection
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/app/helpers/direction_detector.js41
-rw-r--r--app/assets/javascripts/app/helpers/handlebars-helpers.js3
-rw-r--r--app/assets/javascripts/jasmine-load-all.js1
3 files changed, 42 insertions, 3 deletions
diff --git a/app/assets/javascripts/app/helpers/direction_detector.js b/app/assets/javascripts/app/helpers/direction_detector.js
index ee1495718..768aeb8b3 100644
--- a/app/assets/javascripts/app/helpers/direction_detector.js
+++ b/app/assets/javascripts/app/helpers/direction_detector.js
@@ -18,7 +18,7 @@
return false;
}
- var charCode = str.charCodeAt(0);
+ var charCode = this._fixedCharCodeAt(str, 0);
if(charCode >= 1536 && charCode <= 1791) // Sarabic, Persian, ...
return true;
@@ -34,6 +34,12 @@
else if(charCode>=64256 && charCode<=64335) // Hebrew present
return true;
+ else if(charCode>=68096 && charCode<=68184) // Kharoshthi
+ return true;
+
+ else if(charCode>=67840 && charCode<=67871) // Phoenician
+ return true;
+
else if(charCode>=1792 && charCode<=1871) // Syriac
return true;
@@ -47,6 +53,39 @@
return true;
return false;
+ },
+
+ // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
+ _fixedCharCodeAt: function(str, idx) {
+ str += '';
+ var code,
+ end = str.length;
+
+ var surrogatePairs = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
+ while ((surrogatePairs.exec(str)) != null) {
+ var li = surrogatePairs.lastIndex;
+ if (li - 2 < idx) {
+ idx++;
+ }
+ else {
+ break;
+ }
+ }
+
+ if (idx >= end || idx < 0) {
+ return NaN;
+ }
+
+ code = str.charCodeAt(idx);
+
+ var hi, low;
+ if (0xD800 <= code && code <= 0xDBFF) {
+ hi = code;
+ low = str.charCodeAt(idx+1);
+ // Go one further, since one of the "characters" is part of a surrogate pair
+ return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
+ }
+ return code;
}
};
})();
diff --git a/app/assets/javascripts/app/helpers/handlebars-helpers.js b/app/assets/javascripts/app/helpers/handlebars-helpers.js
index bfc718ba3..1be1cd98d 100644
--- a/app/assets/javascripts/app/helpers/handlebars-helpers.js
+++ b/app/assets/javascripts/app/helpers/handlebars-helpers.js
@@ -59,8 +59,9 @@ Handlebars.registerHelper('hovercardable', function(person) {
Handlebars.registerHelper('personImage', function(person, size, imageClass) {
/* we return here if person.avatar is blank, because this happens when a
* user is unauthenticated. we don't know why this happens... */
+ if( !person.avatar &&
+ !(person.profile && person.profile.avatar) ) return;
var avatar = person.avatar || person.profile.avatar;
- if( !avatar ) return;
var name = ( person.name ) ? person.name : 'avatar';
size = ( !_.isString(size) ) ? "small" : size;
diff --git a/app/assets/javascripts/jasmine-load-all.js b/app/assets/javascripts/jasmine-load-all.js
index 8d777a10c..eda5e0faa 100644
--- a/app/assets/javascripts/jasmine-load-all.js
+++ b/app/assets/javascripts/jasmine-load-all.js
@@ -6,6 +6,5 @@
//= require inbox
//= require mobile
//= require profile
-//= require people
//= require contact-list
//= require sinon