单击按钮后将短代码插入编辑器

时间:2015-08-08 15:11:19

标签: javascript html forms

我在“添加媒体”按钮旁边创建了一个按钮。单击该按钮时,我希望它自动将短代码插入编辑器,如下所示:

[myshortcode]

请帮帮我。

1 个答案:

答案 0 :(得分:1)

以下是一个示例,您可以根据需要进行调整:

In [1]: data = """VOD   02/25/2013  00:00:00.000     0 
VOD   02/25/2013  00:01:00.000     0 
VOD   02/25/2013  00:02:00.000     0 
VOD   02/25/2013  00:03:00.000     0 
VOD   02/25/2013  00:04:00.000     0 
VOD   02/25/2013  00:05:00.000     0 
VOD   02/25/2013  00:06:00.000     0 """

In [2]: df = pd.read_csv(StringIO(data),sep='\s+',names=['ticker','date','time','value'])

In [3]: df2 = pd.concat([df]*100000*2)

In [4]: df2.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 1400000 entries, 0 to 6
Data columns (total 4 columns):
ticker    1400000 non-null object
date      1400000 non-null object
time      1400000 non-null object
value     1400000 non-null int64
dtypes: int64(1), object(3)
memory usage: 53.4+ MB

In [5]: result1 = pd.to_datetime(df2['date'] + ' ' + df2['time'],format='%m/%d/%Y %H:%M:%S.%f')

In [6]: result2 = pd.to_datetime(df2['date'], format="%m/%d/%Y") +  pd.to_timedelta(df2['time'])
result1
In [7]: result1.equals(result2)
Out[7]: True

In [9]: result1.head()
Out[9]: 
0   2013-02-25 00:00:00
1   2013-02-25 00:01:00
2   2013-02-25 00:02:00
3   2013-02-25 00:03:00
4   2013-02-25 00:04:00
dtype: datetime64[ns]