fork download
  1. importPackage(javax.swing);
  2. importPackage(javax.swing.table);
  3. importPackage(javax.swing.event);
  4. importPackage(java.awt);
  5. importPackage(java.awt.event);
  6. importPackage(java.util);
  7. importPackage(java.util.regex);
  8. importPackage(java.util.concurrent);
  9. importPackage(java.lang);
  10. importPackage(java.io);
  11.  
  12. var APP_NAME = "logsearch";
  13.  
  14. var g = {
  15. cancel: false,
  16. thread: createCachedThreadPool(),
  17. defaultValues: (function () {
  18. var o = {
  19. blist : [],
  20. set1 : false,
  21. set2 : false,
  22. set3 : false,
  23. set4 : false,
  24. title : null,
  25. name : null,
  26. mail : null,
  27. id : null,
  28. be : null,
  29. message : null,
  30. label : null,
  31. lnum : null,
  32. unum : null,
  33. lanc : null,
  34. uanc : null,
  35. lyear : null,
  36. lmonth : null,
  37. ldate : null,
  38. lday : null,
  39. lhours : null,
  40. lmin : null,
  41. uyear : null,
  42. umonth : null,
  43. udate : null,
  44. uday : null,
  45. uhours : null,
  46. umin : null,
  47. repanc : false
  48. };
  49.  
  50. var argLine = v2c.context.argLine + "";
  51. if (argLine !== "") {
  52. eval(argLine);
  53. for (var arg in args) {
  54. o[arg] = args[arg];
  55. }
  56. }
  57.  
  58. return o;
  59. }())
  60. }
  61.  
  62. var normalizeStr = (function () {
  63. var table = {
  64. "ガ": "ガ", "ギ": "ギ", "グ": "グ", "ゲ": "ゲ", "ゴ": "ゴ",
  65. "ザ": "ザ", "ジ": "ジ", "ズ": "ズ", "ゼ": "ゼ", "ゾ": "ゾ",
  66. "ダ": "ダ", "ヂ": "ヂ", "ヅ": "ヅ", "デ": "デ", "ド": "ド",
  67. "バ": "バ", "ビ": "ビ", "ブ": "ブ", "ベ": "ベ", "ボ": "ボ",
  68. "パ": "パ", "ピ": "ピ", "プ": "プ", "ペ": "ペ", "ポ": "ポ",
  69. "ヴ": "ヴ",
  70. "ア": "ア","イ": "イ", "ウ": "ウ", "エ": "エ", "オ": "オ",
  71. "カ": "カ", "キ": "キ", "ク": "ク", "ケ": "ケ", "コ": "コ",
  72. "サ": "サ", "シ": "シ", "ス": "ス", "セ": "セ", "ソ": "ソ",
  73. "タ": "タ", "チ": "チ", "ツ": "ツ", "テ": "テ", "ト": "ト",
  74. "ナ": "ナ", "ニ": "ニ", "ヌ": "ヌ", "ネ": "ネ", "ノ": "ノ",
  75. "ハ": "ハ", "ヒ": "ヒ", "フ": "フ", "ヘ": "ヘ", "ホ": "ホ",
  76. "マ": "マ", "ミ": "ミ", "ム": "ム", "メ": "メ", "モ": "モ",
  77. "ヤ": "ヤ", "ユ": "ユ", "ヨ": "ヨ",
  78. "ラ": "ラ", "リ": "リ", "ル": "ル", "レ": "レ", "ロ": "ロ",
  79. "ワ": "ワ", "ヲ": "ヲ", "ン": "ン",
  80. "ァ": "ァ", "ィ": "ィ", "ゥ": "ゥ", "ェ": "ェ", "ォ": "ォ", "ャ": "ャ", "ュ": "ュ", "ョ": "ョ", "ッ": "ッ",
  81. "。": "。", "「": "「", "」": "」", "、": "、", "・": "・", "ー": "ー"
  82. };
  83.  
  84. return function (str) {
  85. str = str + "";
  86. str = str.replace(/[A-Za-z0-9]/g, function(s) {
  87. return String.fromCharCode(s.charCodeAt(0) - 65248);
  88. });
  89. var result = "";
  90. var str = str.split("");
  91. for (var i = 0; i < str.length; i++){
  92. var c = str[i];
  93. var nc = str[i + 1];
  94. if (table[c + nc]) {
  95. result += table[c + nc];
  96. i++;
  97. }
  98. else {
  99. result += (table[c]) ? table[c] : c;
  100. }
  101. }
  102. return result;
  103. };
  104. }());
  105.  
  106. function createCachedThreadPool () {
  107. var ex = java.util.concurrent.Executors.newCachedThreadPool();
  108. return {
  109. submit: function (f) {
  110. return ex.submit(new Callable() {
  111. call: function () {
  112. return f();
  113. }
  114. });
  115. }
  116. };
  117. }
  118.  
  119. function saveDat (boardName, dat, subject, resCount) {
  120. var s = File.separator;
  121. var unixtime = Math.floor((new Date()) / 1000);
  122.  
  123. var dir = new File(v2c.saveDir, s + "log" + s + "localboard");
  124. if (!dir.exists()) dir.mkdir();
  125. dir = new File(dir, boardName);
  126. if (!dir.exists()) dir.mkdir();
  127. var datFile = new File(dir, unixtime + ".dat");
  128.  
  129. var pw = new PrintWriter(new BufferedWriter(new FileWriter(datFile, false)));
  130. pw.print(dat);
  131. pw.close();
  132.  
  133.  
  134. var subjectFile = new File(dir, "subject.txt");
  135. var pw = new PrintWriter(new BufferedWriter(new FileWriter(subjectFile, true)));
  136. pw.print(unixtime + ".dat<>" + subject + " (" + resCount + ")" + "\n");
  137. pw.close();
  138.  
  139. return unixtime;
  140. }
  141.  
  142. function readDat(file) {
  143. var resList = new ArrayList();
  144. var br = new BufferedReader(new FileReader(file));
  145. var line;
  146. while( (line = br.readLine()) ) {
  147. resList.add(line);
  148. }
  149. br.close();
  150. return resList;
  151. }
  152.  
  153. function getMatchesResFromThread(thread, o, callback) {
  154. /*
  155. o =
  156. {
  157. beID: BeID
  158. id: ID
  159. lowerRefCount: 被参照数 下限
  160. upperRefCount: 被参照数 上限
  161. lowerNumber: レス番号 下限
  162. upperNumber: レス番号 上限
  163. mail: メール欄
  164. name: 名前欄
  165. title: スレタイ
  166. message: 本文
  167. lowerDate: 投稿時刻 下限
  168. upperDate: 投稿時刻 上限
  169. 投稿時刻 = {
  170. fullYear: 年 4ケタ
  171. month: 月 0から11の整数 0=1月
  172. date: 日 1から31の整数
  173. day: 曜日 0から6の整数 0=日曜日
  174. hours: 時間 0から23の整数
  175. minutes: 分 0から59の整数
  176. }
  177. resLabel: レスに設定されているレスラベル
  178. }
  179. */
  180.  
  181. var e = {};
  182. var list = new ArrayList();
  183.  
  184. if (o) {
  185.  
  186.  
  187. if (o.lowerDate) {
  188. if (o.lowerDate.month === undefined) o.lowerDate.month = 0;
  189. if (o.lowerDate.date === undefined) o.lowerDate.date = 1;
  190. if (o.lowerDate.hours === undefined) o.lowerDate.hours = 0;
  191. if (o.lowerDate.minutes === undefined) o.lowerDate.minutes = 0;
  192. o.lowerDate.monthdate = parseInt(o.lowerDate.month) + parseInt(o.lowerDate.date) * 0.01;
  193. o.lowerDate.hoursminutes = parseInt(o.lowerDate.hours) + parseInt(o.lowerDate.minutes) * 0.01;
  194. var lowerDate = o.lowerDate;
  195. }
  196.  
  197. if (o.upperDate) {
  198. if (o.upperDate.month === undefined) o.upperDate.month = 11;
  199. if (o.upperDate.date === undefined) o.upperDate.date = 31;
  200. if (o.upperDate.hours === undefined) o.upperDate.hours = 23;
  201. if (o.upperDate.minutes === undefined) o.upperDate.minutes = 59;
  202. o.upperDate.monthdate = parseInt(o.upperDate.month) + parseInt(o.upperDate.date) * 0.01;
  203. o.upperDate.hoursminutes = parseInt(o.upperDate.hours) + parseInt(o.upperDate.minutes) * 0.01;
  204. var upperDate = o.upperDate;
  205. }
  206.  
  207. if (o.title && !(o.title instanceof RegExp)) o.title = new RegExp(o.title);
  208. if (o.message && !(o.message instanceof RegExp)) o.message = new RegExp(o.message);
  209. if (o.resLabel && !(o.resLabel instanceof RegExp)) o.resLabel = new RegExp(o.resLabel);
  210. if (o.beID && !(o.beID instanceof RegExp)) o.beID = new RegExp(o.beID);
  211. if (o.id && !(o.id instanceof RegExp)) o.id = new RegExp(o.id);
  212. if (o.mail && !(o.mail instanceof RegExp)) o.mail = new RegExp(o.mail);
  213. if (o.name && !(o.name instanceof RegExp)) o.name = new RegExp(o.name);
  214.  
  215. if (o.title && !o.title.test(thread.title)) {
  216. return list;
  217. }
  218. }
  219.  
  220. for (var resCount = thread.resCount, i = 0; i < resCount; i++) {
  221. var res = thread.getRes(i);
  222.  
  223. if (!res) continue;
  224. if ((res.date && res.date + "") === "Over 1000 Thread") continue;
  225.  
  226. if (o) {
  227. if ( ( o.message && !o.message.test(res.message) ) ||
  228. ( o.resLabel && ( !res.resLabel || !o.resLabel.test(res.resLabel.name) ) ) ||
  229. ( o.beID && ( res.beID === 0 || !o.beID.test(res.beID) ) ) ||
  230. ( o.id && ( !res.id || !o.id.test(res.id) ) ) ||
  231. ( o.mail && ( !o.mail.test(res.mail) ) ) ||
  232. ( o.name && ( !o.name.test(res.name) ) )
  233. ) {
  234. continue;
  235. }
  236.  
  237. if ( (o.lowerNumber && o.lowerNumber > res.number) ||
  238. (o.upperNumber && o.upperNumber < res.number)
  239. ) {
  240. continue;
  241. }
  242.  
  243. if ( (o.lowerRefCount && o.lowerRefCount > res.refCount) ||
  244. (o.upperRefCount && o.upperRefCount < res.refCount)
  245. ) {
  246. continue;
  247. }
  248.  
  249. if (o.lowerDate || o.upperDate) {
  250. var date = new Date(res.time);
  251. var monthdate = date.getMonth() + date.getDate() * 0.01;
  252. var hoursminutes = date.getHours() + date.getMinutes() * 0.01;
  253. }
  254.  
  255. if ( (o.lowerDate && (
  256. ( lowerDate.fullYear != undefined && lowerDate.fullYear > date.getFullYear() ) ||
  257. ( lowerDate.monthdate > monthdate ) ||
  258. ( lowerDate.day != undefined && lowerDate.day > date.getDay() ) ||
  259. ( lowerDate.hoursminutes > hoursminutes )
  260. )
  261. ) ||
  262. (o.upperDate && (
  263. ( upperDate.fullYear != undefined && upperDate.fullYear < date.getFullYear() ) ||
  264. ( upperDate.monthdate < monthdate ) ||
  265. ( upperDate.day != undefined && upperDate.day < date.getDay() ) ||
  266. ( upperDate.hoursminutes < hoursminutes )
  267. )
  268. )
  269. ) {
  270. continue;
  271. }
  272. }
  273.  
  274. list.add(res);
  275.  
  276.  
  277. if (callback) {
  278. e.progressValue = (i + 1) / resCount;
  279. if (callback(e) === false) break;
  280. }
  281. }
  282.  
  283. return list;
  284. }
  285.  
  286.  
  287. function makeModelItem(displayString, value) {
  288. return {
  289. displayString: displayString,
  290. value: value
  291. };
  292. }
  293. function listModelWrapper () {
  294. var listItems = new LinkedList();
  295. //var listenerList = new EventListenerList();
  296. var listModel = new ListModel({
  297. addListDataListener: function (l) {
  298. //listenerList.add(l.getClass(), l);
  299. },
  300. removeListDataListener: function () {
  301. //listenerList.remove(l.getClass(), l);
  302. },
  303. getElementAt: function (index) {
  304. return listItems.get(index).displayString;
  305. },
  306. getSize: function () {
  307. return listItems.size();
  308. }
  309. });
  310.  
  311. return {
  312. addListDataListener: listModel.addListDataListener,
  313. removeListDataListener: listModel.removeListDataListener,
  314. getElementAt: listModel.getElementAt,
  315. getSize: listModel.getSize,
  316. model: listModel,
  317. items: listItems,
  318. add: function (item) {
  319. listItems.add(item);
  320. },
  321. addFirst: function (item) {
  322. listItems.addFirst(item);
  323. },
  324. exists: function (item) {
  325. for (var length = listItems.size(), i = 0; i < length; i++) {
  326. var lItem = listItems.get(i);
  327. if (lItem.displayString === item.displayString && lItem.value === item.value) {
  328. return true;
  329. }
  330. }
  331. return false;
  332. },
  333. remove: function (index) {
  334. listItems.remove(index);
  335. },
  336. clear: function () {
  337. for (var length = listItems.size(), i = length - 1; i >= 0; i--) {
  338. this.remove(i);
  339. }
  340. }
  341. };
  342. }
  343.  
  344. function createGridBagPanel () {
  345. var panel = new JPanel(new GridBagLayout());
  346. return {
  347. getPanel: function () {
  348. return panel;
  349. },
  350. add: function (o) {
  351. var gbc = new GridBagConstraints();
  352. for(var option in o.options) {
  353. gbc[option] = o.options[option];
  354. }
  355. panel.add(o.component, gbc);
  356. }
  357. };
  358. }
  359.  
  360. function Window() {
  361. var gbp = createGridBagPanel();
  362. var frame = new JFrame();
  363. //frame.setSize(width, height);
  364.  
  365. frame.setAlwaysOnTop(true);
  366. frame.addWindowListener(new WindowListener() {
  367. windowClosing: function(e){
  368. frame.dispose();
  369. }
  370. });
  371.  
  372. frame.add(gbp.getPanel());
  373.  
  374. return {
  375. add: gbp.add,
  376. frame: frame,
  377. show: function () {
  378. frame.pack();
  379. frame.setLocationRelativeTo(null);
  380. frame.setVisible(true);
  381. }
  382. };
  383. }
  384.  
  385. function makeBoardsModel () {
  386. var boards = v2c.boards;
  387. var model = listModelWrapper();
  388.  
  389. for (var i = 0, length = boards.length; i < length; i++) {
  390. var board = boards[i];
  391. if (board.bbs.is2ch) {
  392. var name = board.name;
  393. if (name.length() === 0) name = "名無しの板 " + "(" + board.url + ")";
  394.  
  395. model.add(makeModelItem(name, board));
  396. }
  397. }
  398.  
  399. return model;
  400. }
  401.  
  402. function makeSearchModel () {
  403. var boards = v2c.boards;
  404. var model = listModelWrapper();
  405.  
  406. for (var i = 0, length = boards.length; i < length; i++) {
  407. model.add(makeModelItem("dummy", null));
  408. }
  409.  
  410. return model;
  411. }
  412.  
  413. function resMatcher (searchOptions) {
  414. var e = {};
  415. var matches = new HashMap();
  416.  
  417. var dispatchOnProgress = function (callback, progressValue) {
  418. if (callback) {
  419. e.progressValue = progressValue;
  420. var ret = callback(e);
  421. if (ret === false) return false;
  422. }
  423. return true;
  424. };
  425.  
  426. return {
  427. matchThread: function (thread, callback) {
  428. if (!matches.containsKey(thread)) {
  429. var list = getMatchesResFromThread(thread, searchOptions, function (e) {
  430. return dispatchOnProgress(callback, e.progressValue);
  431. });
  432. if (list.size() !== 0) {
  433. matches.put(thread, list);
  434. }
  435. }
  436. },
  437. matchBoard: function (board, callback) {
  438. var threads = board.threadsWithLog;
  439. if (threads.length === 0) {
  440. dispatchOnProgress(callback, 1.0);
  441. }
  442. else {
  443. for (var length = threads.length, i = 0; i < length; i++) {
  444. var thread = threads[i];
  445. this.matchThread(thread);
  446.  
  447. if (dispatchOnProgress(callback, (i + 1) / length) === false) return;
  448. }
  449. }
  450. },
  451. build: function (argString, callback) {
  452. var sb = new StringBuilder();
  453. var itiSb = new StringBuilder();
  454.  
  455. var threads = matches.keySet().toArray();
  456.  
  457. threads = threads.sort(function(a, b){
  458. return (a.key - b.key);
  459. });
  460.  
  461. var cancel = false;
  462. var date = new Date();
  463. var dateStr = date.getFullYear() + "/" + ("0" + (date.getMonth() + 1)).slice(-2) + "/" + ("0" + date.getDate()).slice(-2) + " " + ("0" + date.getHours()).slice(-2) + ":" + ("0" + date.getMinutes()).slice(-2);
  464. var iti = "抽出<><>" + dateStr + " ID:V2C<>パネルの設定<br>" + argString +"<br><br>$message<>抽出\n";
  465. var count = 2;
  466.  
  467. for (var length = threads.length, i = 0; i < length; i++) {
  468. var thread = threads[i];
  469. var matchesRes = matches.get(thread);
  470. var size = matchesRes.size();
  471.  
  472. var resList = readDat(thread.localFile);
  473.  
  474. if (size === 1) {
  475. var anchor = '&gt;&gt;' + count;
  476. }
  477. else {
  478. var anchor = '&gt;&gt;' + count + '-' + (count + size - 1);
  479. }
  480.  
  481. count += size;
  482.  
  483. var rescsv = "";
  484. for (var j = 0; j < size; j++) {
  485. var res = matchesRes.get(j);
  486. rescsv += (j === 0) ? res.number : "," + res.number;
  487.  
  488. //var source = res.source;
  489. var source = resList.get(res.index);
  490.  
  491. if (callback) {
  492. var e = {};
  493. e.res = res;
  494. e.thread = thread;
  495. e.source = source;
  496. e.progressValue = i / length + (j + 1) / size / length;
  497.  
  498. if (callback(e) === false) {
  499. cancel = true;
  500. }
  501. if (cancel) break;
  502. source = e.source;
  503. }
  504.  
  505. sb.append(source);
  506. sb.append("\n");
  507. }
  508. itiSb.append(anchor + " " + thread.title + " " + thread.url + rescsv + "<br>");
  509. if (cancel) break;
  510. }
  511. sb.insert(0, iti.replace("$message", itiSb.toString()));
  512.  
  513. return sb.toString();
  514. }
  515. };
  516. }
  517.  
  518.  
  519. var window = new Window();
  520.  
  521. var components = (function () {
  522.  
  523. var refSearch = new JTextField();
  524. var refSearchEnable = true;
  525. var boardsModel = makeBoardsModel();
  526. var defaultModelItems = boardsModel.items.clone();
  527. var boardsList = new JList(boardsModel.model);
  528. var boardsListScroll = new JScrollPane(boardsList);
  529.  
  530. var toRightButton = new JButton("↓");
  531. var toLeftButton = new JButton("↑");
  532.  
  533. toRightButton.setPreferredSize(new Dimension(50, 20));
  534. toLeftButton.setPreferredSize(new Dimension(50, 20));
  535.  
  536. var searchModel = makeSearchModel();
  537. var searchList = new JList(searchModel.model);
  538. var searchListScroll = new JScrollPane(searchList);
  539.  
  540. var searchButton = new JButton("検索開始");
  541. var cancelButton = new JButton("キャンセル");
  542.  
  543.  
  544. var searchTitleCheck = new JCheckBox("スレタイ");
  545. var searchTitle = new JTextField();
  546. var searchNameCheck = new JCheckBox("名前");
  547. var searchName = new JTextField();
  548. var searchMailCheck = new JCheckBox("メール");
  549. var searchMail = new JTextField();
  550. var searchIDCheck = new JCheckBox("ID");
  551. var searchID = new JTextField();
  552. var searchBeIDCheck = new JCheckBox("BE");
  553. var searchBeID = new JTextField();
  554. var searchMessageCheck = new JCheckBox("本文");
  555. var searchMessage = new JTextField();
  556. var searchLabelCheck = new JCheckBox("ラベル");
  557. var list = ["全てのラベル"];
  558. for (var i = 0; i < v2c.resLabels.length; i++) {
  559. list.push(v2c.resLabels[i].name);
  560. }
  561. var searchLabel = new JComboBox(list);
  562. var list = [];
  563. for (var i = 1999; i <= parseInt((new Date()).getFullYear()); i++) {
  564. list.push(i.toString());
  565. }
  566. var searchYear1Check = new JCheckBox("年");
  567. var searchYear1 = new JComboBox(list);
  568. var searchYear2Check = new JCheckBox("年");
  569. var searchYear2 = new JComboBox(list);
  570.  
  571. var list = [];
  572. for (var i = 1; i <= 12; i++) {
  573. list.push(i.toString());
  574. }
  575. var searchMonth1Check = new JCheckBox("月");
  576. var searchMonth1 = new JComboBox(list);
  577. var searchMonth2Check = new JCheckBox("月");
  578. var searchMonth2 = new JComboBox(list);
  579.  
  580. var list = [];
  581. for (var i = 1; i <= 31; i++) {
  582. list.push(i.toString());
  583. }
  584. var searchDate1Check = new JCheckBox("日");
  585. var searchDate1 = new JComboBox(list);
  586. var searchDate2Check = new JCheckBox("日");
  587. var searchDate2 = new JComboBox(list);
  588.  
  589. var searchDay1Check = new JCheckBox("曜日");
  590. var searchDay1 = new JComboBox(["日", "月", "火", "水", "木", "金", "土"]);
  591. var searchDay2Check = new JCheckBox("曜日");
  592. var searchDay2 = new JComboBox(["日", "月", "火", "水", "木", "金", "土"]);
  593.  
  594. var list = [];
  595. for (var i = 0; i <= 23; i++) {
  596. list.push(i.toString());
  597. }
  598. var searchHours1Check = new JCheckBox("時");
  599. var searchHours1 = new JComboBox(list);
  600. var searchHours2Check = new JCheckBox("時");
  601. var searchHours2 = new JComboBox(list);
  602.  
  603. var list = [];
  604. for (var i = 0; i <= 59; i++) {
  605. list.push(i.toString());
  606. }
  607. var searchMinutes1Check = new JCheckBox("分");
  608. var searchMinutes1 = new JComboBox(list);
  609. var searchMinutes2Check = new JCheckBox("分");
  610. var searchMinutes2 = new JComboBox(list);
  611.  
  612. var searchNumber1Check = new JCheckBox("下限");
  613. var searchNumber1 = new JSpinner();
  614. searchNumber1.setValue(1);
  615. searchNumber1.setEditor(new JSpinner.NumberEditor(searchNumber1, "###0"));
  616.  
  617. var searchNumber2Check = new JCheckBox("上限");
  618. var searchNumber2 = new JSpinner();
  619. searchNumber2.setEditor(new JSpinner.NumberEditor(searchNumber2, "###0"));
  620. searchNumber2.setValue(1);
  621.  
  622. var searchRefcount1Check = new JCheckBox("下限");
  623. var searchRefcount1 = new JSpinner();
  624. searchRefcount1.setEditor(new JSpinner.NumberEditor(searchRefcount1, "###0"));
  625. searchRefcount1.setValue(0);
  626.  
  627. var searchRefcount2Check = new JCheckBox("上限");
  628. var searchRefcount2 = new JSpinner();
  629. searchRefcount2.setEditor(new JSpinner.NumberEditor(searchRefcount2, "###0"));
  630. searchRefcount2.setValue(0);
  631.  
  632. var searchSelectedThreadCheck = new JCheckBox("選択しているスレッドを含める");
  633. var searchSelectedBoardCheck = new JCheckBox("選択している板を含める(未実装)");
  634. searchSelectedBoardCheck.setEnabled(false);
  635. var searchViewThreadCheck = new JCheckBox("開いているスレッドを含める");
  636. var searchViewBoardCheck = new JCheckBox("開いている板を含める(未実装)");
  637. searchViewBoardCheck.setEnabled(false);
  638. var searchViewThreadBoardCheck = new JCheckBox("開いているスレッドが所属する板を含める");
  639. var searchSelectedThreadBoardCheck = new JCheckBox("選択しているスレッドが所属する板を含める");
  640.  
  641. var progressLabel = new JLabel("");
  642. var progress = new JProgressBar(0, 100);
  643.  
  644. var replaceAnchorCheck = new JCheckBox("アンカーを絶対参照に書き換える");
  645.  
  646.  
  647. refSearch.addKeyListener(function () {
  648. this.keyReleased = function (e) {
  649. if (refSearchEnable) {
  650. boardsModel.clear();
  651. var regExp = new RegExp(normalizeStr(refSearch.getText()), "i");
  652. for (var i = 0, length = defaultModelItems.size(); i < length; i++) {
  653. var item = defaultModelItems.get(i);
  654. var name = normalizeStr(item.displayString);
  655. if (name.match(regExp) && !searchModel.exists(item)) {
  656. boardsModel.add(item);
  657. }
  658. }
  659. boardsList.repaint();
  660. boardsList.revalidate();
  661. }
  662. }
  663. });
  664. refSearch.addInputMethodListener(function () {
  665. this.inputMethodTextChanged = function (e) {
  666. refSearchEnable = (e.getText() === null);
  667. }
  668. });
  669.  
  670. toLeftButton.addActionListener(new ActionListener({
  671. actionPerformed: function (e) {
  672. var index = searchList.getSelectedIndices();
  673. for (var length = index.length, i = length - 1; i >= 0; i--) {
  674. boardsModel.addFirst(searchModel.items.get(index[i]));
  675. searchModel.remove(index[i]);
  676. }
  677. boardsList.repaint();
  678. boardsList.revalidate();
  679. searchList.repaint();
  680. searchList.revalidate();
  681. searchList.clearSelection();
  682. boardsList.clearSelection();
  683. }
  684. }));
  685.  
  686. toRightButton.addActionListener(new ActionListener({
  687. actionPerformed: function (e) {
  688. var index = boardsList.getSelectedIndices();
  689. for (var length = index.length, i = length - 1; i >= 0; i--) {
  690. searchModel.add(boardsModel.items.get(index[i]));
  691. boardsModel.remove(index[i]);
  692. }
  693. boardsList.repaint();
  694. boardsList.revalidate();
  695. searchList.repaint();
  696. searchList.revalidate();
  697. searchList.clearSelection();
  698. boardsList.clearSelection();
  699. }
  700. }));
  701.  
  702. var makeSearchOptions = function () {
  703.  
  704. var searchOptions = {};
  705. if (searchTitleCheck.isSelected() ) searchOptions.title = searchTitle.getText();
  706. if (searchNameCheck.isSelected() ) searchOptions.name = searchName.getText();
  707. if (searchMailCheck.isSelected() ) searchOptions.mail = searchMail.getText();
  708. if (searchIDCheck.isSelected() ) searchOptions.id = searchID.getText();
  709. if (searchBeIDCheck.isSelected() ) searchOptions.beID = searchBeID.getText();
  710. if (searchMessageCheck.isSelected()) searchOptions.message = searchMessage.getText();
  711. if (searchLabelCheck.isSelected() ) {
  712. if (searchLabel.getSelectedIndex() === 0) {
  713. searchOptions.resLabel = new RegExp(".+");
  714. }
  715. else {
  716. searchOptions.resLabel = new RegExp("^" + searchLabel.getSelectedItem() + "$");
  717. }
  718. }
  719.  
  720.  
  721. if (searchNumber1Check.isSelected()) searchOptions.lowerNumber = searchNumber1.getValue();
  722. if (searchNumber2Check.isSelected()) searchOptions.upperNumber = searchNumber2.getValue();
  723. if (searchRefcount1Check.isSelected()) searchOptions.lowerRefCount = searchRefcount1.getValue();
  724. if (searchRefcount2Check.isSelected()) searchOptions.upperRefCount = searchRefcount2.getValue();
  725.  
  726. searchOptions.lowerDate = {};
  727. searchOptions.upperDate = {};
  728. var dayTable = {
  729. "日": "0",
  730. "月": "1",
  731. "火": "2",
  732. "水": "3",
  733. "木": "4",
  734. "金": "5",
  735. "土": "6"
  736. };
  737.  
  738. if (searchYear1Check.isSelected() ) searchOptions.lowerDate.fullYear = searchYear1.getSelectedItem();
  739. if (searchMonth1Check.isSelected() ) searchOptions.lowerDate.month = parseInt(searchMonth1.getSelectedItem()) - 1;
  740. if (searchDate1Check.isSelected() ) searchOptions.lowerDate.date = parseInt(searchDate1.getSelectedItem());
  741. if (searchDay1Check.isSelected() ) searchOptions.lowerDate.day = dayTable[(searchDay1.getSelectedItem() + "")];
  742. if (searchHours1Check.isSelected() ) searchOptions.lowerDate.hours = parseInt(searchHours1.getSelectedItem());
  743. if (searchMinutes1Check.isSelected()) searchOptions.lowerDate.minutes = parseInt(searchMinutes1.getSelectedItem());
  744.  
  745. if (searchYear2Check.isSelected() ) searchOptions.upperDate.fullYear = searchYear2.getSelectedItem();
  746. if (searchMonth2Check.isSelected() ) searchOptions.upperDate.month = parseInt(searchMonth2.getSelectedItem()) - 1;
  747. if (searchDate2Check.isSelected() ) searchOptions.upperDate.date = parseInt(searchDate2.getSelectedItem());
  748. if (searchDay2Check.isSelected() ) searchOptions.upperDate.day = dayTable[(searchDay2.getSelectedItem() + "")];
  749. if (searchHours2Check.isSelected() ) searchOptions.upperDate.hours = parseInt(searchHours2.getSelectedItem());
  750. if (searchMinutes2Check.isSelected()) searchOptions.upperDate.minutes = parseInt(searchMinutes2.getSelectedItem());
  751.  
  752. return searchOptions;
  753. };
  754.  
  755. searchButton.addActionListener(new ActionListener({
  756. actionPerformed:
  757. function () {
  758. g.thread.submit(
  759. function () {
  760.  
  761. g.cancel = false;
  762. searchButton.setEnabled(false);
  763. progress.setValue(0);
  764.  
  765. var searchOptions = makeSearchOptions();
  766. var progressValue = 0;
  767.  
  768. var matcher = resMatcher(searchOptions);
  769.  
  770.  
  771. var taskNo = 1;
  772. var taskCount = 0;
  773. if (searchModel.items.size() > 0) taskCount += 1;
  774. if (searchSelectedThreadCheck.isSelected()) taskCount += 1;
  775. if (searchViewThreadCheck.isSelected()) taskCount += 1;
  776. if (searchSelectedThreadBoardCheck.isSelected()) taskCount += 1;
  777. if (searchViewThreadBoardCheck.isSelected()) taskCount += 1;
  778.  
  779. /**********************************
  780. * 板指定
  781. **********************************/
  782. if (!g.cancel && searchModel.items.size() > 0) {
  783. progressLabel.setText(taskNo + " / " + taskCount);
  784. taskNo += 1;
  785.  
  786. var items = searchModel.items;
  787. for (var size = items.size(), i = 0; i < size; i++) {
  788. if (g.cancel) break;
  789. var board = items.get(i).value;
  790. matcher.matchBoard(board, function (e) {
  791. progressValue = i / size + e.progressValue / size;
  792. progress.setValue(progressValue * 100);
  793. if (g.cancel) return false;
  794. });
  795. }
  796. }
  797.  
  798. /**********************************
  799. * 選択しているスレッドを含める
  800. **********************************/
  801. if (!g.cancel && searchSelectedThreadCheck.isSelected()) {
  802. progressLabel.setText(taskNo + " / " + taskCount);
  803. taskNo += 1;
  804.  
  805. var thread = v2c.resPane.selectedThread;
  806. matcher.matchThread(thread, function (e) {
  807. progressValue = e.progressValue;
  808. progress.setValue(progressValue * 100);
  809. if (g.cancel) return false;
  810. });
  811. }
  812.  
  813. /**********************************
  814. * 開いているスレッドを含める
  815. **********************************/
  816. if (!g.cancel && searchViewThreadCheck.isSelected()) {
  817. progressLabel.setText(taskNo + " / " + taskCount);
  818. taskNo += 1;
  819.  
  820. var threads = v2c.resPane.threads;
  821. for (var length = threads.length, i = 0; i < length; i++) {
  822. if (g.cancel) break;
  823.  
  824. var thread = threads[i];
  825. matcher.matchThread(thread, function (e) {
  826. progressValue = i / length + e.progressValue / length;
  827. progress.setValue(progressValue * 100);
  828. if (g.cancel) return false;
  829. });
  830. }
  831. }
  832.  
  833.  
  834. /**********************************
  835. * 選択しているスレッドが所属する板を含める
  836. **********************************/
  837. if (!g.cancel && searchSelectedThreadBoardCheck.isSelected()) {
  838. progressLabel.setText(taskNo + " / " + taskCount);
  839. taskNo += 1;
  840.  
  841. var board = v2c.resPane.selectedThread.board;
  842. matcher.matchBoard(board, function (e) {
  843. progressValue = e.progressValue;
  844. progress.setValue(progressValue * 100);
  845. if (g.cancel) return false;
  846. });
  847. }
  848.  
  849. /**********************************
  850. * 開いているスレッドが所属する板を含める
  851. **********************************/
  852. if (!g.cancel && searchViewThreadBoardCheck.isSelected()) {
  853. progressLabel.setText(taskNo + " / " + taskCount);
  854. taskNo += 1;
  855. var memo = {};
  856. var threads = v2c.resPane.threads;
  857. for (var length = threads.length, i = 0; i < length; i++) {
  858. if (g.cancel) break;
  859. var thread = threads[i];
  860. var board = thread.board;
  861.  
  862. if (!memo[board.url]) {
  863. memo[board.url] = true;
  864.  
  865. matcher.matchBoard(board, function (e) {
  866. progressValue = i / length + e.progressValue / length;
  867. progress.setValue(progressValue * 100);
  868. if (g.cancel) return false;
  869. });
  870. }
  871. }
  872. }
  873.  
  874. g.cancel = false;
  875.  
  876. var resTitle = "抽出結果";
  877. var dat = matcher.build(getArgsString(), function (e) {
  878. progressLabel.setText("抽出結果構成中");
  879. progress.setValue(e.progressValue * 100);
  880. if (replaceAnchorCheck.isSelected()) e.source = e.source.replaceAll("<a.+?([0-9]+)</a>", "&gt;&gt;" + e.thread.url + "$1");
  881. e.source = e.source.replaceAll("(.+)<>.*$", '$1<br><hr>' + e.thread.title + " " + e.thread.url + e.res.number + "<>");
  882. if (g.cancel) return false;
  883. });
  884. var resCount = dat.split("\n").length;
  885. var unixtime = saveDat(APP_NAME, dat, resTitle, resCount);
  886. var lth = v2c.getThread("http://localboard/test/read.cgi/" + APP_NAME + "/" + unixtime + "/", resTitle, resCount);
  887. lth.open(false);
  888.  
  889. progressLabel.setText("完了");
  890. searchButton.setEnabled(true);
  891. }
  892. );
  893. }
  894. }));
  895.  
  896. cancelButton.addActionListener(new ActionListener({
  897. actionPerformed: function (e) {
  898. g.cancel = true;
  899. }
  900. }));
  901.  
  902. return {
  903. refSearch : refSearch,
  904. boardsList : boardsList,
  905. searchList : searchList,
  906. boardsModel : boardsModel,
  907. searchModel : searchModel,
  908. boardsListScroll : boardsListScroll,
  909. searchListScroll : searchListScroll,
  910. toRightButton : toRightButton,
  911. toLeftButton : toLeftButton,
  912. searchButton : searchButton,
  913. cancelButton : cancelButton,
  914. searchTitle : searchTitle,
  915. searchName : searchName,
  916. searchMail : searchMail,
  917. searchID : searchID,
  918. searchBeID : searchBeID,
  919. searchMessage : searchMessage,
  920. searchLabel : searchLabel,
  921. searchTitleCheck : searchTitleCheck,
  922. searchNameCheck : searchNameCheck,
  923. searchMailCheck : searchMailCheck,
  924. searchIDCheck : searchIDCheck,
  925. searchBeIDCheck : searchBeIDCheck,
  926. searchMessageCheck : searchMessageCheck,
  927. searchLabelCheck : searchLabelCheck,
  928. searchYear1 : searchYear1,
  929. searchYear1Check : searchYear1Check,
  930. searchMonth1 : searchMonth1,
  931. searchMonth1Check : searchMonth1Check,
  932. searchDate1 : searchDate1,
  933. searchDate1Check : searchDate1Check,
  934. searchDay1 : searchDay1,
  935. searchDay1Check : searchDay1Check,
  936. searchHours1 : searchHours1,
  937. searchHours1Check : searchHours1Check,
  938. searchMinutes1 : searchMinutes1,
  939. searchMinutes1Check : searchMinutes1Check,
  940. searchYear2 : searchYear2,
  941. searchYear2Check : searchYear2Check,
  942. searchMonth2 : searchMonth2,
  943. searchMonth2Check : searchMonth2Check,
  944. searchDate2 : searchDate2,
  945. searchDate2Check : searchDate2Check,
  946. searchDay2 : searchDay2,
  947. searchDay2Check : searchDay2Check,
  948. searchHours2 : searchHours2,
  949. searchHours2Check : searchHours2Check,
  950. searchMinutes2 : searchMinutes2,
  951. searchMinutes2Check : searchMinutes2Check,
  952. searchNumber1 : searchNumber1,
  953. searchNumber1Check : searchNumber1Check,
  954. searchNumber2 : searchNumber2,
  955. searchNumber2Check : searchNumber2Check,
  956. searchRefcount1 : searchRefcount1,
  957. searchRefcount1Check : searchRefcount1Check,
  958. searchRefcount2 : searchRefcount2,
  959. searchRefcount2Check : searchRefcount2Check,
  960. searchSelectedThreadCheck : searchSelectedThreadCheck,
  961. searchSelectedBoardCheck : searchSelectedBoardCheck,
  962. searchViewThreadCheck : searchViewThreadCheck,
  963. searchViewBoardCheck : searchViewBoardCheck,
  964. searchViewThreadBoardCheck : searchViewThreadBoardCheck,
  965. searchSelectedThreadBoardCheck : searchSelectedThreadBoardCheck,
  966. progress : progress,
  967. progressLabel : progressLabel,
  968. replaceAnchorCheck : replaceAnchorCheck
  969. };
  970. }());
  971.  
  972.  
  973.  
  974. window.add({
  975. component:
  976. (function () {
  977. var panel = new JPanel();
  978. panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
  979.  
  980. var gbp = createGridBagPanel();
  981.  
  982. gbp.add({
  983. component:
  984. new JLabel("フィルタ"),
  985. options:
  986. {
  987. gridx: 0,
  988. gridy: 0
  989. }
  990. });
  991. gbp.add({
  992. component:
  993. components.refSearch,
  994. options:
  995. {
  996. gridx: 1,
  997. gridy: 0,
  998. weightx: 1,
  999. insets: new Insets(0, 5, 0, 0),
  1000. fill: GridBagConstraints.BOTH
  1001. }
  1002. });
  1003. gbp.add({
  1004. component:
  1005. components.boardsListScroll,
  1006. options:
  1007. {
  1008. gridx: 0,
  1009. gridy: 1,
  1010. weightx: 1,
  1011. weighty: 1,
  1012. gridwidth: 2,
  1013. insets: new Insets(10, 0, 0, 0),
  1014. fill: GridBagConstraints.BOTH
  1015. }
  1016. });
  1017.  
  1018. var panel1 = gbp.getPanel();
  1019. panel1.setBorder(BorderFactory.createTitledBorder("板一覧"));
  1020.  
  1021. var panel2 = new JPanel();
  1022. panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));
  1023. panel2.add(components.toRightButton);
  1024. panel2.add(components.toLeftButton);
  1025.  
  1026. var panel3 = new JPanel();
  1027. panel3.setLayout(new BoxLayout(panel3, BoxLayout.PAGE_AXIS));
  1028. panel3.add(components.searchListScroll);
  1029. panel3.setBorder(BorderFactory.createTitledBorder("検索対象"));
  1030.  
  1031. panel.add(panel1);
  1032. panel.add(panel2);
  1033. panel.add(panel3);
  1034. panel.setBorder(BorderFactory.createTitledBorder("板指定"));
  1035.  
  1036. return panel;
  1037. }()),
  1038. options:
  1039. {
  1040. gridx: 0,
  1041. gridy: 0,
  1042. weightx: 0.5,
  1043. weighty: 1,
  1044. gridheight: 4,
  1045. insets: new Insets(10, 10, 10, 10),
  1046. fill: GridBagConstraints.BOTH
  1047. }
  1048. });
  1049.  
  1050. window.add({
  1051. component:
  1052. (function () {
  1053. var gbp = createGridBagPanel();
  1054. var panel = gbp.getPanel();
  1055. var set = function (component, x, y) {
  1056. gbp.add({
  1057. component: component,
  1058. options:
  1059. {
  1060. gridx: x,
  1061. gridy: y,
  1062. fill: GridBagConstraints.BOTH
  1063. }
  1064. });
  1065. };
  1066.  
  1067. set(components.searchSelectedThreadCheck, 0, 0);
  1068. set(components.searchSelectedThreadBoardCheck, 0, 1);
  1069.  
  1070. set(components.searchViewThreadCheck, 1, 0);
  1071. set(components.searchViewThreadBoardCheck, 1, 1);
  1072.  
  1073. // set(components.searchSelectedBoardCheck, 2, 0);
  1074. // set(components.searchViewBoardCheck, 2, 1);
  1075.  
  1076. panel.setBorder(BorderFactory.createTitledBorder("その他指定"));
  1077.  
  1078. return panel;
  1079. }()),
  1080. options:
  1081. {
  1082. gridx: 1,
  1083. gridy: 0,
  1084. weightx: 0.5,
  1085. insets: new Insets(10, 10, 3, 10),
  1086. fill: GridBagConstraints.BOTH
  1087. }
  1088. });
  1089.  
  1090. window.add({
  1091. component:
  1092. (function () {
  1093. var gbp = createGridBagPanel();
  1094. var i = 0;
  1095. var set = function (name, index) {
  1096. gbp.add({
  1097. component: components[name + "Check"],
  1098. options:
  1099. {
  1100. gridx: 0,
  1101. gridy: index,
  1102. anchor: GridBagConstraints.WEST
  1103. }
  1104. });
  1105. gbp.add({
  1106. component: components[name],
  1107. options:
  1108. {
  1109. gridx: 1,
  1110. gridy: index,
  1111. weightx: 1,
  1112. insets: new Insets(0, 0, 5, 0),
  1113. fill: GridBagConstraints.BOTH
  1114. }
  1115. });
  1116. }
  1117.  
  1118. set("searchTitle", i++);
  1119. set("searchName", i++);
  1120. set("searchMail", i++);
  1121. set("searchID", i++);
  1122. set("searchBeID", i++);
  1123. set("searchMessage", i++);
  1124. set("searchLabel", i++);
  1125.  
  1126.  
  1127. gbp.add({
  1128. component:
  1129. (function () {
  1130.  
  1131. var panel = new JPanel();
  1132. panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
  1133.  
  1134. var panel1 = new JPanel();
  1135. panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS));
  1136. panel1.add(components.searchNumber1Check);
  1137. panel1.add(components.searchNumber1);
  1138. panel1.add(components.searchNumber2Check);
  1139. panel1.add(components.searchNumber2);
  1140. panel1.setBorder(BorderFactory.createTitledBorder("レス番号"));
  1141.  
  1142. var panel2 = new JPanel();
  1143. panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));
  1144. panel2.add(components.searchRefcount1Check);
  1145. panel2.add(components.searchRefcount1);
  1146. panel2.add(components.searchRefcount2Check);
  1147. panel2.add(components.searchRefcount2);
  1148. panel2.setBorder(BorderFactory.createTitledBorder("被参照数"));
  1149.  
  1150. panel.add(panel1);
  1151. panel.add(panel2);
  1152.  
  1153. return panel;
  1154. }()),
  1155. options:
  1156. {
  1157. gridx: 0,
  1158. gridy: i++,
  1159. gridwidth: 2,
  1160. fill: GridBagConstraints.BOTH
  1161. }
  1162. });
  1163.  
  1164. gbp.add({
  1165. component:
  1166. (function () {
  1167. var panel = new JPanel();
  1168. panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
  1169. panel.add(components.searchYear1Check);
  1170. panel.add(components.searchYear1);
  1171. panel.add(components.searchMonth1Check);
  1172. panel.add(components.searchMonth1);
  1173. panel.add(components.searchDate1Check);
  1174. panel.add(components.searchDate1);
  1175. panel.add(components.searchDay1Check);
  1176. panel.add(components.searchDay1);
  1177. panel.add(components.searchHours1Check);
  1178. panel.add(components.searchHours1);
  1179. panel.add(components.searchMinutes1Check);
  1180. panel.add(components.searchMinutes1);
  1181. panel.setBorder(BorderFactory.createTitledBorder("投稿時刻 下限"));
  1182. return panel;
  1183. }()),
  1184. options:
  1185. {
  1186. gridx: 0,
  1187. gridy: i++,
  1188. gridwidth: 2,
  1189. fill: GridBagConstraints.BOTH
  1190. }
  1191. });
  1192.  
  1193. gbp.add({
  1194. component:
  1195. (function () {
  1196. var panel = new JPanel();
  1197. panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
  1198. panel.add(components.searchYear2Check);
  1199. panel.add(components.searchYear2);
  1200. panel.add(components.searchMonth2Check);
  1201. panel.add(components.searchMonth2);
  1202. panel.add(components.searchDate2Check);
  1203. panel.add(components.searchDate2);
  1204. panel.add(components.searchDay2Check);
  1205. panel.add(components.searchDay2);
  1206. panel.add(components.searchDay2Check);
  1207. panel.add(components.searchDay2);
  1208. panel.add(components.searchHours2Check);
  1209. panel.add(components.searchHours2);
  1210. panel.add(components.searchMinutes2Check);
  1211. panel.add(components.searchMinutes2);
  1212. panel.setBorder(BorderFactory.createTitledBorder("投稿時刻 上限"));
  1213. return panel;
  1214. }()),
  1215. options:
  1216. {
  1217. gridx: 0,
  1218. gridy: i++,
  1219. gridwidth: 2,
  1220. fill: GridBagConstraints.BOTH
  1221. }
  1222. });
  1223.  
  1224. var panel = gbp.getPanel();
  1225. panel.setBorder(BorderFactory.createTitledBorder("検索条件"));
  1226.  
  1227. return panel;
  1228. }()),
  1229. options:
  1230. {
  1231. gridx: 1,
  1232. gridy:1,
  1233. weightx: 0.5,
  1234. insets: new Insets(3, 10, 3, 10),
  1235. fill: GridBagConstraints.HORIZONTAL
  1236. }
  1237. });
  1238.  
  1239.  
  1240. window.add({
  1241. component:
  1242. (function () {
  1243. var gbp = createGridBagPanel();
  1244. var panel = gbp.getPanel();
  1245. var set = function (component, x, y) {
  1246. gbp.add({
  1247. component: component,
  1248. options:
  1249. {
  1250. gridx: x,
  1251. gridy: y,
  1252. fill: GridBagConstraints.BOTH
  1253. }
  1254. });
  1255. };
  1256.  
  1257. set(components.replaceAnchorCheck, 0, 0);
  1258.  
  1259. panel.setBorder(BorderFactory.createTitledBorder("オプション"));
  1260.  
  1261. return panel;
  1262. }()),
  1263. options:
  1264. {
  1265. gridx: 1,
  1266. gridy: 2,
  1267. weightx: 1,
  1268. insets: new Insets(0, 10, 3, 10),
  1269. fill: GridBagConstraints.BOTH
  1270. }
  1271. });
  1272.  
  1273. window.add({
  1274. component:
  1275. (function () {
  1276. var gbp = createGridBagPanel();
  1277. var panel = gbp.getPanel();
  1278.  
  1279. var panel1 = new JPanel(new GridLayout(2,1));
  1280.  
  1281. panel1.add(components.progressLabel);
  1282. panel1.add(components.progress);
  1283.  
  1284. var panel2 = new JPanel();
  1285. panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));
  1286. panel2.add(components.searchButton);
  1287. panel2.add(components.cancelButton);
  1288.  
  1289. gbp.add({
  1290. component: panel1,
  1291. options:
  1292. {
  1293. gridx: 0,
  1294. gridy: 0,
  1295. weightx: 1000,
  1296. insets: new Insets(5, 5, 5, 5),
  1297. fill: GridBagConstraints.HORIZONTAL
  1298. }
  1299. });
  1300. gbp.add({
  1301. component: panel2,
  1302. options:
  1303. {
  1304. gridx: 0,
  1305. gridy: 1
  1306. }
  1307. });
  1308. panel.setBorder(BorderFactory.createTitledBorder("実行"));
  1309. return panel;
  1310. }()),
  1311. options:
  1312. {
  1313. gridx: 1,
  1314. gridy: 3,
  1315. weightx: 1,
  1316. insets: new Insets(0, 10, 10, 10),
  1317. fill: GridBagConstraints.HORIZONTAL
  1318. }
  1319. });
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326. function setDefaultValues() {
  1327.  
  1328. var setComboBox = function (componentName, compValue) {
  1329. var combobox = components[componentName];
  1330. var check = components[componentName + "Check"];
  1331. for (var i = 0; i < combobox.getItemCount(); i++) {
  1332. var value = combobox.getItemAt(i);
  1333. if (compValue + "" === value + "") {
  1334. check.setSelected(true);
  1335. combobox.setSelectedIndex(i);
  1336. break;
  1337. }
  1338. }
  1339. }
  1340.  
  1341. var h = {};
  1342. var boardList = g.defaultValues.blist;
  1343. for (var i = 0; i < boardList.length; i++) {
  1344. h[boardList[i]] = true;
  1345. }
  1346.  
  1347. for (var i = components.boardsModel.items.size() - 1; i >= 0; i--) {
  1348. var modelItem = components.boardsModel.items.get(i);
  1349. var url = modelItem.value.url;
  1350. if (h[url]) {
  1351. components.boardsModel.remove(modelItem);
  1352. components.searchModel.add(modelItem);
  1353. }
  1354. }
  1355.  
  1356. components.searchSelectedThreadCheck.setSelected(g.defaultValues.set1);
  1357. components.searchViewThreadCheck.setSelected(g.defaultValues.set2);
  1358. components.searchSelectedThreadBoardCheck.setSelected(g.defaultValues.set3);
  1359. components.searchViewThreadBoardCheck.setSelected(g.defaultValues.set4);
  1360. components.replaceAnchorCheck.setSelected(g.defaultValues.repanc);
  1361.  
  1362. if (g.defaultValues.title !== null) {
  1363. components.searchTitleCheck.setSelected(true);
  1364. components.searchTitle.setText(g.defaultValues.title);
  1365. }
  1366. if (g.defaultValues.name !== null) {
  1367. components.searchNameCheck.setSelected(true);
  1368. components.searchName.setText(g.defaultValues.name);
  1369. }
  1370. if (g.defaultValues.mail !== null) {
  1371. components.searchMailCheck.setSelected(true);
  1372. components.searchMail.setText(g.defaultValues.mail);
  1373. }
  1374. if (g.defaultValues.id !== null) {
  1375. components.searchIDCheck.setSelected(true);
  1376. components.searchID.setText(g.defaultValues.id);
  1377. }
  1378. if (g.defaultValues.be !== null) {
  1379. components.searchBeIDCheck.setSelected(true);
  1380. components.searchBeID.setText(g.defaultValues.be);
  1381. }
  1382. if (g.defaultValues.message !== null) {
  1383. components.searchMessageCheck.setSelected(true);
  1384. components.searchMessage.setText(g.defaultValues.message);
  1385. }
  1386. if (g.defaultValues.label !== null) {
  1387. setComboBox("searchLabel", g.defaultValues.label);
  1388. }
  1389. if (g.defaultValues.lnum !== null) {
  1390. components.searchNumber1Check.setSelected(true);
  1391. components.searchNumber1.setValue(parseInt(g.defaultValues.lnum));
  1392. }
  1393. if (g.defaultValues.unum !== null) {
  1394. components.searchNumber2Check.setSelected(true);
  1395. components.searchNumber2.setValue(parseInt(g.defaultValues.unum));
  1396. }
  1397. if (g.defaultValues.lanc !== null) {
  1398. components.searchRefcount1Check.setSelected(true);
  1399. components.searchRefcount1.setValue(parseInt(g.defaultValues.lanc));
  1400. }
  1401. if (g.defaultValues.uanc !== null) {
  1402. components.searchRefcount2Check.setSelected(true);
  1403. components.searchRefcount2.setValue(parseInt(g.defaultValues.uanc));
  1404. }
  1405. if (g.defaultValues.lyear !== null) setComboBox("searchYear1" , g.defaultValues.lyear);
  1406. if (g.defaultValues.uyear !== null) setComboBox("searchYear2" , g.defaultValues.uyear);
  1407. if (g.defaultValues.lmonth !== null) setComboBox("searchMonth1" , g.defaultValues.lmonth);
  1408. if (g.defaultValues.umonth !== null) setComboBox("searchMonth2" , g.defaultValues.umonth);
  1409. if (g.defaultValues.ldate !== null) setComboBox("searchDate1" , g.defaultValues.ldate);
  1410. if (g.defaultValues.udate !== null) setComboBox("searchDate2" , g.defaultValues.udate);
  1411. if (g.defaultValues.lday !== null) setComboBox("searchDay1" , g.defaultValues.lday);
  1412. if (g.defaultValues.uday !== null) setComboBox("searchDay2" , g.defaultValues.uday);
  1413. if (g.defaultValues.lhours !== null) setComboBox("searchHours1" , g.defaultValues.lhours);
  1414. if (g.defaultValues.uhours !== null) setComboBox("searchHours2" , g.defaultValues.uhours);
  1415. if (g.defaultValues.lmin !== null) setComboBox("searchMinutes1" , g.defaultValues.lmin);
  1416. if (g.defaultValues.umin !== null) setComboBox("searchMinutes2" , g.defaultValues.umin);
  1417. }
  1418.  
  1419. function getArgsString() {
  1420. var args = "${SCRIPT:FrwT} " + APP_NAME + ".js args={";
  1421.  
  1422. var blist = [];
  1423. for (var i = components.searchModel.items.size() - 1; i >= 0; i--) {
  1424. var modelItem = components.searchModel.items.get(i);
  1425. blist.push('"' + modelItem.value.url + '"');
  1426. }
  1427.  
  1428. if (blist.toString() != "") args += "blist:[" + blist.toString() + "],";
  1429.  
  1430. if (components.searchSelectedThreadCheck.isSelected()) args += "set1:true,";
  1431. if (components.searchViewThreadCheck.isSelected()) args += "set2:true,";
  1432. if (components.searchSelectedThreadBoardCheck.isSelected()) args += "set3:true,";
  1433. if (components.searchViewThreadBoardCheck.isSelected()) args += "set4:true,";
  1434. if (components.replaceAnchorCheck.isSelected()) args += "repanc:true,";
  1435.  
  1436. if (components.searchTitleCheck.isSelected() ) args += "title:\"" + components.searchTitle.getText() + "\",";
  1437. if (components.searchNameCheck.isSelected() ) args += "name:\"" + components.searchName.getText() + "\",";
  1438. if (components.searchMailCheck.isSelected() ) args += "mail:\"" + components.searchMail.getText() + "\",";
  1439. if (components.searchIDCheck.isSelected() ) args += "id:\"" + components.searchID.getText() + "\",";
  1440. if (components.searchBeIDCheck.isSelected() ) args += "be:\"" + components.searchBeID.getText() + "\",";
  1441. if (components.searchMessageCheck.isSelected()) args += "message:\"" + components.searchMessage.getText() + "\",";
  1442. if (components.searchLabelCheck.isSelected() ) args += "label:\"" + components.searchLabel.getSelectedItem() + "\",";
  1443.  
  1444. if (components.searchNumber1Check.isSelected() ) args += "lnum:" + ~~components.searchNumber1.getValue() + ",";
  1445. if (components.searchNumber2Check.isSelected() ) args += "unum:" + ~~components.searchNumber2.getValue() + ",";
  1446. if (components.searchRefcount1Check.isSelected()) args += "lanc:" + ~~components.searchRefcount1.getValue() + ",";
  1447. if (components.searchRefcount2Check.isSelected()) args += "uanc:" + ~~components.searchRefcount2.getValue() + ",";
  1448.  
  1449. if (components.searchYear1Check.isSelected() ) args += "lyear:" + components.searchYear1.getSelectedItem() + ",";
  1450. if (components.searchMonth1Check.isSelected() ) args += "lmonth:" + components.searchMonth1.getSelectedItem() + ",";
  1451. if (components.searchDate1Check.isSelected() ) args += "ldate:" + components.searchDate1.getSelectedItem() + ",";
  1452. if (components.searchDay1Check.isSelected() ) args += "lday:\"" + components.searchDay1.getSelectedItem() + "\",";
  1453. if (components.searchHours1Check.isSelected() ) args += "lhours:" + components.searchHours1.getSelectedItem() + ",";
  1454. if (components.searchMinutes1Check.isSelected()) args += "lmin:" + components.searchMinutes1.getSelectedItem() + ",";
  1455.  
  1456. if (components.searchYear2Check.isSelected() ) args += "uyear:" + components.searchYear2.getSelectedItem() + ",";
  1457. if (components.searchMonth2Check.isSelected() ) args += "umonth:" + components.searchMonth2.getSelectedItem() + ",";
  1458. if (components.searchDate2Check.isSelected() ) args += "udate:" + components.searchDate2.getSelectedItem() + ",";
  1459. if (components.searchDay2Check.isSelected() ) args += "uday:\"" + components.searchDay2.getSelectedItem() + "\",";
  1460. if (components.searchHours2Check.isSelected() ) args += "uhours:" + components.searchHours2.getSelectedItem() + ",";
  1461. if (components.searchMinutes2Check.isSelected()) args += "umin:" + components.searchMinutes2.getSelectedItem() + ",";
  1462.  
  1463. args = args.replace(/,$/, "}");
  1464.  
  1465. return args;
  1466. }
  1467.  
  1468. window.show();
  1469. components.searchModel.clear();
  1470. setDefaultValues();
  1471.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty