| | 140 | |
| | 141 | <script type="text/javascript"> |
| | 142 | function pick(metadata_type, textbox_id) { |
| | 143 | var textbox = document.getElementById(textbox_id); |
| | 144 | |
| | 145 | // For adding the new metadata to the textarea |
| | 146 | var add_md = function(picked) { |
| | 147 | var last = textbox.value.substring(textbox.value.length - 1); |
| | 148 | if(last == "\r" || last == "\n") { |
| | 149 | // Already has new line |
| | 150 | } else { |
| | 151 | textbox.value = textbox.value + "\r\n"; |
| | 152 | } |
| | 153 | |
| | 154 | textbox.value = textbox.value + picked; |
| | 155 | }; |
| | 156 | |
| | 157 | // Fetch the data |
| | 158 | $.getJSON("[% cgi_url %]?action=metadata;format=json;type=" + metadata_type, function(data) { |
| | 159 | // alert(data[metadata_type][0]); |
| | 160 | // add_md(data[metadata_type][1]); |
| | 161 | }); |
| | 162 | } |
| | 163 | |
| | 164 | function pick_locale() { |
| | 165 | pick("locale", "locales"); |
| | 166 | } |
| | 167 | function pick_category() { |
| | 168 | pick("category", "categories"); |
| | 169 | } |
| | 170 | |
| | 171 | $(document).ready(function() { |
| | 172 | $("#pick_locale").html("<a href='javascript:pick_locale()'>pick Locale</a>"); |
| | 173 | $("#pick_category").html("<a href='javascript:pick_category()'>pick Category</a>"); |
| | 174 | }); |
| | 175 | </script> |