OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 /** | 71 /** |
72 * @param {string} id | 72 * @param {string} id |
73 * @return {WebInspector.Snippet} | 73 * @return {WebInspector.Snippet} |
74 */ | 74 */ |
75 snippetForId: function(id) | 75 snippetForId: function(id) |
76 { | 76 { |
77 return this._snippets[id]; | 77 return this._snippets[id]; |
78 }, | 78 }, |
79 | 79 |
| 80 /** |
| 81 * @param {string} name |
| 82 * @return {WebInspector.Snippet} |
| 83 */ |
| 84 snippetForName: function(name) |
| 85 { |
| 86 var snippets = Object.values(this._snippets); |
| 87 for (var i = 0; i < snippets.length; ++i) |
| 88 if (snippets[i].name === name) |
| 89 return snippets[i]; |
| 90 return null; |
| 91 }, |
| 92 |
80 _loadSettings: function() | 93 _loadSettings: function() |
81 { | 94 { |
82 var savedSnippets = this._snippetsSetting.get(); | 95 var savedSnippets = this._snippetsSetting.get(); |
83 for (var i = 0; i < savedSnippets.length; ++i) | 96 for (var i = 0; i < savedSnippets.length; ++i) |
84 this._snippetAdded(WebInspector.Snippet.fromObject(this, savedSnippe
ts[i])); | 97 this._snippetAdded(WebInspector.Snippet.fromObject(this, savedSnippe
ts[i])); |
85 }, | 98 }, |
86 | 99 |
87 /** | 100 /** |
88 * @param {WebInspector.Snippet} snippet | 101 * @param {WebInspector.Snippet} snippet |
89 */ | 102 */ |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 { | 214 { |
202 var serializedSnippet = {}; | 215 var serializedSnippet = {}; |
203 serializedSnippet.id = this.id; | 216 serializedSnippet.id = this.id; |
204 serializedSnippet.name = this.name; | 217 serializedSnippet.name = this.name; |
205 serializedSnippet.content = this.content; | 218 serializedSnippet.content = this.content; |
206 return serializedSnippet; | 219 return serializedSnippet; |
207 }, | 220 }, |
208 | 221 |
209 __proto__: WebInspector.Object.prototype | 222 __proto__: WebInspector.Object.prototype |
210 } | 223 } |
OLD | NEW |