OSDN Git Service

NP_Paint v1.18
[nucleus-jp/nucleus-plugins.git] / trunk / NP_Paint / paint / paint.js
1 // vim: tabstop=2:shiftwidth=2\r
2 \r
3 /**\r
4   * paint.js ($Revision: 1.15 $)\r
5   * by hsur ( http://blog.cles.jp/np_cles )\r
6   * \r
7   * $Id: paint.js,v 1.15 2010/06/06 11:44:19 hsur Exp $\r
8 */\r
9 \r
10 /*\r
11   * Copyright (C) 2005-2010 CLES. All rights reserved.\r
12   *\r
13   * This program is free software; you can redistribute it and/or\r
14   * modify it under the terms of the GNU General Public License\r
15   * as published by the Free Software Foundation; either version 2\r
16   * of the License, or (at your option) any later version.\r
17   * \r
18   * This program is distributed in the hope that it will be useful,\r
19   * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
20   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
21   * GNU General Public License for more details.\r
22   * \r
23   * You should have received a copy of the GNU General Public License\r
24   * along with this program; if not, write to the Free Software\r
25   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\r
26   * \r
27   * In addition, as a special exception, cles( http://blog.cles.jp/np_cles ) gives\r
28   * permission to link the code of this program with those files in the PEAR\r
29   * library that are licensed under the PHP License (or with modified versions\r
30   * of those files that use the same license as those files), and distribute\r
31   * linked combinations including the two. You must obey the GNU General Public\r
32   * License in all respects for all of the code used other than those files in\r
33   * the PEAR library that are licensed under the PHP License. If you modify\r
34   * this file, you may extend this exception to your version of the file,\r
35   * but you are not obligated to do so. If you do not wish to do so, delete\r
36   * this exception statement from your version.\r
37 */\r
38 \r
39 function getLoginkey()\r
40 {\r
41         var url = 'http://'+location.host+location.pathname;\r
42         var pars = 'action=plugin&name=Paint&type=getLoginkey';\r
43         \r
44         //var d = $('message');\r
45         //d.innerHTML = url + '?' + pars;\r
46 \r
47         var myAjax = new Ajax.Request(\r
48                 url, \r
49                 { method: 'get', parameters: pars, onSuccess: setLoginkey, onFailure: getLoginkeyFailed }\r
50         );\r
51 }\r
52 \r
53 function setLoginkey(originalRequest)\r
54 {\r
55         var xmldoc = originalRequest.responseXML;\r
56         var loginkey = xmldoc.getElementsByTagName('loginkey')[0].firstChild.nodeValue;\r
57 \r
58         var pat = new RegExp('loginkey=[^&=]+', 'i');\r
59         header = header.replace(pat, 'loginkey=' + loginkey);\r
60         \r
61         var d = $('message');\r
62         d.innerHTML = 'Ticket update OK -> ' + header;\r
63         document.paintbbs.str_header = header;\r
64 }\r
65 \r
66 function getLoginkeyFailed(originalRequest)\r
67 {\r
68         var d = $('message');\r
69         d.innerHTML = 'Ticket update NG';\r
70 }