Skip to content

Commit

Permalink
request done
Browse files Browse the repository at this point in the history
  • Loading branch information
nowa committed Jul 15, 2008
1 parent 9cc22a4 commit 43d9791
Show file tree
Hide file tree
Showing 5 changed files with 367 additions and 33 deletions.
116 changes: 111 additions & 5 deletions jplus.tmproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,70 @@
<key>caret</key>
<dict>
<key>column</key>
<integer>15</integer>
<integer>22</integer>
<key>line</key>
<integer>46</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>25</integer>
</dict>
<key>src/core/function.js</key>
<dict>
<key>caret</key>
<dict>
<key>column</key>
<integer>70</integer>
<key>line</key>
<integer>45</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>41</integer>
</dict>
<key>src/core/jplus.js</key>
<dict>
<key>caret</key>
<dict>
<key>column</key>
<integer>13</integer>
<key>line</key>
<integer>43</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>2</integer>
</dict>
<key>src/core/object.js</key>
<dict>
<key>caret</key>
<dict>
<key>column</key>
<integer>33</integer>
<key>line</key>
<integer>140</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>0</integer>
</dict>
<key>src/dom/element.js</key>
<dict>
<key>caret</key>
<dict>
<key>column</key>
<integer>37</integer>
<key>line</key>
<integer>135</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>80</integer>
<integer>120</integer>
</dict>
<key>src/event/event.js</key>
<dict>
Expand All @@ -47,27 +103,77 @@
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>8</integer>
</dict>
<key>src/native/array.js</key>
<dict>
<key>caret</key>
<dict>
<key>column</key>
<integer>5</integer>
<key>line</key>
<integer>63</integer>
</dict>
<key>columnSelection</key>
<false/>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>45</integer>
<key>selectFrom</key>
<dict>
<key>column</key>
<integer>1</integer>
<key>line</key>
<integer>63</integer>
</dict>
<key>selectTo</key>
<dict>
<key>column</key>
<integer>10</integer>
<key>line</key>
<integer>63</integer>
</dict>
</dict>
<key>src/native/hash.js</key>
<dict>
<key>caret</key>
<dict>
<key>column</key>
<integer>21</integer>
<key>line</key>
<integer>66</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>114</integer>
</dict>
<key>src/request/request.js</key>
<dict>
<key>caret</key>
<dict>
<key>column</key>
<integer>35</integer>
<integer>23</integer>
<key>line</key>
<integer>33</integer>
<integer>54</integer>
</dict>
<key>firstVisibleColumn</key>
<integer>0</integer>
<key>firstVisibleLine</key>
<integer>2</integer>
<integer>40</integer>
</dict>
</dict>
<key>openDocuments</key>
<array>
<string>src/request/request.js</string>
<string>src/core/object.js</string>
<string>src/core/function.js</string>
<string>src/event/event.js</string>
<string>src/dom/element.js</string>
<string>src/core/jplus.js</string>
<string>src/native/hash.js</string>
<string>src/native/array.js</string>
<string>examples/dev.html</string>
</array>
<key>showFileHierarchyDrawer</key>
Expand Down
16 changes: 15 additions & 1 deletion src/core/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@ JPlus.BrowserFeatures = {
}

if (JPlus.Browser.MobileSafari)
JPlus.BrowserFeatures.SpecificElementExtensions = false;
JPlus.BrowserFeatures.SpecificElementExtensions = false;

function $exec(text){
if (!text) return text;
if (window.execScript){
window.execScript(text);
} else {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.text = text;
document.head.appendChild(script);
document.head.removeChild(script);
}
return text;
};
12 changes: 12 additions & 0 deletions src/core/jplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,16 @@ function $pick(){
if ($defined(arguments[i])) return arguments[i];
}
return null;
};

function $try(fn, bind, args){
try {
return fn.apply(bind, $splat(args));
} catch(e){
return false;
}
};

function $random(min, max){
return Math.floor(Math.random() * (max - min + 1) + min);
};
17 changes: 14 additions & 3 deletions src/native/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ Object.extend(String.prototype, {
return this.replace(new RegExp(String.patterns.script, 'img'), '');
},

extractScripts: function() {
var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
return (this.match(matchAll) || []).map(function(scriptTag) {
return (scriptTag.match(matchOne) || ['', ''])[1];
});
},

evalScripts: function() {
return this.extractScripts().map(function(script) { return eval(script) });
},

/**
* 转义字符串里html tag
*
Expand Down Expand Up @@ -332,15 +344,14 @@ Object.extend(String.prototype, {
* @author from prototype1.6
* @class String
* @method repeat
* @param {Integer:count} 重复的次数
* @param {Boolean:sanitize} 不eval
* @return {String} string
*/
evalJSON: function(sanitize) {
var json = this.unfilterJSON();
try {
if (!sanitize || json.isJSON()) return eval('(' + json + ')');
} catch (e) { }
throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
} catch (e) { throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); }
}

});
Expand Down
Loading

0 comments on commit 43d9791

Please sign in to comment.