Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced the custom "xsplit" function with the standard JavaScript split function #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions admin/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ qtranxj_split = function(text)
result[lang] = '';
}
var split_regex = /(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\]|\[:\])/gi;
var blocks = text.xsplit(split_regex);
var blocks = text.split(split_regex);
if(!qtranxj_isArray(blocks))
return result;
if(blocks.length==1){//no language separator found, enter it to all languages
Expand Down Expand Up @@ -173,27 +173,6 @@ function qtranxj_get_cookie(cname)
return '';
}

String.prototype.xsplit = function(_regEx){
// Most browsers can do this properly, so let them work, they'll do it faster
if ('a~b'.split(/(~)/).length === 3){ return this.split(_regEx); }

if (!_regEx.global)
{ _regEx = new RegExp(_regEx.source, 'g' + (_regEx.ignoreCase ? 'i' : '')); }

// IE (and any other browser that can't capture the delimiter)
// will, unfortunately, have to be slowed down
var start = 0, arr=[];
var result;
while((result = _regEx.exec(this)) != null){
arr.push(this.slice(start, result.index));
if(result.length > 1) arr.push(result[1]);
start = _regEx.lastIndex;
}
if(start < this.length) arr.push(this.slice(start));
if(start == this.length) arr.push(''); //delim at the end
return arr;
};

function qtranxj_isArray(obj){ return obj.constructor.toString().indexOf('Array') >= 0; }

function qtranxj_ce(tagName, props, pNode, isFirst)
Expand Down Expand Up @@ -498,7 +477,7 @@ var qTranslateX=function(pg)
if(frm.form){
form = document.getElementById(frm.form.id);
}else{
form = this.getWrapForm();
form = this.getWrapForm();
}
//co('form=',form);
//c('frm.fields.length='+frm.fields.length);
Expand All @@ -511,11 +490,11 @@ var qTranslateX=function(pg)
var containers=[];
if(fld.container_id){
var container = document.getElementById(fld.container_id);
if(container) containers.push(container);
if(container) containers.push(container);
}else if(fld.container_class){
containers = document.getElementsByClassName(fld.container_class);
containers = document.getElementsByClassName(fld.container_class);
}else if(form){
containers.push(form);
containers.push(form);
}
var sep = fld.encode;
switch( sep ){
Expand Down Expand Up @@ -562,13 +541,13 @@ var qTranslateX=function(pg)
}
}
}else{
continue;
continue;
}
break;
}
}
}
return true;
return true;
}

this.addContentHooksTinyMCE=function()
Expand Down Expand Up @@ -665,8 +644,8 @@ var qTranslateX=function(pg)
for(var i=0; i < qTranslateConfig.page_config.anchors.length; ++i){
var anchor = qTranslateConfig.page_config.anchors[i];
var f = document.getElementById(anchor);
if(f) anchors.push(f);
}
if(f) anchors.push(f);
}
}
if(!anchors.length){
var f=pg.langSwitchWrapAnchor;
Expand Down