Вход Регистрация
Файл: upload/admin/view/javascript/ckeditor/plugins/codemirror/js/util/javascript-hint.js
Строк: 261
<?php
(function () {
  function forEach(
arrf) {
    for (var 
0arr.lengthe; ++if(arr[i]);
  }
  
  function 
arrayContains(arritem) {
    if (!Array.
prototype.indexOf) {
      var 
arr.length;
      while (
i--) {
        if (
arr[i] === item) {
          return 
true;
        }
      }
      return 
false;
    }
    return 
arr.indexOf(item) != -1;
  }

  function 
scriptHint(editorkeywordsgetTokenoptions) {
    
// Find the token at the cursor
    
var cur editor.getCursor(), token getToken(editorcur), tprop token;
    
// If it's not a 'word-style' token, ignore the token.
        
if (!/^[w$_]*$/.test(token.string)) {
      
token tprop = {startcur.chendcur.chstring""statetoken.state,
                       
typetoken.string == "." "property" null};
    }
    
// If it is a property, find out what it is a property of.
    
while (tprop.type == "property") {
      
tprop getToken(editor, {linecur.linechtprop.start});
      if (
tprop.string != ".") return;
      
tprop getToken(editor, {linecur.linechtprop.start});
      if (
tprop.string == ')') {
        var 
level 1;
        do {
          
tprop getToken(editor, {linecur.linechtprop.start});
          switch (
tprop.string) {
          case 
')'level++; break;
          case 
'('level--; break;
          default: break;
          }
        } while (
level 0);
        
tprop getToken(editor, {linecur.linechtprop.start});
    if (
tprop.type == 'variable')
      
tprop.type 'function';
    else return; 
// no clue
      
}
      if (!
context) var context = [];
      
context.push(tprop);
    }
    return {list: 
getCompletions(tokencontextkeywordsoptions),
            
from: {linecur.linechtoken.start},
            
to: {linecur.linechtoken.end}};
  }

  
CodeMirror.javascriptHint = function(editoroptions) {
    return 
scriptHint(editorjavascriptKeywords,
                      function (
ecur) {return e.getTokenAt(cur);},
                      
options);
  };

  function 
getCoffeeScriptToken(editorcur) {
  
// This getToken, it is for coffeescript, imitates the behavior of
  // getTokenAt method in javascript.js, that is, returning "property"
  // type and treat "." as indepenent token.
    
var token editor.getTokenAt(cur);
    if (
cur.ch == token.start && token.string.charAt(0) == '.') {
      
token.end token.start;
      
token.string '.';
      
token.type "property";
    }
    else if (/^.[
w$_]*$/.test(token.string)) {
      
token.type "property";
      
token.start++;
      
token.string token.string.replace(/./, '');
    }
    return 
token;
  }

  
CodeMirror.coffeescriptHint = function(editoroptions) {
    return 
scriptHint(editorcoffeescriptKeywordsgetCoffeeScriptTokenoptions);
  };

  var 
stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
                     
"toUpperCase toLowerCase split concat match replace search").split(" ");
  var 
arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
                    
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
  var 
funcProps "prototype apply call bind".split(" ");
  var 
javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
                  
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
  var 
coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
                  
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");

  function 
getCompletions(tokencontextkeywordsoptions) {
    var 
found = [], start token.string;
    function 
maybeAdd(str) {
      if (
str.indexOf(start) == && !arrayContains(foundstr)) found.push(str);
    }
    function 
gatherCompletions(obj) {
      if (
typeof obj == "string") forEach(stringPropsmaybeAdd);
      else if (
obj instanceof Array) forEach(arrayPropsmaybeAdd);
      else if (
obj instanceof Function) forEach(funcPropsmaybeAdd);
      for (var 
name in objmaybeAdd(name);
    }

    if (
context) {
      
// If this is a property, see if it belongs to some object we can
      // find in the current environment.
      
var obj context.pop(), base;
      if (
obj.type == "variable") {
        if (
options && options.additionalContext)
          
base options.additionalContext[obj.string];
        
base base || window[obj.string];
      } else if (
obj.type == "string") {
        
base "";
      } else if (
obj.type == "atom") {
        
base 1;
      } else if (
obj.type == "function") {
        if (
window.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
            (
typeof window.jQuery == 'function'))
          
base window.jQuery();
        else if (
window.!= null && (obj.string == '_') && (typeof window.== 'function'))
          
base window._();
      }
      while (
base != null && context.length)
        
base base[context.pop().string];
      if (
base != nullgatherCompletions(base);
    }
    else {
      
// If not, just look in the window object and any local scope
      // (reading into JS mode internals to get at the local variables)
      
for (var token.state.localVarsvv.nextmaybeAdd(v.name);
      
gatherCompletions(window);
      forEach(
keywordsmaybeAdd);
    }
    return 
found;
  }
})();
?>
Онлайн: 0
Реклама