AIRNovel 二軍タグ リファレンス

はじめに

  • 「二軍タグ」とはAIRNovel本体に入れるほどではない、しかしプラグインでは(セキュリティーポリシーなどの理由で)実現できないタグ機能の事です。
  • 利用したい場合は SDK/an_sdk/../addition_script.as に追加しコンパイルして下さい。
  • ここに公開したActionScriptソースは全てMIT Licenseです。自由に改変してご活用ください。
  • その他はタグリファレンスの「はじめに」と同様です。
[let_json_decode] json分解取得 json文字列から値を取得し、変数に代入する。
成否は変数const.an.let_json_decode.successにセットされる。成功した場合はtrue。
属性必須省略時値域・型コメント
nameyString(変数名書式)変数名
jsonyStringjson文字列
pathyString jsonツリー構造上の参照する値へのパス。「.」(ピリオド)で区切る。

addition_script.asに追加するソース(必ずUTF-8で保存、コメント行は省略)
// json分解取得
hTag.let_json_decode = function(hArg:Object):Boolean {
	const name:String = hArg.name;
	if (! name) throw("[let_json_decode] nameは必須です");
	const json:String = hArg.json;
	if (! json) throw("[let_json_decode] jsonは必須です");
	const path:String = hArg.path;
	if (! path) throw("[let_json_decode] pathは必須です");

	hTmp["const.an.let_json_decode.success"] = false;
	try {
		var o:Object = CmnLib.parseJson(json);

		const vctPath:Vector.<String> = Vector.<String>(path.split("."));
		const len:uint = vctPath.length;
		for (var i:uint=0; i<len; ++i) {
			o = o[vctPath[i]];
		}

		setVal(name, o.toString());
		hTmp["const.an.let_json_decode.success"] = true;
	}
	catch (e:Error) {
		traceDbg("[let_json_decode]例外 mes="+ e.message +"("+ e.name +")");
	}
	catch (mes:String) {
		traceDbg(mes);
	}

	return false;
};
[let_webapi] webapi取得 指定URLのHTTPサービスから文字列を取得し、変数に代入する。
成否は変数const.an.let_webapi.successにセットされる。成功した場合はtrue。
エラー時は変数const.an.let_webapi.errにエラーメッセージをセットする。
属性必須省略時値域・型コメント
nameyString(変数名書式)変数名
urlyString(URL)セットする値を返すネット上のURL

addition_script.asに追加するソース(必ずUTF-8で保存、コメント行は省略)
// webapi取得
hTag.let_webapi = function(hArg:Object):Boolean {
	const name:String = hArg.name;
	if (! name) throw("[let_webapi] nameは必須です");
	const url:String = hArg.url;
	if (! url) throw("[let_webapi] urlは必須です");

	hTmp["const.an.let_webapi.success"] = false;
	const ldMng:LoadMng = new LoadMng();
	ldMng.getURLLoader(
		url
	,	function (ldr:URLLoader):void {
			setVal(name, ldr.data.toString());
			hTmp["const.an.let_webapi.success"] = true;
		}
	,	function (e:Event):Boolean {
			hTmp["const.an.let_webapi.err"] = e.toString();
			traceDbg("[let_webapi] IO_ERROR["+ e.toString() +"]");

			return true;	// throwせず続行
		}
	);
	error(IOError, err_let_webapi);
	error(SecurityError, err_let_webapi);
	ldMng.join();
	ldMng.start();

	return true;
};
	function err_let_webapi(e:Error, t:Thread):void {
		trace('読み込みエラーが発生しました');
	}
[set_clipboard] クリップボード設定 文字列をクリップボードに入れる。
属性必須省略時値域・型コメント
textnそのページの本文Stringクリップボードに入れる文字列

addition_script.asに追加するソース(必ずUTF-8で保存、コメント行は省略)
// set_clipboardクリップボードへ設定
hTag.set_clipboard = function(hArg:Object):Boolean {
	var text:String = hArg.text;
	if (! text) {
		text = (hTmp["const.an.last_page_text"] as Function)();
	}
	text = text.replace(/(|.+?)?《.+?》|\n+/g, "");

	import flash.desktop.Clipboard;
	import flash.desktop.ClipboardFormats;

	Clipboard.generalClipboard.clear();
	Clipboard.generalClipboard.setData(
		ClipboardFormats.TEXT_FORMAT
	,	text
	);

	return false;
};
inserted by FC2 system