src/crypto.c: possible fix for memory leak related
[citadel.git] / webcit / tiny_mce / plugins / insertdatetime / editor_plugin_src.js
1 /* Import plugin specific language pack */\r
2 tinyMCE.importPluginLanguagePack('insertdatetime', 'cs,el,en,fr_ca,it,ko,sv,zh_cn,fa,fr,de,pl,pt_br,nl,da,he,nb,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl');\r
3 \r
4 function TinyMCE_insertdatetime_getInfo() {\r
5         return {\r
6                 longname : 'Insert date/time',\r
7                 author : 'Moxiecode Systems',\r
8                 authorurl : 'http://tinymce.moxiecode.com',\r
9                 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_insertdatetime.html',\r
10                 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion\r
11         };\r
12 };\r
13 \r
14 /**\r
15  * Returns the HTML contents of the insertdate, inserttime controls.\r
16  */\r
17 function TinyMCE_insertdatetime_getControlHTML(control_name) {\r
18         switch (control_name) {\r
19                 case "insertdate":\r
20                         var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertDate\');return false;';\r
21                         return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_insertdate" src="{$pluginurl}/images/insertdate.gif" title="{$lang_insertdate_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';\r
22 \r
23                 case "inserttime":\r
24                         var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertTime\');return false;';\r
25                         return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_inserttime" src="{$pluginurl}/images/inserttime.gif" title="{$lang_inserttime_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';\r
26         }\r
27 \r
28         return "";\r
29 }\r
30 \r
31 /**\r
32  * Executes the mceInsertDate command.\r
33  */\r
34 function TinyMCE_insertdatetime_execCommand(editor_id, element, command, user_interface, value) {\r
35         /* Adds zeros infront of value */\r
36         function addZeros(value, len) {\r
37                 value = "" + value;\r
38 \r
39                 if (value.length < len) {\r
40                         for (var i=0; i<(len-value.length); i++)\r
41                                 value = "0" + value;\r
42                 }\r
43 \r
44                 return value;\r
45         }\r
46 \r
47         /* Returns the date object in the specified format */\r
48         function getDateTime(date, format) {\r
49                 format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y");\r
50                 format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p");\r
51                 format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear());\r
52                 format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear());\r
53                 format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2));\r
54                 format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2));\r
55                 format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2));\r
56                 format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2));\r
57                 format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2));\r
58                 format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1));\r
59                 format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM"));\r
60                 format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]);\r
61                 format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]);\r
62                 format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]);\r
63                 format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]);\r
64                 format = tinyMCE.regexpReplace(format, "%%", "%");\r
65 \r
66                 return format;\r
67         }\r
68 \r
69         // Handle commands\r
70         switch (command) {\r
71                 case "mceInsertDate":\r
72                         tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt'))));\r
73                         return true;\r
74 \r
75                 case "mceInsertTime":\r
76                         tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt'))));\r
77                         return true;\r
78         }\r
79 \r
80         // Pass to next handler in chain\r
81         return false;\r
82 }\r