code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is itstructures.com code. * * The Initial Developer of the Original Code is IT Structures. * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #pragma once #include <map> #include <vector> #include <atlbase.h> #include <comdef.h> #include <npapi.h> #include <npfunctions.h> #include <npruntime.h> #include "variants.h" extern NPNetscapeFuncs NPNFuncs; extern NPClass GenericNPObjectClass; typedef bool (*DefaultInvoker)(void *object, const NPVariant *args, uint32_t argCount, NPVariant *result); struct ltnum { bool operator()(long n1, long n2) const { return n1 < n2; } }; struct ltstr { bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; } }; bool toString(void *object, const NPVariant *args, uint32_t argCount, NPVariant *result); class GenericNPObject: public NPObject { private: GenericNPObject(const GenericNPObject &); bool invalid; DefaultInvoker defInvoker; void *defInvokerObject; std::vector<NPVariant> numeric_mapper; // the members of alpha mapper can be reassigned to anything the user wishes std::map<const char *, NPVariant, ltstr> alpha_mapper; // these cannot accept other types than they are initially defined with std::map<const char *, NPVariant, ltstr> immutables; public: friend bool toString(void *, const NPVariant *, uint32_t, NPVariant *); GenericNPObject(NPP instance); GenericNPObject(NPP instance, bool isMethodObj); ~GenericNPObject(); void Invalidate() {invalid = true;} void SetDefaultInvoker(DefaultInvoker di, void *context) { defInvoker = di; defInvokerObject = context; } static bool _HasMethod(NPObject *npobj, NPIdentifier name) { return ((GenericNPObject *)npobj)->HasMethod(name); } static bool _Invoke(NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result) { return ((GenericNPObject *)npobj)->Invoke(methodName, args, argCount, result); } static bool _InvokeDefault(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { if (((GenericNPObject *)npobj)->defInvoker) { return (((GenericNPObject *)npobj)->InvokeDefault)(args, argCount, result); } else { return false; } } static bool _HasProperty(NPObject *npobj, NPIdentifier name) { return ((GenericNPObject *)npobj)->HasProperty(name); } static bool _GetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result) { return ((GenericNPObject *)npobj)->GetProperty(name, result); } static bool _SetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value) { return ((GenericNPObject *)npobj)->SetProperty(name, value); } static bool _RemoveProperty(NPObject *npobj, NPIdentifier name) { return ((GenericNPObject *)npobj)->RemoveProperty(name); } static bool _Enumerate(NPObject *npobj, NPIdentifier **identifiers, uint32_t *identifierCount) { return ((GenericNPObject *)npobj)->Enumerate(identifiers, identifierCount); } bool HasMethod(NPIdentifier name); bool Invoke(NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); bool InvokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result); bool HasProperty(NPIdentifier name); bool GetProperty(NPIdentifier name, NPVariant *result); bool SetProperty(NPIdentifier name, const NPVariant *value); bool RemoveProperty(NPIdentifier name); bool Enumerate(NPIdentifier **identifiers, uint32_t *identifierCount); };
007slmg-np-activex-justep
ffactivex/GenericNPObject.h
C++
mpl11
5,100
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor: * Chuan Qiu <qiuc12@gmail.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "atlthunk.h" #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <stdio.h> #include "ApiHook\Hook.h" typedef struct tagEXCEPTION_REGISTER { tagEXCEPTION_REGISTER *prev; _except_handler_type handler; }EXCEPTION_REGISTER, *LPEXCEPTION_REGISTER; /* Supported patterns: C7 44 24 04 XX XX XX XX mov [esp+4], imm32 E9 YY YY YY YY jmp imm32 B9 XX XX XX XX mov ecx, imm32 E9 YY YY YY YY jmp imm32 BA XX XX XX XX mov edx, imm32 B9 YY YY YY YY mov ecx, imm32 FF E1 jmp ecx B9 XX XX XX XX mov ecx, imm32 B8 YY YY YY YY mov eax, imm32 FF E0 jmp eax 59 pop ecx 58 pop eax 51 push ecx FF 60 04 jmp [eax+4] */ /* Pattern 1: C7 44 24 04 XX XX XX XX mov [esp+4], imm32 E9 YY YY YY YY jmp imm32 */ BYTE pattern1[] = {0xC7, 0x44, 0x24, 0x04, 0, 0, 0, 0, 0xE9, 0, 0, 0, 0}; void _process_pattern1(struct _CONTEXT *ContextRecord) { LPDWORD esp = (LPDWORD)(ContextRecord->Esp); DWORD imm1 = *(LPDWORD)(ContextRecord->Eip + 4); DWORD imm2 = *(LPDWORD)(ContextRecord->Eip + 9); esp[1] = imm1; ContextRecord->Eip += imm2 + 13; } /* Pattern 2: B9 XX XX XX XX mov ecx, imm32 E9 YY YY YY YY jmp imm32 */ BYTE pattern2[] = {0xB9, 0, 0, 0, 0, 0xE9, 0, 0, 0, 0}; void _process_pattern2(struct _CONTEXT *ContextRecord) { DWORD imm1 = *(LPDWORD)(ContextRecord->Eip + 1); DWORD imm2 = *(LPDWORD)(ContextRecord->Eip + 6); ContextRecord->Ecx = imm1; ContextRecord->Eip += imm2 + 10; } /* Pattern 3: BA XX XX XX XX mov edx, imm32 B9 YY YY YY YY mov ecx, imm32 FF E1 jmp ecx */ BYTE pattern3[] = {0xBA, 0, 0, 0, 0, 0xB9, 0, 0, 0, 0, 0xFF, 0xE1}; void _process_pattern3(struct _CONTEXT *ContextRecord) { DWORD imm1 = *(LPDWORD)(ContextRecord->Eip + 1); DWORD imm2 = *(LPDWORD)(ContextRecord->Eip + 6); ContextRecord->Edx = imm1; ContextRecord->Ecx = imm2; ContextRecord->Eip += imm2; } /* B9 XX XX XX XX mov ecx, imm32 B8 YY YY YY YY mov eax, imm32 FF E0 jmp eax */ BYTE pattern4[] = {0xB9, 0, 0, 0, 0, 0xB8, 0, 0, 0, 0, 0xFF, 0xE0}; void _process_pattern4(struct _CONTEXT *ContextRecord) { DWORD imm1 = *(LPDWORD)(ContextRecord->Eip + 1); DWORD imm2 = *(LPDWORD)(ContextRecord->Eip + 6); ContextRecord->Ecx = imm1; ContextRecord->Eax = imm2; ContextRecord->Eip += imm2; } /* 59 pop ecx 58 pop eax 51 push ecx FF 60 04 jmp [eax+4] */ BYTE pattern5[] = {0x59, 0x58, 0x51, 0xFF, 0x60, 0x04}; void _process_pattern5(struct _CONTEXT *ContextRecord) { LPDWORD stack = (LPDWORD)(ContextRecord->Esp); ContextRecord->Ecx = stack[0]; ContextRecord->Eax = stack[1]; stack[1] = stack[0]; ContextRecord->Esp += 4; ContextRecord->Eip = *(LPDWORD)(ContextRecord->Eax + 4); } ATL_THUNK_PATTERN patterns[] = { {pattern1, sizeof(pattern1), _process_pattern1}, {pattern2, sizeof(pattern2), _process_pattern2}, {pattern3, sizeof(pattern3), _process_pattern3}, {pattern4, sizeof(pattern4), _process_pattern4}, {pattern5, sizeof(pattern5), _process_pattern5} }; ATL_THUNK_PATTERN *match_patterns(LPVOID eip) { LPBYTE codes = (LPBYTE)eip; for (int i = 0; i < sizeof(patterns) / sizeof(patterns[0]); ++i) { BOOL match = TRUE; for (int j = 0; j < patterns[i].pattern_size && match; ++j) { if (patterns[i].pattern[j] != 0 && patterns[i].pattern[j] != codes[j]) match = FALSE; } if (match) { return &patterns[i]; } } return NULL; } EXCEPTION_DISPOSITION __cdecl _except_handler_atl_thunk( struct _EXCEPTION_RECORD *ExceptionRecord, void * EstablisherFrame, struct _CONTEXT *ContextRecord, void * DispatcherContext ) { if ((ExceptionRecord->ExceptionFlags) || ExceptionRecord->ExceptionCode != STATUS_ACCESS_VIOLATION || ExceptionRecord->ExceptionAddress != (LPVOID)ContextRecord->Eip) { // Not expected Access violation exception return ExceptionContinueSearch; } // Try to match patterns ATL_THUNK_PATTERN *pattern = match_patterns((LPVOID)ContextRecord->Eip); if (pattern) { //DWORD old; // We can't always protect the ATL by except_handler, so we mark it executable. //BOOL ret = VirtualProtect((LPVOID)ContextRecord->Eip, pattern->pattern_size, PAGE_EXECUTE_READWRITE, &old); pattern->enumerator(ContextRecord); return ExceptionContinueExecution; } else { return ExceptionContinueSearch; } } #ifndef ATL_THUNK_APIHOOK _except_handler_type original_handler4; #else HOOKINFO hook_handler; #endif #if 0 EXCEPTION_DISPOSITION __cdecl my_except_handler4( struct _EXCEPTION_RECORD *ExceptionRecord, void * EstablisherFrame, struct _CONTEXT *ContextRecord, void * DispatcherContext ) { //assert(original_handler); EXCEPTION_DISPOSITION step1 = _except_handler_atl_thunk(ExceptionRecord, EstablisherFrame, ContextRecord, DispatcherContext); if (step1 == ExceptionContinueExecution) return step1; #ifndef ATL_THUNK_APIHOOK _except_handler_type original_handler = original_handler4; #else _except_handler_type original_handler = (_except_handler_type)hook_handler4.Stub; #endif return original_handler(ExceptionRecord, EstablisherFrame, ContextRecord, DispatcherContext); } EXCEPTION_DISPOSITION __cdecl my_except_handler3( struct _EXCEPTION_RECORD *ExceptionRecord, void * EstablisherFrame, struct _CONTEXT *ContextRecord, void * DispatcherContext ) { //assert(original_handler); EXCEPTION_DISPOSITION step1 = _except_handler_atl_thunk(ExceptionRecord, EstablisherFrame, ContextRecord, DispatcherContext); if (step1 == ExceptionContinueExecution) return step1; #ifndef ATL_THUNK_APIHOOK // We won't wrap handler3, this shouldn't be used.. _except_handler_type original_handler = original_handler3; #else _except_handler_type original_handler = (_except_handler_type)hook_handler4.Stub; #endif return original_handler(ExceptionRecord, EstablisherFrame, ContextRecord, DispatcherContext); } #endif BOOL CheckDEPEnabled() { // In case of running in a XP SP2. HMODULE hInst = LoadLibrary(TEXT("Kernel32.dll")); typedef BOOL (WINAPI *SetProcessDEPPolicyType)( __in DWORD dwFlags ); typedef BOOL (WINAPI *GetProcessDEPPolicyType)( __in HANDLE hProcess, __out LPDWORD lpFlags, __out PBOOL lpPermanent ); SetProcessDEPPolicyType setProc = (SetProcessDEPPolicyType)GetProcAddress(hInst, "SetProcessDEPPolicy"); GetProcessDEPPolicyType getProc = (GetProcessDEPPolicyType)GetProcAddress(hInst, "GetProcessDEPPolicy"); if (setProc) { // This is likely to fail, but we set it first. setProc(PROCESS_DEP_ENABLE); } BOOL enabled = FALSE; DWORD lpFlags; BOOL lpPermanent; if (getProc && getProc(GetCurrentProcess(), &lpFlags, &lpPermanent)) { enabled = (lpFlags == (PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION | PROCESS_DEP_ENABLE)); } return enabled; } extern "C" void _KiUserExceptionDispatcher_hook(); extern "C" DWORD _KiUserExceptionDispatcher_origin; extern "C" DWORD _KiUserExceptionDispatcher_ATL_p; typedef void (__stdcall *ZwContinueType)(struct _CONTEXT *, int); ZwContinueType ZwContinue; int __cdecl _KiUserExceptionDispatcher_ATL( struct _EXCEPTION_RECORD *ExceptionRecord, struct _CONTEXT *ContextRecord) { if (_except_handler_atl_thunk(ExceptionRecord, NULL, ContextRecord, NULL) == ExceptionContinueExecution) { ZwContinue(ContextRecord, 0); } return 0; } bool atlThunkInstalled = false; void InstallAtlThunkEnumeration() { if (atlThunkInstalled) return; if (CheckDEPEnabled()) { #ifndef ATL_THUNK_APIHOOK // Chrome is protected by DEP. EXCEPTION_REGISTER *reg; __asm { mov eax, fs:[0] mov reg, eax } while ((DWORD)reg->prev != 0xFFFFFFFF) reg = reg->prev; // replace the old handler original_handler = reg->handler; reg->handler = _except_handler; #else _KiUserExceptionDispatcher_ATL_p = (DWORD)_KiUserExceptionDispatcher_ATL; ZwContinue = (ZwContinueType) GetProcAddress(GetModuleHandle(TEXT("ntdll")), "ZwContinue"); HEInitHook(&hook_handler, GetProcAddress(GetModuleHandle(TEXT("ntdll")), "KiUserExceptionDispatcher") , _KiUserExceptionDispatcher_hook); HEStartHook(&hook_handler); _KiUserExceptionDispatcher_origin = (DWORD)hook_handler.Stub; atlThunkInstalled = true; #endif } } void UninstallAtlThunkEnumeration() { #ifdef ATL_THUNK_APIHOOK if (!atlThunkInstalled) return; HEStopHook(&hook_handler); atlThunkInstalled = false; #endif }
007slmg-np-activex-justep
ffactivex/AtlThunk.cpp
C++
mpl11
10,401
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor: * Chuan Qiu <qiuc12@gmail.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "HTMLDocumentContainer.h" #include "npactivex.h" #include <MsHTML.h> const GUID HTMLDocumentContainer::IID_TopLevelBrowser = {0x4C96BE40, 0x915C, 0x11CF, {0x99, 0xD3, 0x00, 0xAA, 0x00, 0x4A, 0xE8, 0x37}}; HTMLDocumentContainer::HTMLDocumentContainer() : dispatcher(NULL) { } void HTMLDocumentContainer::Init(NPP instance, ITypeLib *htmlLib) { NPObjectProxy npWindow; NPNFuncs.getvalue(instance, NPNVWindowNPObject, &npWindow); NPVariantProxy documentVariant; if (NPNFuncs.getproperty(instance, npWindow, NPNFuncs.getstringidentifier("document"), &documentVariant) && NPVARIANT_IS_OBJECT(documentVariant)) { NPObject *npDocument = NPVARIANT_TO_OBJECT(documentVariant); dispatcher = new FakeDispatcher(instance, htmlLib, npDocument); } npp = instance; } HRESULT HTMLDocumentContainer::get_LocationURL(BSTR *str) { NPObjectProxy npWindow; NPNFuncs.getvalue(npp, NPNVWindowNPObject, &npWindow); NPVariantProxy LocationVariant; if (!NPNFuncs.getproperty(npp, npWindow, NPNFuncs.getstringidentifier("location"), &LocationVariant) || !NPVARIANT_IS_OBJECT(LocationVariant)) { return E_FAIL; } NPObject *npLocation = NPVARIANT_TO_OBJECT(LocationVariant); NPVariantProxy npStr; if (!NPNFuncs.getproperty(npp, npLocation, NPNFuncs.getstringidentifier("href"), &npStr)) return E_FAIL; CComBSTR bstr(npStr.value.stringValue.UTF8Length, npStr.value.stringValue.UTF8Characters); *str = bstr.Detach(); return S_OK; } HRESULT STDMETHODCALLTYPE HTMLDocumentContainer::get_Document( __RPC__deref_out_opt IDispatch **ppDisp) { if (dispatcher) return dispatcher->QueryInterface(DIID_DispHTMLDocument, (LPVOID*)ppDisp); return E_FAIL; } HTMLDocumentContainer::~HTMLDocumentContainer(void) { }
007slmg-np-activex-justep
ffactivex/HTMLDocumentContainer.cpp
C++
mpl11
3,293
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is itstructures.com code. * * The Initial Developer of the Original Code is IT Structures. * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit #include <atlbase.h> #include <atlstr.h> // TODO: reference additional headers your program requires here
007slmg-np-activex-justep
ffactivex/stdafx.h
C
mpl11
2,250
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor: * Chuan Qiu <qiuc12@gmail.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "NPSafeArray.h" #include "npactivex.h" #include "objectProxy.h" #include <OleAuto.h> NPClass NPSafeArray::npClass = { /* version */ NP_CLASS_STRUCT_VERSION, /* allocate */ NPSafeArray::Allocate, /* deallocate */ NPSafeArray::Deallocate, /* invalidate */ NPSafeArray::Invalidate, /* hasMethod */ NPSafeArray::HasMethod, /* invoke */ NPSafeArray::Invoke, /* invokeDefault */ NPSafeArray::InvokeDefault, /* hasProperty */ NPSafeArray::HasProperty, /* getProperty */ NPSafeArray::GetProperty, /* setProperty */ NPSafeArray::SetProperty, /* removeProperty */ NULL, /* enumerate */ NULL, /* construct */ NPSafeArray::InvokeDefault }; NPSafeArray::NPSafeArray(NPP npp): ScriptBase(npp) { NPNFuncs.getvalue(npp, NPNVWindowNPObject, &window); } NPSafeArray::~NPSafeArray(void) { } // Some wrappers to adapt NPAPI's interface. NPObject* NPSafeArray::Allocate(NPP npp, NPClass *aClass) { return new NPSafeArray(npp); } void NPSafeArray::Deallocate(NPObject *obj){ delete static_cast<NPSafeArray*>(obj); } LPSAFEARRAY NPSafeArray::GetArrayPtr() { return arr_.m_psa; } NPInvokeDefaultFunctionPtr NPSafeArray::GetFuncPtr(NPIdentifier name) { if (name == NPNFuncs.getstringidentifier("getItem")) { return NPSafeArray::GetItem; } else if (name == NPNFuncs.getstringidentifier("toArray")) { return NPSafeArray::ToArray; } else if (name == NPNFuncs.getstringidentifier("lbound")) { return NPSafeArray::LBound; } else if (name == NPNFuncs.getstringidentifier("ubound")) { return NPSafeArray::UBound; } else if (name == NPNFuncs.getstringidentifier("dimensions")) { return NPSafeArray::Dimensions; } else { return NULL; } } void NPSafeArray::Invalidate(NPObject *obj) { NPSafeArray *safe = static_cast<NPSafeArray*>(obj); safe->arr_.Destroy(); } bool NPSafeArray::HasMethod(NPObject *npobj, NPIdentifier name) { return GetFuncPtr(name) != NULL; } void NPSafeArray::RegisterVBArray(NPP npp) { NPObjectProxy window; NPNFuncs.getvalue(npp, NPNVWindowNPObject, &window); NPIdentifier vbarray = NPNFuncs.getstringidentifier("VBArray"); if (!NPNFuncs.hasproperty(npp, window, vbarray)) { NPVariantProxy var; NPObject *def = NPNFuncs.createobject(npp, &npClass); OBJECT_TO_NPVARIANT(def, var); NPNFuncs.setproperty(npp, window, vbarray, &var); } } NPSafeArray *NPSafeArray::CreateFromArray(NPP instance, SAFEARRAY *array) { NPSafeArray *ret = (NPSafeArray *)NPNFuncs.createobject(instance, &npClass); ret->arr_.Attach(array); return ret; } bool NPSafeArray::Invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { NPSafeArray *safe = static_cast<NPSafeArray*>(npobj); if (safe->arr_.m_psa == NULL) return false; NPInvokeDefaultFunctionPtr ptr = GetFuncPtr(name); if (ptr) { return ptr(npobj, args, argCount, result); } else { return false; } } bool NPSafeArray::InvokeDefault(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { NPSafeArray *safe = static_cast<NPSafeArray*>(npobj); if (safe->arr_.m_psa != NULL) return false; if (argCount < 1) return false; if (!NPVARIANT_IS_OBJECT(*args)) { return false; } NPObject *obj = NPVARIANT_TO_OBJECT(*args); if (obj->_class != &NPSafeArray::npClass) { return false; } NPSafeArray *safe_original = static_cast<NPSafeArray*>(obj); if (safe_original->arr_.m_psa == NULL) { return false; } NPSafeArray *ret = CreateFromArray(safe->instance, safe_original->arr_); OBJECT_TO_NPVARIANT(ret, *result); return true; } bool NPSafeArray::GetItem(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { NPSafeArray *safe = static_cast<NPSafeArray*>(npobj); if (safe->arr_.m_psa == NULL) return false; LONG dim = safe->arr_.GetDimensions(); if (argCount < safe->arr_.GetDimensions()) { return false; } CAutoVectorPtr<LONG>pos(new LONG[dim]); for (int i = 0; i < dim; ++i) { if (NPVARIANT_IS_DOUBLE(args[i])) { pos[i] = (LONG)NPVARIANT_TO_DOUBLE(args[i]); } else if (NPVARIANT_IS_INT32(args[i])) { pos[i] = NPVARIANT_TO_INT32(args[i]); } else { return false; } } VARIANT var; if (!SUCCEEDED(safe->arr_.MultiDimGetAt(pos, var))) { return false; } Variant2NPVar(&var, result, safe->instance); return true; } bool NPSafeArray::Dimensions(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { NPSafeArray *safe = static_cast<NPSafeArray*>(npobj); if (safe->arr_.m_psa == NULL) return false; INT32_TO_NPVARIANT(safe->arr_.GetDimensions(), *result); return true; } bool NPSafeArray::UBound(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { NPSafeArray *safe = static_cast<NPSafeArray*>(npobj); if (safe->arr_.m_psa == NULL) return false; int dim = 1; if (argCount >= 1) { if (NPVARIANT_IS_INT32(*args)) { dim = NPVARIANT_TO_INT32(*args); } else if (NPVARIANT_IS_DOUBLE(*args)) { dim = (LONG)NPVARIANT_TO_DOUBLE(*args); } else { return false; } } try{ INT32_TO_NPVARIANT(safe->arr_.GetUpperBound(dim - 1), *result); } catch (...) { return false; } return true; } bool NPSafeArray::LBound(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { NPSafeArray *safe = static_cast<NPSafeArray*>(npobj); if (safe->arr_.m_psa == NULL) return false; int dim = 1; if (argCount >= 1) { if (NPVARIANT_IS_INT32(*args)) { dim = NPVARIANT_TO_INT32(*args); } else if (NPVARIANT_IS_DOUBLE(*args)) { dim = (LONG)NPVARIANT_TO_DOUBLE(*args); } else { return false; } } try{ INT32_TO_NPVARIANT(safe->arr_.GetLowerBound(dim - 1), *result); } catch (...) { return false; } return true; } bool NPSafeArray::ToArray(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { NPSafeArray *safe = static_cast<NPSafeArray*>(npobj); if (safe->arr_.m_psa == NULL) return false; long count = 1, dim = safe->arr_.GetDimensions(); for (int d = 0; d < dim; ++d) { count *= safe->arr_.GetCount(d); } NPString command = {"[]", 2}; if (!NPNFuncs.evaluate(safe->instance, safe->window, &command, result)) return false; VARIANT* vars = (VARIANT*)safe->arr_.m_psa->pvData; NPIdentifier push = NPNFuncs.getstringidentifier("push"); for (long i = 0; i < count; ++i) { NPVariantProxy v; NPVariant arg; Variant2NPVar(&vars[i], &arg, safe->instance); if (!NPNFuncs.invoke(safe->instance, NPVARIANT_TO_OBJECT(*result), push, &arg, 1, &v)) { return false; } } return true; } bool NPSafeArray::HasProperty(NPObject *npobj, NPIdentifier name) { return false; } bool NPSafeArray::GetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result) { return false; } bool NPSafeArray::SetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value) { return false; }
007slmg-np-activex-justep
ffactivex/NPSafeArray.cpp
C++
mpl11
8,634
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is RSJ Software GmbH code. * * The Initial Developer of the Original Code is * RSJ Software GmbH. * Portions created by the Initial Developer are Copyright (C) 2009 * the Initial Developer. All Rights Reserved. * * Contributors: * Ruediger Jungbeck <ruediger.jungbeck@rsj.de> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ // This function is totally disabled now. #if 0 #include <stdio.h> #include <windows.h> #include <winreg.h> #include "npactivex.h" #include "atlutil.h" #include "authorize.h" // ---------------------------------------------------------------------------- #define SUB_KEY L"SOFTWARE\\MozillaPlugins\\@itstructures.com/npactivex\\MimeTypes\\application/x-itst-activex" // ---------------------------------------------------------------------------- BOOL TestExplicitAuthorizationUTF8 (const char *MimeType, const char *AuthorizationType, const char *DocumentUrl, const char *ProgramId); BOOL TestExplicitAuthorization (const wchar_t *MimeType, const wchar_t *AuthorizationType, const wchar_t *DocumentUrl, const wchar_t *ProgramId); BOOL WildcardMatch (const wchar_t *Mask, const wchar_t *Value); HKEY FindKey (const wchar_t *MimeType, const wchar_t *AuthorizationType); // --------------------------------------------------------------------------- HKEY BaseKeys[] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }; // ---------------------------------------------------------------------------- BOOL TestAuthorization (NPP Instance, int16 ArgC, char *ArgN[], char *ArgV[], const char *MimeType) { BOOL ret = FALSE; NPObject *globalObj = NULL; NPIdentifier identifier; NPVariant varLocation; NPVariant varHref; bool rc = false; int16 i; char *wrkHref; #ifdef NDEF _asm{int 3}; #endif if (Instance == NULL) { return (FALSE); } // Determine owning document // Get the window object. NPNFuncs.getvalue(Instance, NPNVWindowNPObject, &globalObj); // Create a "location" identifier. identifier = NPNFuncs.getstringidentifier("location"); // Get the location property from the window object (which is another object). rc = NPNFuncs.getproperty(Instance, globalObj, identifier, &varLocation); NPNFuncs.releaseobject(globalObj); if (!rc){ np_log(Instance, 0, "AxHost.TestAuthorization: could not get the location from the global object"); return false; } // Get a pointer to the "location" object. NPObject *locationObj = varLocation.value.objectValue; // Create a "href" identifier. identifier = NPNFuncs.getstringidentifier("href"); // Get the location property from the location object. rc = NPNFuncs.getproperty(Instance, locationObj, identifier, &varHref); NPNFuncs.releasevariantvalue(&varLocation); if (!rc) { np_log(Instance, 0, "AxHost.TestAuthorization: could not get the href from the location property"); return false; } ret = TRUE; wrkHref = (char *) alloca(varHref.value.stringValue.UTF8Length + 1); memcpy(wrkHref, varHref.value.stringValue.UTF8Characters, varHref.value.stringValue.UTF8Length); wrkHref[varHref.value.stringValue.UTF8Length] = 0x00; NPNFuncs.releasevariantvalue(&varHref); for (i = 0; i < ArgC; ++i) { // search for any needed information: clsid, event handling directives, etc. if (0 == strnicmp(ArgN[i], PARAM_CLSID, strlen(PARAM_CLSID))) { ret &= TestExplicitAuthorizationUTF8(MimeType, PARAM_CLSID, wrkHref, ArgV[i]); } else if (0 == strnicmp(ArgN[i], PARAM_PROGID, strlen(PARAM_PROGID))) { // The class id of the control we are asked to load ret &= TestExplicitAuthorizationUTF8(MimeType, PARAM_PROGID, wrkHref, ArgV[i]); } else if( 0 == strnicmp(ArgN[i], PARAM_CODEBASEURL, strlen(PARAM_CODEBASEURL))) { ret &= TestExplicitAuthorizationUTF8(MimeType, PARAM_CODEBASEURL, wrkHref, ArgV[i]); } } np_log(Instance, 1, "AxHost.TestAuthorization: returning %s", ret ? "True" : "False"); return (ret); } // ---------------------------------------------------------------------------- BOOL TestExplicitAuthorizationUTF8 (const char *MimeType, const char *AuthorizationType, const char *DocumentUrl, const char *ProgramId) { USES_CONVERSION; BOOL ret; ret = TestExplicitAuthorization(A2W(MimeType), A2W(AuthorizationType), A2W(DocumentUrl), A2W(ProgramId)); return (ret); } // ---------------------------------------------------------------------------- BOOL TestExplicitAuthorization (const wchar_t *MimeType, const wchar_t *AuthorizationType, const wchar_t *DocumentUrl, const wchar_t *ProgramId) { BOOL ret = FALSE; #ifndef NO_REGISTRY_AUTHORIZE HKEY hKey; HKEY hSubKey; ULONG i; ULONG j; ULONG keyNameLen; ULONG valueNameLen; wchar_t keyName[_MAX_PATH]; wchar_t valueName[_MAX_PATH]; if (DocumentUrl == NULL) { return (FALSE); } if (ProgramId == NULL) { return (FALSE); } #ifdef NDEF MessageBox(NULL, DocumentUrl, ProgramId, MB_OK); #endif if ((hKey = FindKey(MimeType, AuthorizationType)) != NULL) { for (i = 0; !ret; i++) { keyNameLen = sizeof(keyName); if (RegEnumKey(hKey, i, keyName, keyNameLen) == ERROR_SUCCESS) { if (WildcardMatch(keyName, DocumentUrl)) { if (RegOpenKeyEx(hKey, keyName, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) { for (j = 0; ; j++) { valueNameLen = sizeof(valueName); if (RegEnumValue(hSubKey, j, valueName, &valueNameLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) { break; } if (WildcardMatch(valueName, ProgramId)) { ret = TRUE; break; } } RegCloseKey(hSubKey); } if (ret) { break; } } } else { break; } } RegCloseKey(hKey); } #endif return (ret); } // ---------------------------------------------------------------------------- BOOL WildcardMatch (const wchar_t *Mask, const wchar_t *Value) { size_t i; size_t j = 0; size_t maskLen; size_t valueLen; maskLen = wcslen(Mask); valueLen = wcslen(Value); for (i = 0; i < maskLen + 1; i++) { if (Mask[i] == '?') { j++; continue; } if (Mask[i] == '*') { for (; j < valueLen + 1; j++) { if (WildcardMatch(Mask + i + 1, Value + j)) { return (TRUE); } } return (FALSE); } if ((j <= valueLen) && (Mask[i] == tolower(Value[j]))) { j++; continue; } return (FALSE); } return (TRUE); } // ---------------------------------------------------------------------------- HKEY FindKey (const wchar_t *MimeType, const wchar_t *AuthorizationType) { HKEY ret = NULL; HKEY plugins; wchar_t searchKey[_MAX_PATH]; wchar_t pluginName[_MAX_PATH]; DWORD j; size_t i; for (i = 0; i < ARRAYSIZE(BaseKeys); i++) { if (RegOpenKeyEx(BaseKeys[i], L"SOFTWARE\\MozillaPlugins", 0, KEY_ENUMERATE_SUB_KEYS, &plugins) == ERROR_SUCCESS) { for (j = 0; ret == NULL; j++) { if (RegEnumKey(plugins, j, pluginName, sizeof(pluginName)) != ERROR_SUCCESS) { break; } wsprintf(searchKey, L"%s\\MimeTypes\\%s\\%s", pluginName, MimeType, AuthorizationType); if (RegOpenKeyEx(plugins, searchKey, 0, KEY_ENUMERATE_SUB_KEYS, &ret) == ERROR_SUCCESS) { break; } ret = NULL; } RegCloseKey(plugins); if (ret != NULL) { break; } } } return (ret); } #endif
007slmg-np-activex-justep
ffactivex/authorize.cpp
C++
mpl11
10,040
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is itstructures.com code. * * The Initial Developer of the Original Code is IT Structures. * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Contributor: * Ruediger Jungbeck <ruediger.jungbeck@rsj.de> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include <atlbase.h> #include <atlsafe.h> #include <npapi.h> #include <npfunctions.h> #include "FakeDispatcher.h" #include <npruntime.h> #include "scriptable.h" #include "GenericNPObject.h" #include <OleAuto.h> #include "variants.h" #include "NPSafeArray.h" void BSTR2NPVar(BSTR bstr, NPVariant *npvar, NPP instance) { char *npStr = NULL; size_t sourceLen; size_t bytesNeeded; sourceLen = lstrlenW(bstr); bytesNeeded = WideCharToMultiByte(CP_UTF8, 0, bstr, sourceLen, NULL, 0, NULL, NULL); bytesNeeded += 1; // complete lack of documentation on Mozilla's part here, I have no // idea how this string is supposed to be freed npStr = (char *)NPNFuncs.memalloc(bytesNeeded); if (npStr) { int len = WideCharToMultiByte(CP_UTF8, 0, bstr, sourceLen, npStr, bytesNeeded - 1, NULL, NULL); npStr[len] = 0; STRINGN_TO_NPVARIANT(npStr, len, (*npvar)); } else { VOID_TO_NPVARIANT(*npvar); } } BSTR NPStringToBstr(const NPString npstr) { size_t bytesNeeded; bytesNeeded = MultiByteToWideChar( CP_UTF8, 0, npstr.UTF8Characters, npstr.UTF8Length, NULL, 0); bytesNeeded += 1; BSTR bstr = (BSTR)CoTaskMemAlloc(sizeof(OLECHAR) * bytesNeeded); if (bstr) { int len = MultiByteToWideChar( CP_UTF8, 0, npstr.UTF8Characters, npstr.UTF8Length, bstr, bytesNeeded); bstr[len] = 0; return bstr; } return NULL; } void Unknown2NPVar(IUnknown *unk, NPVariant *npvar, NPP instance) { FakeDispatcher *disp = NULL; if (!unk) { NULL_TO_NPVARIANT(*npvar); } else if (SUCCEEDED(unk->QueryInterface(IID_IFakeDispatcher, (void**)&disp))) { OBJECT_TO_NPVARIANT(disp->getObject(), *npvar); NPNFuncs.retainobject(disp->getObject()); disp->Release(); } else { NPObject *obj = Scriptable::FromIUnknown(instance, unk); OBJECT_TO_NPVARIANT(obj, (*npvar)); } } #define GETVALUE(var, val) (((var->vt) & VT_BYREF) ? *(var->p##val) : (var->val)) void Variant2NPVar(const VARIANT *var, NPVariant *npvar, NPP instance) { NPObject *obj = NULL; if (!var || !npvar) { return; } VOID_TO_NPVARIANT(*npvar); USES_CONVERSION; switch (var->vt & ~VT_BYREF) { case VT_ARRAY | VT_VARIANT: NPSafeArray::RegisterVBArray(instance); NPSafeArray *obj; obj = NPSafeArray::CreateFromArray(instance, var->parray); OBJECT_TO_NPVARIANT(obj, (*npvar)); break; case VT_EMPTY: VOID_TO_NPVARIANT((*npvar)); break; case VT_NULL: NULL_TO_NPVARIANT((*npvar)); break; case VT_LPSTR: // not sure it can even appear in a VARIANT, but... STRINGZ_TO_NPVARIANT(var->pcVal, (*npvar)); break; case VT_BSTR: BSTR2NPVar(GETVALUE(var, bstrVal), npvar, instance); break; case VT_I1: INT32_TO_NPVARIANT((INT32)GETVALUE(var, cVal), (*npvar)); break; case VT_I2: INT32_TO_NPVARIANT((INT32)GETVALUE(var, iVal), (*npvar)); break; case VT_I4: INT32_TO_NPVARIANT((INT32)GETVALUE(var, lVal), (*npvar)); break; case VT_UI1: INT32_TO_NPVARIANT((INT32)GETVALUE(var, bVal), (*npvar)); break; case VT_UI2: INT32_TO_NPVARIANT((INT32)GETVALUE(var, uiVal), (*npvar)); break; case VT_UI4: case VT_UINT: INT32_TO_NPVARIANT((INT32)GETVALUE(var, ulVal), (*npvar)); break; case VT_INT: INT32_TO_NPVARIANT((INT32)GETVALUE(var, lVal), (*npvar)); break; case VT_BOOL: BOOLEAN_TO_NPVARIANT((GETVALUE(var, boolVal) == VARIANT_TRUE) ? true : false, (*npvar)); break; case VT_R4: DOUBLE_TO_NPVARIANT((double)GETVALUE(var, fltVal), (*npvar)); break; case VT_R8: DOUBLE_TO_NPVARIANT(GETVALUE(var, dblVal), (*npvar)); break; case VT_DATE: DOUBLE_TO_NPVARIANT(GETVALUE(var, date), (*npvar)); break; case VT_DISPATCH: case VT_USERDEFINED: case VT_UNKNOWN: Unknown2NPVar(GETVALUE(var, punkVal), npvar, instance); break; case VT_VARIANT: Variant2NPVar(var->pvarVal, npvar, instance); break; default: // Some unsupported type np_log(instance, 0, "Unsupported variant type %d", var->vt); VOID_TO_NPVARIANT(*npvar); break; } } #undef GETVALUE ITypeLib *pHtmlLib; void NPVar2Variant(const NPVariant *npvar, VARIANT *var, NPP instance) { if (!var || !npvar) { return; } var->vt = VT_EMPTY; switch (npvar->type) { case NPVariantType_Void: var->vt = VT_EMPTY; var->ulVal = 0; break; case NPVariantType_Null: var->vt = VT_NULL; var->byref = NULL; break; case NPVariantType_Bool: var->vt = VT_BOOL; var->boolVal = npvar->value.boolValue ? VARIANT_TRUE : VARIANT_FALSE; break; case NPVariantType_Int32: var->vt = VT_I4; var->ulVal = npvar->value.intValue; break; case NPVariantType_Double: var->vt = VT_R8; var->dblVal = npvar->value.doubleValue; break; case NPVariantType_String: (CComVariant&)*var = NPStringToBstr(npvar->value.stringValue); break; case NPVariantType_Object: NPObject *object = NPVARIANT_TO_OBJECT(*npvar); var->vt = VT_DISPATCH; if (object->_class == &Scriptable::npClass) { Scriptable* scriptObj = (Scriptable*)object; scriptObj->getControl(&var->punkVal); } else if (object->_class == &NPSafeArray::npClass) { NPSafeArray* arrayObj = (NPSafeArray*)object; var->vt = VT_ARRAY | VT_VARIANT; var->parray = arrayObj->GetArrayPtr(); } else { IUnknown *val = new FakeDispatcher(instance, pHtmlLib, object); var->punkVal = val; } break; } } size_t VariantSize(VARTYPE vt) { if ((vt & VT_BYREF) || (vt & VT_ARRAY)) return sizeof(LPVOID); switch (vt) { case VT_EMPTY: case VT_NULL: case VT_VOID: return 0; case VT_I1: case VT_UI1: return 1; case VT_I2: case VT_UI2: return 2; case VT_R8: case VT_DATE: case VT_I8: case VT_UI8: case VT_CY: return 8; case VT_I4: case VT_R4: case VT_UI4: case VT_BOOL: return 4; case VT_BSTR: case VT_DISPATCH: case VT_ERROR: case VT_UNKNOWN: case VT_DECIMAL: case VT_INT: case VT_UINT: case VT_HRESULT: case VT_PTR: case VT_SAFEARRAY: case VT_CARRAY: case VT_USERDEFINED: case VT_LPSTR: case VT_LPWSTR: case VT_INT_PTR: case VT_UINT_PTR: return sizeof(LPVOID); case VT_VARIANT: return sizeof(VARIANT); default: return 0; } } HRESULT ConvertVariantToGivenType(ITypeInfo *baseType, const TYPEDESC &vt, const VARIANT &var, LPVOID dest) { // var is converted from NPVariant, so only limited types are possible. HRESULT hr = S_OK; switch (vt.vt) { case VT_EMPTY: case VT_VOID: case VT_NULL: return S_OK; case VT_I1: case VT_UI1: case VT_I2: case VT_UI2: case VT_I4: case VT_R4: case VT_UI4: case VT_BOOL: case VT_INT: case VT_UINT: int intvalue; intvalue = NULL; if (var.vt == VT_R8) intvalue = (int)var.dblVal; else if (var.vt == VT_BOOL) intvalue = (int)var.boolVal; else if (var.vt == VT_UI4) intvalue = var.intVal; else return E_FAIL; **(int**)dest = intvalue; hr = S_OK; break; case VT_R8: double dblvalue; dblvalue = 0.0; if (var.vt == VT_R8) dblvalue = (double)var.dblVal; else if (var.vt == VT_BOOL) dblvalue = (double)var.boolVal; else if (var.vt == VT_UI4) dblvalue = var.intVal; else return E_FAIL; **(double**)dest = dblvalue; hr = S_OK; break; case VT_DATE: case VT_I8: case VT_UI8: case VT_CY: // I don't know how to deal with these types.. __asm{int 3}; case VT_BSTR: case VT_DISPATCH: case VT_ERROR: case VT_UNKNOWN: case VT_DECIMAL: case VT_HRESULT: case VT_SAFEARRAY: case VT_CARRAY: case VT_LPSTR: case VT_LPWSTR: case VT_INT_PTR: case VT_UINT_PTR: **(ULONG***)dest = var.pulVal; break; case VT_USERDEFINED: { if (var.vt != VT_UNKNOWN && var.vt != VT_DISPATCH) { return E_FAIL; } else { ITypeInfo *newType; baseType->GetRefTypeInfo(vt.hreftype, &newType); IUnknown *unk = var.punkVal; TYPEATTR *attr; newType->GetTypeAttr(&attr); hr = unk->QueryInterface(attr->guid, (LPVOID*)dest); unk->Release(); newType->ReleaseTypeAttr(attr); newType->Release(); } } break; case VT_PTR: return ConvertVariantToGivenType(baseType, *vt.lptdesc, var, *(LPVOID*)dest); break; case VT_VARIANT: memcpy(*(VARIANT**)dest, &var, sizeof(var)); default: _asm{int 3} } return hr; } void RawTypeToVariant(const TYPEDESC &desc, LPVOID source, VARIANT* var) { BOOL pointer = FALSE; switch (desc.vt) { case VT_BSTR: case VT_DISPATCH: case VT_ERROR: case VT_UNKNOWN: case VT_SAFEARRAY: case VT_CARRAY: case VT_LPSTR: case VT_LPWSTR: case VT_INT_PTR: case VT_UINT_PTR: case VT_PTR: // These are pointers pointer = TRUE; break; default: if (var->vt & VT_BYREF) pointer = TRUE; } if (pointer) { var->vt = desc.vt; var->pulVal = *(PULONG*)source; } else if (desc.vt == VT_VARIANT) { // It passed by object, but we use as a pointer var->vt = desc.vt; var->pulVal = (PULONG)source; } else { var->vt = desc.vt | VT_BYREF; var->pulVal = (PULONG)source; } }
007slmg-np-activex-justep
ffactivex/variants.cpp
C++
mpl11
11,038
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is itstructures.com code. * * The Initial Developer of the Original Code is IT Structures. * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include <algorithm> #include <string> #include "GenericNPObject.h" static NPObject* AllocateGenericNPObject(NPP npp, NPClass *aClass) { return new GenericNPObject(npp, false); } static NPObject* AllocateMethodNPObject(NPP npp, NPClass *aClass) { return new GenericNPObject(npp, true); } static void DeallocateGenericNPObject(NPObject *obj) { if (!obj) { return; } GenericNPObject *m = (GenericNPObject *)obj; delete m; } static void InvalidateGenericNPObject(NPObject *obj) { if (!obj) { return; } ((GenericNPObject *)obj)->Invalidate(); } NPClass GenericNPObjectClass = { /* version */ NP_CLASS_STRUCT_VERSION, /* allocate */ AllocateGenericNPObject, /* deallocate */ DeallocateGenericNPObject, /* invalidate */ InvalidateGenericNPObject, /* hasMethod */ GenericNPObject::_HasMethod, /* invoke */ GenericNPObject::_Invoke, /* invokeDefault */ GenericNPObject::_InvokeDefault, /* hasProperty */ GenericNPObject::_HasProperty, /* getProperty */ GenericNPObject::_GetProperty, /* setProperty */ GenericNPObject::_SetProperty, /* removeProperty */ GenericNPObject::_RemoveProperty, /* enumerate */ GenericNPObject::_Enumerate, /* construct */ NULL }; NPClass MethodNPObjectClass = { /* version */ NP_CLASS_STRUCT_VERSION, /* allocate */ AllocateMethodNPObject, /* deallocate */ DeallocateGenericNPObject, /* invalidate */ InvalidateGenericNPObject, /* hasMethod */ GenericNPObject::_HasMethod, /* invoke */ GenericNPObject::_Invoke, /* invokeDefault */ GenericNPObject::_InvokeDefault, /* hasProperty */ GenericNPObject::_HasProperty, /* getProperty */ GenericNPObject::_GetProperty, /* setProperty */ GenericNPObject::_SetProperty, /* removeProperty */ GenericNPObject::_RemoveProperty, /* enumerate */ GenericNPObject::_Enumerate, /* construct */ NULL }; // Some standard JavaScript methods bool toString(void *object, const NPVariant *args, uint32_t argCount, NPVariant *result) { GenericNPObject *map = (GenericNPObject *)object; if (!map || map->invalid) return false; // no args expected or cared for... std::string out; std::vector<NPVariant>::iterator it; for (it = map->numeric_mapper.begin(); it < map->numeric_mapper.end(); ++it) { if (NPVARIANT_IS_VOID(*it)) { out += ","; } else if (NPVARIANT_IS_NULL(*it)) { out += ","; } else if (NPVARIANT_IS_BOOLEAN(*it)) { if ((*it).value.boolValue) { out += "true,"; } else { out += "false,"; } } else if (NPVARIANT_IS_INT32(*it)) { char tmp[50]; memset(tmp, 0, sizeof(tmp)); _snprintf(tmp, 49, "%d,", (*it).value.intValue); out += tmp; } else if (NPVARIANT_IS_DOUBLE(*it)) { char tmp[50]; memset(tmp, 0, sizeof(tmp)); _snprintf(tmp, 49, "%f,", (*it).value.doubleValue); out += tmp; } else if (NPVARIANT_IS_STRING(*it)) { out += std::string((*it).value.stringValue.UTF8Characters, (*it).value.stringValue.UTF8Characters + (*it).value.stringValue.UTF8Length); out += ","; } else if (NPVARIANT_IS_OBJECT(*it)) { out += "[object],"; } } // calculate how much space we need std::string::size_type size = out.length(); char *s = (char *)NPNFuncs.memalloc(size * sizeof(char)); if (NULL == s) { return false; } memcpy(s, out.c_str(), size); s[size - 1] = 0; // overwrite the last "," STRINGZ_TO_NPVARIANT(s, (*result)); return true; } // Some helpers static void free_numeric_element(NPVariant elem) { NPNFuncs.releasevariantvalue(&elem); } static void free_alpha_element(std::pair<const char *, NPVariant> elem) { NPNFuncs.releasevariantvalue(&(elem.second)); } // And now the GenericNPObject implementation GenericNPObject::GenericNPObject(NPP instance, bool isMethodObj): invalid(false), defInvoker(NULL), defInvokerObject(NULL) { NPVariant val; INT32_TO_NPVARIANT(0, val); immutables["length"] = val; if (!isMethodObj) { NPObject *obj = NULL; obj = NPNFuncs.createobject(instance, &MethodNPObjectClass); if (NULL == obj) { throw NULL; } ((GenericNPObject *)obj)->SetDefaultInvoker(&toString, this); OBJECT_TO_NPVARIANT(obj, val); immutables["toString"] = val; } } GenericNPObject::~GenericNPObject() { for_each(immutables.begin(), immutables.end(), free_alpha_element); for_each(alpha_mapper.begin(), alpha_mapper.end(), free_alpha_element); for_each(numeric_mapper.begin(), numeric_mapper.end(), free_numeric_element); } bool GenericNPObject::HasMethod(NPIdentifier name) { if (invalid) return false; if (NPNFuncs.identifierisstring(name)) { char *key = NPNFuncs.utf8fromidentifier(name); if (immutables.count(key) > 0) { if (NPVARIANT_IS_OBJECT(immutables[key])) { return (NULL != immutables[key].value.objectValue->_class->invokeDefault); } } else if (alpha_mapper.count(key) > 0) { if (NPVARIANT_IS_OBJECT(alpha_mapper[key])) { return (NULL != alpha_mapper[key].value.objectValue->_class->invokeDefault); } } } return false; } bool GenericNPObject::Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { if (invalid) return false; if (NPNFuncs.identifierisstring(name)) { char *key = NPNFuncs.utf8fromidentifier(name); if (immutables.count(key) > 0) { if ( NPVARIANT_IS_OBJECT(immutables[key]) && immutables[key].value.objectValue->_class->invokeDefault) { return immutables[key].value.objectValue->_class->invokeDefault(immutables[key].value.objectValue, args, argCount, result); } } else if (alpha_mapper.count(key) > 0) { if ( NPVARIANT_IS_OBJECT(alpha_mapper[key]) && alpha_mapper[key].value.objectValue->_class->invokeDefault) { return alpha_mapper[key].value.objectValue->_class->invokeDefault(alpha_mapper[key].value.objectValue, args, argCount, result); } } } return true; } bool GenericNPObject::InvokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result) { if (invalid) return false; if (defInvoker) { defInvoker(defInvokerObject, args, argCount, result); } return true; } // This method is also called before the JS engine attempts to add a new // property, most likely it's trying to check that the key is supported. // It only returns false if the string name was not found, or does not // hold a callable object bool GenericNPObject::HasProperty(NPIdentifier name) { if (invalid) return false; if (NPNFuncs.identifierisstring(name)) { char *key = NPNFuncs.utf8fromidentifier(name); if (immutables.count(key) > 0) { if (NPVARIANT_IS_OBJECT(immutables[key])) { return (NULL == immutables[key].value.objectValue->_class->invokeDefault); } } else if (alpha_mapper.count(key) > 0) { if (NPVARIANT_IS_OBJECT(alpha_mapper[key])) { return (NULL == alpha_mapper[key].value.objectValue->_class->invokeDefault); } } return false; } return true; } static bool CopyNPVariant(NPVariant *dst, const NPVariant *src) { dst->type = src->type; if (NPVARIANT_IS_STRING(*src)) { NPUTF8 *str = (NPUTF8 *)NPNFuncs.memalloc((src->value.stringValue.UTF8Length + 1) * sizeof(NPUTF8)); if (NULL == str) { return false; } dst->value.stringValue.UTF8Length = src->value.stringValue.UTF8Length; memcpy(str, src->value.stringValue.UTF8Characters, src->value.stringValue.UTF8Length); str[dst->value.stringValue.UTF8Length] = 0; dst->value.stringValue.UTF8Characters = str; } else if (NPVARIANT_IS_OBJECT(*src)) { NPNFuncs.retainobject(NPVARIANT_TO_OBJECT(*src)); dst->value.objectValue = src->value.objectValue; } else { dst->value = src->value; } return true; } #define MIN(x, y) ((x) < (y)) ? (x) : (y) bool GenericNPObject::GetProperty(NPIdentifier name, NPVariant *result) { if (invalid) return false; try { if (NPNFuncs.identifierisstring(name)) { char *key = NPNFuncs.utf8fromidentifier(name); if (immutables.count(key) > 0) { if (!CopyNPVariant(result, &(immutables[key]))) { return false; } } else if (alpha_mapper.count(key) > 0) { if (!CopyNPVariant(result, &(alpha_mapper[key]))) { return false; } } } else { // assume int... unsigned long key = (unsigned long)NPNFuncs.intfromidentifier(name); if (numeric_mapper.size() > key) { if (!CopyNPVariant(result, &(numeric_mapper[key]))) { return false; } } } } catch (...) { } return true; } bool GenericNPObject::SetProperty(NPIdentifier name, const NPVariant *value) { if (invalid) return false; try { if (NPNFuncs.identifierisstring(name)) { char *key = NPNFuncs.utf8fromidentifier(name); if (immutables.count(key) > 0) { // the key is already defined as immutable, check the new value type if (value->type != immutables[key].type) { return false; } // Seems ok, copy the new value if (!CopyNPVariant(&(immutables[key]), value)) { return false; } } else if (!CopyNPVariant(&(alpha_mapper[key]), value)) { return false; } } else { // assume int... NPVariant var; if (!CopyNPVariant(&var, value)) { return false; } unsigned long key = (unsigned long)NPNFuncs.intfromidentifier(name); if (key >= numeric_mapper.size()) { // there's a gap we need to fill NPVariant pad; VOID_TO_NPVARIANT(pad); numeric_mapper.insert(numeric_mapper.end(), key - numeric_mapper.size() + 1, pad); } numeric_mapper.at(key) = var; NPVARIANT_TO_INT32(immutables["length"])++; } } catch (...) { } return true; } bool GenericNPObject::RemoveProperty(NPIdentifier name) { if (invalid) return false; try { if (NPNFuncs.identifierisstring(name)) { char *key = NPNFuncs.utf8fromidentifier(name); if (alpha_mapper.count(key) > 0) { NPNFuncs.releasevariantvalue(&(alpha_mapper[key])); alpha_mapper.erase(key); } } else { // assume int... unsigned long key = (unsigned long)NPNFuncs.intfromidentifier(name); if (numeric_mapper.size() > key) { NPNFuncs.releasevariantvalue(&(numeric_mapper[key])); numeric_mapper.erase(numeric_mapper.begin() + key); } NPVARIANT_TO_INT32(immutables["length"])--; } } catch (...) { } return true; } bool GenericNPObject::Enumerate(NPIdentifier **identifiers, uint32_t *identifierCount) { if (invalid) return false; try { *identifiers = (NPIdentifier *)NPNFuncs.memalloc(sizeof(NPIdentifier) * numeric_mapper.size()); if (NULL == *identifiers) { return false; } *identifierCount = 0; std::vector<NPVariant>::iterator it; unsigned int i = 0; char str[10] = ""; for (it = numeric_mapper.begin(); it < numeric_mapper.end(); ++it, ++i) { // skip empty (padding) elements if (NPVARIANT_IS_VOID(*it)) continue; _snprintf(str, sizeof(str), "%u", i); (*identifiers)[(*identifierCount)++] = NPNFuncs.getstringidentifier(str); } } catch (...) { } return true; }
007slmg-np-activex-justep
ffactivex/GenericNPObject.cpp
C++
mpl11
13,001
//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by npactivex.rc // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
007slmg-np-activex-justep
ffactivex/resource.h
C
mpl11
403
maxVf = 200 # Generating the header head = """// Copyright qiuc12@gmail.com // This file is generated autmatically by python. DONT MODIFY IT! #pragma once #include <OleAuto.h> class FakeDispatcher; HRESULT DualProcessCommand(int commandId, FakeDispatcher *disp, ...); extern "C" void DualProcessCommandWrap(); class FakeDispatcherBase : public IDispatch { private:""" pattern = """ \tvirtual HRESULT __stdcall fv{0}(char x) {{ \t\tva_list va = &x; \t\tHRESULT ret = ProcessCommand({0}, va); \t\tva_end(va); \t\treturn ret; \t}} """ pattern = """ \tvirtual HRESULT __stdcall fv{0}();""" end = """ protected: \tconst static int kMaxVf = {0}; }}; """ f = open("FakeDispatcherBase.h", "w") f.write(head) for i in range(0, maxVf): f.write(pattern.format(i)) f.write(end.format(maxVf)) f.close() head = """; Copyright qiuc12@gmail.com ; This file is generated automatically by python. DON'T MODIFY IT! """ f = open("FakeDispatcherBase.asm", "w") f.write(head) f.write(".386\n") f.write(".model flat\n") f.write("_DualProcessCommandWrap proto\n") ObjFormat = "?fv{0}@FakeDispatcherBase@@EAGJXZ" for i in range(0, maxVf): f.write("PUBLIC " + ObjFormat.format(i) + "\n") f.write(".code\n") for i in range(0, maxVf): f.write(ObjFormat.format(i) + " proc\n") f.write(" push {0}\n".format(i)) f.write(" jmp _DualProcessCommandWrap\n") f.write(ObjFormat.format(i) + " endp\n") f.write("\nend\n") f.close()
007slmg-np-activex-justep
ffactivex/FakeDispatcherBase_gen.py
Python
mpl11
1,484
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor: * Chuan Qiu <qiuc12@gmail.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor: * Chuan Qiu <qiuc12@gmail.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "Host.h" #include "npactivex.h" #include "ObjectManager.h" #include "objectProxy.h" #include <npapi.h> #include <npruntime.h> CHost::CHost(NPP npp) : ref_cnt_(1), instance(npp), lastObj(NULL) { } CHost::~CHost(void) { UnRegisterObject(); np_log(instance, 3, "CHost::~CHost"); } void CHost::AddRef() { ++ref_cnt_; } void CHost::Release() { --ref_cnt_; if (!ref_cnt_) delete this; } NPObject *CHost::GetScriptableObject() { return lastObj; } NPObject *CHost::RegisterObject() { lastObj = CreateScriptableObject(); if (!lastObj) return NULL; lastObj->host = this; // It doesn't matter which npp in setting. return lastObj; } void CHost::UnRegisterObject() { return; NPObjectProxy embed; NPNFuncs.getvalue(instance, NPNVPluginElementNPObject, &embed); NPVariant var; VOID_TO_NPVARIANT(var); NPNFuncs.removeproperty(instance, embed, NPNFuncs.getstringidentifier("object")); np_log(instance, 3, "UnRegisterObject"); lastObj = NULL; } NPP CHost::ResetNPP(NPP newNPP) { // Doesn't support now.. _asm{int 3}; NPP ret = instance; UnRegisterObject(); instance = newNPP; np_log(newNPP, 3, "Reset NPP from 0x%08x to 0x%08x", ret, newNPP); RegisterObject(); return ret; } CHost *CHost::GetInternalObject(NPP npp, NPObject *embed_element) { NPVariantProxy var; if (!NPNFuncs.getproperty(npp, embed_element, NPNFuncs.getstringidentifier("__npp_instance__"), &var)) return NULL; if (NPVARIANT_IS_INT32(var)) { return (CHost*)((NPP)var.value.intValue)->pdata; } else if (NPVARIANT_IS_DOUBLE(var)) { return (CHost*)((NPP)((int32)var.value.doubleValue))->pdata; } return NULL; } ScriptBase *CHost::GetMyScriptObject() { NPObjectProxy embed; NPNFuncs.getvalue(instance, NPNVPluginElementNPObject, &embed); return GetInternalObject(instance, embed)->lastObj; }
007slmg-np-activex-justep
ffactivex/Host.cpp
C++
mpl11
4,946
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is itstructures.com code. * * The Initial Developer of the Original Code is IT Structures. * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #pragma once #include "Host.h" namespace ATL { template <typename T> class CComObject; } class CControlEventSink; class CControlSite; class PropertyList; class CAxHost : public CHost{ private: CAxHost(const CAxHost &); bool isValidClsID; bool isKnown; bool noWindow; protected: // The window handle to our plugin area in the browser HWND Window; WNDPROC OldProc; // The class/prog id of the control CLSID ClsID; LPCWSTR CodeBaseUrl; CComObject<CControlEventSink> *Sink; RECT lastRect; PropertyList *Props_; public: CAxHost(NPP inst); ~CAxHost(); static CLSID ParseCLSIDFromSetting(LPCSTR clsid, int length); virtual NPP ResetNPP(NPP npp); CComObject<CControlSite> *Site; void SetNPWindow(NPWindow *window); void ResetWindow(); PropertyList *Props() { return Props_; } void Clear(); void setWindow(HWND win); HWND getWinfow(); void UpdateRect(RECT rcPos); bool verifyClsID(LPOLESTR oleClsID); bool setClsID(const char *clsid); bool setClsID(const CLSID& clsid); CLSID getClsID() { return this->ClsID; } void setNoWindow(bool value); bool setClsIDFromProgID(const char *progid); void setCodeBaseUrl(LPCWSTR clsid); bool hasValidClsID(); bool CreateControl(bool subscribeToEvents); void UpdateRectSize(LPRECT origRect); void SetRectSize(LPSIZEL size); bool AddEventHandler(wchar_t *name, wchar_t *handler); HRESULT GetControlUnknown(IUnknown **pObj); short HandleEvent(void *event); ScriptBase *CreateScriptableObject(); };
007slmg-np-activex-justep
ffactivex/axhost.h
C++
mpl11
3,248
#pragma once #include <npapi.h> #include <npruntime.h> #include <OleAuto.h> #include "scriptable.h" #include "npactivex.h" #include <map> using std::map; using std::pair; class ScriptFunc : public NPObject { private: static NPClass npClass; Scriptable *script; MEMBERID dispid; void setControl(Scriptable *script, MEMBERID dispid) { NPNFuncs.retainobject(script); this->script = script; this->dispid = dispid; } static map<pair<Scriptable*, MEMBERID>, ScriptFunc*> M; bool InvokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result); public: ScriptFunc(NPP inst); ~ScriptFunc(void); static NPObject *_Allocate(NPP npp, NPClass *npClass) { return new ScriptFunc(npp); } static void _Deallocate(NPObject *object) { ScriptFunc *obj = (ScriptFunc*)(object); delete obj; } static ScriptFunc* GetFunctionObject(NPP npp, Scriptable *script, MEMBERID dispid); static bool _InvokeDefault(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { return ((ScriptFunc *)npobj)->InvokeDefault(args, argCount, result); } };
007slmg-np-activex-justep
ffactivex/ScriptFunc.h
C++
mpl11
1,139
#ifndef _HOOK_H_ #define _HOOK_H_ typedef struct _HOOKINFO_ { PBYTE Stub; DWORD CodeLength; LPVOID FuncAddr; LPVOID FakeAddr; }HOOKINFO, *PHOOKINFO; VOID HEInitHook(PHOOKINFO HookInfo, LPVOID FuncAddr, LPVOID FakeAddr); BOOL HEStartHook(PHOOKINFO HookInfo); BOOL HEStopHook(PHOOKINFO HookInfo); #endif
007slmg-np-activex-justep
ffactivex/ApiHook/Hook.h
C
mpl11
323
// (c) Code By Extreme // Description:Inline Hook Engine // Last update:2010-6-26 #include <Windows.h> #include <stdio.h> #include "Hook.h" #define JMPSIZE 5 #define NOP 0x90 extern DWORD ade_getlength(LPVOID Start, DWORD WantLength); static VOID BuildJmp(PBYTE Buffer,DWORD JmpFrom, DWORD JmpTo) { DWORD JmpAddr; JmpAddr = JmpFrom - JmpTo - JMPSIZE; Buffer[0] = 0xE9; Buffer[1] = (BYTE)(JmpAddr & 0xFF); Buffer[2] = (BYTE)((JmpAddr >> 8) & 0xFF); Buffer[3] = (BYTE)((JmpAddr >> 16) & 0xFF); Buffer[4] = (BYTE)((JmpAddr >> 24) & 0xFF); } VOID HEInitHook(PHOOKINFO HookInfo, LPVOID FuncAddr, LPVOID FakeAddr) { HookInfo->FakeAddr = FakeAddr; HookInfo->FuncAddr = FuncAddr; return; } BOOL HEStartHook(PHOOKINFO HookInfo) { BOOL CallRet; BOOL FuncRet = 0; PVOID BufAddr; DWORD dwTmp; DWORD OldProtect; LPVOID FuncAddr; DWORD CodeLength; // Init the basic value FuncAddr = HookInfo->FuncAddr; CodeLength = ade_getlength(FuncAddr, JMPSIZE); HookInfo->CodeLength = CodeLength; if (HookInfo->FakeAddr == NULL || FuncAddr == NULL || CodeLength == NULL) { FuncRet = 1; goto Exit1; } // Alloc buffer to store the code then write them to the head of the function BufAddr = malloc(CodeLength); if (BufAddr == NULL) { FuncRet = 2; goto Exit1; } // Alloc buffer to store original code HookInfo->Stub = (PBYTE)malloc(CodeLength + JMPSIZE); if (HookInfo->Stub == NULL) { FuncRet = 3; goto Exit2; } // Fill buffer to nop. This could make hook stable FillMemory(BufAddr, CodeLength, NOP); // Build buffers BuildJmp((PBYTE)BufAddr, (DWORD)HookInfo->FakeAddr, (DWORD)FuncAddr); BuildJmp(&(HookInfo->Stub[CodeLength]), (DWORD)((PBYTE)FuncAddr + CodeLength), (DWORD)((PBYTE)HookInfo->Stub + CodeLength)); // [V1.1] Bug fixed: VirtualProtect Stub CallRet = VirtualProtect(HookInfo->Stub, CodeLength, PAGE_EXECUTE_READWRITE, &OldProtect); if (!CallRet) { FuncRet = 4; goto Exit3; } // Set the block of memory could be read and write CallRet = VirtualProtect(FuncAddr, CodeLength, PAGE_EXECUTE_READWRITE, &OldProtect); if (!CallRet) { FuncRet = 4; goto Exit3; } // Copy the head of function to stub CallRet = ReadProcessMemory(GetCurrentProcess(), FuncAddr, HookInfo->Stub, CodeLength, &dwTmp); if (!CallRet || dwTmp != CodeLength) { FuncRet = 5; goto Exit3; } // Write hook code back to the head of the function CallRet = WriteProcessMemory(GetCurrentProcess(), FuncAddr, BufAddr, CodeLength, &dwTmp); if (!CallRet || dwTmp != CodeLength) { FuncRet = 6; goto Exit3; } // Make hook stable FlushInstructionCache(GetCurrentProcess(), FuncAddr, CodeLength); VirtualProtect(FuncAddr, CodeLength, OldProtect, &dwTmp); // All done goto Exit2; // Error handle Exit3: free(HookInfo->Stub); Exit2: free (BufAddr); Exit1: return FuncRet; } BOOL HEStopHook(PHOOKINFO HookInfo) { BOOL CallRet; DWORD dwTmp; DWORD OldProtect; LPVOID FuncAddr = HookInfo->FuncAddr; DWORD CodeLength = HookInfo->CodeLength; CallRet = VirtualProtect(FuncAddr, CodeLength, PAGE_EXECUTE_READWRITE, &OldProtect); if (!CallRet) { return 1; } CallRet = WriteProcessMemory(GetCurrentProcess(), FuncAddr, HookInfo->Stub, CodeLength, &dwTmp); if (!CallRet || dwTmp != CodeLength) { return 2; } FlushInstructionCache(GetCurrentProcess(), FuncAddr, CodeLength); VirtualProtect(FuncAddr, CodeLength, OldProtect, &dwTmp); free(HookInfo->Stub); return 0; }
007slmg-np-activex-justep
ffactivex/ApiHook/Hook.cpp
C++
mpl11
3,588
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "StdAfx.h" #include "PropertyBag.h" CPropertyBag::CPropertyBag() { } CPropertyBag::~CPropertyBag() { } /////////////////////////////////////////////////////////////////////////////// // IPropertyBag implementation HRESULT STDMETHODCALLTYPE CPropertyBag::Read(/* [in] */ LPCOLESTR pszPropName, /* [out][in] */ VARIANT __RPC_FAR *pVar, /* [in] */ IErrorLog __RPC_FAR *pErrorLog) { if (pszPropName == NULL) { return E_INVALIDARG; } if (pVar == NULL) { return E_INVALIDARG; } VARTYPE vt = pVar->vt; VariantInit(pVar); for (unsigned long i = 0; i < m_PropertyList.GetSize(); i++) { if (wcsicmp(m_PropertyList.GetNameOf(i), pszPropName) == 0) { const VARIANT *pvSrc = m_PropertyList.GetValueOf(i); if (!pvSrc) { return E_FAIL; } CComVariant vNew; HRESULT hr = (vt == VT_EMPTY) ? vNew.Copy(pvSrc) : vNew.ChangeType(vt, pvSrc); if (FAILED(hr)) { return E_FAIL; } // Copy the new value vNew.Detach(pVar); return S_OK; } } // Property does not exist in the bag return E_FAIL; } HRESULT STDMETHODCALLTYPE CPropertyBag::Write(/* [in] */ LPCOLESTR pszPropName, /* [in] */ VARIANT __RPC_FAR *pVar) { if (pszPropName == NULL) { return E_INVALIDARG; } if (pVar == NULL) { return E_INVALIDARG; } CComBSTR bstrName(pszPropName); m_PropertyList.AddOrReplaceNamedProperty(bstrName, *pVar); return S_OK; }
007slmg-np-activex-justep
ffactivex/common/PropertyBag.cpp
C++
mpl11
3,426
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@eircom.net> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef PROPERTYBAG_H #define PROPERTYBAG_H #include "PropertyList.h" // Object wrapper for property list. This class can be set up with a // list of properties and used to initialise a control with them class CPropertyBag : public CComObjectRootEx<CComSingleThreadModel>, public IPropertyBag { // List of properties in the bag PropertyList m_PropertyList; public: // Constructor CPropertyBag(); // Destructor virtual ~CPropertyBag(); BEGIN_COM_MAP(CPropertyBag) COM_INTERFACE_ENTRY(IPropertyBag) END_COM_MAP() // IPropertyBag methods virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read(/* [in] */ LPCOLESTR pszPropName, /* [out][in] */ VARIANT __RPC_FAR *pVar, /* [in] */ IErrorLog __RPC_FAR *pErrorLog); virtual HRESULT STDMETHODCALLTYPE Write(/* [in] */ LPCOLESTR pszPropName, /* [in] */ VARIANT __RPC_FAR *pVar); }; typedef CComObject<CPropertyBag> CPropertyBagInstance; #endif
007slmg-np-activex-justep
ffactivex/common/PropertyBag.h
C++
mpl11
2,769
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@netscape.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef CONTROLSITE_H #define CONTROLSITE_H #include "IOleCommandTargetImpl.h" #include <atlstr.h> #include "PropertyList.h" // Temoporarily removed by bug 200680. Stops controls misbehaving and calling // windowless methods when they shouldn't. // COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSiteWindowless, IOleInPlaceSiteWindowless) \ // Class that defines the control's security policy with regards to // what controls it hosts etc. class CControlSiteSecurityPolicy { public: // Test if the class is safe to host virtual BOOL IsClassSafeToHost(const CLSID & clsid) = 0; // Test if the specified class is marked safe for scripting virtual BOOL IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists) = 0; // Test if the instantiated object is safe for scripting on the specified interface virtual BOOL IsObjectSafeForScripting(IUnknown *pObject, const IID &iid) = 0; }; // // Class for hosting an ActiveX control // // This class supports both windowed and windowless classes. The normal // steps to hosting a control are this: // // CControlSiteInstance *pSite = NULL; // CControlSiteInstance::CreateInstance(&pSite); // pSite->AddRef(); // pSite->Create(clsidControlToCreate); // pSite->Attach(hwndParentWindow, rcPosition); // // Where propertyList is a named list of values to initialise the new object // with, hwndParentWindow is the window in which the control is being created, // and rcPosition is the position in window coordinates where the control will // be rendered. // // Destruction is this: // // pSite->Detach(); // pSite->Release(); // pSite = NULL; class CControlSite : public CComObjectRootEx<CComSingleThreadModel>, public IOleClientSite, public IOleInPlaceSiteWindowless, public IOleControlSite, public IAdviseSinkEx, public IDispatch, public IOleCommandTargetImpl<CControlSite>, public IBindStatusCallback, public IWindowForBindingUI { private: // Site management values // Handle to parent window HWND m_hWndParent; // Position of the site and the contained object RECT m_rcObjectPos; // Flag indicating if client site should be set early or late unsigned m_bSetClientSiteFirst:1; // Flag indicating whether control is visible or not unsigned m_bVisibleAtRuntime:1; // Flag indicating if control is in-place active unsigned m_bInPlaceActive:1; // Flag indicating if control is UI active unsigned m_bUIActive:1; // Flag indicating if control is in-place locked and cannot be deactivated unsigned m_bInPlaceLocked:1; // Flag indicating if the site allows windowless controls unsigned m_bSupportWindowlessActivation:1; // Flag indicating if control is windowless (after being created) unsigned m_bWindowless:1; // Flag indicating if only safely scriptable controls are allowed unsigned m_bSafeForScriptingObjectsOnly:1; // Return the default security policy object static CControlSiteSecurityPolicy *GetDefaultControlSecurityPolicy(); // The URL for creating Moniker CString url; friend class CAxHost; protected: // Pointers to object interfaces // Raw pointer to the object CComPtr<IUnknown> m_spObject; // Pointer to objects IViewObject interface CComQIPtr<IViewObject, &IID_IViewObject> m_spIViewObject; // Pointer to object's IOleObject interface CComQIPtr<IOleObject, &IID_IOleObject> m_spIOleObject; // Pointer to object's IOleInPlaceObject interface CComQIPtr<IOleInPlaceObject, &IID_IOleInPlaceObject> m_spIOleInPlaceObject; // Pointer to object's IOleInPlaceObjectWindowless interface CComQIPtr<IOleInPlaceObjectWindowless, &IID_IOleInPlaceObjectWindowless> m_spIOleInPlaceObjectWindowless; // CLSID of the control CComQIPtr<IOleControl> m_spIOleControl; CLSID m_CLSID; // Parameter list PropertyList m_ParameterList; // Pointer to the security policy CControlSiteSecurityPolicy *m_pSecurityPolicy; // Document and Service provider IUnknown *m_spInner; void (*m_spInnerDeallocater)(IUnknown *m_spInner); // Binding variables // Flag indicating whether binding is in progress unsigned m_bBindingInProgress; // Result from the binding operation HRESULT m_hrBindResult; // Double buffer drawing variables used for windowless controls // Area of buffer RECT m_rcBuffer; // Bitmap to buffer HBITMAP m_hBMBuffer; // Bitmap to buffer HBITMAP m_hBMBufferOld; // Device context HDC m_hDCBuffer; // Clipping area of site HRGN m_hRgnBuffer; // Flags indicating how the buffer was painted DWORD m_dwBufferFlags; // The last control size passed by GetExtent SIZEL m_currentSize; // Ambient properties // Locale ID LCID m_nAmbientLocale; // Foreground colour COLORREF m_clrAmbientForeColor; // Background colour COLORREF m_clrAmbientBackColor; // Flag indicating if control should hatch itself bool m_bAmbientShowHatching:1; // Flag indicating if control should have grab handles bool m_bAmbientShowGrabHandles:1; // Flag indicating if control is in edit/user mode bool m_bAmbientUserMode:1; // Flag indicating if control has a 3d border or not bool m_bAmbientAppearance:1; // Flag indicating if the size passed in is different from the control. bool m_needUpdateContainerSize:1; protected: // Notifies the attached control of a change to an ambient property virtual void FireAmbientPropertyChange(DISPID id); public: // Construction and destruction // Constructor CControlSite(); // Destructor virtual ~CControlSite(); BEGIN_COM_MAP(CControlSite) COM_INTERFACE_ENTRY(IOleWindow) COM_INTERFACE_ENTRY(IOleClientSite) COM_INTERFACE_ENTRY(IOleInPlaceSite) COM_INTERFACE_ENTRY(IOleInPlaceSiteWindowless) COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSite, IOleInPlaceSiteWindowless) COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSiteEx, IOleInPlaceSiteWindowless) COM_INTERFACE_ENTRY(IOleControlSite) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY_IID(IID_IAdviseSink, IAdviseSinkEx) COM_INTERFACE_ENTRY_IID(IID_IAdviseSink2, IAdviseSinkEx) COM_INTERFACE_ENTRY_IID(IID_IAdviseSinkEx, IAdviseSinkEx) COM_INTERFACE_ENTRY(IOleCommandTarget) COM_INTERFACE_ENTRY(IBindStatusCallback) COM_INTERFACE_ENTRY(IWindowForBindingUI) COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_spInner) END_COM_MAP() BEGIN_OLECOMMAND_TABLE() END_OLECOMMAND_TABLE() // Returns the window used when processing ole commands HWND GetCommandTargetWindow() { return NULL; // TODO } // Object creation and management functions // Creates and initialises an object virtual HRESULT Create(REFCLSID clsid, PropertyList &pl = PropertyList(), LPCWSTR szCodebase = NULL, IBindCtx *pBindContext = NULL); // Attaches the object to the site virtual HRESULT Attach(HWND hwndParent, const RECT &rcPos, IUnknown *pInitStream = NULL); // Detaches the object from the site virtual HRESULT Detach(); // Returns the IUnknown pointer for the object virtual HRESULT GetControlUnknown(IUnknown **ppObject); // Sets the bounding rectangle for the object virtual HRESULT SetPosition(const RECT &rcPos); // Draws the object using the provided DC virtual HRESULT Draw(HDC hdc); // Performs the specified action on the object virtual HRESULT DoVerb(LONG nVerb, LPMSG lpMsg = NULL); // Sets an advise sink up for changes to the object virtual HRESULT Advise(IUnknown *pIUnkSink, const IID &iid, DWORD *pdwCookie); // Removes an advise sink virtual HRESULT Unadvise(const IID &iid, DWORD dwCookie); // Get the control size, in pixels. virtual HRESULT GetControlSize(LPSIZEL size); // Set the control size, in pixels. virtual HRESULT SetControlSize(const LPSIZEL size, LPSIZEL out); void SetUrl(BSTR url); void SetInnerWindow(IUnknown *unk, void (*Deleter)(IUnknown *unk)) { m_spInner = unk; m_spInnerDeallocater = Deleter; } // Set the security policy object. Ownership of this object remains with the caller and the security // policy object is meant to exist for as long as it is set here. virtual void SetSecurityPolicy(CControlSiteSecurityPolicy *pSecurityPolicy) { m_pSecurityPolicy = pSecurityPolicy; } virtual CControlSiteSecurityPolicy *GetSecurityPolicy() const { return m_pSecurityPolicy; } // Methods to set ambient properties virtual void SetAmbientUserMode(BOOL bUser); // Inline helper methods // Returns the object's CLSID virtual const CLSID &GetObjectCLSID() const { return m_CLSID; } // Tests if the object is valid or not virtual BOOL IsObjectValid() const { return (m_spObject) ? TRUE : FALSE; } // Returns the parent window to this one virtual HWND GetParentWindow() const { return m_hWndParent; } // Returns the inplace active state of the object virtual BOOL IsInPlaceActive() const { return m_bInPlaceActive; } // Returns the m_bVisibleAtRuntime virtual BOOL IsVisibleAtRuntime() const { return m_bVisibleAtRuntime; } // Return and reset m_needUpdateContainerSize virtual BOOL CheckAndResetNeedUpdateContainerSize() { BOOL ret = m_needUpdateContainerSize; m_needUpdateContainerSize = false; return ret; } // IDispatch virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo); virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr); // IAdviseSink implementation virtual /* [local] */ void STDMETHODCALLTYPE OnDataChange(/* [unique][in] */ FORMATETC __RPC_FAR *pFormatetc, /* [unique][in] */ STGMEDIUM __RPC_FAR *pStgmed); virtual /* [local] */ void STDMETHODCALLTYPE OnViewChange(/* [in] */ DWORD dwAspect, /* [in] */ LONG lindex); virtual /* [local] */ void STDMETHODCALLTYPE OnRename(/* [in] */ IMoniker __RPC_FAR *pmk); virtual /* [local] */ void STDMETHODCALLTYPE OnSave(void); virtual /* [local] */ void STDMETHODCALLTYPE OnClose(void); // IAdviseSink2 virtual /* [local] */ void STDMETHODCALLTYPE OnLinkSrcChange(/* [unique][in] */ IMoniker __RPC_FAR *pmk); // IAdviseSinkEx implementation virtual /* [local] */ void STDMETHODCALLTYPE OnViewStatusChange(/* [in] */ DWORD dwViewStatus); // IOleWindow implementation virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd); virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode); // IOleClientSite implementation virtual HRESULT STDMETHODCALLTYPE SaveObject(void); virtual HRESULT STDMETHODCALLTYPE GetMoniker(/* [in] */ DWORD dwAssign, /* [in] */ DWORD dwWhichMoniker, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmk); virtual HRESULT STDMETHODCALLTYPE GetContainer(/* [out] */ IOleContainer __RPC_FAR *__RPC_FAR *ppContainer); virtual HRESULT STDMETHODCALLTYPE ShowObject(void); virtual HRESULT STDMETHODCALLTYPE OnShowWindow(/* [in] */ BOOL fShow); virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(void); // IOleInPlaceSite implementation virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate(void); virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate(void); virtual HRESULT STDMETHODCALLTYPE OnUIActivate(void); virtual HRESULT STDMETHODCALLTYPE GetWindowContext(/* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, /* [out] */ LPRECT lprcPosRect, /* [out] */ LPRECT lprcClipRect, /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo); virtual HRESULT STDMETHODCALLTYPE Scroll(/* [in] */ SIZE scrollExtant); virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate(/* [in] */ BOOL fUndoable); virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate(void); virtual HRESULT STDMETHODCALLTYPE DiscardUndoState(void); virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo(void); virtual HRESULT STDMETHODCALLTYPE OnPosRectChange(/* [in] */ LPCRECT lprcPosRect); // IOleInPlaceSiteEx implementation virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(/* [out] */ BOOL __RPC_FAR *pfNoRedraw, /* [in] */ DWORD dwFlags); virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(/* [in] */ BOOL fNoRedraw); virtual HRESULT STDMETHODCALLTYPE RequestUIActivate(void); // IOleInPlaceSiteWindowless implementation virtual HRESULT STDMETHODCALLTYPE CanWindowlessActivate(void); virtual HRESULT STDMETHODCALLTYPE GetCapture(void); virtual HRESULT STDMETHODCALLTYPE SetCapture(/* [in] */ BOOL fCapture); virtual HRESULT STDMETHODCALLTYPE GetFocus(void); virtual HRESULT STDMETHODCALLTYPE SetFocus(/* [in] */ BOOL fFocus); virtual HRESULT STDMETHODCALLTYPE GetDC(/* [in] */ LPCRECT pRect, /* [in] */ DWORD grfFlags, /* [out] */ HDC __RPC_FAR *phDC); virtual HRESULT STDMETHODCALLTYPE ReleaseDC(/* [in] */ HDC hDC); virtual HRESULT STDMETHODCALLTYPE InvalidateRect(/* [in] */ LPCRECT pRect, /* [in] */ BOOL fErase); virtual HRESULT STDMETHODCALLTYPE InvalidateRgn(/* [in] */ HRGN hRGN, /* [in] */ BOOL fErase); virtual HRESULT STDMETHODCALLTYPE ScrollRect(/* [in] */ INT dx, /* [in] */ INT dy, /* [in] */ LPCRECT pRectScroll, /* [in] */ LPCRECT pRectClip); virtual HRESULT STDMETHODCALLTYPE AdjustRect(/* [out][in] */ LPRECT prc); virtual HRESULT STDMETHODCALLTYPE OnDefWindowMessage(/* [in] */ UINT msg, /* [in] */ WPARAM wParam, /* [in] */ LPARAM lParam, /* [out] */ LRESULT __RPC_FAR *plResult); // IOleControlSite implementation virtual HRESULT STDMETHODCALLTYPE OnControlInfoChanged(void); virtual HRESULT STDMETHODCALLTYPE LockInPlaceActive(/* [in] */ BOOL fLock); virtual HRESULT STDMETHODCALLTYPE GetExtendedControl(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDisp); virtual HRESULT STDMETHODCALLTYPE TransformCoords(/* [out][in] */ POINTL __RPC_FAR *pPtlHimetric, /* [out][in] */ POINTF __RPC_FAR *pPtfContainer, /* [in] */ DWORD dwFlags); virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(/* [in] */ MSG __RPC_FAR *pMsg, /* [in] */ DWORD grfModifiers); virtual HRESULT STDMETHODCALLTYPE OnFocus(/* [in] */ BOOL fGotFocus); virtual HRESULT STDMETHODCALLTYPE ShowPropertyFrame( void); // IBindStatusCallback virtual HRESULT STDMETHODCALLTYPE OnStartBinding(/* [in] */ DWORD dwReserved, /* [in] */ IBinding __RPC_FAR *pib); virtual HRESULT STDMETHODCALLTYPE GetPriority(/* [out] */ LONG __RPC_FAR *pnPriority); virtual HRESULT STDMETHODCALLTYPE OnLowResource(/* [in] */ DWORD reserved); virtual HRESULT STDMETHODCALLTYPE OnProgress(/* [in] */ ULONG ulProgress, /* [in] */ ULONG ulProgressMax, /* [in] */ ULONG ulStatusCode, /* [in] */ LPCWSTR szStatusText); virtual HRESULT STDMETHODCALLTYPE OnStopBinding(/* [in] */ HRESULT hresult, /* [unique][in] */ LPCWSTR szError); virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBindInfo( /* [out] */ DWORD __RPC_FAR *grfBINDF, /* [unique][out][in] */ BINDINFO __RPC_FAR *pbindinfo); virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnDataAvailable(/* [in] */ DWORD grfBSCF, /* [in] */ DWORD dwSize, /* [in] */ FORMATETC __RPC_FAR *pformatetc, /* [in] */ STGMEDIUM __RPC_FAR *pstgmed); virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable(/* [in] */ REFIID riid, /* [iid_is][in] */ IUnknown __RPC_FAR *punk); // IWindowForBindingUI virtual HRESULT STDMETHODCALLTYPE GetWindow(/* [in] */ REFGUID rguidReason, /* [out] */ HWND *phwnd); }; #endif
007slmg-np-activex-justep
ffactivex/common/ControlSite.h
C++
mpl11
18,194
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@eircom.net> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "StdAfx.h" #include "ItemContainer.h" CItemContainer::CItemContainer() { } CItemContainer::~CItemContainer() { } /////////////////////////////////////////////////////////////////////////////// // IParseDisplayName implementation HRESULT STDMETHODCALLTYPE CItemContainer::ParseDisplayName(/* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ LPOLESTR pszDisplayName, /* [out] */ ULONG __RPC_FAR *pchEaten, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmkOut) { // TODO return E_NOTIMPL; } /////////////////////////////////////////////////////////////////////////////// // IOleContainer implementation HRESULT STDMETHODCALLTYPE CItemContainer::EnumObjects(/* [in] */ DWORD grfFlags, /* [out] */ IEnumUnknown __RPC_FAR *__RPC_FAR *ppenum) { HRESULT hr = E_NOTIMPL; /* if (ppenum == NULL) { return E_POINTER; } *ppenum = NULL; typedef CComObject<CComEnumOnSTL<IEnumUnknown, &IID_IEnumUnknown, IUnknown*, _CopyInterface<IUnknown>, CNamedObjectList > > enumunk; enumunk* p = NULL; p = new enumunk; if(p == NULL) { return E_OUTOFMEMORY; } hr = p->Init(); if (SUCCEEDED(hr)) { hr = p->QueryInterface(IID_IEnumUnknown, (void**) ppenum); } if (FAILED(hRes)) { delete p; } */ return hr; } HRESULT STDMETHODCALLTYPE CItemContainer::LockContainer(/* [in] */ BOOL fLock) { // TODO return S_OK; } /////////////////////////////////////////////////////////////////////////////// // IOleItemContainer implementation HRESULT STDMETHODCALLTYPE CItemContainer::GetObject(/* [in] */ LPOLESTR pszItem, /* [in] */ DWORD dwSpeedNeeded, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) { if (pszItem == NULL) { return E_INVALIDARG; } if (ppvObject == NULL) { return E_INVALIDARG; } *ppvObject = NULL; return MK_E_NOOBJECT; } HRESULT STDMETHODCALLTYPE CItemContainer::GetObjectStorage(/* [in] */ LPOLESTR pszItem, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvStorage) { // TODO return MK_E_NOOBJECT; } HRESULT STDMETHODCALLTYPE CItemContainer::IsRunning(/* [in] */ LPOLESTR pszItem) { // TODO return MK_E_NOOBJECT; }
007slmg-np-activex-justep
ffactivex/common/ItemContainer.cpp
C++
mpl11
4,191
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@netscape.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef CONTROLEVENTSINK_H #define CONTROLEVENTSINK_H #include <map> // This class listens for events from the specified control class CControlEventSink : public CComObjectRootEx<CComSingleThreadModel>, public IDispatch { public: CControlEventSink(); // Current event connection point CComPtr<IConnectionPoint> m_spEventCP; CComPtr<ITypeInfo> m_spEventSinkTypeInfo; DWORD m_dwEventCookie; IID m_EventIID; typedef std::map<DISPID, wchar_t *> EventMap; EventMap events; NPP instance; protected: virtual ~CControlEventSink(); bool m_bSubscribed; static HRESULT WINAPI SinkQI(void* pv, REFIID riid, LPVOID* ppv, DWORD dw) { CControlEventSink *pThis = (CControlEventSink *) pv; if (!IsEqualIID(pThis->m_EventIID, GUID_NULL) && IsEqualIID(pThis->m_EventIID, riid)) { return pThis->QueryInterface(__uuidof(IDispatch), ppv); } return E_NOINTERFACE; } public: BEGIN_COM_MAP(CControlEventSink) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY_FUNC_BLIND(0, SinkQI) END_COM_MAP() virtual HRESULT SubscribeToEvents(IUnknown *pControl); virtual void UnsubscribeFromEvents(); virtual BOOL GetEventSinkIID(IUnknown *pControl, IID &iid, ITypeInfo **typeInfo); virtual HRESULT InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); // IDispatch virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo); virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr); }; typedef CComObject<CControlEventSink> CControlEventSinkInstance; #endif
007slmg-np-activex-justep
ffactivex/common/ControlEventSink.h
C++
mpl11
4,288
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@netscape.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "stdafx.h" #include "ControlSiteIPFrame.h" CControlSiteIPFrame::CControlSiteIPFrame() { m_hwndFrame = NULL; } CControlSiteIPFrame::~CControlSiteIPFrame() { } /////////////////////////////////////////////////////////////////////////////// // IOleWindow implementation HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::GetWindow(/* [out] */ HWND __RPC_FAR *phwnd) { if (phwnd == NULL) { return E_INVALIDARG; } *phwnd = m_hwndFrame; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::ContextSensitiveHelp(/* [in] */ BOOL fEnterMode) { return S_OK; } /////////////////////////////////////////////////////////////////////////////// // IOleInPlaceUIWindow implementation HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::GetBorder(/* [out] */ LPRECT lprectBorder) { return INPLACE_E_NOTOOLSPACE; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::RequestBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths) { return INPLACE_E_NOTOOLSPACE; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetActiveObject(/* [unique][in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject, /* [unique][string][in] */ LPCOLESTR pszObjName) { return S_OK; } /////////////////////////////////////////////////////////////////////////////// // IOleInPlaceFrame implementation HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::InsertMenus(/* [in] */ HMENU hmenuShared, /* [out][in] */ LPOLEMENUGROUPWIDTHS lpMenuWidths) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetMenu(/* [in] */ HMENU hmenuShared, /* [in] */ HOLEMENU holemenu, /* [in] */ HWND hwndActiveObject) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::RemoveMenus(/* [in] */ HMENU hmenuShared) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetStatusText(/* [in] */ LPCOLESTR pszStatusText) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::EnableModeless(/* [in] */ BOOL fEnable) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::TranslateAccelerator(/* [in] */ LPMSG lpmsg, /* [in] */ WORD wID) { ATLTRACE("Not implemnted"); return E_NOTIMPL; }
007slmg-np-activex-justep
ffactivex/common/ControlSiteIPFrame.cpp
C++
mpl11
4,135
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@eircom.net> * Ruediger Jungbeck <ruediger.jungbeck@rsj.de> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, // but are changed infrequently #if !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_) #define AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // under MSVC shut off copious warnings about debug symbol too long #ifdef _MSC_VER #pragma warning( disable: 4786 ) #endif //#include "jstypes.h" //#include "prtypes.h" // Mozilla headers //#include "jscompat.h" //#include "prthread.h" //#include "prprf.h" //#include "nsID.h" //#include "nsIComponentManager.h" //#include "nsIServiceManager.h" //#include "nsStringAPI.h" //#include "nsCOMPtr.h" //#include "nsComponentManagerUtils.h" //#include "nsServiceManagerUtils.h" //#include "nsIDocument.h" //#include "nsIDocumentObserver.h" //#include "nsVoidArray.h" //#include "nsIDOMNode.h" //#include "nsIDOMNodeList.h" //#include "nsIDOMDocument.h" //#include "nsIDOMDocumentType.h" //#include "nsIDOMElement.h" //#undef _WIN32_WINNT //#define _WIN32_WINNT 0x0400 #define _ATL_APARTMENT_THREADED //#define _ATL_STATIC_REGISTRY // #define _ATL_DEBUG_INTERFACES // ATL headers // The ATL headers that come with the platform SDK have bad for scoping #if _MSC_VER >= 1400 #pragma conform(forScope, push, atlhack, off) #endif #include <atlbase.h> //You may derive a class from CComModule and use it if you want to override //something, but do not change the name of _Module extern CComModule _Module; #include <atlcom.h> #include <atlctl.h> #if _MSC_VER >= 1400 #pragma conform(forScope, pop, atlhack) #endif #include <mshtml.h> #include <mshtmhst.h> #include <docobj.h> //#include <winsock2.h> #include <comdef.h> #include <vector> #include <list> #include <string> // New winsock2.h doesn't define this anymore typedef long int32; #define NS_SCRIPTABLE #include "nscore.h" #include "npapi.h" //#include "npupp.h" #include "npfunctions.h" #include "nsID.h" #include <npruntime.h> #include "../variants.h" #include "PropertyList.h" #include "PropertyBag.h" #include "ItemContainer.h" #include "ControlSite.h" #include "ControlSiteIPFrame.h" #include "ControlEventSink.h" extern NPNetscapeFuncs NPNFuncs; // Turn off warnings about debug symbols for templates being too long #pragma warning(disable : 4786) #define TRACE_METHOD(fn) \ { \ ATLTRACE(_T("0x%04x %s()\n"), (int) GetCurrentThreadId(), _T(#fn)); \ } #define TRACE_METHOD_ARGS(fn, pattern, args) \ { \ ATLTRACE(_T("0x%04x %s(") _T(pattern) _T(")\n"), (int) GetCurrentThreadId(), _T(#fn), args); \ } //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. #define NS_ASSERTION(x, y) #endif // !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED)
007slmg-np-activex-justep
ffactivex/common/StdAfx.h
C++
mpl11
4,966
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@netscape.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "StdAfx.h" #include "../npactivex.h" #include "ControlEventSink.h" CControlEventSink::CControlEventSink() : m_dwEventCookie(0), m_bSubscribed(false), m_EventIID(GUID_NULL), events() { } CControlEventSink::~CControlEventSink() { UnsubscribeFromEvents(); } BOOL CControlEventSink::GetEventSinkIID(IUnknown *pControl, IID &iid, ITypeInfo **typeInfo) { iid = GUID_NULL; if (!pControl) { return FALSE; } // IProvideClassInfo2 way is easiest // CComQIPtr<IProvideClassInfo2> classInfo2 = pControl; // if (classInfo2) // { // classInfo2->GetGUID(GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid); // if (!::IsEqualIID(iid, GUID_NULL)) // { // return TRUE; // } // } // Yuck, the hard way CComQIPtr<IProvideClassInfo> classInfo = pControl; if (!classInfo) { np_log(instance, 0, "no classInfo"); return FALSE; } // Search the class type information for the default source interface // which is the outgoing event sink. CComPtr<ITypeInfo> classTypeInfo; classInfo->GetClassInfo(&classTypeInfo); if (!classTypeInfo) { np_log(instance, 0, "noclassTypeinfo"); return FALSE; } TYPEATTR *classAttr = NULL; if (FAILED(classTypeInfo->GetTypeAttr(&classAttr))) { np_log(instance, 0, "noclassTypeinfo->GetTypeAttr"); return FALSE; } INT implFlags = 0; for (UINT i = 0; i < classAttr->cImplTypes; i++) { // Search for the interface with the [default, source] attr if (SUCCEEDED(classTypeInfo->GetImplTypeFlags(i, &implFlags)) && implFlags == (IMPLTYPEFLAG_FDEFAULT | IMPLTYPEFLAG_FSOURCE)) { CComPtr<ITypeInfo> eventSinkTypeInfo; HREFTYPE hRefType; if (SUCCEEDED(classTypeInfo->GetRefTypeOfImplType(i, &hRefType)) && SUCCEEDED(classTypeInfo->GetRefTypeInfo(hRefType, &eventSinkTypeInfo))) { TYPEATTR *eventSinkAttr = NULL; if (SUCCEEDED(eventSinkTypeInfo->GetTypeAttr(&eventSinkAttr))) { iid = eventSinkAttr->guid; if (typeInfo) { *typeInfo = eventSinkTypeInfo.p; (*typeInfo)->AddRef(); } eventSinkTypeInfo->ReleaseTypeAttr(eventSinkAttr); } } break; } } classTypeInfo->ReleaseTypeAttr(classAttr); return (!::IsEqualIID(iid, GUID_NULL)); } void CControlEventSink::UnsubscribeFromEvents() { if (m_bSubscribed) { DWORD tmpCookie = m_dwEventCookie; m_dwEventCookie = 0; m_bSubscribed = false; // Unsubscribe and reset - This seems to complete release and destroy us... m_spEventCP->Unadvise(tmpCookie); // Unadvise handles the Release m_spEventCP.Release(); } else { m_spEventCP.Release(); } } HRESULT CControlEventSink::SubscribeToEvents(IUnknown *pControl) { if (!pControl) { np_log(instance, 0, "not valid control"); return E_INVALIDARG; } // Throw away any existing connections UnsubscribeFromEvents(); // Grab the outgoing event sink IID which will be used to subscribe // to events via the connection point container. IID iidEventSink; CComPtr<ITypeInfo> typeInfo; if (!GetEventSinkIID(pControl, iidEventSink, &typeInfo)) { np_log(instance, 0, "Can't get event sink iid"); return E_FAIL; } // Get the connection point CComQIPtr<IConnectionPointContainer> ccp = pControl; CComPtr<IConnectionPoint> cp; if (!ccp) { np_log(instance, 0, "not valid ccp"); return E_FAIL; } // Custom IID m_EventIID = iidEventSink; DWORD dwCookie = 0;/* CComPtr<IEnumConnectionPoints> e; ccp->EnumConnectionPoints(&e); e->Next(1, &cp, &dwCookie);*/ if (FAILED(ccp->FindConnectionPoint(m_EventIID, &cp))) { np_log(instance, 0, "failed to find connection point"); return E_FAIL; } if (FAILED(cp->Advise(this, &dwCookie))) { np_log(instance, 0, "failed to advise"); return E_FAIL; } m_bSubscribed = true; m_spEventCP = cp; m_dwEventCookie = dwCookie; m_spEventSinkTypeInfo = typeInfo; return S_OK; } HRESULT CControlEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { USES_CONVERSION; if (DISPATCH_METHOD != wFlags) { // any other reason to call us?! return S_FALSE; } EventMap::iterator cur = events.find(dispIdMember); if (events.end() != cur) { // invoke this event handler NPVariant result; NPVariant *args = NULL; if (pDispParams->cArgs > 0) { args = (NPVariant *)calloc(pDispParams->cArgs, sizeof(NPVariant)); if (!args) { return S_FALSE; } for (unsigned int i = 0; i < pDispParams->cArgs; ++i) { // convert the arguments in reverse order Variant2NPVar(&pDispParams->rgvarg[i], &args[pDispParams->cArgs - i - 1], instance); } } NPObject *globalObj = NULL; NPNFuncs.getvalue(instance, NPNVWindowNPObject, &globalObj); NPIdentifier handler = NPNFuncs.getstringidentifier(W2A((*cur).second)); bool success = NPNFuncs.invoke(instance, globalObj, handler, args, pDispParams->cArgs, &result); NPNFuncs.releaseobject(globalObj); for (unsigned int i = 0; i < pDispParams->cArgs; ++i) { // convert the arguments if (args[i].type == NPVariantType_String) { // was allocated earlier by Variant2NPVar NPNFuncs.memfree((void *)args[i].value.stringValue.UTF8Characters); } } if (!success) { return S_FALSE; } if (pVarResult) { // set the result NPVar2Variant(&result, pVarResult, instance); } NPNFuncs.releasevariantvalue(&result); } return S_OK; } /////////////////////////////////////////////////////////////////////////////// // IDispatch implementation HRESULT STDMETHODCALLTYPE CControlEventSink::GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlEventSink::GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlEventSink::GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlEventSink::Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr) { return InternalInvoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); }
007slmg-np-activex-justep
ffactivex/common/ControlEventSink.cpp
C++
mpl11
9,226
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@netscape.com> * Brent Booker * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "StdAfx.h" #include <Objsafe.h> #include "ControlSite.h" #include "PropertyBag.h" #include "ControlSiteIPFrame.h" class CDefaultControlSiteSecurityPolicy : public CControlSiteSecurityPolicy { // Test if the specified class id implements the specified category BOOL ClassImplementsCategory(const CLSID & clsid, const CATID &catid, BOOL &bClassExists); public: // Test if the class is safe to host virtual BOOL IsClassSafeToHost(const CLSID & clsid); // Test if the specified class is marked safe for scripting virtual BOOL IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists); // Test if the instantiated object is safe for scripting on the specified interface virtual BOOL IsObjectSafeForScripting(IUnknown *pObject, const IID &iid); }; BOOL CDefaultControlSiteSecurityPolicy::ClassImplementsCategory(const CLSID &clsid, const CATID &catid, BOOL &bClassExists) { bClassExists = FALSE; // Test if there is a CLSID entry. If there isn't then obviously // the object doesn't exist and therefore doesn't implement any category. // In this situation, the function returns REGDB_E_CLASSNOTREG. CRegKey key; if (key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ) != ERROR_SUCCESS) { // Must fail if we can't even open this! return FALSE; } LPOLESTR szCLSID = NULL; if (FAILED(StringFromCLSID(clsid, &szCLSID))) { return FALSE; } USES_CONVERSION; CRegKey keyCLSID; LONG lResult = keyCLSID.Open(key, W2CT(szCLSID), KEY_READ); CoTaskMemFree(szCLSID); if (lResult != ERROR_SUCCESS) { // Class doesn't exist return FALSE; } keyCLSID.Close(); // CLSID exists, so try checking what categories it implements bClassExists = TRUE; CComQIPtr<ICatInformation> spCatInfo; HRESULT hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatInformation, (LPVOID*) &spCatInfo); if (spCatInfo == NULL) { // Must fail if we can't open the category manager return FALSE; } // See what categories the class implements CComQIPtr<IEnumCATID> spEnumCATID; if (FAILED(spCatInfo->EnumImplCategoriesOfClass(clsid, &spEnumCATID))) { // Can't enumerate classes in category so fail return FALSE; } // Search for matching categories BOOL bFound = FALSE; CATID catidNext = GUID_NULL; while (spEnumCATID->Next(1, &catidNext, NULL) == S_OK) { if (::IsEqualCATID(catid, catidNext)) { return TRUE; } } return FALSE; } // Test if the class is safe to host BOOL CDefaultControlSiteSecurityPolicy::IsClassSafeToHost(const CLSID & clsid) { return TRUE; } // Test if the specified class is marked safe for scripting BOOL CDefaultControlSiteSecurityPolicy::IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists) { // Test the category the object belongs to return ClassImplementsCategory(clsid, CATID_SafeForScripting, bClassExists); } // Test if the instantiated object is safe for scripting on the specified interface BOOL CDefaultControlSiteSecurityPolicy::IsObjectSafeForScripting(IUnknown *pObject, const IID &iid) { if (!pObject) { return FALSE; } // Ask the control if its safe for scripting CComQIPtr<IObjectSafety> spObjectSafety = pObject; if (!spObjectSafety) { return FALSE; } DWORD dwSupported = 0; // Supported options (mask) DWORD dwEnabled = 0; // Enabled options // Assume scripting via IDispatch, now we doesn't support IDispatchEx if (SUCCEEDED(spObjectSafety->GetInterfaceSafetyOptions( iid, &dwSupported, &dwEnabled))) { if (dwEnabled & dwSupported & INTERFACESAFE_FOR_UNTRUSTED_CALLER) { // Object is safe return TRUE; } } // Set it to support untrusted caller. if(FAILED(spObjectSafety->SetInterfaceSafetyOptions( iid, INTERFACESAFE_FOR_UNTRUSTED_CALLER, INTERFACESAFE_FOR_UNTRUSTED_CALLER))) { return FALSE; } return TRUE; } /////////////////////////////////////////////////////////////////////////////// // Constructor CControlSite::CControlSite() { TRACE_METHOD(CControlSite::CControlSite); m_hWndParent = NULL; m_CLSID = CLSID_NULL; m_bSetClientSiteFirst = FALSE; m_bVisibleAtRuntime = TRUE; memset(&m_rcObjectPos, 0, sizeof(m_rcObjectPos)); m_bInPlaceActive = FALSE; m_bUIActive = FALSE; m_bInPlaceLocked = FALSE; m_bWindowless = FALSE; m_bSupportWindowlessActivation = TRUE; m_bSafeForScriptingObjectsOnly = FALSE; m_pSecurityPolicy = GetDefaultControlSecurityPolicy(); // Initialise ambient properties m_nAmbientLocale = 0; m_clrAmbientForeColor = ::GetSysColor(COLOR_WINDOWTEXT); m_clrAmbientBackColor = ::GetSysColor(COLOR_WINDOW); m_bAmbientUserMode = true; m_bAmbientShowHatching = true; m_bAmbientShowGrabHandles = true; m_bAmbientAppearance = true; // 3d // Windowless variables m_hDCBuffer = NULL; m_hRgnBuffer = NULL; m_hBMBufferOld = NULL; m_hBMBuffer = NULL; m_spInner = NULL; m_needUpdateContainerSize = false; m_currentSize.cx = m_currentSize.cy = -1; } // Destructor CControlSite::~CControlSite() { TRACE_METHOD(CControlSite::~CControlSite); Detach(); if (m_spInner && m_spInnerDeallocater) { m_spInnerDeallocater(m_spInner); } } // Create the specified control, optionally providing properties to initialise // it with and a name. HRESULT CControlSite::Create(REFCLSID clsid, PropertyList &pl, LPCWSTR szCodebase, IBindCtx *pBindContext) { TRACE_METHOD(CControlSite::Create); m_CLSID = clsid; m_ParameterList = pl; // See if security policy will allow the control to be hosted if (m_pSecurityPolicy && !m_pSecurityPolicy->IsClassSafeToHost(clsid)) { return E_FAIL; } // See if object is script safe BOOL checkForObjectSafety = FALSE; if (m_pSecurityPolicy && m_bSafeForScriptingObjectsOnly) { BOOL bClassExists = FALSE; BOOL bIsSafe = m_pSecurityPolicy->IsClassMarkedSafeForScripting(clsid, bClassExists); if (!bClassExists && szCodebase) { // Class doesn't exist, so allow code below to fetch it } else if (!bIsSafe) { // The class is not flagged as safe for scripting, so // we'll have to create it to ask it if its safe. checkForObjectSafety = TRUE; } } //Now Check if the control version needs to be updated. BOOL bUpdateControlVersion = FALSE; wchar_t *szURL = NULL; DWORD dwFileVersionMS = 0xffffffff; DWORD dwFileVersionLS = 0xffffffff; if(szCodebase) { HKEY hk = NULL; wchar_t wszKey[60] = L""; wchar_t wszData[MAX_PATH]; LPWSTR pwszClsid = NULL; DWORD dwSize = 255; DWORD dwHandle, dwLength, dwRegReturn; DWORD dwExistingFileVerMS = 0xffffffff; DWORD dwExistingFileVerLS = 0xffffffff; BOOL bFoundLocalVerInfo = FALSE; StringFromCLSID(clsid, (LPOLESTR*)&pwszClsid); swprintf(wszKey, L"%s%s%s\0", L"CLSID\\", pwszClsid, L"\\InprocServer32"); if ( RegOpenKeyExW( HKEY_CLASSES_ROOT, wszKey, 0, KEY_READ, &hk ) == ERROR_SUCCESS ) { dwRegReturn = RegQueryValueExW( hk, L"", NULL, NULL, (LPBYTE)wszData, &dwSize ); RegCloseKey( hk ); } if(dwRegReturn == ERROR_SUCCESS) { VS_FIXEDFILEINFO *pFileInfo; UINT uLen; dwLength = GetFileVersionInfoSizeW( wszData , &dwHandle ); LPBYTE lpData = new BYTE[dwLength]; GetFileVersionInfoW(wszData, 0, dwLength, lpData ); bFoundLocalVerInfo = VerQueryValueW( lpData, L"\\", (LPVOID*)&pFileInfo, &uLen ); if(bFoundLocalVerInfo) { dwExistingFileVerMS = pFileInfo->dwFileVersionMS; dwExistingFileVerLS = pFileInfo->dwFileVersionLS; } delete [] lpData; } // Test if the code base ends in #version=a,b,c,d const wchar_t *szHash = wcsrchr(szCodebase, wchar_t('#')); if (szHash) { if (wcsnicmp(szHash, L"#version=", 9) == 0) { int a, b, c, d; if (swscanf(szHash + 9, L"%d,%d,%d,%d", &a, &b, &c, &d) == 4) { dwFileVersionMS = MAKELONG(b,a); dwFileVersionLS = MAKELONG(d,c); //If local version info was found compare it if(bFoundLocalVerInfo) { if(dwFileVersionMS > dwExistingFileVerMS) bUpdateControlVersion = TRUE; if((dwFileVersionMS == dwExistingFileVerMS) && (dwFileVersionLS > dwExistingFileVerLS)) bUpdateControlVersion = TRUE; } } } szURL = _wcsdup(szCodebase); // Terminate at the hash mark if (szURL) szURL[szHash - szCodebase] = wchar_t('\0'); } else { szURL = _wcsdup(szCodebase); } } CComPtr<IUnknown> spObject; HRESULT hr; //If the control needs to be updated do not call CoCreateInstance otherwise you will lock files //and force a reboot on CoGetClassObjectFromURL if(!bUpdateControlVersion) { // Create the object hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void **) &spObject); if (SUCCEEDED(hr) && checkForObjectSafety) { m_bSafeForScriptingObjectsOnly = m_pSecurityPolicy->IsObjectSafeForScripting(spObject, __uuidof(IDispatch)); // Drop through, success! } } // Do we need to download the control? if ((FAILED(hr) && szCodebase) || (bUpdateControlVersion)) { if (!szURL) return E_OUTOFMEMORY; CComPtr<IBindCtx> spBindContext; CComPtr<IBindStatusCallback> spBindStatusCallback; CComPtr<IBindStatusCallback> spOldBSC; // Create our own bind context or use the one provided? BOOL useInternalBSC = FALSE; if (!pBindContext) { useInternalBSC = TRUE; hr = CreateBindCtx(0, &spBindContext); if (FAILED(hr)) { free(szURL); return hr; } spBindStatusCallback = dynamic_cast<IBindStatusCallback *>(this); hr = RegisterBindStatusCallback(spBindContext, spBindStatusCallback, &spOldBSC, 0); if (FAILED(hr)) { free(szURL); return hr; } } else { spBindContext = pBindContext; } //If the version from the CODEBASE value is greater than the installed control //Call CoGetClassObjectFromURL with CLSID_NULL to prevent system change reboot prompt if(bUpdateControlVersion) { hr = CoGetClassObjectFromURL(clsid, szURL, dwFileVersionMS, dwFileVersionLS, NULL, spBindContext, CLSCTX_INPROC_HANDLER | CLSCTX_INPROC_SERVER, 0, IID_IClassFactory, NULL); } else { hr = CoGetClassObjectFromURL(CLSID_NULL, szURL, dwFileVersionMS, dwFileVersionLS, NULL, spBindContext, CLSCTX_ALL, NULL, IID_IUnknown, NULL); } free(szURL); // Handle the internal binding synchronously so the object exists // or an error code is available when the method returns. if (useInternalBSC) { if (MK_S_ASYNCHRONOUS == hr) { m_bBindingInProgress = TRUE; m_hrBindResult = E_FAIL; // Spin around waiting for binding to complete HANDLE hFakeEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL); while (m_bBindingInProgress) { MSG msg; // Process pending messages while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!::GetMessage(&msg, NULL, 0, 0)) { m_bBindingInProgress = FALSE; break; } ::TranslateMessage(&msg); ::DispatchMessage(&msg); } if (!m_bBindingInProgress) break; // Sleep for a bit or the next msg to appear ::MsgWaitForMultipleObjects(1, &hFakeEvent, FALSE, 500, QS_ALLEVENTS); } ::CloseHandle(hFakeEvent); // Set the result hr = m_hrBindResult; } // Destroy the bind status callback & context if (spBindStatusCallback) { RevokeBindStatusCallback(spBindContext, spBindStatusCallback); spBindStatusCallback.Release(); spBindContext.Release(); } } //added to create control if (SUCCEEDED(hr)) { // Create the object hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void **) &spObject); if (SUCCEEDED(hr) && checkForObjectSafety) { // Assume scripting via IDispatch m_bSafeForScriptingObjectsOnly = m_pSecurityPolicy->IsObjectSafeForScripting(spObject, __uuidof(IDispatch)); } } //EOF test code } if (spObject) { m_spObject = spObject; CComQIPtr<IObjectWithSite> site = m_spObject; if (site) { site->SetSite(GetUnknown()); } } return hr; } // Attach the created control to a window and activate it HRESULT CControlSite::Attach(HWND hwndParent, const RECT &rcPos, IUnknown *pInitStream) { TRACE_METHOD(CControlSite::Attach); if (hwndParent == NULL) { NS_ASSERTION(0, "No parent hwnd"); return E_INVALIDARG; } m_hWndParent = hwndParent; m_rcObjectPos = rcPos; // Object must have been created if (m_spObject == NULL) { return E_UNEXPECTED; } m_spIOleControl = m_spObject; m_spIViewObject = m_spObject; m_spIOleObject = m_spObject; if (m_spIOleObject == NULL) { return E_FAIL; } if (m_spIOleControl) { m_spIOleControl->FreezeEvents(true); } DWORD dwMiscStatus; m_spIOleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus); if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) { m_bSetClientSiteFirst = TRUE; } if (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME) { m_bVisibleAtRuntime = FALSE; } // Some objects like to have the client site as the first thing // to be initialised (for ambient properties and so forth) if (m_bSetClientSiteFirst) { m_spIOleObject->SetClientSite(this); } // If there is a parameter list for the object and no init stream then // create one here. CPropertyBagInstance *pPropertyBag = NULL; if (pInitStream == NULL && m_ParameterList.GetSize() > 0) { CPropertyBagInstance::CreateInstance(&pPropertyBag); pPropertyBag->AddRef(); for (unsigned long i = 0; i < m_ParameterList.GetSize(); i++) { pPropertyBag->Write(m_ParameterList.GetNameOf(i), const_cast<VARIANT *>(m_ParameterList.GetValueOf(i))); } pInitStream = (IPersistPropertyBag *) pPropertyBag; } // Initialise the control from store if one is provided if (pInitStream) { CComQIPtr<IPropertyBag, &IID_IPropertyBag> spPropertyBag = pInitStream; CComQIPtr<IStream, &IID_IStream> spStream = pInitStream; CComQIPtr<IPersistStream, &IID_IPersistStream> spIPersistStream = m_spIOleObject; CComQIPtr<IPersistPropertyBag, &IID_IPersistPropertyBag> spIPersistPropertyBag = m_spIOleObject; if (spIPersistPropertyBag && spPropertyBag) { spIPersistPropertyBag->Load(spPropertyBag, NULL); } else if (spIPersistStream && spStream) { spIPersistStream->Load(spStream); } } else { // Initialise the object if possible CComQIPtr<IPersistStreamInit, &IID_IPersistStreamInit> spIPersistStreamInit = m_spIOleObject; if (spIPersistStreamInit) { spIPersistStreamInit->InitNew(); } } SIZEL size, sizein; sizein.cx = m_rcObjectPos.right - m_rcObjectPos.left; sizein.cy = m_rcObjectPos.bottom - m_rcObjectPos.top; SetControlSize(&sizein, &size); m_rcObjectPos.right = m_rcObjectPos.left + size.cx; m_rcObjectPos.bottom = m_rcObjectPos.top + size.cy; m_spIOleInPlaceObject = m_spObject; if (m_spIOleControl) { m_spIOleControl->FreezeEvents(false); } // In-place activate the object if (m_bVisibleAtRuntime) { DoVerb(OLEIVERB_INPLACEACTIVATE); } m_spIOleInPlaceObjectWindowless = m_spObject; // For those objects which haven't had their client site set yet, // it's done here. if (!m_bSetClientSiteFirst) { m_spIOleObject->SetClientSite(this); } return S_OK; } // Set the control size, in pixels. HRESULT CControlSite::SetControlSize(const LPSIZEL size, LPSIZEL out) { if (!size || !out) { return E_POINTER; } if (!m_spIOleObject) { return E_FAIL; } SIZEL szInitialHiMetric, szCustomHiMetric, szFinalHiMetric; SIZEL szCustomPixel, szFinalPixel; szFinalPixel = *size; szCustomPixel = *size; if (m_currentSize.cx == size->cx && m_currentSize.cy == size->cy) { // Don't need to change. return S_OK; } if (SUCCEEDED(m_spIOleObject->GetExtent(DVASPECT_CONTENT, &szInitialHiMetric))) { if (m_currentSize.cx == -1 && szCustomPixel.cx == 300 && szCustomPixel.cy == 150) { szFinalHiMetric = szInitialHiMetric; } else { AtlPixelToHiMetric(&szCustomPixel, &szCustomHiMetric); szFinalHiMetric = szCustomHiMetric; } } if (SUCCEEDED(m_spIOleObject->SetExtent(DVASPECT_CONTENT, &szFinalHiMetric))) { if (SUCCEEDED(m_spIOleObject->GetExtent(DVASPECT_CONTENT, &szFinalHiMetric))) { AtlHiMetricToPixel(&szFinalHiMetric, &szFinalPixel); } } m_currentSize = szFinalPixel; if (szCustomPixel.cx != szFinalPixel.cx && szCustomPixel.cy != szFinalPixel.cy) { m_needUpdateContainerSize = true; } *out = szFinalPixel; return S_OK; } // Unhook the control from the window and throw it all away HRESULT CControlSite::Detach() { TRACE_METHOD(CControlSite::Detach); if (m_spIOleInPlaceObjectWindowless) { m_spIOleInPlaceObjectWindowless.Release(); } CComQIPtr<IObjectWithSite> site = m_spObject; if (site) { site->SetSite(NULL); } if (m_spIOleInPlaceObject) { m_spIOleInPlaceObject->InPlaceDeactivate(); m_spIOleInPlaceObject.Release(); } if (m_spIOleObject) { m_spIOleObject->Close(OLECLOSE_NOSAVE); m_spIOleObject->SetClientSite(NULL); m_spIOleObject.Release(); } m_spIViewObject.Release(); m_spObject.Release(); return S_OK; } // Return the IUnknown of the contained control HRESULT CControlSite::GetControlUnknown(IUnknown **ppObject) { *ppObject = NULL; if (m_spObject) { m_spObject->QueryInterface(IID_IUnknown, (void **) ppObject); return S_OK; } else { return E_FAIL; } } // Subscribe to an event sink on the control HRESULT CControlSite::Advise(IUnknown *pIUnkSink, const IID &iid, DWORD *pdwCookie) { if (m_spObject == NULL) { return E_UNEXPECTED; } if (pIUnkSink == NULL || pdwCookie == NULL) { return E_INVALIDARG; } return AtlAdvise(m_spObject, pIUnkSink, iid, pdwCookie); } // Unsubscribe event sink from the control HRESULT CControlSite::Unadvise(const IID &iid, DWORD dwCookie) { if (m_spObject == NULL) { return E_UNEXPECTED; } return AtlUnadvise(m_spObject, iid, dwCookie); } // Draw the control HRESULT CControlSite::Draw(HDC hdc) { TRACE_METHOD(CControlSite::Draw); // Draw only when control is windowless or deactivated if (m_spIViewObject) { if (m_bWindowless || !m_bInPlaceActive) { RECTL *prcBounds = (m_bWindowless) ? NULL : (RECTL *) &m_rcObjectPos; m_spIViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, hdc, prcBounds, NULL, NULL, 0); } } else { // Draw something to indicate no control is there HBRUSH hbr = CreateSolidBrush(RGB(200,200,200)); FillRect(hdc, &m_rcObjectPos, hbr); DeleteObject(hbr); } return S_OK; } // Execute the specified verb HRESULT CControlSite::DoVerb(LONG nVerb, LPMSG lpMsg) { TRACE_METHOD(CControlSite::DoVerb); if (m_spIOleObject == NULL) { return E_FAIL; } // InstallAtlThunk(); return m_spIOleObject->DoVerb(nVerb, lpMsg, this, 0, m_hWndParent, &m_rcObjectPos); } // Set the position on the control HRESULT CControlSite::SetPosition(const RECT &rcPos) { HWND hwnd; TRACE_METHOD(CControlSite::SetPosition); m_rcObjectPos = rcPos; if (m_spIOleInPlaceObject && SUCCEEDED(m_spIOleInPlaceObject->GetWindow(&hwnd))) { m_spIOleInPlaceObject->SetObjectRects(&m_rcObjectPos, &m_rcObjectPos); } return S_OK; } HRESULT CControlSite::GetControlSize(LPSIZEL size){ if (m_spIOleObject) { SIZEL szHiMetric; HRESULT hr = m_spIOleObject->GetExtent(DVASPECT_CONTENT, &szHiMetric); AtlHiMetricToPixel(&szHiMetric, size); return hr; } return E_FAIL; } void CControlSite::FireAmbientPropertyChange(DISPID id) { if (m_spObject) { CComQIPtr<IOleControl> spControl = m_spObject; if (spControl) { spControl->OnAmbientPropertyChange(id); } } } void CControlSite::SetAmbientUserMode(BOOL bUserMode) { bool bNewMode = bUserMode ? true : false; if (m_bAmbientUserMode != bNewMode) { m_bAmbientUserMode = bNewMode; FireAmbientPropertyChange(DISPID_AMBIENT_USERMODE); } } /////////////////////////////////////////////////////////////////////////////// // CControlSiteSecurityPolicy implementation CControlSiteSecurityPolicy *CControlSite::GetDefaultControlSecurityPolicy() { static CDefaultControlSiteSecurityPolicy defaultControlSecurityPolicy; return &defaultControlSecurityPolicy; } /////////////////////////////////////////////////////////////////////////////// // IDispatch implementation HRESULT STDMETHODCALLTYPE CControlSite::GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlSite::GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlSite::GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlSite::Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr) { if (wFlags & DISPATCH_PROPERTYGET) { CComVariant vResult; switch (dispIdMember) { case DISPID_AMBIENT_APPEARANCE: vResult = CComVariant(m_bAmbientAppearance); break; case DISPID_AMBIENT_FORECOLOR: vResult = CComVariant((long) m_clrAmbientForeColor); break; case DISPID_AMBIENT_BACKCOLOR: vResult = CComVariant((long) m_clrAmbientBackColor); break; case DISPID_AMBIENT_LOCALEID: vResult = CComVariant((long) m_nAmbientLocale); break; case DISPID_AMBIENT_USERMODE: vResult = CComVariant(m_bAmbientUserMode); break; case DISPID_AMBIENT_SHOWGRABHANDLES: vResult = CComVariant(m_bAmbientShowGrabHandles); break; case DISPID_AMBIENT_SHOWHATCHING: vResult = CComVariant(m_bAmbientShowHatching); break; default: return DISP_E_MEMBERNOTFOUND; } VariantCopy(pVarResult, &vResult); return S_OK; } return E_FAIL; } /////////////////////////////////////////////////////////////////////////////// // IAdviseSink implementation void STDMETHODCALLTYPE CControlSite::OnDataChange(/* [unique][in] */ FORMATETC __RPC_FAR *pFormatetc, /* [unique][in] */ STGMEDIUM __RPC_FAR *pStgmed) { } void STDMETHODCALLTYPE CControlSite::OnViewChange(/* [in] */ DWORD dwAspect, /* [in] */ LONG lindex) { // Redraw the control InvalidateRect(NULL, FALSE); } void STDMETHODCALLTYPE CControlSite::OnRename(/* [in] */ IMoniker __RPC_FAR *pmk) { } void STDMETHODCALLTYPE CControlSite::OnSave(void) { } void STDMETHODCALLTYPE CControlSite::OnClose(void) { } /////////////////////////////////////////////////////////////////////////////// // IAdviseSink2 implementation void STDMETHODCALLTYPE CControlSite::OnLinkSrcChange(/* [unique][in] */ IMoniker __RPC_FAR *pmk) { } /////////////////////////////////////////////////////////////////////////////// // IAdviseSinkEx implementation void STDMETHODCALLTYPE CControlSite::OnViewStatusChange(/* [in] */ DWORD dwViewStatus) { } /////////////////////////////////////////////////////////////////////////////// // IOleWindow implementation HRESULT STDMETHODCALLTYPE CControlSite::GetWindow(/* [out] */ HWND __RPC_FAR *phwnd) { *phwnd = m_hWndParent; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::ContextSensitiveHelp(/* [in] */ BOOL fEnterMode) { return S_OK; } /////////////////////////////////////////////////////////////////////////////// // IOleClientSite implementation HRESULT STDMETHODCALLTYPE CControlSite::SaveObject(void) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::GetMoniker(/* [in] */ DWORD dwAssign, /* [in] */ DWORD dwWhichMoniker, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmk) { if (!ppmk) { return E_INVALIDARG; } if (dwWhichMoniker != OLEWHICHMK_CONTAINER) { return E_FAIL; } return CreateURLMoniker(NULL, url, ppmk); } void CControlSite::SetUrl(BSTR url) { this->url = url; } HRESULT STDMETHODCALLTYPE CControlSite::GetContainer(/* [out] */ IOleContainer __RPC_FAR *__RPC_FAR *ppContainer) { if (!ppContainer) return E_INVALIDARG; CComQIPtr<IOleContainer> container(this->GetUnknown()); *ppContainer = container; if (*ppContainer) { (*ppContainer)->AddRef(); } return (*ppContainer) ? S_OK : E_NOINTERFACE; } HRESULT STDMETHODCALLTYPE CControlSite::ShowObject(void) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnShowWindow(/* [in] */ BOOL fShow) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::RequestNewObjectLayout(void) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } /////////////////////////////////////////////////////////////////////////////// // IOleInPlaceSite implementation HRESULT STDMETHODCALLTYPE CControlSite::CanInPlaceActivate(void) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceActivate(void) { m_bInPlaceActive = TRUE; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnUIActivate(void) { m_bUIActive = TRUE; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::GetWindowContext(/* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, /* [out] */ LPRECT lprcPosRect, /* [out] */ LPRECT lprcClipRect, /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo) { *lprcPosRect = m_rcObjectPos; *lprcClipRect = m_rcObjectPos; CControlSiteIPFrameInstance *pIPFrame = NULL; CControlSiteIPFrameInstance::CreateInstance(&pIPFrame); pIPFrame->AddRef(); *ppFrame = (IOleInPlaceFrame *) pIPFrame; *ppDoc = NULL; lpFrameInfo->fMDIApp = FALSE; lpFrameInfo->hwndFrame = NULL; lpFrameInfo->haccel = NULL; lpFrameInfo->cAccelEntries = 0; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::Scroll(/* [in] */ SIZE scrollExtant) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnUIDeactivate(/* [in] */ BOOL fUndoable) { m_bUIActive = FALSE; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceDeactivate(void) { m_bInPlaceActive = FALSE; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::DiscardUndoState(void) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::DeactivateAndUndo(void) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnPosRectChange(/* [in] */ LPCRECT lprcPosRect) { if (lprcPosRect == NULL) { return E_INVALIDARG; } SetPosition(m_rcObjectPos); return S_OK; } /////////////////////////////////////////////////////////////////////////////// // IOleInPlaceSiteEx implementation HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceActivateEx(/* [out] */ BOOL __RPC_FAR *pfNoRedraw, /* [in] */ DWORD dwFlags) { m_bInPlaceActive = TRUE; if (pfNoRedraw) { *pfNoRedraw = FALSE; } if (dwFlags & ACTIVATE_WINDOWLESS) { if (!m_bSupportWindowlessActivation) { return E_INVALIDARG; } m_bWindowless = TRUE; } return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnInPlaceDeactivateEx(/* [in] */ BOOL fNoRedraw) { m_bInPlaceActive = FALSE; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::RequestUIActivate(void) { return S_FALSE; } /////////////////////////////////////////////////////////////////////////////// // IOleInPlaceSiteWindowless implementation HRESULT STDMETHODCALLTYPE CControlSite::CanWindowlessActivate(void) { // Allow windowless activation? return (m_bSupportWindowlessActivation) ? S_OK : S_FALSE; } HRESULT STDMETHODCALLTYPE CControlSite::GetCapture(void) { // TODO capture the mouse for the object return S_FALSE; } HRESULT STDMETHODCALLTYPE CControlSite::SetCapture(/* [in] */ BOOL fCapture) { // TODO capture the mouse for the object return S_FALSE; } HRESULT STDMETHODCALLTYPE CControlSite::GetFocus(void) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::SetFocus(/* [in] */ BOOL fFocus) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::GetDC(/* [in] */ LPCRECT pRect, /* [in] */ DWORD grfFlags, /* [out] */ HDC __RPC_FAR *phDC) { if (phDC == NULL) { return E_INVALIDARG; } // Can't do nested painting if (m_hDCBuffer != NULL) { return E_UNEXPECTED; } m_rcBuffer = m_rcObjectPos; if (pRect != NULL) { m_rcBuffer = *pRect; } m_hBMBuffer = NULL; m_dwBufferFlags = grfFlags; // See if the control wants a DC that is onscreen or offscreen if (m_dwBufferFlags & OLEDC_OFFSCREEN) { m_hDCBuffer = CreateCompatibleDC(NULL); if (m_hDCBuffer == NULL) { // Error return E_OUTOFMEMORY; } long cx = m_rcBuffer.right - m_rcBuffer.left; long cy = m_rcBuffer.bottom - m_rcBuffer.top; m_hBMBuffer = CreateCompatibleBitmap(m_hDCBuffer, cx, cy); m_hBMBufferOld = (HBITMAP) SelectObject(m_hDCBuffer, m_hBMBuffer); SetViewportOrgEx(m_hDCBuffer, m_rcBuffer.left, m_rcBuffer.top, NULL); // TODO When OLEDC_PAINTBKGND we must draw every site behind this one } else { // TODO When OLEDC_PAINTBKGND we must draw every site behind this one // Get the window DC m_hDCBuffer = GetWindowDC(m_hWndParent); if (m_hDCBuffer == NULL) { // Error return E_OUTOFMEMORY; } // Clip the control so it can't trash anywhere it isn't allowed to draw if (!(m_dwBufferFlags & OLEDC_NODRAW)) { m_hRgnBuffer = CreateRectRgnIndirect(&m_rcBuffer); // TODO Clip out opaque areas of sites behind this one SelectClipRgn(m_hDCBuffer, m_hRgnBuffer); } } *phDC = m_hDCBuffer; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::ReleaseDC(/* [in] */ HDC hDC) { // Release the DC if (hDC == NULL || hDC != m_hDCBuffer) { return E_INVALIDARG; } // Test if the DC was offscreen or onscreen if ((m_dwBufferFlags & OLEDC_OFFSCREEN) && !(m_dwBufferFlags & OLEDC_NODRAW)) { // BitBlt the buffer into the control's object SetViewportOrgEx(m_hDCBuffer, 0, 0, NULL); HDC hdc = GetWindowDC(m_hWndParent); long cx = m_rcBuffer.right - m_rcBuffer.left; long cy = m_rcBuffer.bottom - m_rcBuffer.top; BitBlt(hdc, m_rcBuffer.left, m_rcBuffer.top, cx, cy, m_hDCBuffer, 0, 0, SRCCOPY); ::ReleaseDC(m_hWndParent, hdc); } else { // TODO If OLEDC_PAINTBKGND is set draw the DVASPECT_CONTENT of every object above this one } // Clean up settings ready for next drawing if (m_hRgnBuffer) { SelectClipRgn(m_hDCBuffer, NULL); DeleteObject(m_hRgnBuffer); m_hRgnBuffer = NULL; } SelectObject(m_hDCBuffer, m_hBMBufferOld); if (m_hBMBuffer) { DeleteObject(m_hBMBuffer); m_hBMBuffer = NULL; } // Delete the DC if (m_dwBufferFlags & OLEDC_OFFSCREEN) { ::DeleteDC(m_hDCBuffer); } else { ::ReleaseDC(m_hWndParent, m_hDCBuffer); } m_hDCBuffer = NULL; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::InvalidateRect(/* [in] */ LPCRECT pRect, /* [in] */ BOOL fErase) { // Clip the rectangle against the object's size and invalidate it RECT rcI = { 0, 0, 0, 0 }; if (pRect == NULL) { rcI = m_rcObjectPos; } else { IntersectRect(&rcI, &m_rcObjectPos, pRect); } ::InvalidateRect(m_hWndParent, &rcI, fErase); return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::InvalidateRgn(/* [in] */ HRGN hRGN, /* [in] */ BOOL fErase) { if (hRGN == NULL) { ::InvalidateRect(m_hWndParent, &m_rcObjectPos, fErase); } else { // Clip the region with the object's bounding area HRGN hrgnClip = CreateRectRgnIndirect(&m_rcObjectPos); if (CombineRgn(hrgnClip, hrgnClip, hRGN, RGN_AND) != ERROR) { ::InvalidateRgn(m_hWndParent, hrgnClip, fErase); } DeleteObject(hrgnClip); } return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::ScrollRect(/* [in] */ INT dx, /* [in] */ INT dy, /* [in] */ LPCRECT pRectScroll, /* [in] */ LPCRECT pRectClip) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::AdjustRect(/* [out][in] */ LPRECT prc) { if (prc == NULL) { return E_INVALIDARG; } // Clip the rectangle against the object position RECT rcI = { 0, 0, 0, 0 }; IntersectRect(&rcI, &m_rcObjectPos, prc); *prc = rcI; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnDefWindowMessage(/* [in] */ UINT msg, /* [in] */ WPARAM wParam, /* [in] */ LPARAM lParam, /* [out] */ LRESULT __RPC_FAR *plResult) { if (plResult == NULL) { return E_INVALIDARG; } // Pass the message to the windowless control if (m_bWindowless && m_spIOleInPlaceObjectWindowless) { return m_spIOleInPlaceObjectWindowless->OnWindowMessage(msg, wParam, lParam, plResult); } else if (m_spIOleInPlaceObject) { HWND wnd; if (SUCCEEDED(m_spIOleInPlaceObject->GetWindow(&wnd))) SendMessage(wnd, msg, wParam, lParam); } return S_FALSE; } /////////////////////////////////////////////////////////////////////////////// // IOleControlSite implementation HRESULT STDMETHODCALLTYPE CControlSite::OnControlInfoChanged(void) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::LockInPlaceActive(/* [in] */ BOOL fLock) { m_bInPlaceLocked = fLock; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::GetExtendedControl(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDisp) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlSite::TransformCoords(/* [out][in] */ POINTL __RPC_FAR *pPtlHimetric, /* [out][in] */ POINTF __RPC_FAR *pPtfContainer, /* [in] */ DWORD dwFlags) { HRESULT hr = S_OK; if (pPtlHimetric == NULL) { return E_INVALIDARG; } if (pPtfContainer == NULL) { return E_INVALIDARG; } HDC hdc = ::GetDC(m_hWndParent); ::SetMapMode(hdc, MM_HIMETRIC); POINT rgptConvert[2]; rgptConvert[0].x = 0; rgptConvert[0].y = 0; if (dwFlags & XFORMCOORDS_HIMETRICTOCONTAINER) { rgptConvert[1].x = pPtlHimetric->x; rgptConvert[1].y = pPtlHimetric->y; ::LPtoDP(hdc, rgptConvert, 2); if (dwFlags & XFORMCOORDS_SIZE) { pPtfContainer->x = (float)(rgptConvert[1].x - rgptConvert[0].x); pPtfContainer->y = (float)(rgptConvert[0].y - rgptConvert[1].y); } else if (dwFlags & XFORMCOORDS_POSITION) { pPtfContainer->x = (float)rgptConvert[1].x; pPtfContainer->y = (float)rgptConvert[1].y; } else { hr = E_INVALIDARG; } } else if (dwFlags & XFORMCOORDS_CONTAINERTOHIMETRIC) { rgptConvert[1].x = (int)(pPtfContainer->x); rgptConvert[1].y = (int)(pPtfContainer->y); ::DPtoLP(hdc, rgptConvert, 2); if (dwFlags & XFORMCOORDS_SIZE) { pPtlHimetric->x = rgptConvert[1].x - rgptConvert[0].x; pPtlHimetric->y = rgptConvert[0].y - rgptConvert[1].y; } else if (dwFlags & XFORMCOORDS_POSITION) { pPtlHimetric->x = rgptConvert[1].x; pPtlHimetric->y = rgptConvert[1].y; } else { hr = E_INVALIDARG; } } else { hr = E_INVALIDARG; } ::ReleaseDC(m_hWndParent, hdc); return hr; } HRESULT STDMETHODCALLTYPE CControlSite::TranslateAccelerator(/* [in] */ MSG __RPC_FAR *pMsg, /* [in] */ DWORD grfModifiers) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlSite::OnFocus(/* [in] */ BOOL fGotFocus) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::ShowPropertyFrame(void) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } /////////////////////////////////////////////////////////////////////////////// // IBindStatusCallback implementation HRESULT STDMETHODCALLTYPE CControlSite::OnStartBinding(DWORD dwReserved, IBinding __RPC_FAR *pib) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::GetPriority(LONG __RPC_FAR *pnPriority) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnLowResource(DWORD reserved) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText) { return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnStopBinding(HRESULT hresult, LPCWSTR szError) { m_bBindingInProgress = FALSE; m_hrBindResult = hresult; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::GetBindInfo(DWORD __RPC_FAR *pgrfBINDF, BINDINFO __RPC_FAR *pbindInfo) { *pgrfBINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_GETNEWESTVERSION | BINDF_NOWRITECACHE; pbindInfo->cbSize = sizeof(BINDINFO); pbindInfo->szExtraInfo = NULL; memset(&pbindInfo->stgmedData, 0, sizeof(STGMEDIUM)); pbindInfo->grfBindInfoF = 0; pbindInfo->dwBindVerb = 0; pbindInfo->szCustomVerb = NULL; return S_OK; } HRESULT STDMETHODCALLTYPE CControlSite::OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC __RPC_FAR *pformatetc, STGMEDIUM __RPC_FAR *pstgmed) { ATLTRACE("Not implemnted"); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CControlSite::OnObjectAvailable(REFIID riid, IUnknown __RPC_FAR *punk) { return S_OK; } // IWindowForBindingUI HRESULT STDMETHODCALLTYPE CControlSite::GetWindow( /* [in] */ REFGUID rguidReason, /* [out] */ HWND *phwnd) { *phwnd = NULL; return S_OK; }
007slmg-np-activex-justep
ffactivex/common/ControlSite.cpp
C++
mpl11
45,015
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@netscape.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef CONTROLSITEIPFRAME_H #define CONTROLSITEIPFRAME_H class CControlSiteIPFrame : public CComObjectRootEx<CComSingleThreadModel>, public IOleInPlaceFrame { public: CControlSiteIPFrame(); virtual ~CControlSiteIPFrame(); HWND m_hwndFrame; BEGIN_COM_MAP(CControlSiteIPFrame) COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleInPlaceFrame) COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceUIWindow, IOleInPlaceFrame) COM_INTERFACE_ENTRY(IOleInPlaceFrame) END_COM_MAP() // IOleWindow virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd); virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode); // IOleInPlaceUIWindow implementation virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetBorder(/* [out] */ LPRECT lprectBorder); virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE RequestBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths); virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths); virtual HRESULT STDMETHODCALLTYPE SetActiveObject(/* [unique][in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject, /* [unique][string][in] */ LPCOLESTR pszObjName); // IOleInPlaceFrame implementation virtual HRESULT STDMETHODCALLTYPE InsertMenus(/* [in] */ HMENU hmenuShared, /* [out][in] */ LPOLEMENUGROUPWIDTHS lpMenuWidths); virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetMenu(/* [in] */ HMENU hmenuShared, /* [in] */ HOLEMENU holemenu, /* [in] */ HWND hwndActiveObject); virtual HRESULT STDMETHODCALLTYPE RemoveMenus(/* [in] */ HMENU hmenuShared); virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetStatusText(/* [in] */ LPCOLESTR pszStatusText); virtual HRESULT STDMETHODCALLTYPE EnableModeless(/* [in] */ BOOL fEnable); virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(/* [in] */ LPMSG lpmsg, /* [in] */ WORD wID); }; typedef CComObject<CControlSiteIPFrame> CControlSiteIPFrameInstance; #endif
007slmg-np-activex-justep
ffactivex/common/ControlSiteIPFrame.h
C++
mpl11
3,891
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@eircom.net> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef IOLECOMMANDIMPL_H #define IOLECOMMANDIMPL_H // Implementation of the IOleCommandTarget interface. The template is // reasonably generic and reusable which is a good thing given how needlessly // complicated this interface is. Blame Microsoft for that and not me. // // To use this class, derive your class from it like this: // // class CComMyClass : public IOleCommandTargetImpl<CComMyClass> // { // ... Ensure IOleCommandTarget is listed in the interface map ... // BEGIN_COM_MAP(CComMyClass) // COM_INTERFACE_ENTRY(IOleCommandTarget) // // etc. // END_COM_MAP() // ... And then later on define the command target table ... // BEGIN_OLECOMMAND_TABLE() // OLECOMMAND_MESSAGE(OLECMDID_PRINT, NULL, ID_PRINT, L"Print", L"Print the page") // OLECOMMAND_MESSAGE(OLECMDID_SAVEAS, NULL, 0, L"SaveAs", L"Save the page") // OLECOMMAND_HANDLER(IDM_EDITMODE, &CGID_MSHTML, EditModeHandler, L"EditMode", L"Switch to edit mode") // END_OLECOMMAND_TABLE() // ... Now the window that OLECOMMAND_MESSAGE sends WM_COMMANDs to ... // HWND GetCommandTargetWindow() const // { // return m_hWnd; // } // ... Now procedures that OLECOMMAND_HANDLER calls ... // static HRESULT _stdcall EditModeHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); // } // // The command table defines which commands the object supports. Commands are // defined by a command id and a command group plus a WM_COMMAND id or procedure, // and a verb and short description. // // Notice that there are two macros for handling Ole Commands. The first, // OLECOMMAND_MESSAGE sends a WM_COMMAND message to the window returned from // GetCommandTargetWindow() (that the derived class must implement if it uses // this macro). // // The second, OLECOMMAND_HANDLER calls a static handler procedure that // conforms to the OleCommandProc typedef. The first parameter, pThis means // the static handler has access to the methods and variables in the class // instance. // // The OLECOMMAND_HANDLER macro is generally more useful when a command // takes parameters or needs to return a result to the caller. // template< class T > class IOleCommandTargetImpl : public IOleCommandTarget { struct OleExecData { const GUID *pguidCmdGroup; DWORD nCmdID; DWORD nCmdexecopt; VARIANT *pvaIn; VARIANT *pvaOut; }; public: typedef HRESULT (_stdcall *OleCommandProc)(T *pT, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut); struct OleCommandInfo { ULONG nCmdID; const GUID *pCmdGUID; ULONG nWindowsCmdID; OleCommandProc pfnCommandProc; wchar_t *szVerbText; wchar_t *szStatusText; }; // Query the status of the specified commands (test if is it supported etc.) virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID __RPC_FAR *pguidCmdGroup, ULONG cCmds, OLECMD __RPC_FAR prgCmds[], OLECMDTEXT __RPC_FAR *pCmdText) { T* pT = static_cast<T*>(this); if (prgCmds == NULL) { return E_INVALIDARG; } OleCommandInfo *pCommands = pT->GetCommandTable(); ATLASSERT(pCommands); BOOL bCmdGroupFound = FALSE; BOOL bTextSet = FALSE; // Iterate through list of commands and flag them as supported/unsupported for (ULONG nCmd = 0; nCmd < cCmds; nCmd++) { // Unsupported by default prgCmds[nCmd].cmdf = 0; // Search the support command list for (int nSupported = 0; pCommands[nSupported].pCmdGUID != &GUID_NULL; nSupported++) { OleCommandInfo *pCI = &pCommands[nSupported]; if (pguidCmdGroup && pCI->pCmdGUID && memcmp(pguidCmdGroup, pCI->pCmdGUID, sizeof(GUID)) == 0) { continue; } bCmdGroupFound = TRUE; if (pCI->nCmdID != prgCmds[nCmd].cmdID) { continue; } // Command is supported so flag it and possibly enable it prgCmds[nCmd].cmdf = OLECMDF_SUPPORTED; if (pCI->nWindowsCmdID != 0) { prgCmds[nCmd].cmdf |= OLECMDF_ENABLED; } // Copy the status/verb text for the first supported command only if (!bTextSet && pCmdText) { // See what text the caller wants wchar_t *pszTextToCopy = NULL; if (pCmdText->cmdtextf & OLECMDTEXTF_NAME) { pszTextToCopy = pCI->szVerbText; } else if (pCmdText->cmdtextf & OLECMDTEXTF_STATUS) { pszTextToCopy = pCI->szStatusText; } // Copy the text pCmdText->cwActual = 0; memset(pCmdText->rgwz, 0, pCmdText->cwBuf * sizeof(wchar_t)); if (pszTextToCopy) { // Don't exceed the provided buffer size size_t nTextLen = wcslen(pszTextToCopy); if (nTextLen > pCmdText->cwBuf) { nTextLen = pCmdText->cwBuf; } wcsncpy(pCmdText->rgwz, pszTextToCopy, nTextLen); pCmdText->cwActual = nTextLen; } bTextSet = TRUE; } break; } } // Was the command group found? if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; } return S_OK; } // Execute the specified command virtual HRESULT STDMETHODCALLTYPE Exec(const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT __RPC_FAR *pvaIn, VARIANT __RPC_FAR *pvaOut) { T* pT = static_cast<T*>(this); BOOL bCmdGroupFound = FALSE; OleCommandInfo *pCommands = pT->GetCommandTable(); ATLASSERT(pCommands); // Search the support command list for (int nSupported = 0; pCommands[nSupported].pCmdGUID != &GUID_NULL; nSupported++) { OleCommandInfo *pCI = &pCommands[nSupported]; if (pguidCmdGroup && pCI->pCmdGUID && memcmp(pguidCmdGroup, pCI->pCmdGUID, sizeof(GUID)) == 0) { continue; } bCmdGroupFound = TRUE; if (pCI->nCmdID != nCmdID) { continue; } // Send ourselves a WM_COMMAND windows message with the associated // identifier and exec data OleExecData cData; cData.pguidCmdGroup = pguidCmdGroup; cData.nCmdID = nCmdID; cData.nCmdexecopt = nCmdexecopt; cData.pvaIn = pvaIn; cData.pvaOut = pvaOut; if (pCI->pfnCommandProc) { pCI->pfnCommandProc(pT, pCI->pCmdGUID, pCI->nCmdID, nCmdexecopt, pvaIn, pvaOut); } else if (pCI->nWindowsCmdID != 0 && nCmdexecopt != OLECMDEXECOPT_SHOWHELP) { HWND hwndTarget = pT->GetCommandTargetWindow(); if (hwndTarget) { ::SendMessage(hwndTarget, WM_COMMAND, LOWORD(pCI->nWindowsCmdID), (LPARAM) &cData); } } else { // Command supported but not implemented continue; } return S_OK; } // Was the command group found? if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; } return OLECMDERR_E_NOTSUPPORTED; } }; // Macros to be placed in any class derived from the IOleCommandTargetImpl // class. These define what commands are exposed from the object. #define BEGIN_OLECOMMAND_TABLE() \ OleCommandInfo *GetCommandTable() \ { \ static OleCommandInfo s_aSupportedCommands[] = \ { #define OLECOMMAND_MESSAGE(id, group, cmd, verb, desc) \ { id, group, cmd, NULL, verb, desc }, #define OLECOMMAND_HANDLER(id, group, handler, verb, desc) \ { id, group, 0, handler, verb, desc }, #define END_OLECOMMAND_TABLE() \ { 0, &GUID_NULL, 0, NULL, NULL, NULL } \ }; \ return s_aSupportedCommands; \ }; #endif
007slmg-np-activex-justep
ffactivex/common/IOleCommandTargetImpl.h
C++
mpl11
10,589
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@eircom.net> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef PROPERTYLIST_H #define PROPERTYLIST_H // A simple array class for managing name/value pairs typically fed to controls // during initialization by IPersistPropertyBag class PropertyList { struct Property { BSTR bstrName; VARIANT vValue; } *mProperties; unsigned long mListSize; unsigned long mMaxListSize; bool EnsureMoreSpace() { // Ensure enough space exists to accomodate a new item const unsigned long kGrowBy = 10; if (!mProperties) { mProperties = (Property *) malloc(sizeof(Property) * kGrowBy); if (!mProperties) return false; mMaxListSize = kGrowBy; } else if (mListSize == mMaxListSize) { Property *pNewProperties; pNewProperties = (Property *) realloc(mProperties, sizeof(Property) * (mMaxListSize + kGrowBy)); if (!pNewProperties) return false; mProperties = pNewProperties; mMaxListSize += kGrowBy; } return true; } public: PropertyList() : mProperties(NULL), mListSize(0), mMaxListSize(0) { } ~PropertyList() { } void Clear() { if (mProperties) { for (unsigned long i = 0; i < mListSize; i++) { SysFreeString(mProperties[i].bstrName); // Safe even if NULL VariantClear(&mProperties[i].vValue); } free(mProperties); mProperties = NULL; } mListSize = 0; mMaxListSize = 0; } unsigned long GetSize() const { return mListSize; } const BSTR GetNameOf(unsigned long nIndex) const { if (nIndex > mListSize) { return NULL; } return mProperties[nIndex].bstrName; } const VARIANT *GetValueOf(unsigned long nIndex) const { if (nIndex > mListSize) { return NULL; } return &mProperties[nIndex].vValue; } bool AddOrReplaceNamedProperty(const BSTR bstrName, const VARIANT &vValue) { if (!bstrName) return false; for (unsigned long i = 0; i < GetSize(); i++) { // Case insensitive if (wcsicmp(mProperties[i].bstrName, bstrName) == 0) { return SUCCEEDED( VariantCopy(&mProperties[i].vValue, const_cast<VARIANT *>(&vValue))); } } return AddNamedProperty(bstrName, vValue); } bool AddNamedProperty(const BSTR bstrName, const VARIANT &vValue) { if (!bstrName || !EnsureMoreSpace()) return false; Property *pProp = &mProperties[mListSize]; pProp->bstrName = ::SysAllocString(bstrName); if (!pProp->bstrName) { return false; } VariantInit(&pProp->vValue); if (FAILED(VariantCopy(&pProp->vValue, const_cast<VARIANT *>(&vValue)))) { SysFreeString(pProp->bstrName); return false; } mListSize++; return true; } }; #endif
007slmg-np-activex-justep
ffactivex/common/PropertyList.h
C++
mpl11
5,004
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adam Lock <adamlock@eircom.net> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef ITEMCONTAINER_H #define ITEMCONTAINER_H // typedef std::map<tstring, CIUnkPtr> CNamedObjectList; // Class for managing a list of named objects. class CItemContainer : public CComObjectRootEx<CComSingleThreadModel>, public IOleItemContainer { // CNamedObjectList m_cNamedObjectList; public: CItemContainer(); virtual ~CItemContainer(); BEGIN_COM_MAP(CItemContainer) COM_INTERFACE_ENTRY_IID(IID_IParseDisplayName, IOleItemContainer) COM_INTERFACE_ENTRY_IID(IID_IOleContainer, IOleItemContainer) COM_INTERFACE_ENTRY_IID(IID_IOleItemContainer, IOleItemContainer) END_COM_MAP() // IParseDisplayName implementation virtual HRESULT STDMETHODCALLTYPE ParseDisplayName(/* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ LPOLESTR pszDisplayName, /* [out] */ ULONG __RPC_FAR *pchEaten, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmkOut); // IOleContainer implementation virtual HRESULT STDMETHODCALLTYPE EnumObjects(/* [in] */ DWORD grfFlags, /* [out] */ IEnumUnknown __RPC_FAR *__RPC_FAR *ppenum); virtual HRESULT STDMETHODCALLTYPE LockContainer(/* [in] */ BOOL fLock); // IOleItemContainer implementation virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetObject(/* [in] */ LPOLESTR pszItem, /* [in] */ DWORD dwSpeedNeeded, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetObjectStorage(/* [in] */ LPOLESTR pszItem, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvStorage); virtual HRESULT STDMETHODCALLTYPE IsRunning(/* [in] */ LPOLESTR pszItem); }; typedef CComObject<CItemContainer> CItemContainerInstance; #endif
007slmg-np-activex-justep
ffactivex/common/ItemContainer.h
C++
mpl11
3,631
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor: * Chuan Qiu <qiuc12@gmail.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #pragma once #include "Host.h" #include <atlsafe.h> #include "objectProxy.h" class NPSafeArray: public ScriptBase { public: NPSafeArray(NPP npp); ~NPSafeArray(void); static NPSafeArray* CreateFromArray(NPP instance, SAFEARRAY* array); static void RegisterVBArray(NPP npp); static NPClass npClass; SAFEARRAY* NPSafeArray::GetArrayPtr(); private: static NPInvokeDefaultFunctionPtr GetFuncPtr(NPIdentifier name); CComSafeArray<VARIANT> arr_; NPObjectProxy window; // Some wrappers to adapt NPAPI's interface. static NPObject* Allocate(NPP npp, NPClass *aClass); static void Deallocate(NPObject *obj); static void Invalidate(NPObject *obj); static bool HasMethod(NPObject *npobj, NPIdentifier name); static bool Invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result); static bool InvokeDefault(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); static bool GetItem(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); static bool ToArray(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); static bool UBound(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); static bool LBound(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); static bool Dimensions(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); static bool HasProperty(NPObject *npobj, NPIdentifier name); static bool GetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result); static bool SetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value); };
007slmg-np-activex-justep
ffactivex/NPSafeArray.h
C++
mpl11
3,324
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is RSJ Software GmbH code. * * The Initial Developer of the Original Code is * RSJ Software GmbH. * Portions created by the Initial Developer are Copyright (C) 2009 * the Initial Developer. All Rights Reserved. * * Contributors: * Ruediger Jungbeck <ruediger.jungbeck@rsj.de> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ BOOL TestAuthorization (NPP Instance, int16 ArgC, char *ArgN[], char *ArgV[], const char *MimeType);
007slmg-np-activex-justep
ffactivex/authorize.h
C
mpl11
2,050
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor: * Chuan Qiu <qiuc12@gmail.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #pragma once #include <npapi.h> #include <npruntime.h> struct ScriptBase; class CHost { public: void AddRef(); void Release(); CHost(NPP npp); virtual ~CHost(void); NPObject *GetScriptableObject(); NPP GetInstance() { return instance; } static CHost *GetInternalObject(NPP npp, NPObject *embed_element); NPObject *RegisterObject(); void UnRegisterObject(); virtual NPP ResetNPP(NPP newNpp); protected: NPP instance; ScriptBase *lastObj; ScriptBase *GetMyScriptObject(); virtual ScriptBase *CreateScriptableObject() = 0; private: int ref_cnt_; }; struct ScriptBase: NPObject { NPP instance; CHost* host; ScriptBase(NPP instance_) : instance(instance_) { } };
007slmg-np-activex-justep
ffactivex/Host.h
C++
mpl11
2,241
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="/list.css" /> <link rel="stylesheet" type="text/css" href="/options.css" /> <script src="/jquery.js"></script> <script src="/configure.js"></script> <script src="/i18n.js"></script> <script src="/list.js"></script> <script src="/listtypes.js"></script> <script src="/options.js"></script> <script src="/gas.js"></script> <title i18n="option_title"></title> </head> <body> <div class="description"> <span i18n="option_help"></span> <a class="help" i18n="help" target="_blank"></a> <a href="donate.html" target="_blank" i18n="donate"></a> </div> <div id="tbSetting"> </div> <div> <div style="float:left"> <div id="ruleCmds"> <button id="addRule" i18n="add"></button> <button id="deleteRule" i18n="delete"></button> <button id="moveUp" i18n="moveUp"></button> <button id="moveDown" i18n="moveDown"></button> </div> <div style="margin-top:15px"> <input id="log_enable" type="checkbox"> <span i18n="log_enable"> </span> </input> <input id="tracking" type="checkbox"> <span i18n="tracking"> </span> </input> </div> </div> <script src="share.js"></script> </div> <div id="footer" style="clear:both"> <span i18n="copyright"> </span> <a href="donate.html" target="_blank" i18n="donate"></a> <a class="help" i18n="help" target="_blank"></a> <a href="log.html" i18n="view_log" target="_blank"></a> <span id="follow"> <iframe width="136" height="24" frameborder="0" allowtransparency="true" marginwidth="0" marginheight="0" scrolling="no" border="0" src="http://widget.weibo.com/relationship/followbutton.php?language=zh_cn&width=136&height=24&uid=2356524070&style=2&btn=red&dpc=1"></iframe> </span> </div> </body> </html>
007slmg-np-activex-justep
chrome/options.html
HTML
mpl11
2,115
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var tabStatus = {}; var version; var firstRun = false; var firstUpgrade = false; var blackList = [ /^https?:\/\/[^\/]*\.taobao\.com\/.*/i, /^https?:\/\/[^\/]*\.alipay\.com\/.*/i ]; var MAX_LOG = 400; (function getVersion() { $.ajax('manifest.json', { success: function(v) { v = JSON.parse(v); version = v.version; trackVersion(version); } }); })(); function startListener() { chrome.extension.onConnect.addListener(function(port) { if (!port.sender.tab) { console.error('Not connect from tab'); return; } initPort(port); }); chrome.extension.onRequest.addListener( function(request, sender, sendResponse) { if (!sender.tab) { console.error('Request from non-tab'); } else if (request.command == 'Configuration') { var config = setting.getPageConfig(request.href); sendResponse(config); if (request.top) { resetTabStatus(sender.tab.id); var dummy = {href: request.href, clsid: 'NULL', urldetect: true}; if (!config.pageRule && setting.getFirstMatchedRule( dummy, setting.defaultRules)) { detectControl(dummy, sender.tab.id, 0); } } } else if (request.command == 'GetNotification') { getNotification(request, sender, sendResponse); } else if (request.command == 'DismissNotification') { chrome.tabs.sendRequest( sender.tab.id, {command: 'DismissNotificationPage'}); sendResponse({}); } else if (request.command == 'BlockSite') { setting.blocked.push({type: 'wild', value: request.site}); setting.update(); sendResponse({}); } } ); } var blocked = {}; function notifyUser(request, tabId) { var s = tabStatus[tabId]; if (s.notify && (s.urldetect || s.count > s.actived)) { console.log('Notify the user on tab ', tabId); chrome.tabs.sendRequest(tabId, {command: 'NotifyUser', tabid: tabId}, null); } } var greenIcon = chrome.extension.getURL('icon16.png'); var grayIcon = chrome.extension.getURL('icon16-gray.png'); var errorIcon = chrome.extension.getURL('icon16-error.png'); var responseCommands = {}; function resetTabStatus(tabId) { tabStatus[tabId] = { count: 0, actived: 0, error: 0, urldetect: 0, notify: true, issueId: null, logs: {'0': []}, objs: {'0': []}, frames: 1, tracking: false }; } function initPort(port) { var tabId = port.sender.tab.id; if (!(tabId in tabStatus)) { resetTabStatus(tabId); } var status = tabStatus[tabId]; var frameId = tabStatus[tabId].frames++; status.logs[frameId] = []; status.objs[frameId] = []; port.onMessage.addListener(function(request) { var resp = responseCommands[request.command]; if (resp) { delete request.command; resp(request, tabId, frameId); } else { console.error('Unknown command ' + request.command); } }); port.onDisconnect.addListener(function() { for (var i = 0; i < status.objs[frameId].length; ++i) { countTabObject(status, status.objs[frameId][i], -1); } showTabStatus(tabId); if (status.tracking) { if (status.count == 0) { // Open the log page. window.open('log.html?tabid=' + tabId); status.tracking = false; } } else { // Clean up after 1 min. window.setTimeout(function() { status.logs[frameId] = []; status.objs[frameId] = []; }, 60 * 1000); } }); } chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) { if (tabStatus[tabId]) { tabStatus[tabId].removed = true; var TIMEOUT = 1000 * 60 * 5; // clean up after 5 mins. window.setTimeout(function() { delete tabStatus[tabId]; }, TIMEOUT); } }); function countTabObject(status, info, delta) { for (var i = 0; i < blackList.length; ++i) { if (info.href.match(blackList[i])) { return; } } if (setting.getFirstMatchedRule(info, setting.blocked)) { status.notify = false; } if (info.urldetect) { status.urldetect += delta; // That's not a object. return; } if (info.actived) { status.actived += delta; if (delta > 0) { trackUse(info.rule); } } else if (delta > 0) { trackNotUse(info.href); } status.count += delta; var issue = setting.getMatchedIssue(info); if (issue) { status.error += delta; status.issueId = issue.identifier; if (delta > 0) { trackIssue(issue); } } } function showTabStatus(tabId) { if (tabStatus[tabId].removed) { return; } var status = tabStatus[tabId]; var title = ''; var iconPath = greenIcon; if (!status.count && !status.urldetect) { chrome.pageAction.hide(tabId); return; } else { chrome.pageAction.show(tabId); } if (status.urldetect) { // Matched some rule. iconPath = grayIcon; title = $$('status_urldetect'); } else if (status.count == 0) { // Do nothing.. } else if (status.error != 0) { // Error iconPath = errorIcon; title = $$('status_error'); } else if (status.count != status.actived) { // Disabled.. iconPath = grayIcon; title = $$('status_disabled'); } else { // OK iconPath = greenIcon; title = $$('status_ok'); } chrome.pageAction.setIcon({ tabId: tabId, path: iconPath }); chrome.pageAction.setTitle({ tabId: tabId, title: title }); chrome.pageAction.setPopup({ tabId: tabId, popup: 'popup.html?tabid=' + tabId }); } function detectControl(request, tabId, frameId) { var status = tabStatus[tabId]; if (frameId != 0 && status.objs[0].length) { // Remove the item to identify the page. countTabObject(status, status.objs[0][0], -1); status.objs[0] = []; } status.objs[frameId].push(request); countTabObject(status, request, 1); showTabStatus(tabId); notifyUser(request, tabId); } responseCommands.DetectControl = detectControl; responseCommands.Log = function(request, tabId, frameId) { var logs = tabStatus[tabId].logs[frameId]; if (logs.length < MAX_LOG) { logs.push(request.message); } else if (logs.length == MAX_LOG) { logs.push('More logs clipped'); } }; function generateLogFile(tabId) { var status = tabStatus[tabId]; if (!status) { return 'No log for tab ' + tabId; } var ret = '---------- Start of log --------------\n'; ret += 'UserAgent: ' + navigator.userAgent + '\n'; ret += 'Extension version: ' + version + '\n'; ret += '\n'; var frameCount = 0; for (var i = 0; i < status.frames; ++i) { if (status.objs[i].length == 0 && status.logs[i].length == 0) { continue; } if (frameCount) { ret += '\n\n'; } ++frameCount; ret += '------------ Frame ' + (i + 1) + ' ------------------\n'; ret += 'Objects:\n'; for (var j = 0; j < status.objs[i].length; ++j) { ret += JSON.stringify(status.objs[i][j]) + '\n'; } ret += '\n'; ret += 'Log:\n'; for (var j = 0; j < status.logs[i].length; ++j) { ret += status.logs[i][j] + '\n'; } } ret += '\n---------------- End of log ---------------\n'; ret += stringHash(ret); if (frameCount == 0) { return 'No log for tab ' + tabId; } return ret; } function getNotification(request, sender, sendResponse) { var tabid = sender.tab.id; chrome.tabs.get(tabid, function(tab) { var config = {}; config.tabId = tab.id; config.site = tab.url.replace(/[^:]*:\/\/([^\/]*).*/, '$1'); config.sitePattern = tab.url.replace(/([^:]*:\/\/[^\/]*).*/, '$1/*'); if (tabStatus[tabid].urldetect) { config.message = $$('status_urldetect'); } else { config.message = $$('status_disabled'); } config.closeMsg = $$('bar_close'); config.enableMsg = $$('bar_enable'); config.blockMsg = $$('bar_block', config.site); sendResponse(config); }); }
007slmg-np-activex-justep
chrome/common.js
JavaScript
mpl11
8,465
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. // Permission for experimental not given. var handler = chrome.webRequest; function onBeforeSendHeaders(details) { var rule = setting.getFirstMatchedRule( {href: details.url}, setting.cache.userAgent); if (!rule || !(rule.userAgent in agents)) { return {}; } for (var i = 0; i < details.requestHeaders.length; ++i) { if (details.requestHeaders[i].name == 'User-Agent') { details.requestHeaders[i].value = agents[rule.userAgent]; break; } } return {requestHeaders: details.requestHeaders}; } function registerRequestListener() { if (!handler) { return; } var filters = { urls: ['<all_urls>'], types: ['main_frame', 'sub_frame', 'xmlhttprequest'] }; try { handler.onBeforeSendHeaders.addListener( onBeforeSendHeaders, filters, ['requestHeaders', 'blocking']); } catch (e) { console.log('Your browser doesn\'t support webRequest'); } }
007slmg-np-activex-justep
chrome/web.js
JavaScript
mpl11
1,139
body { background-color: #ffd; } body > div { margin: 10px; max-width: 1000px; } #tbSetting { width: 1000px; height: 500px; } .itemline.newline:not(.editing) { display:none; } div[property=status] { width: 75px } div[property=title] { width: 200px } div[property=type] { width: 60px } div[property=value] { width: 320px } div[property=userAgent] { width: 80px } div[property=script] { width: 350px } [property=status] button { width: 70px; } #ruleCmds button { width: 100px; margin: 4px 8px 3px 8px; } #share { float:left; padding: 5px 0 0 40px; height: 100px; } #footer * { margin: 0 10px; }
007slmg-np-activex-justep
chrome/options.css
CSS
mpl11
696
.list { width: 800px; height: 400px; font-family: Arial, sans-serif; overflow-x: hidden; border: 3px solid #0D5995; background-color: #0D5995; padding: 1px; padding-top: 10px; border-top-left-radius: 15px; border-top-right-radius: 15px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; } .listscroll { overflow-x: scroll; overflow-y: scroll; background-color: white; } .listitems { display: inline-block; } .listvalue, .header { display: inline-block; width: 80px; margin: 0px 6px; } .headers { background-color: transparent; position: relative; white-space: nowrap; display: inline-block; color:white; padding: 5px 0px; } .header{ white-space: normal; } .itemline { height: 32px; } .itemline:nth-child(odd) { background-color: white; } .itemline:nth-child(even) { background-color: whitesmoke; } .itemline.selected { background-color: #aaa; } .itemline:hover { background-color: #bbcee9 } .itemline.error, .itemline.error:hover { background-color: salmon; } .itemline > div { white-space: nowrap; padding: 4px 0px 0 0; } .itemline.editing > div{ padding: 3px 0px 0 0; } .valdisp, .valinput { background-color: transparent; width: 100%; display: block; } .listvalue { overflow-x: hidden; } .itemline.editing .listvalue:not(.readonly) .valdisp { display: none; } .valdisp { font-size: 13px; } .itemline:not(.editing) .valinput, .listvalue.readonly .valinput { display: none; } .itemline :focus { outline: none; } .valinput { border:1px solid #aaa; background-color: white; padding: 3px; margin: 0; } .itemline .valinput:focus { outline-color: rgba(0, 128, 256, 0.5); outline: 5px auto rgba(0, 128, 256, 0.5); }
007slmg-np-activex-justep
chrome/list.css
CSS
mpl11
1,865
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. /* Rule: { identifier: an unique identifier title: description type: Can be "wild", "regex", "clsid" value: pattern, correspond to type userAgent: the useragent value. See var "agents" for options. script: script to inject. Separated by spaces } Order: { status: enabled / disabled / custom position: default / custom identifier: identifier of rule } Issue: { type: Can be "wild", "regex", "clsid" value: pattern, correspond to type description: The description of this issue issueId: Issue ID on issue tracking page url: optional, support page for issue tracking. Use code.google.com if omitted. } ServerSide: ActiveXConfig: { version: version rules: object of user-defined rules, propertied by identifiers defaultRules: ojbect of default rules scripts: mapping of workaround scripts, by identifiers. order: the order of rules cache: to accerlerate processing issues: The bugs/unsuppoted sites that we have accepted. misc:{ lastUpdate: last timestamp of updating logEnabled: log tracking: Allow GaS tracking. verbose: verbose level of logging } } PageSide: ActiveXConfig: { pageSide: Flag of pageSide. pageScript: Helper script to execute on context of page extScript: Helper script to execute on context of extension pageRule: If page is matched. clsidRules: If page is not matched or disabled. valid CLSID rules logEnabled: log verbose: verbose level of logging } */ function ActiveXConfig(input) { var settings; if (input === undefined) { var defaultSetting = { version: 3, rules: {}, defaultRules: {}, scriptContents: {}, scripts: {}, order: [], notify: [], issues: [], blocked: [], misc: { lastUpdate: 0, logEnabled: false, tracking: true, verbose: 3 } }; input = defaultSetting; } settings = ActiveXConfig.convertVersion(input); settings.removeInvalidItems(); settings.update(); return settings; } var settingKey = 'setting'; clsidPattern = /[^0-9A-F][0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}[^0-9A-F]/; var agents = { ie9: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)', ie8: 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0)', ie7: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64;)', ff7win: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1)' + ' Gecko/20100101 Firefox/7.0.1', ip5: 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X)' + ' AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1' + ' Mobile/9A334 Safari/7534.48.3', ipad5: 'Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46' + '(KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3' }; function getUserAgent(key) { // This script is always run under sandbox, so useragent should be always // correct. if (!key || !(key in agents)) { return ''; } var current = navigator.userAgent; var wow64 = current.indexOf('WOW64') >= 0; var value = agents[key]; if (!wow64) { value = value.replace(' WOW64;', ''); } return value; } ActiveXConfig.convertVersion = function(setting) { if (setting.version == 3) { if (!setting.blocked) { setting.blocked = []; } setting.__proto__ = ActiveXConfig.prototype; return setting; } else if (setting.version == 2) { function parsePattern(pattern) { pattern = pattern.trim(); var title = pattern.match(/###(.*)/); if (title) { return { pattern: pattern.match(/(.*)###/)[1].trim(), title: title[1].trim() }; } else { return { pattern: pattern, title: 'Rule' }; } } var ret = new ActiveXConfig(); if (setting.logEnabled) { ret.misc.logEnabled = true; } var urls = setting.url_plain.split('\n'); for (var i = 0; i < urls.length; ++i) { var rule = ret.createRule(); var pattern = parsePattern(urls[i]); rule.title = pattern.title; var url = pattern.pattern; if (url.substr(0, 2) == 'r/') { rule.type = 'regex'; rule.value = url.substr(2); } else { rule.type = 'wild'; rule.value = url; } ret.addCustomRule(rule, 'convert'); } var clsids = setting.trust_clsids.split('\n'); for (var i = 0; i < clsids.length; ++i) { var rule = ret.createRule(); rule.type = 'clsid'; var pattern = parsePattern(clsids[i]); rule.title = pattern.title; rule.value = pattern.pattern; ret.addCustomRule(rule, 'convert'); } firstUpgrade = true; return ret; } }; ActiveXConfig.prototype = { // Only used for user-scripts shouldEnable: function(object) { if (this.pageRule) { return this.pageRule; } var clsidRule = this.getFirstMatchedRule(object, this.clsidRules); if (clsidRule) { return clsidRule; } else { return null; } }, createRule: function() { return { title: 'Rule', type: 'wild', value: '', userAgent: '', scriptItems: '' }; }, removeInvalidItems: function() { if (this.pageSide) { return; } function checkIdentifierMatches(item, prop) { if (typeof item[prop] != 'object') { console.log('reset ', prop); item[prop] = {}; } for (var i in item[prop]) { var ok = true; if (typeof item[prop][i] != 'object') { ok = false; } if (ok && item[prop][i].identifier != i) { ok = false; } if (!ok) { console.log('remove corrupted item ', i, ' in ', prop); delete item[prop][i]; } } } checkIdentifierMatches(this, 'rules'); checkIdentifierMatches(this, 'defaultRules'); checkIdentifierMatches(this, 'scripts'); checkIdentifierMatches(this, 'issues'); var newOrder = []; for (var i = 0; i < this.order.length; ++i) { if (this.getItem(this.order[i])) { newOrder.push(this.order[i]); } else { console.log('remove order item ', this.order[i]); } } this.order = newOrder; }, addCustomRule: function(newItem, auto) { if (!this.validateRule(newItem)) { return; } var identifier = this.createIdentifier(); newItem.identifier = identifier; this.rules[identifier] = newItem; this.order.push({ status: 'custom', position: 'custom', identifier: identifier }); this.update(); trackAddCustomRule(newItem, auto); }, updateDefaultRules: function(newRules) { var deleteAll = false, ruleToDelete = {}; if (typeof this.defaultRules != 'object') { // There might be some errors! // Clear all defaultRules console.log('Corrupted default rules, reload all'); deleteAll = true; this.defaultRules = {}; } else { for (var i in this.defaultRules) { if (!(i in newRules)) { console.log('Remove rule ' + i); ruleToDelete[i] = true; delete this.defaultRules[i]; } } } var newOrder = []; for (var i = 0; i < this.order.length; ++i) { if (this.order[i].position == 'custom' || (!deleteAll && !ruleToDelete[this.order[i].identifier])) { newOrder.push(this.order[i]); } } this.order = newOrder; var position = 0; for (var i in newRules) { if (!(i in this.defaultRules)) { this.addDefaultRule(newRules[i], position); position++; } this.defaultRules[i] = newRules[i]; } }, loadDefaultConfig: function() { var setting = this; $.ajax({ url: '/settings/setting.json', dataType: 'json', success: function(nv, status, xhr) { console.log('Update default rules'); setting.updateDefaultRules(nv); setting.update(); } }); $.ajax({ url: '/settings/scripts.json', dataType: 'json', success: function(nv, status, xhr) { console.log('Update scripts'); setting.scripts = nv; setting.loadAllScripts(); setting.update(); } }); $.ajax({ url: '/settings/issues.json', dataType: 'json', success: function(nv, status, xhr) { setting.issues = nv; setting.update(); } }); }, getPageConfig: function(href) { var ret = {}; ret.pageSide = true; ret.version = this.version; ret.verbose = this.misc.verbose; ret.logEnabled = this.misc.logEnabled; ret.pageRule = this.getFirstMatchedRule({href: href}); if (!ret.pageRule) { ret.clsidRules = this.cache.clsidRules; } else { var script = this.getScripts(ret.pageRule.script); ret.pageScript = script.page; ret.extScript = script.extension; } return ret; }, getFirstMatchedRule: function(object, rules) { var useCache = false; if (!rules) { rules = this.cache.validRules; useCache = true; } if (Array.isArray(rules)) { for (var i = 0; i < rules.length; ++i) { if (this.isRuleMatched(rules[i], object, useCache ? i : -1)) { return rules[i]; } } } else { for (var i in rules) { if (this.isRuleMatched(rules[i], object)) { return rules[i]; } } } return null; }, getMatchedIssue: function(filter) { return this.getFirstMatchedRule(filter, this.issues); }, activeRule: function(rule) { for (var i = 0; i < this.order.length; ++i) { if (this.order[i].identifier == rule.identifier) { if (this.order[i].status == 'disabled') { this.order[i].status = 'enabled'; trackAutoEnable(rule.identifier); } break; } } this.update(); }, validateRule: function(rule) { var ret = true; try { if (rule.type == 'wild') { ret &= this.convertUrlWildCharToRegex(rule.value) != null; } else if (rule.type == 'regex') { ret &= rule.value != ''; var r = new RegExp(rule.value, 'i'); } else if (rule.type == 'clsid') { var v = rule.value.toUpperCase(); if (!clsidPattern.test(v) || v.length > 55) ret = false; } } catch (e) { ret = false; } return ret; }, isRuleMatched: function(rule, object, id) { if (rule.type == 'wild' || rule.type == 'regex') { var regex; if (id >= 0) { regex = this.cache.regex[id]; } else if (rule.type == 'wild') { regex = this.convertUrlWildCharToRegex(rule.value); } else if (rule.type == 'regex') { regex = new RegExp('^' + rule.value + '$', 'i'); } if (object.href && regex.test(object.href)) { return true; } } else if (rule.type == 'clsid') { if (object.clsid) { var v1 = clsidPattern.exec(rule.value.toUpperCase()); var v2 = clsidPattern.exec(object.clsid.toUpperCase()); if (v1 && v2 && v1[0] == v2[0]) { return true; } } } return false; }, getScripts: function(script) { var ret = { page: '', extension: '' }; if (!script) { return ret; } var items = script.split(' '); for (var i = 0; i < items.length; ++i) { if (!items[i] || !this.scripts[items[i]]) { continue; } var name = items[i]; var val = '// '; val += items[i] + '\n'; val += this.scriptsContents[name]; val += '\n\n'; ret[this.scripts[name].context] += val; } return ret; }, convertUrlWildCharToRegex: function(wild) { try { function escapeRegex(str, star) { if (!star) star = '*'; var escapeChars = /([\.\\\/\?\{\}\+\[\]])/g; return str.replace(escapeChars, '\\$1').replace('*', star); } wild = wild.toLowerCase(); if (wild == '<all_urls>') { wild = '*://*/*'; } var pattern = /^(.*?):\/\/(\*?[^\/\*]*)\/(.*)$/i; // pattern: [all, scheme, host, page] var parts = pattern.exec(wild); if (parts == null) { return null; } var scheme = parts[1]; var host = parts[2]; var page = parts[3]; var regex = '^' + escapeRegex(scheme, '[^:]*') + ':\\/\\/'; regex += escapeRegex(host, '[^\\/]*') + '/'; regex += escapeRegex(page, '.*'); return new RegExp(regex, 'i'); } catch (e) { return null; } }, update: function() { if (this.pageSide) { return; } this.updateCache(); if (this.cache.listener) { this.cache.listener.trigger('update'); } this.save(); }, // Please remember to call update() after all works are done. addDefaultRule: function(rule, position) { console.log('Add new default rule: ', rule); var custom = null; if (rule.type == 'clsid') { for (var i in this.rules) { var info = {href: 'not-a-URL-/', clsid: rule.value}; if (this.isRuleMatched(this.rules[i], info, -1)) { custom = this.rules[i]; break; } } } else if (rule.keyword && rule.testUrl) { // Try to find matching custom rule for (var i in this.rules) { if (this.isRuleMatched(this.rules[i], {href: rule.testUrl}, -1)) { if (this.rules[i].value.toLowerCase().indexOf(rule.keyword) != -1) { custom = this.rules[i]; break; } } } } var newStatus = 'disabled'; if (custom) { console.log('Convert custom rule', custom, ' to default', rule); // Found a custom rule which is similiar to this default rule. newStatus = 'enabled'; // Remove old one delete this.rules[custom.identifier]; for (var i = 0; i < this.order.length; ++i) { if (this.order[i].identifier == custom.identifier) { this.order.splice(i, 1); break; } } } this.order.splice(position, 0, { position: 'default', status: newStatus, identifier: rule.identifier }); this.defaultRules[rule.identifier] = rule; }, updateCache: function() { if (this.pageSide) { return; } this.cache = { validRules: [], regex: [], clsidRules: [], userAgentRules: [], listener: (this.cache || {}).listener }; for (var i = 0; i < this.order.length; ++i) { if (['custom', 'enabled'].indexOf(this.order[i].status) >= 0) { var rule = this.getItem(this.order[i]); var cacheId = this.cache.validRules.push(rule) - 1; if (rule.type == 'clsid') { this.cache.clsidRules.push(rule); } else if (rule.type == 'wild') { this.cache.regex[cacheId] = this.convertUrlWildCharToRegex(rule.value); } else if (rule.type == 'regex') { this.cache.regex[cacheId] = new RegExp('^' + rule.value + '$', 'i'); } if (rule.userAgent != '') { this.cache.userAgentRules.push(rule); } } } }, save: function() { if (location.protocol == 'chrome-extension:') { // Don't include cache in localStorage. var cache = this.cache; delete this.cache; var scripts = this.scriptsContents; delete this.scriptsContents; localStorage[settingKey] = JSON.stringify(this); this.cache = cache; this.scriptsContents = scripts; } }, createIdentifier: function() { var base = 'custom_' + Date.now() + '_' + this.order.length + '_'; var ret; do { ret = base + Math.round(Math.random() * 65536); } while (this.getItem(ret)); return ret; }, getItem: function(item) { var identifier = item; if (typeof identifier != 'string') { identifier = item.identifier; } if (identifier in this.rules) { return this.rules[identifier]; } else { return this.defaultRules[identifier]; } }, loadAllScripts: function() { this.scriptsContents = {}; setting = this; for (var i in this.scripts) { var item = this.scripts[i]; $.ajax({ url: '/settings/' + item.url, datatype: 'text', context: item, success: function(nv, status, xhr) { setting.scriptsContents[this.identifier] = nv; } }); } } }; function loadLocalSetting() { var setting = undefined; if (localStorage[settingKey]) { try { setting = JSON.parse(localStorage[settingKey]); } catch (e) { setting = undefined; } } if (!setting) { firstRun = true; } return new ActiveXConfig(setting); } function clearSetting() { localStorage.removeItem(settingKey); setting = loadLocalSetting(); }
007slmg-np-activex-justep
chrome/configure.js
JavaScript
mpl11
17,848
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var FLASH_CLSID = '{d27cdb6e-ae6d-11cf-96b8-444553540000}'; var typeId = 'application/x-itst-activex'; var updating = false; function executeScript(script) { var scriptobj = document.createElement('script'); scriptobj.innerHTML = script; var element = document.head || document.body || document.documentElement || document; element.insertBefore(scriptobj, element.firstChild); element.removeChild(scriptobj); } function checkParents(obj) { var parent = obj; var level = 0; while (parent && parent.nodeType == 1) { if (getComputedStyle(parent).display == 'none') { var desp = obj.id + ' at level ' + level; if (scriptConfig.none2block) { parent.style.display = 'block'; parent.style.height = '0px'; parent.style.width = '0px'; log('Remove display:none for ' + desp); } else { log('Warning: Detected display:none for ' + desp); } } parent = parent.parentNode; ++level; } } function getLinkDest(url) { if (typeof url != 'string') { return url; } url = url.trim(); if (/^https?:\/\/.*/.exec(url)) { return url; } if (url[0] == '/') { if (url[1] == '/') { return location.protocol + url; } else { return location.origin + url; } } return location.href.replace(/\/[^\/]*$/, '/' + url); } var hostElement = null; function enableobj(obj) { updating = true; // We can't use classid directly because it confuses the browser. obj.setAttribute('clsid', getClsid(obj)); obj.removeAttribute('classid'); checkParents(obj); var newObj = obj.cloneNode(true); newObj.type = typeId; // Remove all script nodes. They're executed. var scripts = newObj.getElementsByTagName('script'); for (var i = 0; i < scripts.length; ++i) { scripts[i].parentNode.removeChild(scripts[i]); } // Set codebase to full path. var codebase = newObj.getAttribute('codebase'); if (codebase && codebase != '') { newObj.setAttribute('codebase', getLinkDest(codebase)); } newObj.activex_process = true; obj.parentNode.insertBefore(newObj, obj); obj.parentNode.removeChild(obj); obj = newObj; if (obj.id) { var command = ''; if (obj.form && scriptConfig.formid) { var form = obj.form.name; command += 'document.all.' + form + '.' + obj.id; command += ' = document.all.' + obj.id + ';\n'; log('Set form[obj.id]: form: ' + form + ', object: ' + obj.id); } // Allow access by document.obj.id if (obj.id && scriptConfig.documentid) { command += 'delete document.' + obj.id + ';\n'; command += 'document.' + obj.id + '=' + obj.id + ';\n'; } if (command) { executeScript(command); } } log('Enabled object, id: ' + obj.id + ' clsid: ' + getClsid(obj)); updating = false; return obj; } function getClsid(obj) { if (obj.hasAttribute('clsid')) return obj.getAttribute('clsid'); var clsid = obj.getAttribute('classid'); var compos = clsid.indexOf(':'); if (clsid.substring(0, compos).toLowerCase() != 'clsid') return; clsid = clsid.substring(compos + 1); return '{' + clsid + '}'; } function notify(data) { connect(); data.command = 'DetectControl'; port.postMessage(data); } function process(obj) { if (obj.activex_process) return; if (onBeforeLoading.caller == enableobj || onBeforeLoading.caller == process || onBeforeLoading.caller == checkParents) { log('Nested onBeforeLoading ' + obj.id); return; } if (obj.type == typeId) { if (!config || !config.pageRule) { // hack??? Deactive this object. log('Deactive unexpected object ' + obj.outerHTML); return true; } log('Found objects created by client scripts'); notify({ href: location.href, clsid: clsid, actived: true, rule: config.pageRule.identifier }); obj.activex_process = true; return; } if ((obj.type != '' && obj.type != 'application/x-oleobject') || !obj.hasAttribute('classid')) return; if (getClsid(obj).toLowerCase() == FLASH_CLSID) { return; } if (config == null) { // Delay the process of this object. // Hope config will be load soon. log('Pending object ', obj.id); pendingObjects.push(obj); return; } obj.activex_process = true; connect(); var clsid = getClsid(obj); var rule = config.shouldEnable({href: location.href, clsid: clsid}); if (rule) { obj = enableobj(obj); notify({ href: location.href, clsid: clsid, actived: true, rule: rule.identifier }); } else { notify({href: location.href, clsid: clsid, actived: false}); } } function replaceSubElements(obj) { var s = obj.querySelectorAll('object[classid]'); if (obj.tagName == 'OBJECT' && obj.hasAttribute('classid')) { s.push(obj); } for (var i = 0; i < s.length; ++i) { process(s[i]); } } function onBeforeLoading(event) { var obj = event.target; if (obj.nodeName == 'OBJECT') { log('BeforeLoading ' + obj.id); if (process(obj)) { event.preventDefault(); } } } function onError(event) { var message = 'Error: '; message += event.message; message += ' at '; message += event.filename; message += ':'; message += event.lineno; log(message); return false; } function setUserAgent() { if (!config.pageRule) { return; } var agent = getUserAgent(config.pageRule.userAgent); if (agent && agent != '') { log('Set userAgent: ' + config.pageRule.userAgent); var js = '(function(agent) {'; js += 'delete navigator.userAgent;'; js += 'navigator.userAgent = agent;'; js += 'delete navigator.appVersion;'; js += "navigator.appVersion = agent.substr(agent.indexOf('/') + 1);"; js += "if (agent.indexOf('MSIE') >= 0) {"; js += 'delete navigator.appName;'; js += 'navigator.appName = "Microsoft Internet Explorer";}})("'; js += agent; js += '")'; executeScript(js); } } function onSubtreeModified(e) { if (updating) { return; } if (e.nodeType == e.TEXT_NODE) { return; } replaceSubElements(e.srcElement); }
007slmg-np-activex-justep
chrome/inject_actions.js
JavaScript
mpl11
6,568
<html> <head> <script src="jquery.js"></script> <script src="notifybar.js"> </script> <script src="i18n.js"> </script> <link rel="stylesheet" type="text/css" href="notifybar.css" /> </head> <body> <span> <span id="info">ActiveX controls can be used on this site</span> <button id="enable">Enable them now!</button> <button id="block" style="font-size:0.8em">Don't notify me for this site</button> <button id="close">Close</button> </span> </body> </html>
007slmg-np-activex-justep
chrome/notifybar.html
HTML
mpl11
527
body { background-color: #ffd; } .main { width: 500px; height: 340px; padding: 10px; } .status { font-size: 18px; margin: 0 20px; } #issue_view { margin: 15px 10px; } #issue_view > div { margin: 7px 0px; } #share { position: absolute; top: 250px; left: 30px; height: 90px; } button { width: 350px; height: 30px; margin: 4px; } button.defaultRule { background-color: #0A0; } button.customRule { background-color: #aaf; }
007slmg-np-activex-justep
chrome/popup.css
CSS
mpl11
507
<html> <head> <title i18n="view_log"></title> <script src="jquery.js"></script> <script src="gas.js"></script> <script src="i18n.js"></script> <script src="log.js"></script> <style> #text { width: 800px; height: 500px; } div { margin: 10px 0px; } body > div { float:left; } #logs_items { margin-top: 40px; margin-right: 20px; overflow-x: hidden; overflow-y: scroll; width: 300px; height: 500px; white-space: nowrap; border-width: 1px; border-style: solid; } ul.selected { background-color: aqua; } </style> </head> <body> <div id="left"> <div id="logs_items"> </div> </div> <div id="logs_show"> <div i18n="log"> </div> <textarea id="text" wrap="off"> </textarea> <div> <input id="tracking" type="checkbox"></input> <label for="tracking" i18n="log_tracking"></label> </div> <div> <input id="beforeSubmit" type="checkbox"></input> <label for="beforeSubmit" i18n="issue_submit_desp"></label> <a id="submitLink" i18n="issue_submit_goto" style="margin-left:50px;display:none" href="http://code.google.com/p/np-activex/issues/entry?template=Defect%20report%20from%20log" target="_blank"></a> </div> </div> </body> </html>
007slmg-np-activex-justep
chrome/log.html
HTML
mpl11
1,496
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var controlLogFName = '__npactivex_log'; var controlLogEvent = '__npactivex_log_event__'; var config = null; var port = null; var logs = []; var scriptConfig = { none2block: false, formid: false, documentid: false }; function onControlLog(event) { var message = event.data; log(message); } window.addEventListener(controlLogEvent, onControlLog, false); function connect() { if (port) { return; } port = chrome.extension.connect(); for (var i = 0; i < logs.length; ++i) { port.postMessage({command: 'Log', message: logs[i]}); } if (port && config) { logs = undefined; } } function log(message) { var time = (new Date()).toLocaleTimeString(); message = time + ' ' + message; if (config && config.logEnabled) { console.log(message); } if (port) { port.postMessage({command: 'Log', message: message}); } if (!config || !port) { logs.push(message); } } log('PageURL: ' + location.href); var pendingObjects = []; function init(response) { config = new ActiveXConfig(response); if (config.logEnabled) { for (var i = 0; i < logs.length; ++i) { console.log(logs[i]); } } eval(config.extScript); executeScript(config.pageScript); setUserAgent(); log('Page rule:' + JSON.stringify(config.pageRule)); for (var i = 0; i < pendingObjects.length; ++i) { pendingObjects[i].activex_process = false; process(pendingObjects[i]); cacheConfig(); } delete pendingObjects; } function cacheConfig() { sessionStorage.activex_config_cache = JSON.stringify(config); } function loadConfig(response) { if (config) { config = new ActiveXConfig(response); var cache = sessionStorage.activex_config_cache; if (cache) { cacheConfig(); } } else { init(response); } if (config.pageRule) { cacheConfig(); } } function loadSessionConfig() { var cache = sessionStorage.activex_config_cache; if (cache) { log('Loading config from session cache'); init(JSON.parse(cache)); } } loadSessionConfig(); var notifyBar = null; var pageDOMLoaded = false; var needNotifyBar = false; function showNotifyBar(request) { if (notifyBar) { return; } if (!pageDOMLoaded) { needNotifyBar = true; return; } notifyBar = {}; log('Create notification bar'); var barurl = chrome.extension.getURL('notifybar.html'); if (document.body.tagName == 'BODY') { var iframe = document.createElement('iframe'); iframe.frameBorder = 0; iframe.src = barurl; iframe.height = '35px'; iframe.width = '100%'; iframe.style.top = '0px'; iframe.style.left = '0px'; iframe.style.zIndex = '2000'; iframe.style.position = 'fixed'; notifyBar.iframe = iframe; document.body.insertBefore(iframe, document.body.firstChild); var placeHolder = document.createElement('div'); placeHolder.style.height = iframe.height; placeHolder.style.zIndex = '1999'; placeHolder.style.borderWidth = '0px'; placeHolder.style.borderStyle = 'solid'; placeHolder.style.borderBottomWidth = '1px'; document.body.insertBefore(placeHolder, document.body.firstChild); notifyBar.placeHolder = placeHolder; } else if (document.body.tagName == 'FRAMESET') { // We can't do this.. return; } } function dismissNotifyBar() { if (!notifyBar || !notifyBar.iframe) { return; } notifyBar.iframe.parentNode.removeChild(notifyBar.iframe); notifyBar.placeHolder.parentNode.removeChild(notifyBar.placeHolder); } chrome.extension.onRequest.addListener( function(request, sender, sendResponse) { if (self == top && request.command == 'NotifyUser') { showNotifyBar(request); sendResponse({}); } else if (self == top && request.command == 'DismissNotificationPage') { dismissNotifyBar(); sendResponse({}); } }); chrome.extension.sendRequest( {command: 'Configuration', href: location.href, top: self == top}, loadConfig); window.addEventListener('beforeload', onBeforeLoading, true); document.addEventListener('DOMSubtreeModified', onSubtreeModified, true);
007slmg-np-activex-justep
chrome/inject_start.js
JavaScript
mpl11
4,465
if (chrome.extension.getBackgroundPage().firstRun) { document.getElementById('hint').style.display = ''; chrome.extension.getBackgroundPage().firstRun = false; } $(document).ready(function() { $('#share').load('share.html'); });
007slmg-np-activex-justep
chrome/donate.js
JavaScript
mpl11
242
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. /* prop = { header, // String property, // String events, // type, // checkbox, select, input.type, button extra // depend on type } */ function List(config) { this.config = config; this.props = config.props; this.main = config.main; this.selectedLine = -2; this.lines = []; if (!config.getItems) { config.getItems = function() { return config.items; } } if (!config.getItemProp) { config.getItemProp = function(id, prop) { return config.getItem(id)[prop]; } } if (!config.setItemProp) { config.setItemProp = function(id, prop, value) { config.getItem(id)[prop] = value; } } if (!config.getItem) { config.getItem = function(id) { return config.getItems()[id]; } } if (!config.move) { config.move = function(a, b) { if (a != b && a >= 0 && b >= 0 && a < this.count() && b < this.count()) { var list = config.getItems(); var tmp = list[a]; // remove a list.splice(a, 1); // insert b list.splice(b, 0, tmp); } } } if (!config.insert) { config.insert = function(id, newItem) { config.getItems().splice(id, 0, newItem); } } if (!config.remove) { config.remove = function(a) { config.move(a, config.count() - 1); config.getItems().pop(); } } if (!config.validate) { config.validate = function() {return true;}; } if (!config.count) { config.count = function() { return config.getItems().length; } } if (!config.patch) { config.patch = function(id, newVal) { for (var name in newVal) { config.setItemProp(id, name, newVal[name]); } } } if (!config.defaultValue) { config.defaultValue = {}; } config.main.addClass('list'); } List.ids = { noline: -1 }; List.types = {}; List.prototype = { init: function() { with (this) { if (this.inited) { return; } this.inited = true; this.headergroup = $('<div class="headers"></div>'); for (var i = 0; i < props.length; ++i) { var header = $('<div class="header"></div>'). attr('property', props[i].property).html(props[i].header); headergroup.append(header); } this.scrolls = $('<div>').addClass('listscroll'); this.contents = $('<div class="listitems"></div>').appendTo(scrolls); scrolls.scroll(function() { headergroup.css('left', -(scrolls.scrollLeft()) + 'px'); }); contents.click(function(e) { if (e.target == contents[0]) { selectLine(List.ids.noline); } }); $(main).append(headergroup).append(scrolls); var height = this.main.height() - this.headergroup.outerHeight(); this.scrolls.height(height); load(); selectLine(List.ids.noline); } }, editNewLine: function() { this.startEdit(this.lines[this.lines.length - 1]); }, updatePropDisplay: function(line, prop) { var name = prop.property; obj = $('[property=' + name + ']', line); var ctrl = obj[0].listdata; var id = Number(line.attr('row')); if (id == this.config.count()) { var value = this.config.defaultValue[name]; if (value) { ctrl.value = value; } obj.trigger('createNew'); } else { ctrl.value = this.config.getItemProp(id, name); obj.trigger('update'); } }, updateLine: function(line) { for (var i = 0; i < this.props.length; ++i) { this.updatePropDisplay(line, this.props[i]); } if (Number(line.attr('row')) < this.config.count()) { line.trigger('update'); } else { line.addClass('newline'); } }, createLine: function() { with (this) { var line = $('<div></div>').addClass('itemline'); var inner = $('<div>'); line.append(inner); // create input boxes for (var i = 0; i < props.length; ++i) { var prop = props[i]; var ctrl = $('<div></div>').attr('property', prop.property) .addClass('listvalue').attr('tabindex', -1); var valueobj = new List.types[prop.type](ctrl, prop); var data = {list: this, line: line, prop: prop}; for (var e in prop.events) { ctrl.bind(e, data, prop.events[e]); } ctrl.bind('change', function(e) { validate(line); return true; }); ctrl.bind('keyup', function(e) { if (e.keyCode == 27) { cancelEdit(line); } }); ctrl.trigger('create'); inner.append(ctrl); } // Event listeners line.click(function(e) { startEdit(line); }); line.focusin(function(e) { startEdit(line); }); line.focusout(function(e) { finishEdit(line); }); for (var e in this.config.lineEvents) { line.bind(e, {list: this, line: line}, this.config.lineEvents[e]); } var list = this; line.bind('updating', function() { $(list).trigger('updating'); }); line.bind('updated', function() { $(list).trigger('updated'); }); this.bindId(line, this.lines.length); this.lines.push(line); line.appendTo(this.contents); return line; } }, refresh: function(lines) { var all = false; if (lines === undefined) { all = true; lines = []; } for (var i = this.lines.length; i <= this.config.count(); ++i) { var line = this.createLine(); lines.push(i); } while (this.lines.length > this.config.count() + 1) { this.lines.pop().remove(); } $('.newline', this.contents).removeClass('newline'); this.lines[this.lines.length - 1].addClass('newline'); if (all) { for (var i = 0; i < this.lines.length; ++i) { this.updateLine(this.lines[i]); } } else { for (var i = 0; i < lines.length; ++i) { this.updateLine(this.lines[lines[i]]); } } }, load: function() { this.contents.empty(); this.lines = []; this.refresh(); }, bindId: function(line, id) { line.attr('row', id); }, getLineNewValue: function(line) { var ret = {}; for (var i = 0; i < this.props.length; ++i) { this.getPropValue(line, ret, this.props[i]); } return ret; }, getPropValue: function(line, item, prop) { var name = prop.property; obj = $('[property=' + name + ']', line); var ctrl = obj[0].listdata; var value = ctrl.value; if (value !== undefined) { item[name] = value; } return value; }, startEdit: function(line) { if (line.hasClass('editing')) { return; } line.addClass('editing'); this.showLine(line); this.selectLine(line); var list = this; setTimeout(function() { if (!line[0].contains(document.activeElement)) { $('.valinput', line).first().focus(); } list.validate(line); }, 50); }, finishEdit: function(line) { var list = this; function doFinishEdit() { with (list) { if (line[0].contains(document.activeElement)) { return; } var valid = isValid(line); if (valid) { var id = Number(line.attr('row')); var newval = getLineNewValue(line); if (line.hasClass('newline')) { $(list).trigger('updating'); if (!config.insert(id, newval)) { line.removeClass('newline'); list.selectLine(line); $(list).trigger('add', id); addNewLine(); } } else { line.trigger('updating'); config.patch(id, newval); } line.trigger('updated'); } cancelEdit(line); } }; setTimeout(doFinishEdit, 50); }, cancelEdit: function(line) { line.removeClass('editing'); line.removeClass('error'); var id = Number(line.attr('row')); if (id == this.config.count() && this.selectedLine == id) { this.selectedLine = List.ids.noline; } this.updateLine(line); }, addNewLine: function() { with (this) { var line = $('.newline', contents); if (!line.length) { line = createLine().addClass('newline'); } return line; } }, isValid: function(line) { var id = Number(line.attr('row')); var obj = this.getLineNewValue(line); return valid = this.config.validate(id, obj); }, validate: function(line) { if (this.isValid(line)) { line.removeClass('error'); } else { line.addClass('error'); } }, move: function(a, b, keepSelect) { var len = this.config.count(); if (a == b || a < 0 || b < 0 || a >= len || b >= len) { return; } this.config.move(a, b); for (var i = Math.min(a, b); i <= Math.max(a, b); ++i) { this.updateLine(this.getLine(i)); } if (keepSelect) { if (this.selectedLine == a) { this.selectLine(b); } else if (this.selectedLine == b) { this.selectLine(a); } } }, getLine: function(id) { if (id < 0 || id >= this.lines.length) { return null; } return this.lines[id]; }, remove: function(id) { id = Number(id); if (id < 0 || id >= this.config.count()) { return; } $(this).trigger('updating'); var len = this.lines.length; this.getLine(id).trigger('removing'); if (this.config.remove(id)) { return; } this.getLine(len - 1).remove(); this.lines.pop(); for (var i = id; i < len - 1; ++i) { this.updateLine(this.getLine(i)); } if (id >= len - 2) { this.selectLine(id); } else { this.selectLine(List.ids.noline); } $(this).trigger('updated'); }, selectLine: function(id) { var line = id; if (typeof id == 'number') { line = this.getLine(id); } else { id = Number(line.attr('row')); } // Can't select the new line. if (line && line.hasClass('newline')) { line = null; id = List.ids.noline; } if (this.selectedLine == id) { return; } var oldline = this.getLine(this.selectedLine); if (oldline) { this.cancelEdit(oldline); oldline.removeClass('selected'); oldline.trigger('deselect'); this.selectedLine = List.ids.noline; } this.selectedLine = id; if (line != null) { line.addClass('selected'); line.trigger('select'); this.showLine(line); } $(this).trigger('select'); }, showLine: function(line) { var showtop = this.scrolls.scrollTop(); var showbottom = showtop + this.scrolls.height(); var top = line.offset().top - this.contents.offset().top; // Include the scroll bar var bottom = top + line.height() + 20; if (top < showtop) { // show at top this.scrolls.scrollTop(top); } else if (bottom > showbottom) { // show at bottom this.scrolls.scrollTop(Math.max(0, bottom - this.scrolls.height())); } } };
007slmg-np-activex-justep
chrome/list.js
JavaScript
mpl11
11,702
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. replaceSubElements(document); pageDOMLoaded = true; if (needNotifyBar) { showNotifyBar(); }
007slmg-np-activex-justep
chrome/inject_doreplace.js
JavaScript
mpl11
286
<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></meta> <link rel="stylesheet" type="text/css" href="/popup.css" /> <script src="/jquery.js"></script> <script src="/popup.js"></script> <script src="/i18n.js"></script> <script src="/gas.js"></script> </head> <body> <div class="main"> <div> <div id="status_ok" class="status"> <span i18n="status_ok"></span> <button id="submitissue" i18n="submitissue"></button> </div> <div id="status_urldetect" class="status" i18n="status_urldetect"></div> <div id="status_disabled" class="status" i18n="status_disabled"></div> <div id="status_error" class="status" i18n="status_error"></div> </div> <div id="enable_btns"> </div> <div id="issue_view"> <div i18n="issue_desp"> </div> <div id="issue_content"> </div> <div> <a id="issue_track" i18n="issue_track" href="#"></a> </div> </div> <script src="share.js"></script> </div> </body> </html>
007slmg-np-activex-justep
chrome/popup.html
HTML
mpl11
1,145
scriptConfig.formid = true;
007slmg-np-activex-justep
chrome/settings/formid.js
JavaScript
mpl11
29
document.addEventListener('DOMContentLoaded', function() { if (window.doLogin && window.statcus && window.psw) { function makeHidden(obj) { obj.style.display = 'block'; obj.style.height = '0px'; obj.style.width = '0px'; } window.doLogin = function(orig) { return function() { if (statcus.style.display == 'none') { makeHidden(statcus); } if (psw.style.display == 'none') { makeHidden(psw); } orig(); }; }(doLogin); } }, false);
007slmg-np-activex-justep
chrome/settings/cebpay.js
JavaScript
mpl11
558
(function () { function patch() { if (window.ShowPayPage && window.InitControls) { InitControls = function(orig) { return function() { if (CreditCardYear.object === undefined) { CreditCardYear.object = {}; } if (CreditCardMonth.object === undefined) { CreditCardMonth.object = {}; } if (CreditCardCVV2.object === undefined) { CreditCardCVV2.object = {}; } orig(); } } (InitControls); ShowPayPage = function(orig) { return function(par) { orig(par); InitControls(); } } (ShowPayPage); DoSubmit = function(orig) { return function(par) { if (!CardPayNo.Option) { CardPayNo.Option = function() {}; } orig(par); } } (DoSubmit); } if (window.OpenWnd) { var inputs = document.querySelectorAll('div > input[type=hidden]'); for (var i = 0; i < inputs.length; ++i) { window[inputs[i].name] = inputs[i]; } } function patchLoginSwitch(fncName) { if (!(window[fncName])) { return; } window[fncName] = function(orig) { return function(par) { orig(par); MobileNo_Ctrl.PasswdCtrl = false; EMail_Ctrl.PasswdCtrl = false; NetBankUser_Ctrl.PasswdCtrl = false; DebitCardNo_Ctrl.PasswdCtrl = false; CreditCardNo_Ctrl.PasswdCtrl = false; IdNo_Ctrl.PasswdCtrl = false; BookNo_Ctrl.PasswdCtrl = false; } } (window[fncName]); } patchLoginSwitch('changeCreditCardLoginType'); patchLoginSwitch('changeEALoginType'); patchLoginSwitch('showLoginEntry'); CallbackCheckClient = function() {}; } if (document.readyState == 'complete') { patch(); } else { window.addEventListener('load', patch, false); } })();
007slmg-np-activex-justep
chrome/settings/cmb_pay.js
JavaScript
mpl11
1,943
(function() { Document.prototype.getElementById = function(orig) { return function(id) { var a = this.getElementsByName(id); if (a.length > 0) { return a[0]; } return orig.call(this, id); } } (Document.prototype.getElementById); })();
007slmg-np-activex-justep
chrome/settings/ieidname.js
JavaScript
mpl11
290
document.addEventListener('DOMContentLoaded', function() { if (window.PocoUpload) { document.all.PocoUpload.Document = document; } }, false);
007slmg-np-activex-justep
chrome/settings/poco_upload.js
JavaScript
mpl11
149
//******************************************** //*** \u4ee5\u4e0b\u51fd\u6570\u7528\u6765\u5904\u7406\u91d1\u989d\u5343\u5206\u4f4d\u663e\u793a\u53ca\u4eba\u6c11\u5e01\u5927\u5199 //******************************************** var pubarray1 = new Array("\u96f6","\u58f9","\u8d30","\u53c1","\u8086","\u4f0d","\u9646","\u67d2","\u634c","\u7396",""); var pubarray2 = new Array("","\u62fe","\u4f70","\u4edf"); var pubarray3 = new Array("\u5143","\u4e07","\u4ebf","\u5146","",""); var pubarray4 = new Array("\u89d2","\u5206"); var char_len = pubarray1[0].length; /* * \u51fd\u6570\u529f\u80fd\uff1a\u6839\u636e\u8d27\u5e01\u7801\u683c\u5f0f\u5316\u8f85\u5e01\u4f4d\u6570\uff0c\u4e0d\u8db3\u4f4d\u7684\u88650 * * Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32; * curCode -- \u8d27\u5e01\u7801; * * Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32 * * \u4f8b\u5b50\uff1aformatDecimalPart("12345678","001"); * \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a12345678.00 * */ function formatDecimalPart(str,curCode) { var curDec; for(var j = 0; j < curCodeArr.length; j++) { if (curCodeArr[j][0] == curCode) { curDec = curCodeArr[j][3]; break; } } if (str.indexOf(".") == -1) { var tmp = ""; if (curDec == 0) return str; for(var i = 0; i < curDec; i++) { tmp += "0"; } return str + "." + tmp; } else { var strArr = str.split("."); var decimalPart = strArr[1]; while(decimalPart.length < curDec) { decimalPart += "0"; } return strArr[0] + "." + decimalPart; } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32\u7528","\u8fdb\u884c\u5206\u9694,\u5e76\u4e14\u52a0\u4e0a\u5c0f\u6570\u4f4d(\u5904\u7406\u5343\u5206\u4f4d,\u5206\u5e01\u79cd) * * Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32; * curCode -- \u8d27\u5e01\u7801; * * Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32 * * \u4f8b\u5b50\uff1achangePartition("12345678"); * \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a12,345,678.00 * */ function changePartition(str,curCode) { var minus = ""; if(str.substring(0,1) == "-") { str = str.substring(1); minus = "-"; } str = formatDecimalPart(str,curCode); var twopart = str.split("."); var decimal_part = twopart[1]; //format integer part var integer_part="0"; var intlen=twopart[0].length; if(intlen>0) { var i=0; integer_part=""; while(intlen>3) { integer_part=","+twopart[0].substring(intlen-3,intlen)+integer_part; i=i+1; intlen=intlen-3; } integer_part=twopart[0].substring(0,intlen)+integer_part; } if (!decimal_part) return minus + integer_part; else return minus + integer_part + "." + decimal_part } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32\u5904\u7406\u6210\u5927\u5199\u7684\u4eba\u6c11\u5e01 * * Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32; * * Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32 * * \u4f8b\u5b50\uff1achangeUppercase("12345678.90") * \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a\u58f9\u4edf\u8d30\u4f70\u53c1\u62fe\u8086\u4e07\u4f0d\u4edf\u9646\u4f70\u67d2\u62fe\u634c\u5143\u7396\u89d2 * */ function changeUppercase(str) { if(str=="" || eval(str)==0) return "\u96f6"; if(str.substring(0,1) == "-") { if(eval(str.substring(1)) < 0.01) return "\u91d1\u989d\u6709\u8bef!!"; else str = str.substring(1); } var integer_part=""; var decimal_part="\u6574"; var tmpstr=""; var twopart=str.split("."); //\u5904\u7406\u6574\u578b\u90e8\u5206\uff08\u5c0f\u6570\u70b9\u524d\u7684\u6574\u6570\u4f4d\uff09 var intlen=twopart[0].length; if (intlen > 0 && eval(twopart[0]) != 0) { var gp=0; var intarray=new Array(); while(intlen > 4) { intarray[gp]=twopart[0].substring(intlen-4,intlen); gp=gp+1; intlen=intlen-4; } intarray[gp]=twopart[0].substring(0,intlen); for(var i=gp;i>=0;i--) { integer_part=integer_part+every4(intarray[i])+pubarray3[i]; } integer_part=replace(integer_part,"\u4ebf\u4e07","\u4ebf\u96f6"); integer_part=replace(integer_part,"\u5146\u4ebf","\u5146\u96f6"); while(true) { if (integer_part.indexOf("\u96f6\u96f6")==-1) break; integer_part=replace(integer_part,"\u96f6\u96f6","\u96f6"); } integer_part=replace(integer_part,"\u96f6\u5143","\u5143"); /*\u6b64\u5904\u6ce8\u91ca\u662f\u4e3a\u4e86\u89e3\u51b3100000\uff0c\u663e\u793a\u4e3a\u62fe\u4e07\u800c\u4e0d\u662f\u58f9\u62fe\u4e07\u7684\u95ee\u9898\uff0c\u6b64\u6bb5\u7a0b\u5e8f\u628a\u58f9\u62fe\u4e07\u622a\u6210\u4e86\u62fe\u4e07 tmpstr=intarray[gp]; if (tmpstr.length==2 && tmpstr.charAt(0)=="1") { intlen=integer_part.length; integer_part=integer_part.substring(char_len,intlen); } */ } //\u5904\u7406\u5c0f\u6570\u90e8\u5206\uff08\u5c0f\u6570\u70b9\u540e\u7684\u6570\u503c\uff09 tmpstr=""; if(twopart.length==2 && twopart[1]!="") { if(eval(twopart[1])!=0) { decimal_part=""; intlen= (twopart[1].length>2) ? 2 : twopart[1].length; for(var i=0;i<intlen;i++) { tmpstr=twopart[1].charAt(i); decimal_part=decimal_part+pubarray1[eval(tmpstr)]+pubarray4[i]; } decimal_part=replace(decimal_part,"\u96f6\u89d2","\u96f6"); decimal_part=replace(decimal_part,"\u96f6\u5206",""); if(integer_part=="" && twopart[1].charAt(0)==0) { intlen=decimal_part.length; decimal_part=decimal_part.substring(char_len,intlen); } } } tmpstr=integer_part+decimal_part; return tmpstr; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5bf9\u4f4d\u6570\u5c0f\u4e8e\u7b49\u4e8e4\u7684\u6574\u6570\u503c\u5b57\u7b26\u4e32\u8fdb\u884c\u4e2d\u6587\u8d27\u5e01\u7b26\u53f7\u5904\u7406 * * Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32; * * Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32 * * \u4f8b\u5b50\uff1aevery4("1234") * \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a\u58f9\u4edf\u8d30\u4f70\u53c1\u62fe\u8086 * */ function every4(str) { var weishu=str.length-1; var retstr=""; var shuzi; for (var i=0;i<str.length;i++) { shuzi=str.charAt(i); if(shuzi=="0") retstr=retstr+pubarray1[eval(shuzi)]; else retstr=retstr+pubarray1[eval(shuzi)]+pubarray2[weishu]; weishu=weishu-1; } while(true) { if (retstr.indexOf("\u96f6\u96f6")==-1) break; retstr=replace(retstr,"\u96f6\u96f6","\u96f6"); } if(shuzi=="0") { weishu=retstr.length-char_len; retstr=retstr.substring(0,weishu); } return retstr; }
007slmg-np-activex-justep
chrome/settings/_boc_FormatMoneyBase.js
JavaScript
mpl11
7,803
//************************************/ //******* \u5b9a\u4e49\u6240\u6709JS\u63d0\u793a\u8bed *******/ //************************************/ /** CurCode\u8d27\u5e01\u5217\u8868 begin */ var CURCODE_CNY = "\u4eba\u6c11\u5e01\u5143"; var CURCODE_GBP = "\u82f1\u9551"; var CURCODE_HKD = "\u6e2f\u5e01"; var CURCODE_USD = "\u7f8e\u5143"; var CURCODE_CHF = "\u745e\u58eb\u6cd5\u90ce"; var CURCODE_DEM = "\u5fb7\u56fd\u9a6c\u514b"; var CURCODE_FRF = "\u6cd5\u56fd\u6cd5\u90ce"; var CURCODE_SGD = "\u65b0\u52a0\u5761\u5143"; var CURCODE_NLG = "\u8377\u5170\u76fe"; var CURCODE_SEK = "\u745e\u5178\u514b\u90ce"; var CURCODE_DKK = "\u4e39\u9ea6\u514b\u90ce"; var CURCODE_NOK = "\u632a\u5a01\u514b\u90ce"; var CURCODE_ATS = "\u5965\u5730\u5229\u5148\u4ee4"; var CURCODE_BEF = "\u6bd4\u5229\u65f6\u6cd5\u90ce"; var CURCODE_ITL = "\u610f\u5927\u5229\u91cc\u62c9"; var CURCODE_JPY = "\u65e5\u5143"; var CURCODE_CAD = "\u52a0\u62ff\u5927\u5143"; var CURCODE_AUD = "\u6fb3\u5927\u5229\u4e9a\u5143"; var CURCODE_EUR = "\u6b27\u5143"; var CURCODE_IDR = "\u5370\u5c3c\u76fe"; var CURCODE_MOP = "\u6fb3\u95e8\u5143"; var CURCODE_PHP = "\u83f2\u5f8b\u5bbe\u6bd4\u7d22"; var CURCODE_THB = "\u6cf0\u56fd\u94e2"; var CURCODE_NZD = "\u65b0\u897f\u5170\u5143"; var CURCODE_KRW = "\u97e9\u5143"; var CURCODE_XSF = "\u8bb0\u8d26\u745e\u58eb\u6cd5\u90ce"; //edit by zhangfeng var CURCODE_VND = "\u8d8a\u5357\u76fe"; var CURCODE_IDR = "\u5370\u5c3c\u76fe"; //edit by liangd var CURCODE_AED = "\u963f\u8054\u914b\u8fea\u62c9\u59c6"; var CURCODE_ARP = "\u963f\u6839\u5ef7\u6bd4\u7d22"; var CURCODE_BRL = "\u96f7\u4e9a\u5c14"; var CURCODE_EGP = "\u57c3\u53ca\u78c5"; var CURCODE_INR = "\u5370\u5ea6\u5362\u6bd4"; var CURCODE_JOD = "\u7ea6\u65e6\u7b2c\u7eb3\u5c14"; var CURCODE_MNT = "\u8499\u53e4\u56fe\u683c\u91cc\u514b"; var CURCODE_MYR = "\u9a6c\u6765\u897f\u4e9a\u6797\u5409\u7279"; var CURCODE_NGN = "\u5c3c\u65e5\u5229\u4e9a\u5948\u62c9"; var CURCODE_ROL = "\u7f57\u9a6c\u5c3c\u4e9a\u5217\u4f0a"; var CURCODE_TRL = "\u571f\u8033\u5176\u91cc\u62c9"; var CURCODE_UAH = "\u4e4c\u514b\u5170\u683c\u91cc\u592b\u7eb3"; var CURCODE_ZAR = "\u5357\u975e\u5170\u7279"; //edit by cuiyk var CURCODE_RUR = "\u5362\u5e03"; var CURCODE_HUF = "\u798f\u6797"; var CURCODE_KZT = "\u54c8\u8428\u514b\u65af\u5766\u575a\u6208"; var CURCODE_ZMK = "\u8d5e\u6bd4\u4e9a\u514b\u74e6\u67e5"; var CURCODE_XPT = "\u767d\u91d1"; var CURCODE_BND = "\u6587\u83b1\u5e01"; var CURCODE_BWP = "\u535a\u8328\u74e6\u7eb3\u666e\u62c9"; //added by hhf.2009.9.10 modify by cuiyk 2009.11.10 var CURCODE_XAU="\u9ec4\u91d1(\u76ce\u53f8)"; var CURCODE_GLD="\u9ec4\u91d1(\u514b)"; /** CurCode\u8d27\u5e01\u5217\u8868 end */ /** FormCheck\u8868\u5355\u68c0\u67e5 begin */ var COMMA_MSG = "\uff0c"; var ENTER_MSG = "\n"; var NOT_NULL = "\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u8bf7\u4fee\u6539\uff01"; var ILLEGAL_REGEX = "\u4e0d\u7b26\u5408\u8f93\u5165\u683c\u5f0f\uff0c\u8bf7\u4fee\u6539\uff01"; var ILLEGAL_CHAR = "\u6570\u636e\u542b\u4e86\u975e\u6cd5\u5b57\u7b26\uff1a[]^$\\~@#%&<>{}:'\"\uff0c\u8bf7\u4fee\u6539\uff01"; var HAVE_CHINESE = "\u6570\u636e\u542b\u4e86\u4e2d\u6587\u6216\u5176\u4ed6\u975e\u6807\u51c6\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01"; var NOT_ONLY_CHINESE = "\u6570\u636e\u542b\u4e86\u4e2d\u6587\u4ee5\u5916\u7684\u5176\u4ed6\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01"; var NOT_NUMBER = "\u6570\u636e\u5305\u542b\u4e86\u963f\u62c9\u4f2f\u6570\u5b57\u4ee5\u5916\u7684\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01"; var NOT_PHONE_NUMBER = "\u6570\u636e\u5305\u542b\u4e86\u7535\u8bdd\u53f7\u7801\u4ee5\u5916\u7684\u5176\u4ed6\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01"; var LENGTH_MSG = "\u7684\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e"; var LENGTH_EQUAL_MSG = "\u7684\u957f\u5ea6\u5fc5\u987b\u4e3a"; var LENGTH_MSG1 = "\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u5360\u75282\u4e2a\u5b57\u7b26\uff09"; var MODIFY_MSG = "\u8bf7\u4fee\u6539\uff01"; var LENGHT_PERIOD_MSG = "\u7684\u957f\u5ea6\u5fc5\u987b\u4e3a\uff1a"; var MINUS_MSG = "-"; var MONEY_MSG1 = "\u6570\u636e\u4e3a\u975e\u6cd5\u91d1\u989d\uff0c\u8bf7\u4fee\u6539\uff01"; var MONEY_MSG2 = "\u6570\u636e\u4e0d\u80fd\u4e3a\u8d1f\uff0c\u8bf7\u4fee\u6539\uff01"; var MONEY_MSG3 = "\u6570\u636e\u6574\u6570\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01"; var MONEY_MSG4 = "\u6570\u636e\u8f85\u5e01\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01"; var MONEY_MSG = "\u5e94\u5927\u4e8e"; var MONEY_MSG0 = "\u5e94\u5c0f\u4e8e\u7b49\u4e8e"; var EXCHANGERATE_MSG1 = "\u6570\u636e\u975e\u6cd5\uff0c\u8bf7\u4fee\u6539\uff01"; var EXCHANGERATE_MSG2 = "\u6570\u636e\u4e0d\u80fd\u4e3a\u8d1f\uff0c\u8bf7\u4fee\u6539\uff01"; var EXCHANGERATE_MSG3 = "\u6570\u636e\u6574\u6570\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01"; var EXCHANGERATE_MSG4 = "\u6570\u636e\u8f85\u5e01\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01"; var ILLEGAL_DATE = "\u6570\u636e\u4e3a\u975e\u6cd5\u65e5\u671f\uff0c\u8bf7\u4fee\u6539\uff01"; var DATE_LATER_MSG = "\u4e0d\u5e94\u65e9\u4e8e"; var DATE_NOTLATER_MSG = "\u4e0d\u80fd\u665a\u4e8e" var ILLEGAL_DATE_PERIOD = "\u8f93\u5165\u65e5\u671f\u8303\u56f4\u8d85\u8fc7"; var ENTRIES = "\u4e2a"; var MONTH = "\u6708"; var DAY = "\u5929"; /** FormCheck\u8868\u5355\u68c0\u67e5 end */ /** ListCheck\u8868\u5355\u68c0\u67e5 begin */ var ALL_AUTH = "\u6b64\u64cd\u4f5c\u5c06\u6e05\u9664\u60a8\u6240\u505a\u7684\u5176\u4ed6\u9009\u62e9\uff0c\u662f\u5426\u7ee7\u7eed\uff1f"; var CHOICE_MSG = "\u8bf7\u60a8\u81f3\u5c11\u9009\u62e9\u67d0\u4e00"; var ALL_COUNT = "\u672c\u6b21\u5171\u5904\u7406\u4e1a\u52a1\uff1a"; var ALL_MONEY = "\u7b14\uff0c\u603b\u91d1\u989d\uff1a"; var SPACE_MSG = " "; var DOT_MSG = "."; var EXCMARK_MSG = "\uff01"; /** ListCheck\u8868\u5355\u68c0\u67e5 end */ /** \u65e5\u5386\u4f7f\u7528 begin */ var calLanguage="zhCN"; var calMonthArr = new Array("1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"); var calDayArr = new Array("\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"); var calYear = "\u5e74"; var calMonth = "\u6708"; /** \u65e5\u5386\u4f7f\u7528 end */ /** \u6536\u6b3e\u4eba\u5f00\u6237\u884c\u4e0b\u62c9\u83dc\u5355\u4f7f\u7528 begin */ var PLEASE_CHOICE="\u8bf7\u9009\u62e9"; /** \u6536\u6b3e\u4eba\u5f00\u6237\u884c\u4e0b\u62c9\u83dc\u5355\u4f7f\u7528 end */ //author liuy var START_DATE="\u8d77\u59cb\u65e5\u671f"; var END_DATE="\u7ed3\u675f\u65e5\u671f"; /*******************************/ /*** \u81ea\u52a9\u6ce8\u518c\u4f7f\u7528 ***/ /*******************************/ var USER_NAME_IS_EMPTY = "\u8bf7\u8f93\u5165\u7528\u6237\u540d\uff01"; var USER_NAME_IS_INCORRECT = "\u7528\u6237\u540d\u4e0d\u6b63\u786e\uff0c\u7528\u6237\u540d\u75316-20\u4f4d\u957f\u5ea6\u7684\u6570\u5b57\u548c\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u4e0d\u5141\u8bb8\u6709\u7a7a\u683c\uff0c\u81f3\u5c11\u5305\u542b1\u4f4d\u82f1\u6587\u5b57\u6bcd\uff01"; var PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u5bc6\u7801\uff01"; var PASSWORD_IS_INCORRECT = "\u5bc6\u7801\u4e0d\u6b63\u786e\uff0c\u5bc6\u7801\u75318-20\u4f4d\u957f\u5ea6\u7684\u6570\u5b57\u548c\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\uff0c\u533a\u5206\u5927\u5c0f\u5199\uff0c\u81f3\u5c11\u5305\u542b1\u4f4d\u82f1\u6587\u5b57\u6bcd\u548c1\u4f4d\u6570\u5b57\uff01"; var NEW_PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u65b0\u5bc6\u7801\uff01"; var NEW_PASSWORD_IS_INCORRECT = "\u65b0\u5bc6\u7801\u4e0d\u6b63\u786e\uff0c\u5bc6\u7801\u75318-20\u4f4d\u957f\u5ea6\u7684\u6570\u5b57\u548c\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\uff0c\u533a\u5206\u5927\u5c0f\u5199\uff0c\u81f3\u5c11\u5305\u542b1\u4f4d\u82f1\u6587\u5b57\u6bcd\u548c1\u4f4d\u6570\u5b57\uff01"; var CONFIRM_PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u786e\u8ba4\u5bc6\u7801\uff01"; var CONFIRM_PASSWORD_IS_INCORRECT = "\u786e\u8ba4\u5bc6\u7801\u4e0e\u5bc6\u7801\u4e0d\u5339\u914d\uff01"; var OLD_PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u539f\u59cb\u5bc6\u7801\uff01"; var BIRTHDAY_IS_INCORRECT = "\u51fa\u751f\u65e5\u671f\u4e0d\u6b63\u786e\uff01\u65e5\u671f\u7684\u6b63\u786e\u683c\u5f0f\u4e3aYYYY/MM/DD\uff0c\u4e14\u5fc5\u987b\u4e3a\u5408\u6cd5\u7684\u65e5\u671f\uff01"; var BIRTHDAY_MORE_THAN_TODAY = "\u51fa\u751f\u65e5\u671f\u4e0d\u80fd\u5927\u4e8e\u4eca\u5929\uff01"; var PHONE_IS_EMPTY = "\u8bf7\u8f93\u5165\u5e38\u7528\u7535\u8bdd\u53f7\u7801\uff01"; var PHONE_IS_INCORRECT = "\u5e38\u7528\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c\u5b57\u6bcd\u4ee5\u53ca-\uff0c\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e15\uff01"; var PHONE2_IS_INCORRECT = "\u5907\u7528\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c\u5b57\u6bcd\u4ee5\u53ca-\uff0c\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e15\uff01"; var MOBILE_IS_INCORRECT = "\u79fb\u52a8\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u5fc5\u987b\u662f11\u4f4d\u6570\u5b57\uff01"; var EMAIL_IS_EMPTY = "\u8bf7\u8f93\u5165\u7535\u5b50\u4fe1\u7bb1\uff01"; var EMAIL_IS_INCORRECT = "\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01"; var EMAIL1_IS_EMPTY = "\u8bf7\u8f93\u5165\u5e38\u7528\u7684\u7535\u5b50\u4fe1\u7bb1\uff01"; var EMAIL1_IS_INCORRECT = "\u5e38\u7528\u7684\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01"; var EMAIL2_IS_INCORRECT = "\u5907\u7528\u7684\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01"; var ZIPCODE_IS_EMPTY = "\u8bf7\u8f93\u5165\u90ae\u653f\u7f16\u7801\uff01"; var ZIPCODE_IS_INCORRECT = "\u90ae\u653f\u7f16\u7801\u5fc5\u987b\u662f6\u4f4d\u6570\u5b57\uff01"; var ADDRESS_IS_EMPTY = "\u8bf7\u8f93\u5165\u90ae\u653f\u5730\u5740\uff01"; var ADDRESS_IS_INCORRECT = "\u90ae\u653f\u5730\u5740\u4e0d\u6b63\u786e\uff0c\u5730\u5740\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e60\uff01"; var ACCOUNT_EDIT_INPUT_NICKNAME = "\u8bf7\u8f93\u5165\u8d26\u6237\u522b\u540d\uff01"; var WELCOME_IS_EMPTY = "\u8bf7\u8f93\u5165\u6b22\u8fce\u4fe1\u606f\uff01"; var COLOR_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u6700\u559c\u6b22\u7684\u989c\u8272\uff01"; var MOVIE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u6700\u559c\u6b22\u7684\u7535\u5f71\uff01"; var PET_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u6700\u559c\u6b22\u7684\u5ba0\u7269\uff01"; var GENDER_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u6027\u522b\uff01"; var QUESTIONONE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e00\uff01"; var QUESTIONTWO_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e8c\uff01"; var QUESTIONTHREE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e09\uff01"; var ANSWERONE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u95ee\u9898\u4e00\u7b54\u6848\uff01"; var ANSWERTWO_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e8c\u7b54\u6848\uff01"; var ANSWERTHREE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e09\u7b54\u6848\uff01"; //***************User identity related constants********************/ var IDENTITY_TYPE_IS_EMPTY = "\u8bf7\u9009\u62e9\u8bc1\u4ef6\u7c7b\u578b"; var IDENTITY_NO_IS_EMPTY = "\u8bf7\u8f93\u5165\u5408\u6cd5\u7684\u8bc1\u4ef6\u53f7\u7801\u3002"; var IDENTITY_NO_IS_INCORRECT = "\u8eab\u4efd\u8bc1\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u6b63\u786e\u7684\u8eab\u4efd\u8bc1\u53f7\u7801\u5fc5\u987b\u6ee1\u8db3\u4ee5\u4e0b\u89c4\u5219\uff1a" + "\r\n1\u3001\u957f\u5ea6\u5fc5\u987b\u4e3a15\u621618\u3002" + "\r\n2\u3001\u8eab\u4efd\u8bc1\u4e2d\u7684\u51fa\u751f\u65e5\u671f\u5fc5\u987b\u662f\u5408\u6cd5\u7684\u65e5\u671f\u3002" + "\r\n3\u300115\u4f4d\u7684\u8eab\u4efd\u8bc1\u5fc5\u987b\u662f\u6570\u5b57\u3002" + "\r\n4\u300118\u4f4d\u7684\u8eab\u4efd\u8bc1\u524d17\u4f4d\u5fc5\u987b\u662f\u6570\u5b57\uff0c\u6700\u540e\u4e00\u4f4d\u662f\u6570\u5b57\u6216\u5b57\u6bcd\u2018x\u2019\u3001\u2018X\u2019"; //***************User identity related constants end********************/ /*************** psnApplay \u5728\u7ebf\u9884\u7ea6\u7533\u8bf7\u5f00\u6237 lyj 20110321 begin **************************/ var IDENTITYDATE_IS_EMPTY = "\u8bf7\u8f93\u5165\u8bc1\u4ef6\u5230\u671f\u65e5\u671f\uff01"; var IDENTITYDATE_IS_INCORRECT = "\u8bc1\u4ef6\u5230\u671f\u65e5\u671f\u4e0d\u6b63\u786e\uff01\u65e5\u671f\u7684\u6b63\u786e\u683c\u5f0f\u4e3aYYYY/MM/DD\uff0c\u4e14\u5fc5\u987b\u4e3a\u5408\u6cd5\u7684\u65e5\u671f\uff01"; var IDENTITYDATE_LESS_THAN_TODAY = "\u8bc1\u4ef6\u5230\u671f\u65e5\u671f\u4e0d\u80fd\u5c0f\u4e8e\u4eca\u5929\uff01"; var BIRTHDAY_IS_EMPTY = "\u8bf7\u8f93\u5165\u51fa\u751f\u65e5\u671f"; var A_MOBILE_IS_EMPTY = "\u8bf7\u8f93\u5165\u624b\u673a\u53f7\u7801\uff01"; var A_MOBILE_IS_INCORRECT = "\u79fb\u52a8\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u5fc5\u987b\u662f11\u4f4d\u6570\u5b57\uff01"; var A_COUNTRY_IS_EMPTY = "\u8bf7\u8f93\u5165\u56fd\u5bb6\uff01"; var A_PROVINCE_IS_EMPTY = "\u8bf7\u8f93\u5165\u7701/\u76f4\u8f96\u5e02/\u81ea\u6cbb\u533a\uff01"; var A_PROVINCE_IS_INCORRECT = "\u7701/\u76f4\u8f96\u5e02/\u81ea\u6cbb\u533a\u4e0d\u6b63\u786e\uff0c\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e"+"\r\n\u7b49\u4e8e20\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u53602\u4e2a\u5b57\u7b26\uff09\uff0c\u8bf7\u4fee\u6539\uff01"; var A_CITY_IS_EMPTY = "\u8bf7\u8f93\u5165\u57ce\u5e02\uff01"; var A_CITY_IS_INCORRECT = "\u57ce\u5e02\u4e0d\u6b63\u786e\uff0c\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e20\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u53602\u4e2a\u5b57\u7b26\uff09\uff0c\u8bf7\u4fee\u6539\uff01"; var A_ADDRESS_IS_EMPTY = "\u8bf7\u8f93\u5165\u5730\u5740\uff01"; var A_ADDRESS_IS_INCORRECT = "\u5730\u5740\u4e0d\u6b63\u786e\uff0c\u5730\u5740\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e120\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u53602\u4e2a\u5b57\u7b26\uff09\uff0c\u8bf7\u4fee\u6539\uff01"; var A_EMAIL1_IS_INCORRECT = "\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01"; var A_PHONE_IS_INCORRECT = "\u529e\u516c\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c()\u4ee5\u53ca-\uff0c"+"\r\n\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u6216\u7b49\u4e8e14\uff01\u5982\uff1a"+"\r\n\n010-12345678\uff0c(0731)12345678\u3002"; var A_PHONE2_IS_INCORRECT = "\u5bb6\u5ead\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c()\u4ee5\u53ca-\uff0c"+"\r\n\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u6216\u7b49\u4e8e14\uff01\u5982\uff1a"+"\r\n\n010-12345678\uff0c(0731)12345678\u3002"; /*************** psnApplay \u5728\u7ebf\u9884\u7ea6\u7533\u8bf7\u5f00\u6237 lyj 20110321 end **************************/ //***************banking account related constants********************/ var ACCOUNT_IS_EMPTY = "\u8bf7\u8f93\u5165\u94f6\u884c\u8d26\u53f7\u3002"; var ACCOUNT_MUST_BE_NUMBER = "\u94f6\u884c\u8d26\u53f7\u5fc5\u987b\u662f\u6570\u5b57\u3002"; var DEBIT_CARD_IS_INVALID = "\u501f\u8bb0\u5361\u7684\u5361\u53f7\u5fc5\u987b\u662f19\u4f4d\u3002"; var QCC_IS_INVALID = "\u51c6\u8d37\u8bb0\u5361\u7684\u5361\u53f7\u5fc5\u987b\u662f16\u4f4d\u3002"; var BOC_CREDIT_CARD_IS_INVALID = "\u4fe1\u7528\u5361\u7684\u5361\u53f7\u5fc5\u987b\u662f16\u4f4d\u3002"; var ENROLLMENT_ACCOUNT_INVALID = "\u53ea\u6709\u501f\u8bb0\u5361\u624d\u80fd\u4f5c\u4e3a\u6ce8\u518c\u5361"; //***************banking account related constants end********************/ var PASSWORD_NOT_EQUAL_CONFIRM_PASSWORD = "\u5bc6\u7801\u4e0e\u786e\u8ba4\u5bc6\u7801\u4e0d\u4e00\u81f4\u3002"; var EFS_PASSWORD_LEN_INVALID = "\u5bc6\u7801\u7684\u957f\u5ea6\u5fc5\u987b\u5927\u4e8e\u7b49\u4e8e8\u3002"; var USER_NAME_LEN_INVALID = "\u7528\u6237\u540d\u7684\u957f\u5ea6\u5fc5\u987b\u5927\u4e8e\u7b49\u4e8e6\u3002"; var PHONE_PASSWORD_INVALID = "\u7535\u8bdd\u94f6\u884c\u5bc6\u7801\u4e0d\u6b63\u786e\u3002"; var CHECKING_CODE_IS_EMTPY = "\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801\u3002"; var DATE_INVALID = "\u60a8\u8f93\u5165\u7684\u65e5\u671f\u4e0d\u6b63\u786e\u3002"; var EXPIRING_DATE_INVALID = "\u4f60\u8f93\u5165\u7684\u5931\u6548\u65e5\u671f\u4e0d\u6b63\u786e\u3002"; var E_TOKEN_INVALID = "\u52a8\u6001\u53e3\u4ee4\u4e0d\u6b63\u786e\uff0c\u8bf7\u8f93\u51656\u4f4d\u6570\u5b57\u7684\u52a8\u6001\u53e3\u4ee4\u3002"; /*******************************/ /*** \u81ea\u52a9\u6ce8\u518c\u4f7f\u7528 end */ /*******************************/ /*******************************/ /*** \u5b9a\u671f\u5b58\u6b3e **/ /********************************/ var SELECT_CURRENCY = "\u8bf7\u9009\u62e9"; var TRANSFER_ACCOUNT_INVALID = "\u8d26\u6237\u4fe1\u606f\u4e0d\u53ef\u7528\uff0c\u8bf7\u9009\u62e9\u53e6\u4e00\u4e2a\u8d26\u6237\u6216\u8005\u5237\u65b0\u8d26\u6237\u4fe1\u606f"; var TRANSFER_FROM_ACCOUNT = "\u8bf7\u9009\u62e9\u8f6c\u51fa\u8d26\u6237\uff01"; var TRANSFER_TO_ACCOUNT = "\u8bf7\u9009\u62e9\u8f6c\u5165\u8d26\u6237\uff01"; var TRANSFER_AMOUNT = "\u8bf7\u586b\u5199\u8f6c\u8d26\u91d1\u989d\uff01"; var TRANSFER_CURRENCY = "\u8bf7\u8f93\u5165\u5e01\u79cd\u6027\u8d28!"; var TRANSFER_CASHREMIT = "\u8bf7\u9009\u62e9\u949e\u6c47\u6807\u5fd7!"; var TRANSFER_CDTERM = "\u8bf7\u9009\u62e9\u5b58\u671f!"; var TRANSFER_FREQUENCY = "\u8bf7\u9009\u62e9\u5468\u671f!"; var TRANSFER_ENDDATE = "\u8bf7\u9009\u62e9\u7ed3\u675f\u65e5\u671f!"; var SYSDATE = "\u7cfb\u7edf\u5f53\u524d\u65e5\u671f"; var SCHEDULEDATE = "\u9884\u7ea6\u6267\u884c\u65e5\u671f"; var STARTDATE_INVALID = "\u8d77\u59cb\u65e5\u671f\u5fc5\u987b\u662f\u7cfb\u7edf\u5f53\u524d\u65e5\u671f\u672a\u6765\u4e00\u4e2a\u6708\u7684\u4efb\u610f\u4e00\u5929!"; var ENDDATE_INVALID = "\u7ed3\u675f\u65e5\u671f\u5fc5\u987b\u662f\u7cfb\u7edf\u5f53\u524d\u65e5\u671f\u672a\u6765\u516d\u4e2a\u6708\u7684\u4efb\u610f\u4e00\u5929!"; var SCHEDULEDATE_INVALID = "\u9884\u7ea6\u6267\u884c\u65e5\u671f\u5fc5\u987b\u662f\u7cfb\u7edf\u5f53\u524d\u65e5\u671f\u672a\u6765\u4e09\u4e2a\u6708\u5185\u7684\u4efb\u610f\u4e00\u5929!"; var ENDDATE_BEFORE_STARTDATE = "\u7ed3\u675f\u65e5\u671f\u4e0d\u80fd\u5c0f\u4e8e\u8d77\u59cb\u65e5\u671f!"; var FORMAT_ERROR="{0}\u683c\u5f0f\u4e0d\u6b63\u786e\uff0c"; /*******************************/ /*** \u5b89\u5168\u63a7\u4ef6 **/ /********************************/ var SAFECONTROL_INSTALL = "\u8bf7\u9996\u5148\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5b89\u5168\u63a7\u4ef6\u540e\u518d\u767b\u5f55\u7f51\u4e0a\u94f6\u884c\uff0c\u5b89\u88c5\u63a7\u4ef6\u65f6\u8bf7\u5173\u95ed\u6240\u6709\u7684\u6d4f\u89c8\u5668\u7a97\u53e3\u3002"; var SAFECONTROL_VERSION = "\u5b89\u5168\u63a7\u4ef6\u5df2\u7ecf\u5347\u7ea7\uff0c\u8bf7\u9996\u5148\u4e0b\u8f7d\u5e76\u5b89\u88c5\u65b0\u7248\u672c\u5b89\u5168\u63a7\u4ef6\u540e\u518d\u767b\u5f55\u7f51\u4e0a\u94f6\u884c\u3002\u5b89\u88c5\u65b0\u5b89\u5168\u63a7\u4ef6\u524d\u8bf7\u5148\u5230\u63a7\u5236\u9762\u677f\u4e2d\u5378\u8f7d\u65e7\u5b89\u5168\u63a7\u4ef6\uff0c\u5b89\u88c5\u65f6\u5173\u95ed\u6240\u6709\u7684\u6d4f\u89c8\u5668\u7a97\u53e3\u3002"; //edit by yangda var CURCODE_KHR = "\u67ec\u57d4\u5be8\u745e\u5c14"; /* * \u5404\u5e01\u79cd\u91d1\u989d\u683c\u5f0f\u6570\u7ec4 * * curCodeArr[0] -- \u8868\u793a\u8d27\u5e01\u4ee3\u7801 * curCodeArr[1] -- \u8868\u793a\u5e01\u79cd\u540d\u79f0 * curCodeArr[2] -- \u8868\u793a\u6574\u6570\u4f4d\u6570 * curCodeArr[3] -- \u8868\u793a\u8f85\u5e01\u4f4d\u6570 * */ var curCodeArr = new Array( new Array("001",CURCODE_CNY,13,2), new Array("012",CURCODE_GBP,13,2), new Array("013",CURCODE_HKD,13,2), new Array("014",CURCODE_USD,13,2), new Array("015",CURCODE_CHF,13,2), new Array("016",CURCODE_DEM,13,2), new Array("017",CURCODE_FRF,13,2), new Array("018",CURCODE_SGD,13,2), new Array("020",CURCODE_NLG,13,2), new Array("021",CURCODE_SEK,13,2), new Array("022",CURCODE_DKK,13,2), new Array("023",CURCODE_NOK,13,2), new Array("024",CURCODE_ATS,13,2), new Array("025",CURCODE_BEF,13,0), new Array("026",CURCODE_ITL,13,0), new Array("027",CURCODE_JPY,13,0), new Array("028",CURCODE_CAD,13,2), new Array("029",CURCODE_AUD,13,2), new Array("038",CURCODE_EUR,13,2), new Array("056",CURCODE_IDR,13,2), new Array("064",CURCODE_VND,13,0), new Array("081",CURCODE_MOP,13,2), new Array("082",CURCODE_PHP,13,2), new Array("084",CURCODE_THB,13,2), new Array("087",CURCODE_NZD,13,2), new Array("088",CURCODE_KRW,13,0), new Array("095",CURCODE_XSF,13,2), new Array("072",CURCODE_RUR,13,2), new Array("070",CURCODE_ZAR,13,2), new Array("065",CURCODE_HUF,13,2), new Array("101",CURCODE_KZT,13,2), new Array("080",CURCODE_ZMK,13,2), new Array("032",CURCODE_MYR,13,2), //add by cuiyk \u767d\u91d1 \u6587\u83b1\u5e01 \u91cc\u4e9a\u5c14 \u535a\u8328\u74e6\u7eb3\u666e\u62c9 new Array("843",CURCODE_XPT,13,2), new Array("131",CURCODE_BND,13,2), new Array("134",CURCODE_BRL,13,2), new Array("039",CURCODE_BWP,13,2), //added by hhf.\u4e3a\u9ec4\u91d1\u724c\u4ef7\u5c40\u90e8\u5237\u65b0 new Array("034",CURCODE_XAU,13,2), new Array("035",CURCODE_GLD,13,0), //add by zph Riel new Array("166",CURCODE_KHR,13,2) );
007slmg-np-activex-justep
chrome/settings/_boc_resources_zh_CN_CurCode.js
JavaScript
mpl11
20,873
(function(proto) { proto.__defineGetter__("classid", function() { var clsid = this.getAttribute("clsid"); if (clsid == null) { return ""; } return "CLSID:" + clsid.substring(1, clsid.length - 1); }) proto.__defineSetter__("classid", function(value) { var e = document.createEvent('TextEvent'); e.initTextEvent( '__npactivex_log_event__', false, false, window, 'edit clsid ' + value); window.dispatchEvent(e); var oldstyle = this.style.display; this.style.display = "none"; var pos = value.indexOf(":"); this.setAttribute("clsid", "{" + value.substring(pos + 1) + "}"); this.setAttribute("type", "application/x-itst-activex"); this.style.display = oldstyle; }) })(HTMLObjectElement.prototype)
007slmg-np-activex-justep
chrome/settings/clsid.js
JavaScript
mpl11
795
navigator.cpuClass='x86';
007slmg-np-activex-justep
chrome/settings/cpuclass.js
JavaScript
mpl11
26
//************************************** //*** \u4ee5\u4e0b\u51fd\u6570\u662f\u8868\u5355\u68c0\u67e5\u76f8\u5173\u7684\u51fd\u6570 //*** \u6ce8\u610f:\u5f15\u7528\u6b64js\u6587\u4ef6\u65f6,\u5fc5\u987b\u5f15\u7528common.js //************************************** //************************************** //*** \u4ee5\u4e0b\u51fd\u6570\u662fFORM\u8868\u5355\u68c0\u67e5\u51fd\u6570 //************************************** /* * \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u8868\u5355\u5143\u7d20\u7f6e\u4e3aDISABLED(\u5305\u62ec\u6240\u6709\u8868\u5355\u5143\u7d20),\u5e76\u5c06\u8be5\u5143\u7d20\u80cc\u666f\u8272\u81f4\u7070 * * Parameter inputName -- \u6b32DISABLED\u7684\u8868\u5355\u5143\u7d20\u7684\u540d\u79f0; * flag -- \u662f\u5426disabled,true:disabled = true;false:disabled = false; * * \u4f8b\u5b50\uff1a setDisabled("form1.text1",true); * setDisabled("form1.text1|radio1|select1",true); */ function setDisabled(inputName,flag) { var inputObj; var bgStr; if (flag) bgStr = "#e7e7e7"; else bgStr = "#ffffff"; if(inputName.indexOf("|") == -1) { inputObj = eval(CONST_STRDOC + inputName); if (!inputObj.length) { if (inputObj.type != "radio" && inputObj.type != "checkbox") inputObj.style.background = bgStr; inputObj.disabled = flag; } else if (inputObj.type == "select-one" || inputObj.type == "select-multiple") { inputObj.style.background = bgStr; inputObj.disabled = flag; } else { for(var i = 0; i < inputObj.length; i++) { inputObj[i].disabled = flag; } } return; } var tmp = inputName.split("."); var formName = tmp[0]; var objName = tmp[1].split("|"); for (var i = 0; i < objName.length; i++) { inputObj = eval(CONST_STRDOC + formName + "." + objName[i]); if (!inputObj.length) { if (inputObj.type != "radio" && inputObj.type != "checkbox") inputObj.style.background = bgStr; inputObj.disabled = flag; } else if (inputObj.type == "select-one" || inputObj.type == "select-multiple") { inputObj.style.background = bgStr; inputObj.disabled = flag; } else { for(var j = 0; j < inputObj.length; j++) { inputObj[j].disabled = flag; } } } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u8868\u5355\u5143\u7d20\u7f6e\u4e3aREADONLY(\u4ec5\u6587\u672c\u57df\u6216\u8005textarea),\u5e76\u5c06\u8be5\u5143\u7d20\u80cc\u666f\u8272\u81f4\u7070 * * Parameter inputName -- \u6b32DISABLED\u7684\u8868\u5355\u5143\u7d20\u7684\u540d\u79f0; * flag -- \u662f\u5426disabled,true:disabled = true;false:disabled = false; * * \u4f8b\u5b50\uff1a setDisabled("form1.text1",true); * setDisabled("form1.text1|text2",true); */ function setReadOnly(inputName,flag) { var inputObj; var bgStr; if (flag) bgStr = "#e7e7e7"; else bgStr = "#ffffff"; if(inputName.indexOf("|") == -1) { inputObj = eval(CONST_STRDOC + inputName); inputObj.style.background = bgStr; inputObj.readOnly = flag; } var tmp = inputName.split("."); var formName = tmp[0]; var objName = tmp[1].split("|"); for (var i = 0; i < objName.length; i++) { inputObj = eval(CONST_STRDOC + formName + "." + objName[i]); inputObj.style.background = bgStr; inputObj.readOnly = flag; } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u8868\u5355\u8f93\u5165\u57df\u662f\u5426\u4e3a\u7a7a\uff0c\u4e0d\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter objName -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * * Return false --\u4e0d\u4e3a\u7a7a * true -- \u4e3a\u7a7a * * \u4f8b\u5b50\uff1aisEmpty('form1.userName'); */ function isEmpty(objName) { var inputObj = eval(CONST_STRDOC + objName); if (inputObj.value.trim() == null || inputObj.value.trim().length == 0) return true; else return false; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u7a7a,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f * \u4f8b\uff1acheck_empty('form1.userName','\u7528\u6237\u59d3\u540d'); * \u4f8b\uff1acheck_empty('form1.userName|userAge|userAddress','\u7528\u6237\u59d3\u540d|\u7528\u6237\u5e74\u9f84|\u7528\u6237\u5730\u5740'); * \u8868\u5355\u6837\u4f8b\uff1a * <form name='form1' action=''> * \u7528\u6237\u59d3\u540d\uff1a<input type='text' value='' name='userName'> * \u7528\u6237\u5e74\u9f84\uff1a<input type='text' value='' name='userAge'> * \u7528\u6237\u5730\u5740\uff1a<input type='text' value='' name='userAddress'> * </form> */ function check_empty(inputname,msg) { if(inputname.indexOf("|") == -1) { if(isEmpty(inputname)) { alert(msg + ENTER_MSG + NOT_NULL); return false; } return true; } var split_inputname = inputname.split("."); var split_inputs = split_inputname[1].split("|"); var split_msg = msg.split("|"); var errmsg=""; for (var i = 0; i < split_inputs.length; i++) { if(isEmpty(split_inputname[0]+"."+split_inputs[i])) errmsg = errmsg + split_msg[i] + " "; } if(errmsg.length != 0) { alert(errmsg + ENTER_MSG + NOT_NULL); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u4e25\u683c\u975e\u6cd5\u5b57\u7b26\u96c6)[]',^$\~:;!@?#%&<>''"" * \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9) * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_name(inputname,msg) { // var const_arychar=new Array("[","]","^","$","\\","~","@","#","%","&","<",">"); var const_arychar=new Array("[","]","^","$","\\","~","@","#","%","&","<",">","{","}",":","'","\""); // var const_arychar=new Array("[","]","'",",","^","$","\\","~",":",";","!","@","?","#","%","&","<",">","'","'","\"","\"" ); var inputobj,inputvalue; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; for (var i=0;i<const_arychar.length;i++) { if(inputvalue.indexOf(const_arychar[i])!=-1) {//find alert(msg + ENTER_MSG + ILLEGAL_CHAR); return false; } } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0) continue; for (var j=0;j<const_arychar.length;j++) { if(inputvalue.indexOf(const_arychar[j])!=-1) {//find errmsg=errmsg+split_msg[i]+" "; break; } } } if(errmsg!="") { alert(errmsg + ENTER_MSG + ILLEGAL_CHAR); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u5c0f\u989d\u53ca\u63a7\u5236\u5b57\u7b26\u975e\u6cd5\u5b57\u7b26\u96c6){}[]%'" \u0000-\u001F * \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9) * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * * Add By Hongxf */ function check_name3(inputname,msg) { var pattern; pattern = "^[^{}\\[\\]\\%\\'\\\"\\u0000-\\u001F]*$"; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; return regex_match(inputname,msg,pattern); } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0){ continue; }else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){ return false; } } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u9700\u6c42\u53d8\u66f4\u540e\u7684\u5c0f\u989d\u53ca\u63a7\u5236\u5b57\u7b26\u975e\u6cd5\u5b57\u7b26\u96c6){}[]%'" \u0000-\u001F \u65b0\u589e\u9650\u5236: `~$^_|\: * \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9) * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * * Add By Hongxf */ function check_payee_name_xe(inputname,msg) { var pattern; pattern = "^[^{}\\[\\]%'\"`~$^_|\\\\:\\u0000-\\u001F\\u0080-\\u00FF]{1,76}$"; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; return regex_match(inputname,msg,pattern); } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0){ continue; }else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){ return false; } } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u5c0f\u989d\u53ca\u63a7\u5236\u5b57\u7b26\u975e\u6cd5\u5b57\u7b26\u96c6){}[]%'" \u0000-\u001F \u65b0\u589e\u9650\u5236: `~$^_|\:oOiI * \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9) * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * * Add By Hongxf */ function check_payee_name_xeoi(inputname,msg) { var pattern; pattern = "^[^oOiI{}\\[\\]%'\"`~$^_|\\\\:\\u0000-\\u001F\\u0080-\\u00FF]{1,35}$"; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; return regex_match(inputname,msg,pattern); } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0){ continue; }else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){ return false; } } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5ba2\u6237\u7533\u8bf7\u53f7\u683c\u5f0f(1-10,4,90-100) * \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * \u6c47\u5212\u5373\u65f6\u901a\u67e5\u8be2\u5ba2\u6237\u7533\u8bf7\u53f7\u9700\u8981\u4f7f\u7528\u82f1\u6587\u9017\u53f7,\u6545\u5141\u8bb8\u82f1\u6587\u9017\u53f7 * \u7981\u6b62\u4e2d\u6587\u6807\u70b9 * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; allowEng -- \u662f\u5426\u53ef\u4ee5\u542b\u6709\u82f1\u6587(0:\u53ef\u4ee5,1:\u4e0d\u53ef\u4ee5) * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_name2('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_name2('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * * modified by liuy */ function check_name2(inputname,msg,allowEng) { var pattern; if(allowEng=="0"){ pattern = "^[A-Za-z0-9]{1,16}(-[A-Za-z0-9]{1,16})?(,[A-Za-z0-9]{1,16}(-[A-Za-z0-9]{1,16})?)*$"; }else if(allowEng=="1"){ pattern = "^[0-9]{1,16}(-[0-9]{1,16})?(,[0-9]{1,16}(-[0-9]{1,16})?)*$"; } if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; return regex_match(inputname,msg,pattern); } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0){ continue; }else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){ return false; } } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5b57\u7b26\u4e32\u4e2d\u6709\u4e2d\u6587,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u5305\u542b\u4e2d\u6587 * true -- \u4e0d\u5305\u542b * * \u4f8b\uff1acheck_chinese('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_chinese('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_chinese(inputname,msg) { var inputobj,inputvalue; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; for (var i=0;i<inputvalue.length;i++) { if(inputvalue.charCodeAt(i)>255) {//find alert(msg + ENTER_MSG + HAVE_CHINESE); return false; } } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0) continue; for (var j=0;j<inputvalue.length;j++) { if(inputvalue.charCodeAt(j)>255) {//find errmsg=errmsg+split_msg[i]+" "; break; } } } if(errmsg!="") { alert(errmsg + ENTER_MSG + HAVE_CHINESE); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u6570\u5b57,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u5305\u542b\u975e\u6570\u5b57 * true -- \u4e0d\u5305\u542b * * \u4f8b\uff1acheck_number('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_number('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_number(inputname,msg) { var inputobj,inputvalue; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; for (var i=0;i<inputvalue.length;i++) { if(inputvalue.charCodeAt(i)>57 || inputvalue.charCodeAt(i)<48) {//find alert(msg + ENTER_MSG + NOT_NUMBER); return false; } } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0) continue; for (var j=0;j<inputvalue.length;j++) { if(inputvalue.charCodeAt(j)>57 || inputvalue.charCodeAt(j)<48) {//find errmsg=errmsg+split_msg[i]+" "; break; } } } if(errmsg!="") { alert(errmsg + ENTER_MSG + NOT_NUMBER); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * pattern -- \u6b63\u5219\u8868\u8fbe\u5f0f * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1aregex_match('Form1.Input1','\u5b57\u6bb51','A-Z'); * \u4f8b\uff1aregex_match('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53','A-Z'); * */ function regex_match(inputname,msg,pattern) { return regex_match_msg(inputname,msg,pattern,ILLEGAL_REGEX); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * pattern -- \u6b63\u5219\u8868\u8fbe\u5f0f warn -- \u9519\u8bef\u63d0\u793a * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1aregex_match_msg('Form1.Input1','\u5b57\u6bb51','A-Z','\u5fc5\u987b\u4e3a\u5b57\u6bcd'); * \u4f8b\uff1aregex_match_msg('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53','A-Z','\u5fc5\u987b\u4e3a\u5b57\u6bcd'); * */ function regex_match_msg(inputname,msg,pattern,warn) { var inputobj,inputvalue; var regex = new RegExp(pattern); if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if (regex.test(inputvalue)) return true; alert(msg + ENTER_MSG + warn); return false; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; // if(inputvalue.length==0) // continue; if (!regex.test(inputvalue)) { errmsg=errmsg+split_msg[i]+" "; break; } } if(errmsg=="") return true; alert(errmsg + ENTER_MSG + warn); return false; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u7b49\u4e8e\u56fa\u5b9a\u957f\u5ea6,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * inputlength -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u4e0d\u7b49\u4e8e * true -- \u7b49\u4e8e * * \u4f8b\uff1acheck_length('Form1.Input1','8','\u5b57\u6bb51'); * \u4f8b\uff1acheck_length('Form1.Input1|Input2|Input3','6|8|10','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_length(inputname,inputlength,msg) { var inputobj; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); if((inputobj.value.length!=0) && (inputobj.value.length!=inputlength)) { alert(msg + LENGTH_EQUAL_MSG + inputlength + COMMA_MSG + ENTER_MSG + MODIFY_MSG); return false; } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_inputlength=inputlength.split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); if((inputobj.value.length!=0) && (inputobj.value.length!=split_inputlength[i])) errmsg=errmsg+split_msg[i] + LENGTH_EQUAL_MSG + split_inputlength[i] + COMMA_MSG + ENTER_MSG; } if(errmsg.length!=0) { alert(errmsg + MODIFY_MSG); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u5c0f\u4e8e\u6216\u7b49\u4e8e\u6307\u5b9a\u957f\u5ea6,\u63a7\u5236\u4e2d\u6587\u5b57\u7b26,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * inputlength -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u5927\u4e8e\u6307\u5b9a\u957f\u5ea6 * true -- \u5c0f\u4e8e\u6216\u7b49\u4e8e\u6307\u5b9a\u957f\u5ea6 * * \u4f8b\uff1acheck_length_zhCN('Form1.Input1','8','\u5b57\u6bb51'); * \u4f8b\uff1acheck_length_zhCN('Form1.Input1|Input2|Input3','6|8|10','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_length_zhCN(inputname,inputlength,msg) { var inputobj; var inputValue; var inputLength = 0; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); if(inputobj.value.length != 0) { inputValue = inputobj.value; for(var i = 0; i < inputobj.value.length;i++) { if(inputValue.charCodeAt(i)>127) inputLength++; inputLength++; } if (inputLength>inputlength) { alert(msg + LENGTH_MSG + inputlength + LENGTH_MSG1 + COMMA_MSG + ENTER_MSG + MODIFY_MSG); return false; } } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_inputlength=inputlength.split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); if(inputobj.value.length != 0) { inputValue = inputobj.value; for(var j = 0; j < inputobj.value.length;j++) { if(inputValue.charCodeAt(j)>127) inputLength++; inputLength++; } if (inputLength > split_inputlength[i]) errmsg=errmsg+split_msg[i] + LENGTH_MSG + split_inputlength[i] + LENGTH_MSG1 + COMMA_MSG + ENTER_MSG; inputLength = 0; } } if(errmsg.length!=0) { alert(errmsg + MODIFY_MSG); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u5728\u6307\u5b9a\u957f\u5ea6\u4e4b\u95f4,\u63a7\u5236\u4e2d\u6587\u5b57\u7b26,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * inputlength1 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6\u4e0b\u9650; * inputlength2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6\u4e0a\u9650; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u8d85\u51fa\u6307\u5b9a\u957f\u5ea6\u8303\u56f4 * true -- \u672a\u8d85\u51fa\u6307\u5b9a\u957f\u5ea6\u8303\u56f4 * * \u4f8b\uff1acheck_length_period('Form1.Input1','2','8','\u5b57\u6bb51'); * \u4f8b\uff1acheck_length_period('Form1.Input1|Input2|Input3','2|2|2','6|8|10','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_length_period(inputname,inputlength1,inputlength2,msg) { var inputobj; var inputValue; var inputLength = 0; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); if(inputobj.value.length != 0) { inputValue = inputobj.value; for(var i = 0; i < inputobj.value.length;i++) { if(inputValue.charCodeAt(i)>127) inputLength++; inputLength++; } if (inputLength > inputlength2 || inputLength < inputlength1) { alert(msg + LENGHT_PERIOD_MSG + inputlength1 + MINUS_MSG + inputlength2 + COMMA_MSG + ENTER_MSG + MODIFY_MSG); return false; } } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_inputlength1=inputlength1.split("|"); var split_inputlength2=inputlength2.split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); if(inputobj.value.length != 0) { inputValue = inputobj.value; for(var j = 0; j < inputobj.value.length;j++) { if(inputValue.charCodeAt(j)>127) inputLength++; inputLength++; } if (inputLength > split_inputlength2[i] || inputLength < split_inputlength1[i]) errmsg=errmsg+split_msg[i] + LENGHT_PERIOD_MSG + split_inputlength1[i] + MINUS_MSG + split_inputlength2[i] + COMMA_MSG + ENTER_MSG; inputLength = 0; } } if(errmsg.length!=0) { alert(errmsg + MODIFY_MSG); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u91d1\u989d,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * xflag -- 0:\u5355\u3001\u591a\u6587\u672c\u6846\u68c0\u67e5\u91d1\u989d\u662f\u5426\u5408\u6cd5\uff0c\u5355\u65f6inputname2\u548cmsg2\u7528 ''\u6216""\u8868\u793a; * 1:\u4e24\u6587\u672c\u6846\u68c0\u67e5\u91d1\u989d\u662f\u5426\u5408\u6cd5\uff0c\u91d1\u989d\u4e0b\u9650\u662f\u5426\u5927\u4e8e\u91d1\u989d\u4e0a\u9650; * 2:\u4e24\u6587\u672c\u6846\u68c0\u67e5\u91d1\u989d\u662f\u5426\u5408\u6cd5\uff0c\u91d1\u989d\u4e0a\u9650\u662f\u5426\u5c0f\u4e8e\u7b49\u4e8e\u91d1\u989d\u4e0b\u9650; * curCode -- \u8d27\u5e01\u4ee3\u7801,\u4eba\u6c11\u5e01\u4e3a001 * minusFlag -- \u91d1\u989d\u662f\u5426\u53ef\u4ee5\u4e3a\u8d1f,true:\u53ef\u4ee5\u4e3a\u8d1f,false:\u4e0d\u80fd\u4e3a\u8d1f; * * Return false -- \u91d1\u989d\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_money(0,'Form1.Input1','','\u5b57\u6bb51','','001','false'); * \u4f8b\uff1acheck_money(0,'Form1.Input1|Input2|Input3','','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53','','001','false'); * \u4f8b\uff1acheck_money(1,'Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','001','false'); * \u4f8b\uff1acheck_money(2,'Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','001','false'); * */ function check_money(xflag,inputname1,inputname2,msg1,msg2,curCode,minusFlag) { var curName, curLlen, curDec; for(var j = 0; j < curCodeArr.length; j++) { if (curCodeArr[j][0] == curCode) { curName = curCodeArr[j][1]; curLlen = curCodeArr[j][2]; curDec = curCodeArr[j][3]; break; } } if(xflag == 0) { var inputobj; if(inputname1.indexOf("|")==-1) { inputobj = eval(CONST_STRDOC + inputname1); switch(moneyCheck(inputobj.value,curLlen,curDec,minusFlag,"true")) { case "b": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1); return false; case "c": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2); return false; case "d": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3); return false; case "e": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4); return false; } return true; } var split_inputname=inputname1.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg1.split("|"); var minusArr = minusFlag.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); switch(moneyCheck(inputobj.value,curLlen,curDec,minusArr[i],"true")) { case "b": alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1); return false; case "c": alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2); return false; case "d": alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3); return false; case "e": alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4); return false; } } return true; } //xflag=1 if(xflag==1) { var inputobj1=eval(CONST_STRDOC+inputname1); var inputobj2=eval(CONST_STRDOC+inputname2); var inputvalue1 = moneyCheck(inputobj1.value,curLlen,curDec,minusFlag,"true"); var inputvalue2 = moneyCheck(inputobj2.value,curLlen,curDec,minusFlag,"true"); var errmsg=""; switch(inputvalue1) { case "b": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1); return false; case "c": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2); return false; case "d": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3); return false; case "e": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4); return false; } switch(inputvalue2) { case "b": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1); return false; case "c": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2); return false; case "d": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3); return false; case "e": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4); return false; } if(inputvalue1 == 0 || inputvalue2 == 0) return true; if(inputvalue1 > inputvalue2 ) { alert(msg2 + MONEY_MSG + msg1 + COMMA_MSG + MODIFY_MSG); return false; } return true; } //xflag=2 if(xflag==2) { var inputobj1=eval(CONST_STRDOC+inputname1); var inputobj2=eval(CONST_STRDOC+inputname2); var inputvalue1 = moneyCheck(inputobj1.value,curLlen,curDec,minusFlag,"true"); var inputvalue2 = moneyCheck(inputobj2.value,curLlen,curDec,minusFlag,"true"); var errmsg=""; switch(inputvalue1) { case "b": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1); return false; case "c": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2); return false; case "d": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3); return false; case "e": alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4); return false; } switch(inputvalue2) { case "b": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1); return false; case "c": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2); return false; case "d": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3); return false; case "e": alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4); return false; } if(inputvalue1 == 0 || inputvalue2 == 0) return true; if(inputvalue1 > inputvalue2 ) { alert(msg1 + MONEY_MSG0 + msg2 + COMMA_MSG + MODIFY_MSG); return false; } return true; } return false; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u6c47\u7387,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * curCode -- \u8d27\u5e01\u4ee3\u7801,\u4eba\u6c11\u5e01\u4e3a001 * emptyFlag -- \u57df\u662f\u5426\u53ef\u4ee5\u4e3a\u7a7a,true:\u53ef\u4ee5\u4e3a\u7a7a,false:\u4e0d\u80fd\u4e3a\u7a7a; * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_exchangerate("Form1.Input1","\u5b57\u6bb51","027","false"); * \u4f8b\uff1acheck_exchangerate("Form1.Input1|Input2|Input3","2|2|2","6|8|10","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53"); * */ function check_exchangerate(inputname,msg,curCode,emptyFlag) { if(inputname.indexOf("|") == -1) { var inputobj; inputobj = eval(CONST_STRDOC + inputname); /** \u4e3a\u5916\u6c47\u529f\u80fd\u7279\u6b8a\u5904\u7406\uff0c\u5982\u679c\u9875\u9762\u4e0a\u6709\u540c\u540d\u7684input\u57df\uff0c\u5219\u53d6\u7b2c\u4e00\u4e2a\u975edisabled\u7684\u4e3a\u5224\u65ad\u4f9d\u636e */ if (inputobj.length != null) { for(var i = 0; i < inputobj.length; i++) { if (!inputobj[i].disabled) { inputobj = inputobj[i]; break; } } } var curLen = 3; var curDec = 4; if (curCode == "027") { curLen = 3; curDec = 2; } switch(moneyCheck(inputobj.value,curLen,curDec,"false","false")) { case "a": if (emptyFlag == "false") alert(msg + ENTER_MSG + NOT_NULL); return false; case "b": alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG1); return false; case "c": alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG2); return false; case "d": alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG3); return false; case "e": alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG4); return false; } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var curCodeArr=curCode.split("|"); var emptyFlagArr = emptyFlag.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); var curLen = 3; var curDec = 4; if (curCodeArr[i] == "027") { curLen = 3; curDec = 2; } switch(moneyCheck(inputobj.value,curLen,curDec,"false","false")) { case "a": if (emptyFlagArr[i] == "false") alert(split_msg[i] + ENTER_MSG + NOT_NULL); return false; case "b": alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG1); return false; case "c": alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG2); return false; case "d": alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG3); return false; case "e": alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG4); return false; } } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u624b\u673a\u53f7,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f * true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f * * \u4f8b\uff1acheck_mobile("Form1.Input1","\u5b57\u6bb51"); * \u4f8b\uff1acheck_mobile("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53"); * */ function check_mobile(inputname,msg) { return regex_match(inputname,msg,"^([0-9]{11})?$"); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u8eab\u4efd\u8bc1\u53f7,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f * true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f * * \u4f8b\uff1acheck_identify("Form1.Input1","\u5b57\u6bb51"); * \u4f8b\uff1acheck_identify("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53"); * */ function check_identify(inputname,msg) { return regex_match(inputname,msg,"^(\\d{15}|\\d{17}[0-9Xx])?$"); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5EMAIL,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f * true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f * * \u4f8b\uff1acheck_email("Form1.Input1","\u5b57\u6bb51"); * \u4f8b\uff1acheck_email("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53"); * */ function check_email(inputname,msg) { return regex_match(inputname,msg,"^(\\S+@\\S+)?$"); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5E-token,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f * true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f * * \u4f8b\uff1acheck_etoken("Form1.Input1","\u5b57\u6bb51"); * \u4f8b\uff1acheck_etoken("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53"); * */ function check_etoken(inputname,msg) { return regex_match(inputname,msg,"^[0-9A-Za-z+=/]{6,12}$"); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u6d77\u5916\u4e2a\u4eba\u8f6c\u8d26\u6458\u8981,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f * true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f * * \u4f8b\uff1acheck_englishForBoc2000("Form1.Input1","\u5b57\u6bb51"); * \u4f8b\uff1acheck_englishForBoc2000("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53"); * */ function check_englishForBoc2000(inputname,msg) { return regex_match(inputname,msg,"^[ A-Za-z0-9-().,'//s/?/+//]*$"); } /** * \u51fd\u6570\u529f\u80fd\uff1a\u5b9e\u73b0check_date\u51fd\u6570\u7684\u91cd\u8f7d,\u672c\u51fd\u6570\u6839\u636echeck_date(arg1,arg2.....)\u4e2d\u53c2\u6570\u7684\u4e2a\u6570,\u5206\u522b\u8c03\u7528\u4e0d\u540c\u7684\u51fd\u6570,\u5206\u522b\u5b9e\u73b0\u4ee5\u4e0b\u529f\u80fd: * * 1. \u4ec5\u68c0\u67e5\u4e00\u4e2a\u65e5\u671f\u8f93\u5165\u57df\u662f\u5426\u5408\u6cd5:function checkDateSingle(inputname1,msg1) * 2. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u8f93\u5165\u57df(\u8d77\u59cb/\u622a\u6b62\u65e5\u671f)\u662f\u5426\u5408\u6cd5,\u4e14\u622a\u6b62\u665a\u4e8e\u8d77\u59cb:function checkDateTwo(inputname1,inputname2,msg1,msg2) * 3. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u8f93\u5165\u57df\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u65e5\u671f\u8de8\u5ea6\u4e3a\u82e5\u5e72\u6708\uff1a * 4. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4\u662f\u5426\u5728\u67d0\u4e2a\u65e5\u671f\uff08limitDate\uff09\u4e4b\u5185\uff0c\u8de8\u5ea6\u4e3aperiod: * function checkDateTwoLimit(inputname1,inputname2,msg1,msg2,limitDate,period) * 5. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u65e5\u671f\u8de8\u5ea6\u4e3a\u82e5\u5e72\u6708\u3001\u4e14\u53ef\u67e5\u8be2\u8303\u56f4\u662f\u5426\u5728\u67d0\u4e2a\u65e5\u671f\uff08limitDate\uff09\u4e4b\u5185\uff0c\u8de8\u5ea6\u4e3aperiod,\u67e5\u8be2\u8303\u56f4\u4e3ayPeriod * function checkDatePeriodLimit(inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod) * * * Parameter \u53c2\u6570\u542b\u4e49\u89c1\u5404\u51fd\u6570\u6ce8\u91ca * * Return false -- \u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1a1. check_date('Form1.Input1','\u5b57\u6bb51'); * check_date('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * * 2. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52'); * * 3. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52',3); * * 4. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',6); * * 5. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',6,-12); */ function check_date() { switch (arguments.length) { /** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a2,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */ case 2: return checkDateSingle(arguments[0],arguments[1]); break; /** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a4,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */ case 4: return checkDateTwo(arguments[0],arguments[1],arguments[2],arguments[3]); break; /** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a5,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */ case 5: return checkDateTwoPeriod(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4]); break; /** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a6,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */ case 6: return checkDateTwoLimit(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]); break; /** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a7,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */ case 7: return checkDatePeriodLimit(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]); break; default: return false; } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname1 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg1 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false -- \u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheckDateSingle('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheckDateSingle('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function checkDateSingle(inputname1,msg1) { var inputobj; var inputvalue; if(inputname1.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname1); inputvalue = isdate(inputobj.value); if(typeof(inputvalue) == "number" && inputvalue < 0) { alert(msg1 + ENTER_MSG + ILLEGAL_DATE); return false; } return true; } var split_inputname=inputname1.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg1.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue = isdate(inputobj.value); if(typeof(inputvalue) == "number" && inputvalue < 0) errmsg=errmsg+split_msg[i]+" "; } if(errmsg!="") { alert(errmsg + ENTER_MSG + ILLEGAL_DATE); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\uff0c\u5224\u65ad\u622a\u6b62\u65e5\u671f>\u5f00\u59cb\u65e5\u671f * * Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false -- \u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheckDateTwo('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52'); * */ function checkDateTwo(inputname1,inputname2,msg1,msg2) { var inputobj1=eval(CONST_STRDOC+inputname1); var inputobj2=eval(CONST_STRDOC+inputname2); var inputvalue1=isdate(inputobj1.value); var inputvalue2=isdate(inputobj2.value); var errmsg=""; if(typeof(inputvalue1) == "number" && inputvalue1 < 0) errmsg=errmsg+msg1+" "; if(typeof(inputvalue2) == "number" && inputvalue2 < 0) errmsg=errmsg+msg2+" "; if(errmsg!="") { alert(errmsg + ENTER_MSG + ILLEGAL_DATE); return false; } if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0) return true; if(inputvalue2 < inputvalue1) { alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5,\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4 * * Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * period -- \u8d77\u59cb\u65e5\u671f/\u622a\u6b62\u65e5\u671f\u7684\u8de8\u5ea6,\u4ee5\u6708\u4e3a\u5355\u4f4d,\u5982:period=3,\u8868\u793a3\u4e2a\u6708 * * Return false -- \u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheckDateTwoPeriod('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52',3); * */ function checkDateTwoPeriod(inputname1,inputname2,msg1,msg2,period) { var inputobj1=eval(CONST_STRDOC+inputname1); var inputobj2=eval(CONST_STRDOC+inputname2); var inputvalue1=isdate(inputobj1.value); var inputvalue2=isdate(inputobj2.value); var errmsg=""; if(typeof(inputvalue1) == "number" && inputvalue1 < 0) errmsg=errmsg+msg1+" "; if(typeof(inputvalue2) == "number" && inputvalue2 < 0) errmsg=errmsg+msg2+" "; if(errmsg!="") { alert(errmsg + ENTER_MSG + ILLEGAL_DATE); return false; } if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0) return true; if(inputvalue2 < inputvalue1) { alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG); return false; } if (addDate("m",inputvalue1,period) < inputvalue2) { alert(ILLEGAL_DATE_PERIOD + period + ENTRIES + MONTH + COMMA_MSG + MODIFY_MSG); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5,\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4 * * Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * limitDate -- \u622a\u6b62\u65e5\u671f\u7684\u6700\u5927\u503c; * period -- \u8d77\u59cb\u65e5\u671f/\u622a\u6b62\u65e5\u671f\u7684\u8de8\u5ea6,\u4ee5\u6708\u4e3a\u5355\u4f4d,\u5982:period=3,\u8868\u793a3\u4e2a\u6708 * * Return false -- \u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheckDateTwoLimit('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',6); * */ function checkDateTwoLimit(inputname1,inputname2,msg1,msg2,limitDate,period) { var inputobj1=eval(CONST_STRDOC+inputname1); var inputobj2=eval(CONST_STRDOC+inputname2); var inputvalue1=isdate(inputobj1.value); var inputvalue2=isdate(inputobj2.value); var errmsg=""; if(typeof(inputvalue1) == "number" && inputvalue1 < 0) errmsg=errmsg+msg1+" "; if(typeof(inputvalue2) == "number" && inputvalue2 < 0) errmsg=errmsg+msg2+" "; if(errmsg!="") { alert(errmsg + ENTER_MSG + ILLEGAL_DATE); return false; } if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0) return true; var limitEndDateValue = isdate(limitDate); var limitStartDateValue = addDate("m",isdate(limitDate),0-period); var limitStartDate = date2string(limitStartDateValue,"/"); if(inputvalue2 < inputvalue1) { alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG); return false; } if (limitEndDateValue < inputvalue2) { alert(msg2 + DATE_NOTLATER_MSG + limitDate + COMMA_MSG + MODIFY_MSG); return false; } if (inputvalue1 < limitStartDateValue) { alert(msg1 + DATE_LATER_MSG + limitStartDate + COMMA_MSG + MODIFY_MSG); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5,\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4 * * Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * limitDate -- \u67e5\u8be2\u8303\u56f4\u7684\u8d77\u59cb\u65e5\u671f; * period -- \u8d77\u59cb\u65e5\u671f/\u622a\u6b62\u65e5\u671f\u7684\u8de8\u5ea6,\u4ee5\u6708\u4e3a\u5355\u4f4d,\u5982:period=3,\u8868\u793a3\u4e2a\u6708 * yPeriod -- \u67e5\u8be2\u8303\u56f4,\u6708\u4e3a\u5355\u4f4d,-12\u8868\u793a\u4ecelimitDate\u5f80\u524d\u4e00\u5e74,12\u8868\u793a\u4ecelimitDate\u5f80\u540e\u4e00\u5e74 * * Return false -- \u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheckDateTwoLimit('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',3,-12); * */ function checkDatePeriodLimit(inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod) { var inputobj1=eval(CONST_STRDOC+inputname1); var inputobj2=eval(CONST_STRDOC+inputname2); var inputvalue1=isdate(inputobj1.value); var inputvalue2=isdate(inputobj2.value); var errmsg=""; if(typeof(inputvalue1) == "number" && inputvalue1 < 0) errmsg=errmsg+msg1+" "; if(typeof(inputvalue2) == "number" && inputvalue2 < 0) errmsg=errmsg+msg2+" "; if(errmsg!="") { alert(errmsg + ENTER_MSG + ILLEGAL_DATE); return false; } if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0) return true; var limitEndDateValue = null; var limitStartDateValue = null; if (yPeriod >= 0) { limitStartDateValue = isdate(limitDate); limitEndDateValue = addDate("m",isdate(limitDate),yPeriod); } else { limitEndDateValue = isdate(limitDate); limitStartDateValue = addDate("m",isdate(limitDate),yPeriod); } var limitStartDate = date2string(limitStartDateValue,"/"); var limitEndDate = date2string(limitEndDateValue,"/"); if(inputvalue2 < inputvalue1) { alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG); return false; } if (addDate("m",inputvalue1,period) < inputvalue2) { alert(ILLEGAL_DATE_PERIOD + period + ENTRIES + MONTH + COMMA_MSG + MODIFY_MSG); return false; } if (limitEndDateValue < inputvalue2) { alert(msg2 + DATE_NOTLATER_MSG + limitEndDate + COMMA_MSG + MODIFY_MSG); return false; } if (inputvalue1 < limitStartDateValue) { alert(msg1 + DATE_LATER_MSG + limitStartDate + COMMA_MSG + MODIFY_MSG); return false; } return true; } /** * \u51fd\u6570\u529f\u80fd\uff1a\u4fee\u6539checkDatePeriodLimit\u51fd\u6570\u529f\u80fd,\u8de8\u5ea6\u65e5\u671f\u5355\u4f4d\u7531\u6708\u6539\u4e3a\u65e5,\u53ef\u4ee5\u5b9e\u73b0"\u8d77\u59cb\u622a\u81f3\u65e5\u671f\u95f4\u9694\u4e0d\u80fd\u8d85\u8fc7XX\u5929"\u7c7b\u7684\u9700\u6c42 * * \u529f\u80fd: \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u65e5\u671f\u8de8\u5ea6\u4e3a\u82e5\u5e72\u5929\u3001\u4e14\u53ef\u67e5\u8be2\u8303\u56f4\u662f\u5426\u5728\u4ee5\u67d0\u4e2a\u65e5\u671f\uff08limitDate\uff09\u4e3a\u57fa\u51c6,\u8303\u56f4\u5728(yPeriod)\u4e4b\u5185,\u8d77\u59cb\u622a\u81f3\u65e5\u671f\u8de8\u5ea6\u4e3aperiod * function checkDatePeriodLimitByDay(inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod) * * * Parameter: * 1.inputname1: \u8d77\u59cb\u65e5\u671f\u8f93\u5165\u57df\u540d\u79f0 * 2.inputname2: \u622a\u81f3\u65e5\u671f\u8f93\u5165\u57df\u540d\u79f0 * 3.msg1: \u63d0\u793a\u4fe1\u606f\u4e2d,\u5bf9\u4e8e\u8d77\u59cb\u65e5\u671f\u7684\u7ffb\u8bd1 * 4.msg2: \u63d0\u793a\u4fe1\u606f\u4e2d,\u5bf9\u4e8e\u622a\u81f3\u65e5\u671f\u7684\u7ffb\u8bd1 * 5.limitDate: \u5982\u679c\u67e5\u8be2\u8303\u56f4(yPeriod)>=0,\u5219\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u8d77\u59cb\u65e5\u671f,\u6839\u636eyPeriod\u987a\u5ef6\u4e4b\u540e\u7684\u65e5\u671f\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u622a\u81f3\u65e5\u671f; * \u5982\u679c\u67e5\u8be2\u8303\u56f4(yPeriod)<0,\u5219\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u622a\u81f3\u65e5\u671f,\u6839\u636eyPeriod\u63d0\u524d\u7684\u65e5\u671f\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u8d77\u59cb\u65e5\u671f * 6.period: \u7528\u6237\u8f93\u5165\u7684\u8d77\u59cb\u622a\u81f3\u65e5\u671f\u4e4b\u95f4\u7684\u8de8\u5ea6,\u5355\u4f4d\u4e3a"\u5929" * 7.yPeriod: \u67e5\u8be2\u8303\u56f4,\u5173\u8054limitDate\u5224\u65ad,\u5355\u4f4d\u4e3a"\u6708" * * Return false -- \u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheckDatePeriodLimitByDay('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',15,-12); */ function checkDatePeriodLimitByDay (inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod) { var inputobj1=eval(CONST_STRDOC+inputname1); var inputobj2=eval(CONST_STRDOC+inputname2); var inputvalue1=isdate(inputobj1.value); var inputvalue2=isdate(inputobj2.value); var errmsg=""; if(typeof(inputvalue1) == "number" && inputvalue1 < 0) errmsg=errmsg+msg1+" "; if(typeof(inputvalue2) == "number" && inputvalue2 < 0) errmsg=errmsg+msg2+" "; if(errmsg!="") { alert(errmsg + ENTER_MSG + ILLEGAL_DATE); return false; } if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0) return true; var limitEndDateValue = null; var limitStartDateValue = null; if (yPeriod >= 0) { limitStartDateValue = isdate(limitDate); limitEndDateValue = addDate("m",isdate(limitDate),yPeriod); } else { limitEndDateValue = isdate(limitDate); limitStartDateValue = addDate("m",isdate(limitDate),yPeriod); } var limitStartDate = date2string(limitStartDateValue,"/"); var limitEndDate = date2string(limitEndDateValue,"/"); if(inputvalue2 < inputvalue1) { alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG); return false; } if (addDate("d",inputvalue1,period) < inputvalue2) { alert(ILLEGAL_DATE_PERIOD + period + DAY + COMMA_MSG + MODIFY_MSG); return false; } if (limitEndDateValue < inputvalue2) { alert(msg2 + DATE_NOTLATER_MSG + limitEndDate + COMMA_MSG + MODIFY_MSG); return false; } if (inputvalue1 < limitStartDateValue) { alert(msg1 + DATE_LATER_MSG + limitStartDate + COMMA_MSG + MODIFY_MSG); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u65e5\u671f\u6570\u636e,\u83b7\u5f97\u8fd4\u56de\u503c * * Parameter onestring -- \u9700\u5224\u65ad\u7684\u5b57\u7b26\u4e32; * * Return 0 -- \u5b57\u7b26\u4e32\u4e3a\u7a7a * -1 -- \u5b57\u7b26\u4e32\u975e\u65e5\u671f\u6570\u636e * \u65e5\u671f\u503c -- \u5b57\u7b26\u4e32\u4e3a\u65e5\u671f\u6570\u636e\uff0c\u5e76\u83b7\u5f97\u65e5\u671f\u503c * * \u4f8b\uff1aisdate("2000/01/01") \u8fd4\u56de20000101 * \u4f8b\uff1aisdate("") \u8fd4\u56de0 * \u4f8b\uff1aisdate("abc") \u8fd4\u56de-1 * */ function isdate(onestring) { if(onestring.length == 0) return 0; if(onestring.length != 10) return -1; var pattern = /\d{4}\/\d{2}\/\d{2}/; if(!pattern.test(onestring)) return -1; var arrDate = onestring.split("/"); if(parseInt(arrDate[0],10) < 100) arrDate[0] = 2000 + parseInt(arrDate[0],10) + ""; var newdate = new Date(arrDate[0],(parseInt(arrDate[1],10) -1)+"",arrDate[2]); if(newdate.getFullYear() == arrDate[0] && newdate.getMonth() == (parseInt(arrDate[1],10) -1)+"" && newdate.getDate() == arrDate[2]) return newdate; else return -1; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5b57\u7b26\u4e32\u5168\u4e3a\u4e2d\u6587,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u5305\u542b\u975e\u4e2d\u6587 * true -- \u5168\u4e3a\u4e2d\u6587 * * \u4f8b\uff1acheck_chinese_only('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_chinese_only('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_chinese_only(inputname,msg) { var inputobj,inputvalue; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; for (var i=0;i<inputvalue.length;i++) { if(inputvalue.charCodeAt(i)<=255) {//find alert(msg + ENTER_MSG + NOT_ONLY_CHINESE); return false; } } return true; } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0) continue; for (var j=0;j<inputvalue.length;j++) { if(inputvalue.charCodeAt(j)>255) {//find errmsg=errmsg+split_msg[i]+" "; break; } } } if(errmsg!="") { alert(errmsg + ENTER_MSG + NOT_ONLY_CHINESE); return false; } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u6570\u5b57\u3001\u52a0\u53f7\u3001\u7a7a\u683c\u3001\u6a2a\u7ebf,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u5305\u542b\u6570\u5b57\u3001\u52a0\u53f7\u3001\u7a7a\u683c\u3001\u6a2a\u7ebf\u4ee5\u5916\u7684\u5b57\u7b26 * true -- \u4e0d\u5305\u542b * * \u4f8b\uff1acheck_phone('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_phone('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_phone(inputname,msg) { return regex_match(inputname,msg,"[ 0-9-///+]*$"); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5224\u65ad\u91d1\u989d\u7684\u5408\u6cd5\u6027,\u540c\u65f6\u6269\u5c55\u4e3a\u666e\u901a\u6d6e\u70b9\u6570\u7684\u68c0\u67e5(\u79c1\u6709\u51fd\u6570\uff0c\u8bf7\u52ff\u8c03\u7528) * * Parameter str -- \u9700\u5224\u65ad\u7684\u5b57\u7b26\u4e32; * llen -- \u91d1\u989d\u6574\u6570\u90e8\u5206\u7684\u957f\u5ea6; * dec -- \u8f85\u5e01\u4f4d\u6570; * minusFlag -- \u91d1\u989d\u662f\u5426\u53ef\u4ee5\u4e3a\u8d1f,true:\u53ef\u4ee5\u4e3a\u8d1f,false:\u4e0d\u80fd\u4e3a\u8d1f; * isFormatMoney -- \u662f\u5426\u662f\u683c\u5f0f\u5316\u91d1\u989d,true:\u662f,false:\u5426;\u5982\u679c\u4e3a\u5426\uff0c\u53ef\u7528\u505a\u666e\u901a\u6d6e\u70b9\u6570\u7684\u5224\u65ad * * Return a -- \u5b57\u7b26\u4e32\u4e3a\u7a7a * b -- \u5b57\u7b26\u4e32\u975e\u6570\u503c\u6570\u636e * c -- \u91d1\u989d\u4e3a\u8d1f * d -- \u6574\u6570\u90e8\u5206\u8d85\u957f * e -- \u5c0f\u6570\u90e8\u5206\u8d85\u957f * \u6570\u503c -- \u5b57\u7b26\u4e32\u4e3a\u6570\u503c\u6570\u636e\uff0c\u5e76\u83b7\u5f97\u8f6c\u6362\u540e\u7684\u6570\u503c * * \u4f8b\uff1amoneyCheck("123,456,789.34",13,2) \u8fd4\u56de123456789.34 * */ function moneyCheck(str,llen,dec,minusFlag,isFormatMoney) { if(str == null || str == "") return "a"; if(str.length!=0&&str.trim().length == 0) return "b"; var regex; if (isFormatMoney == "true") regex = new RegExp(/(?!^[-]?[0,]*(\.0{1,4})?$)^[-]?(([1-9]\d{0,2}(,\d{3})*)|([1-9]\d*)|0)(\.\d{1,4})?$/); else regex = new RegExp(/(?!^[-]?[0]*(\.0{1,4})?$)^[-]?(([1-9]\d*)|0)(\.\d{1,4})?$/); if (!regex.test(str)) return "b"; var minus = ""; if (minusFlag == "true") { if(str.substring(0,1) == "-") { minus = "-"; str = str.substring(1); } } else { if(str.substring(0,1) == "-") return "c"; } if (str.substring(0,1)==".") str = "0" + str; str = replace(str,",",""); if (str.indexOf(".") == -1) { if (str.length > llen) return "d"; return parseFloat(minus + str); } else { var tmp = str.split("."); if(tmp.length > 2) return "b"; if (tmp[0].length > llen) return "d"; if (tmp[1].length > dec) return "e"; return parseFloat(minus + tmp[0] + "." + tmp[1]); } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u534a\u89d2\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5168\u89d2\u5b57\u7b26\u4e32(\u516c\u6709\u51fd\u6570\uff0c\u8bf7\u8c03\u7528) * * Parameter str -- \u9700\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u4e32\uff0c\u652f\u6301\u534a\u89d2\u5168\u89d2\u6df7\u5408\u5b57\u7b26\u4e32 * flag -- \u8f6c\u6362\u6807\u8bc6\uff0c0\u4e3a\u8f6c\u6362 * * Return \u5168\u89d2\u5b57\u7b26 * * \u4f8b\uff1aDBC2SBC("abcdefg",0) \u8fd4\u56de\uff41\uff42\uff43\uff44\uff45\uff46\uff47 * */ function DBC2SBC(str,flag) { var i; var result=''; if(str.length<=0) { return result; } for(i=0;i<str.length;i++){ str1=str.charCodeAt(i); if(str1<125&&!flag){ if(str1==32){//\u5982\u679c\u662f\u534a\u89d2\u7a7a\u683c\uff0c\u7279\u6b8a\u5904\u7406 result+=String.fromCharCode(12288); }else{ result+=String.fromCharCode(str.charCodeAt(i)+65248); } }else{ result+=String.fromCharCode(str.charCodeAt(i)); } } return result; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u7b49\u4e8e\u679a\u4e3e\u56fa\u5b9a\u957f\u5ea6,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * inputlength -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u679a\u4e3e\u56fa\u5b9a\u957f\u5ea6; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u4e0d\u7b49\u4e8e * true -- \u7b49\u4e8e * * \u4f8b\uff1acheck_length('Form1.Input1','6|8|10','\u5b57\u6bb51'); * */ function check_lengthEnum(inputname,inputlength,msg) { var inputobj; /* if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); if((inputobj.value.length!=0) && (inputobj.value.length!=inputlength)) { alert(msg + LENGTH_EQUAL_MSG + inputlength + COMMA_MSG + ENTER_MSG + MODIFY_MSG); return false; } return true; }*/ var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_inputlength=inputlength.split("|"); var split_msg=msg.split("|"); var errmsg=FORMAT_ERROR.replace("{0}",msg); inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[0]); for (var i=0;i<split_inputlength.length;i++) { if(inputobj.value.length==split_inputlength[i]) { errmsg=""; break } //errmsg=errmsg+split_msg[i] + LENGTH_EQUAL_MSG + split_inputlength[i] + COMMA_MSG + ENTER_MSG; } if(errmsg.length!=0) { alert(errmsg + MODIFY_MSG); return false; } return true; } /* *\u51fd\u6570\u529f\u80fd\uff1a\u53bb\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u7a7a\u767d\u7b26(\u5b57\u7b26\u4e32\u524d\u3001\u4e2d\u95f4\u3001\u540e) * *Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * * *\u4f8b\u5b50\uff1a onblur="trimAllBlank(document.form1.ToAccountNo)" */ function trimAllBlank(inputname) { var result=inputname.value.replace(/(\s)/g,""); inputname.value=result; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5swift\u975e\u6cd5\u5b57\u7b26 ` ~ ! @ # $ % ^ & * _ = [ ] { } ; " < > | \ : - * \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u4e0d\u5408\u6cd5 * true -- \u5408\u6cd5 * * \u4f8b\uff1acheck_swift('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_swift('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_swift(inputname,msg) { var pattern; pattern = "^[^`~!@#\\$%\\^&\\*_=\\[\\]{};\\\"<>\\|\\\\:-]*$"; if(inputname.indexOf("|")==-1) { inputobj=eval(CONST_STRDOC+inputname); inputvalue=inputobj.value; if(inputvalue.length==0) return true; return regex_match(inputname,msg,pattern); } var split_inputname=inputname.split("."); var split_inputs=split_inputname[1].split("|"); var split_msg=msg.split("|"); var errmsg=""; for (var i=0;i<split_inputs.length;i++) { inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]); inputvalue=inputobj.value; if(inputvalue.length==0){ continue; }else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){ return false; } } return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u5b57\u6bcd\u3001\u6570\u5b57,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a * * Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d; * msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f; * * Return false --\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u4ee5\u5916\u7684\u5b57\u7b26 * true -- \u4e0d\u5305\u542b * * \u4f8b\uff1acheck_letter_num('Form1.Input1','\u5b57\u6bb51'); * \u4f8b\uff1acheck_letter_num('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53'); * */ function check_letter_num(inputname,msg) { return regex_match(inputname,msg,"^[ A-Za-z0-9]*$"); } //************************************** //*** FORM\u8868\u5355\u68c0\u67e5\u51fd\u6570\u7ed3\u675f //**************************************
007slmg-np-activex-justep
chrome/settings/_boc_FormCheck.js
JavaScript
mpl11
73,404
(function (doc) { doc.createElement = function(orig) { return function(name) { if (name.trim()[0] == '<') { // We assume the name is correct. document.head.innerHTML += name; var obj = document.head.lastChild; document.head.removeChild(obj); return obj; } else { var val = orig.call(this, name); if (name == "object") { val.setAttribute("type", "application/x-itst-activex"); } return val; } } }(doc.createElement); })(HTMLDocument.prototype);
007slmg-np-activex-justep
chrome/settings/createElement.js
JavaScript
mpl11
556
scriptConfig.documentid = true;
007slmg-np-activex-justep
chrome/settings/documentid.js
JavaScript
mpl11
33
//************************************** //*** \u4ee5\u4e0b\u51fd\u6570\u662fJS\u516c\u7528\u51fd\u6570 //************************************** var CONST_STRDOC="document."; /* * \u51fd\u6570\u529f\u80fd\uff1a\u5220\u9664\u5de6\u53f3\u4e24\u7aef\u7684\u7a7a\u683c * */ String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u8df3\u8f6c\u81f3\u5176\u4ed6\u9875\u9762 * */ function gotoPage(url) { location.href = url; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u8df3\u8f6c\u81f3\u5176\u4ed6\u9875\u9762,\u5e76\u4f20\u9875\u9762\u53c2\u6570 * * Parameter url -- \u8df3\u8f6c\u7684\u94fe\u63a5; * paraName -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u540d\u79f0; * paraValue -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u503c; * * \u4f8b\uff1agotoPage('XXX.do','orderName','ActNo'); * gotoPage('XXX.do','orderName|orderName1|PageNum','ActNo|ibknum|3'); * */ function gotoPageByPara(url,paraName,paraValue) { var urlHavePara = false; if (url.indexOf("?") != -1) urlHavePara = true; if(paraName.indexOf("|") == -1) if (urlHavePara) location.href = url + "&" + paraName + "=" + paraValue ; else location.href = url + "?" + paraName + "=" + paraValue ; else { nameArr = paraName.split("|"); paraArr = paraValue.split("|"); var paraStr = ""; for(var i = 0; i < nameArr.length; i++) { if (i == 0 && !urlHavePara) paraStr = "?" + nameArr[i] + "=" + paraArr[i]; else paraStr += "&" + nameArr[i] + "=" + paraArr[i]; } location.href = url + paraStr; } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u6570\u636e\u4e0b\u8f7d\u4f7f\u7528\uff0c\u4f7f\u7528topFrame\u4e0b\u8f7d * */ function dataDownload(url) { parent.topFrame.location.href = url; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u6570\u636e\u4e0b\u8f7d\u4f7f\u7528\uff0c\u4f7f\u7528topFrame\u4e0b\u8f7d,\u5e76\u4f20\u9875\u9762\u53c2\u6570 * * Parameter url -- \u8df3\u8f6c\u7684\u94fe\u63a5; * paraName -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u540d\u79f0; * paraValue -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u503c; * * \u4f8b\uff1adataDownloadByPara('XXX.do','orderName','ActNo'); * dataDownloadByPara('XXX.do','orderName|orderName1|PageNum','ActNo|ibknum|3'); * */ function dataDownloadByPara(url,paraName,paraValue) { var urlHavePara = false; if (url.indexOf("?") != -1) urlHavePara = true; if(paraName.indexOf("|") == -1) if (urlHavePara) parent.topFrame.location.href = url + "&" + paraName + "=" + paraValue ; else parent.topFrame.location.href = url + "?" + paraName + "=" + paraValue ; else { nameArr = paraName.split("|"); paraArr = paraValue.split("|"); var paraStr = ""; for(var i = 0; i < nameArr.length; i++) { if (i == 0 && !urlHavePara) paraStr = "?" + nameArr[i] + "=" + paraArr[i]; else paraStr += "&" + nameArr[i] + "=" + paraArr[i]; } parent.topFrame.location.href = url + paraStr; } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u6253\u5370\u5f53\u524d\u9875\u9762,\u5e76\u5c4f\u853d\u6253\u5370\u6309\u94ae(\u5982\u679c\u5b58\u5728ID\u4e3aprintDiv\u7684DIV\u5219\u5c4f\u853d) * */ function printPage() { var obj = eval(CONST_STRDOC + "all.printDiv") if (obj && obj.style) { obj.style.display = "none"; window.print(); obj.style.display = ""; } else window.print(); } /* * \u51fd\u6570\u529f\u80fd\uff1a\u7528\u67d0\u5b57\u7b26\u4e32\u66ff\u6362\u6307\u5b9a\u5b57\u7b26\u4e32\u4e2d\u7684\u67d0\u5b57\u7b26\u4e32 * * Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u5f85\u66ff\u6362\u5b57\u4e32\u7684\u5b57\u7b26\u4e32; * str_s -- \u9700\u67e5\u627e\u7684\u5f85\u66ff\u6362\u7684\u5b57\u7b26\u4e32; * str_d -- \u8fdb\u884c\u66ff\u6362\u7684\u5b57\u7b26\u4e32; * * Return \u5b57\u7b26\u4e32 -- \u66ff\u6362\u540e\u7684\u5b57\u7b26\u4e32 * * \u4f8b\u5b50\uff1areplace("\u58f9\u4edf\u96f6\u96f6\u53c1","\u96f6\u96f6","\u96f6") * \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a\u58f9\u4edf\u96f6\u53c1 */ function replace(str,str_s,str_d) { var pos=str.indexOf(str_s); if (pos==-1) return str; var twopart=str.split(str_s); var ret=twopart[0]; for(pos=1;pos<twopart.length;pos++) ret=ret+str_d+twopart[pos]; return ret; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u53d6\u5f97\u8868\u5355\u4e2dradio\u7684\u503c * * Parameter str -- \u8868\u5355\u4e2dradio\u7684\u540d\u5b57; * * Return \u5b57\u7b26\u4e32 -- radio\u7684\u503c * * \u4f8b\u5b50\uff1agetRadioValue('form1.radio') * */ function getRadioValue(str) { var obj = eval(CONST_STRDOC + str); if (!obj) return; if (!obj.length) return obj.value; else { for(var i = 0; i < obj.length; i++) { if (obj[i].checked) { return obj[i].value; } } } } //************************************** //*** JS\u516c\u7528\u51fd\u6570\u7ed3\u675f //************************************** //**************************************/ //******* \u8fdb\u5ea6\u6761\u5904\u7406\u51fd\u6570 begin *******/ //**************************************/ /* * \u51fd\u6570\u529f\u80fd\uff1a\u663e\u793a\u9875\u9762\u5904\u7406\u65f6\u7684\u8fdb\u5ea6\u6761\uff0c\u5e76\u63a7\u5236\u5f53\u524d\u9875\u9762\u7684\u4e8c\u6b21\u63d0\u4ea4\uff0c\u5728checkForm\u4e2d\u8c03\u7528\u3002 */ function pageProcessing() { // try { // processForm(); // } catch (e) { // //alert("error: " + e.description); // } var processObj = document.all.processDiv; var processBlockObj = document.all.processBlockDiv; processObj.style.width = document.documentElement.scrollWidth; processObj.style.height = document.documentElement.scrollHeight; processObj.style.display = ""; processBlockObj.style.left = (document.documentElement.clientWidth - parseInt(processBlockObj.style.width)) / 2 + document.documentElement.scrollLeft; processBlockObj.style.top = (document.documentElement.clientHeight - parseInt(processBlockObj.style.height)) / 2 + document.documentElement.scrollTop; disableAllSelect(); /** 10\u5206\u949f\u540e\uff0c\u8fdb\u5ea6\u6761\u5931\u6548 */ window.setTimeout("pageProcessingDone();",600000); } /** \u4e3a\u6bcf\u4e2a\u9875\u9762\u589e\u52a0\u9632\u7be1\u6539\u529f\u80fd added by fangxi */ var processForm = (function () { if (typeof BocNet == undefined) { //alert("BocNet not found........"); return function() {}; } else { //alert("BocNet defined..."); var VAR1 = "_viewstate1", VAR2 = "_viewstate2"; var f0 = function(m, key, value) { if (!m[key]) m[key] = []; m[key].push(value == null ? '' : String(value)); }; var f1 = function(m, key, item) { f0(m, key, item.value); }; var f2 = function(m, key, item) { if (item.checked) f0(m, key, item.value); }; var f3 = function(m, key, item) { if (item.selectedIndex >= 0) $A(item.options).each(function(e) { if (e.selected) f0(m, key, e.value); }); }; var ByType = { "text": f1, "password": f1, "hidden": f1, "radio": f2, "checkbox":f2, "select-one": f3, "select-multiple": f3 }; var injector = function(m,item) { var key = String(item.name); if (!item.disabled && key && key != VAR1 && key != VAR2) { var f = ByType[item.type]; if (f) f(m, key, item); } return m; }; return function() { //alert("BocNet defined... " + $A(document.forms).length + " form(s) found..."); $A(document.forms).each(function(theform) { var theform = $(theform), result = ["", ""]; //alert("form: " + theform.name + " ... " + $A(theform.elements).length + " element(s) found..."); $H($A(theform.elements).inject({}, injector)).each(function(pair) { if (result[0]) { result[0] += ","; result[1] += ","; } result[0] += pair.key; result[1] += pair.key + "=" + pair.value.join(""); }); //alert(result[0] + "\r\n\r\n" + result[1]); var _viewstate1 = theform.getInputs("hidden", VAR1)[0]; if (!_viewstate1) _viewstate1 = BocNet.Form.createHidden(theform, VAR1); var _viewstate2 = theform.getInputs("hidden", VAR2)[0]; if (!_viewstate2) _viewstate2 = BocNet.Form.createHidden(theform, VAR2); _viewstate1.value = binl2b64(str2binl(result[0])); _viewstate2.value = b64_md5(result[1]); }); } } })(); /* * \u51fd\u6570\u529f\u80fd\uff1a\u9875\u9762\u5904\u7406\u65f6\u7684\u8fdb\u5ea6\u6761\u663e\u793a\u5b8c\u6bd5\u540e\u8c03\u7528\uff0c\u53d6\u6d88\u63a7\u5236\u5f53\u524d\u9875\u9762\u7684\u4e8c\u6b21\u63d0\u4ea4\u3002 */ function pageProcessingDone() { var processObj = document.all.processDiv; var processBlockObj = document.all.processBlockDiv; processObj.style.width = "0"; processObj.style.height = "0"; processObj.style.display = "none"; processBlockObj.style.left = "0"; processBlockObj.style.top = "0"; enableAllSelect(); } /* * \u51fd\u6570\u529f\u80fd\uff1adisable\u5f53\u524d\u9875\u7684\u6240\u6709\u4e0b\u62c9\u83dc\u5355 */ function disableAllSelect() { var obj = document.getElementsByTagName("SELECT"); for(var i = 0; i < obj.length; i++) { obj[i].style.display = "none"; } } /* * \u51fd\u6570\u529f\u80fd\uff1aenable\u5f53\u524d\u9875\u7684\u6240\u6709\u4e0b\u62c9\u83dc\u5355 */ function enableAllSelect() { var obj = document.getElementsByTagName("SELECT"); for(var i = 0; i < obj.length; i++) { obj[i].style.display = ""; } } //**************************************/ //******* \u8fdb\u5ea6\u6761\u5904\u7406\u51fd\u6570 end *******/ //**************************************/ //**************************************/ //******* \u65e5\u671f\u5904\u7406\u51fd\u6570 begin *******/ //**************************************/ /* * \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u65e5\u671f\u6570\u636e\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32 * * Parameter datePara -- \u65e5\u671f\u578b\u6570\u636e; * splitReg -- \u5206\u9694\u7b26 * * Return \u6309\u7167\u5206\u9694\u7b26\u5206\u9694\u7684\u65e5\u671f\u5b57\u7b26\u4e32\u3002 * */ function date2string(datePara,splitReg) { var lMonth = datePara.getMonth() + 1; lMonth = (lMonth < 10 ? "0" + lMonth : lMonth); var lDate = datePara.getDate(); lDate = (lDate < 10 ? "0" + lDate : lDate); return datePara.getFullYear() + splitReg + lMonth + splitReg + lDate; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5f97\u5230\u65e5\u671f\u7684\u589e\u51cf * * Parameter strInterval -- d:\u6309\u5929;m:\u6309\u6708;y:\u6309\u5e74; * dateStr -- \u8d77\u59cb\u65e5\u671f,date\u5bf9\u8c61\u6216\u8005yyyy/MM/dd\u683c\u5f0f * Number -- \u65e5\u671f\u589e\u51cf\u7684\u91cf,\u652f\u6301\u6b63\u8d1f * * Return \u6309\u7167\u5206\u9694\u7b26\u5206\u9694\u7684\u65e5\u671f\u5b57\u7b26\u4e32\u3002 * */ function addDate(strInterval, dateStr, numberPara) { var dtTmp = new Date(Date.parse(dateStr)); switch (strInterval) { case 'd' : return new Date(Date.parse(dtTmp) + (86400000 * numberPara)); case 'm' : /** xulc modified:\u4fee\u6539\u4e86BUG\uff0c1\u670831\u65e5\u5f80\u540e\u4e00\u4e2a\u6708\u4e3a2\u670828\u65e5\uff0c\u4fee\u6539\u524d\u4e3a3\u67082\u65e5 */ var oldY = dtTmp.getFullYear(); /** \u6b32\u53d8\u66f4\u7684\u6708\u4efd */ var newMon = dtTmp.getMonth() + numberPara; /** \u53d8\u66f4\u6708\u4efd\u540e\uff0c\u7cfb\u7edf\u751f\u6210\u7684DATE\u5bf9\u8c61 */ var newDate = new Date(dtTmp.getFullYear(), newMon, dtTmp.getDate()); /** \u53d6\u65b0\u7684DATE\u5bf9\u8c61\u4e2d\u7684\u5e74\u548c\u6708\uff0c\u6309\u7167JS\u7684\u5904\u7406\uff0c\u6b64\u65f61\u670831\u65e5\u5f80\u540e\u4e3a3\u67082\u65e5 */ var tmpMon = newDate.getMonth(); var tmpY = newDate.getFullYear(); /** \u5982\u679c\u4e0d\u662f\u5927\u5c0f\u6708\u4ea4\u66ff\u65f6\u7684\u60c5\u51b5\uff0c\u5373\u65b0\u7684\u6708\u548c\u6b32\u53d8\u66f4\u7684\u6708\u4efd\u5e94\u8be5\u76f8\u7b49 || \u5982\u679c\u8de8\u5e74\uff0c\u4e24\u4e2a\u6708\u4efd\u4e5f\u4e0d\u76f8\u7b49\uff0c\u800c12\u6708\u548c1\u6708\u5747\u4e3a\u5927\u6708 */ if (tmpMon == newMon || oldY != tmpY) return newDate; /** \u5982\u679c\u4e0d\u80fd\u76f4\u63a5\u8fd4\u56de\uff0c\u5219\u5c06\u9519\u8bef\u7684\u6708\u4efd\u5f80\u524d\u51cf\u5929\uff0c\u76f4\u9053\u627e\u5230\u4e0a\u6708\u7684\u6700\u540e\u4e00\u5929 */ while(tmpMon != newMon) { newDate = new Date(newDate.getFullYear(), newDate.getMonth(), (newDate.getDate() - 1)); tmpMon = newDate.getMonth(); } return newDate; case 'y' : return new Date((dtTmp.getFullYear() + numberPara), dtTmp.getMonth(), dtTmp.getDate()); } } //**************************************/ //******* \u65e5\u671f\u5904\u7406\u51fd\u6570 end *******/ //**************************************/ //**************************************/ //******* \u4ee3\u7f34\u8d39\u5904\u7406\u51fd\u6570 begin *******/ //**************************************/ /* * \u51fd\u6570\u529f\u80fd\uff1a\u5faa\u73af\u68c0\u67e5\u8868\u5355\u4e2d\u9700\u68c0\u67e5\u7684\u5143\u7d20 * * Parameter * * Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f * true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f * */ function paysCheck() { for(var i = 0; i < document.forms.length; i++) { var obj = document.forms[i]; for(var j = 0; j < obj.elements.length; j++) { if (obj.elements[j].check && obj.elements[j].check != "") { var checkArr = obj.elements[j].check.split(","); for(var k = 0; k < checkArr.length; k++) { var tmpStr = checkArr[k] + "(\"" + document.forms[i].name + "." + obj.elements[j].name + "\",\"" + obj.elements[j].checkName + "\")"; if (eval(tmpStr)) continue; else return false; } } } } return true; } //**************************************/ //******* \u4ee3\u7f34\u8d39\u5904\u7406\u51fd\u6570 end *******/ //**************************************/
007slmg-np-activex-justep
chrome/settings/_boc_common.js
JavaScript
mpl11
14,532
(function () { var hiddenDivId = "__hiddendiv_activex"; window.__proto__.ActiveXObject = function(progid) { progid = progid.trim(); var e = document.createEvent('TextEvent'); e.initTextEvent( '__npactivex_log_event__', false, false, window, 'Dynamic create ' + progid); window.dispatchEvent(e); if (progid == 'Msxml2.XMLHTTP' || progid == 'Microsoft.XMLHTTP') return new XMLHttpRequest(); var hiddenDiv = document.getElementById(hiddenDivId); if (!hiddenDiv) { if (!document.body) return null; hiddenDiv = document.createElement("div"); hiddenDiv.id = hiddenDivId; hiddenDiv.setAttribute("style", "width:0px; height:0px"); document.body.insertBefore(hiddenDiv, document.body.firstChild) } var obj = document.createElement("object"); obj.setAttribute("type", "application/x-itst-activex"); obj.setAttribute("progid", progid); obj.setAttribute("style", "width:0px; height:0px"); obj.setAttribute("dynamic", ""); hiddenDiv.appendChild(obj); if (obj.object === undefined) { throw new Error('Dynamic create failed ' + progid) } return obj.object } //console.log("ActiveXObject declared"); })();
007slmg-np-activex-justep
chrome/settings/dynamic.js
JavaScript
mpl11
1,221
//************************************** //*** \u663e\u793a\u65e5\u5386 //************************************** var bMoveable=true; //\u8bbe\u7f6e\u65e5\u5386\u662f\u5426\u53ef\u4ee5\u62d6\u52a8 var strFrame; //\u5b58\u653e\u65e5\u5386\u5c42\u7684HTML\u4ee3\u7801 document.writeln('<iframe src="javascript:false" id=meizzDateLayer frameborder=0 style="position: absolute; width: 176px; height: 187px; z-index: 9998; display: none"></iframe>'); strFrame='<style>'; strFrame+='.calData { border:1px solid #a9a9a9; margin:0px; padding:0px; font-family:Verdana, Arial, Helvetica, sans-serif; }'; strFrame+='.calDay {font-decoration: none; font-family: arial; font-size: 12px; color: #000000; background-color: #F8F8F8;}'; strFrame+='.calHeadZh{font-size: 12px; color:#A50031}'; strFrame+='.calHead{font-size: 9px; color:#A50031}'; strFrame+='</style>'; strFrame+='<scr' + 'ipt>'; strFrame+='var datelayerx,datelayery; /*\u5b58\u653e\u65e5\u5386\u63a7\u4ef6\u7684\u9f20\u6807\u4f4d\u7f6e*/'; strFrame+='var bDrag; /*\u6807\u8bb0\u662f\u5426\u5f00\u59cb\u62d6\u52a8*/'; strFrame+='function document.onmousemove() /*\u5728\u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u4e2d\uff0c\u5982\u679c\u5f00\u59cb\u62d6\u52a8\u65e5\u5386\uff0c\u5219\u79fb\u52a8\u65e5\u5386*/'; strFrame+='{if(bDrag && window.event.button==1)'; strFrame+=' {var DateLayer=parent.document.all.meizzDateLayer.style;'; strFrame+=' DateLayer.posLeft += window.event.clientX-datelayerx;/*\u7531\u4e8e\u6bcf\u6b21\u79fb\u52a8\u4ee5\u540e\u9f20\u6807\u4f4d\u7f6e\u90fd\u6062\u590d\u4e3a\u521d\u59cb\u7684\u4f4d\u7f6e\uff0c\u56e0\u6b64\u5199\u6cd5\u4e0ediv\u4e2d\u4e0d\u540c*/'; strFrame+=' DateLayer.posTop += window.event.clientY-datelayery;}}'; strFrame+='function DragStart() /*\u5f00\u59cb\u65e5\u5386\u62d6\u52a8*/'; strFrame+='{var DateLayer=parent.document.all.meizzDateLayer.style;'; strFrame+=' datelayerx=window.event.clientX;'; strFrame+=' datelayery=window.event.clientY;'; strFrame+=' bDrag=true;}'; strFrame+='function DragEnd(){ /*\u7ed3\u675f\u65e5\u5386\u62d6\u52a8*/'; strFrame+=' bDrag=false;}'; strFrame+='</scr' + 'ipt>'; strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false"><span id=tmpSelectYearLayer style="z-index: 9999;position: absolute;top: 3; left: 19;display: none"></span>'; strFrame+='<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 3; left: 110;display: none"></span>'; strFrame+='<table border=1 class="calData" cellspacing=0 cellpadding=0 width=172 height=160 bordercolor=#cecece bgcolor=#ff9900>'; strFrame+=' <tr><td width=172 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=172 height=23>'; strFrame+=' <tr align=center><td width=16 align=center bgcolor=#ffffff style="font-size:12px;cursor: hand;color: #A50031" '; strFrame+=' onclick="parent.meizzPrevY()"><b><</b>'; strFrame+=' </td><td width=60 align=center style="font-size:12px;cursor:default" '; strFrame+='onmouseover="style.backgroundColor=\'#cecece\'" onmouseout="style.backgroundColor=\'white\'" '; strFrame+='onclick="parent.tmpSelectYearInnerHTML(this.innerText.substring(0,4))"><span id=meizzYearHead></span></td>'; strFrame+=' <td width=16 bgcolor=#ffffff align=center style="font-size:12px;cursor: hand;color: #A50031" '; strFrame+=' onclick="parent.meizzNextY()"><b>></b></td>'; strFrame+='<td width=16 align=center bgcolor=#ffffff style="font-size:12px;cursor: hand;color: #A50031" onclick="parent.meizzPrevM()" title="\u5411\u524d\u7ffb 1 \u6708" ><b><</b></td>'; strFrame+='<td width=48 align=center style="font-size:12px;cursor:default" onmouseover="style.backgroundColor=\'#cecece\'" '; strFrame+=' onmouseout="style.backgroundColor=\'white\'" onclick="parent.tmpSelectMonthInnerHTML(this.innerText)"'; strFrame+=' ><span id=meizzMonthHead ></span></td>'; strFrame+=' <td width=16 bgcolor=#ffffff align=center style="font-size:12px;cursor: hand;color: #A50031" '; strFrame+=' onclick="parent.meizzNextM()"><b>></b></td></tr>'; strFrame+=' </table></td></tr>'; strFrame+=' <tr><td width=142 height=18>'; strFrame+='<table border=1 id="calHeadTable" cellspacing=0 cellpadding=0 bgcolor=#cecece ' + (bMoveable? 'onmousedown="DragStart()" onmouseup="DragEnd()"':''); strFrame+=' BORDERCOLORLIGHT=#ffffff BORDERCOLORDARK=#ffffff width=172 height=20 style="cursor:' + (bMoveable ? 'move':'default') + '">'; strFrame+='<tr align=center valign=bottom><td>' + calDayArr[0] + '</td>'; strFrame+='<td>' + calDayArr[1] + '</td><td>' + calDayArr[2] + '</td>'; strFrame+='<td>' + calDayArr[3] + '</td><td>' + calDayArr[4] + '</td>'; strFrame+='<td>' + calDayArr[5] + '</td><td>' + calDayArr[6] + '</td></tr>'; strFrame+='</table></td></tr>'; strFrame+=' <tr><td width=142 height=120>'; strFrame+=' <table border=1 cellspacing=2 cellpadding=0 BORDERCOLORLIGHT=#ffffff BORDERCOLORDARK=#FFFFFF bgcolor=#ffffff width=172 height=120>'; var n=0; for (j=0;j<5;j++){ strFrame+= ' <tr align=center>'; for (i=0;i<7;i++){ strFrame+='<td width=20 height=20 id=meizzDay'+n+' class="calDay" onclick=parent.meizzDayClick(this.innerText,0)></td>';n++;} strFrame+='</tr>';} strFrame+=' <tr align=center>'; for (i=35;i<39;i++)strFrame+='<td width=20 height=20 id=meizzDay'+i+' class="calDay" onclick="parent.meizzDayClick(this.innerText,0)"></td>'; strFrame+=' <td colspan=3 align=right ><span onclick=parent.closeLayer() style="font-size:12px;cursor: hand;color: #A50031"'; strFrame+=' ><b>&#215;</b></span></td></tr>'; strFrame+=' </table></td></tr>'; strFrame+='</table></div>'; window.frames.meizzDateLayer.document.writeln(strFrame); window.frames.meizzDateLayer.document.close(); //\u89e3\u51b3ie\u8fdb\u5ea6\u6761\u4e0d\u7ed3\u675f\u7684\u95ee\u9898 //==================================================== WEB \u9875\u9762\u663e\u793a\u90e8\u5206 ====================================================== var outObject; var outButton; //\u70b9\u51fb\u7684\u6309\u94ae var outDate=""; //\u5b58\u653e\u5bf9\u8c61\u7684\u65e5\u671f var odatelayer=window.frames.meizzDateLayer.document.all; //\u5b58\u653e\u65e5\u5386\u5bf9\u8c61 var yearPeriod = 12; function showCalendar() { switch (arguments.length) { /** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a2,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */ case 2: showCalendarDeal(arguments[0],arguments[1]); break; /** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a4,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */ case 3: yearPeriod = arguments[2]; showCalendarDeal(arguments[0],arguments[1]); break; default: showCalendarDeal(arguments[0],arguments[1]); break; } } function showCalendarDeal(tt,obj) //\u4e3b\u8c03\u51fd\u6570 { if (arguments.length > 2){alert("\u5bf9\u4e0d\u8d77!\u4f20\u5165\u672c\u63a7\u4ef6\u7684\u53c2\u6570\u592a\u591a!");return;} if (arguments.length == 0){alert("\u5bf9\u4e0d\u8d77!\u60a8\u6ca1\u6709\u4f20\u56de\u672c\u63a7\u4ef6\u4efb\u4f55\u53c2\u6570!");return;} if (calLanguage == "zhCN") odatelayer.calHeadTable.className = "calHeadZh"; else odatelayer.calHeadTable.className = "calHead"; var dads = document.all.meizzDateLayer.style; var th = tt; var ttop = tt.offsetTop; //TT\u63a7\u4ef6\u7684\u5b9a\u4f4d\u70b9\u9ad8 var thei = tt.clientHeight; //TT\u63a7\u4ef6\u672c\u8eab\u7684\u9ad8 var tleft = tt.offsetLeft; //TT\u63a7\u4ef6\u7684\u5b9a\u4f4d\u70b9\u5bbd var ttyp = tt.type; //TT\u63a7\u4ef6\u7684\u7c7b\u578b while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;} dads.top = (ttyp=="image")? ttop+thei : ttop+thei+6; dads.left = tleft; outObject = (arguments.length == 1) ? th : obj; outButton = (arguments.length == 1) ? null : th; //\u8bbe\u5b9a\u5916\u90e8\u70b9\u51fb\u7684\u6309\u94ae //\u6839\u636e\u5f53\u524d\u8f93\u5165\u6846\u7684\u65e5\u671f\u663e\u793a\u65e5\u5386\u7684\u5e74\u6708 var reg = /^(\d{4})\/(\d{1,2})\/(\d{1,2})$/; var r = outObject.value.match(reg); if(r!=null) { r[2]=r[2]-1; var d= new Date(r[1], r[2],r[3]); if(d.getFullYear()==r[1] && d.getMonth()==r[2] && d.getDate()==r[3]) { outDate = d; //\u4fdd\u5b58\u5916\u90e8\u4f20\u5165\u7684\u65e5\u671f meizzSetDay(r[1],r[2]+1); } else { outDate = ""; meizzSetDay(new Date().getFullYear(), new Date().getMonth() + 1); } } else { outDate=""; meizzSetDay(new Date().getFullYear(), new Date().getMonth() + 1); } dads.display = ''; event.returnValue=false; } var MonHead = new Array(12); //\u5b9a\u4e49\u9633\u5386\u4e2d\u6bcf\u4e2a\u6708\u7684\u6700\u5927\u5929\u6570 MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30; MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31; var meizzTheYear=new Date().getFullYear(); //\u5b9a\u4e49\u5e74\u7684\u53d8\u91cf\u7684\u521d\u59cb\u503c var meizzTheMonth=new Date().getMonth()+1; //\u5b9a\u4e49\u6708\u7684\u53d8\u91cf\u7684\u521d\u59cb\u503c var meizzWDay=new Array(39); //\u5b9a\u4e49\u5199\u65e5\u671f\u7684\u6570\u7ec4 function document.onclick() //\u4efb\u610f\u70b9\u51fb\u65f6\u5173\u95ed\u8be5\u63a7\u4ef6 //ie6\u7684\u60c5\u51b5\u53ef\u4ee5\u7531\u4e0b\u9762\u7684\u5207\u6362\u7126\u70b9\u5904\u7406\u4ee3\u66ff { with(window.event) { if (srcElement.getAttribute("Author")==null && srcElement != outObject && srcElement != outButton) closeLayer(); } } function document.onkeyup() //\u6309Esc\u952e\u5173\u95ed\uff0c\u5207\u6362\u7126\u70b9\u5173\u95ed { if (window.event.keyCode==27){ if(outObject)outObject.blur(); closeLayer(); } else if(document.activeElement) if(document.activeElement.getAttribute("Author")==null && document.activeElement != outObject && document.activeElement != outButton) { closeLayer(); } } function meizzWriteHead(yy,mm) //\u5f80 head \u4e2d\u5199\u5165\u5f53\u524d\u7684\u5e74\u4e0e\u6708 { odatelayer.meizzYearHead.innerText = yy + calYear; odatelayer.meizzMonthHead.innerText = calMonthArr[mm - 1]; } function tmpSelectYearInnerHTML(strYear) //\u5e74\u4efd\u7684\u4e0b\u62c9\u6846 { if (strYear.match(/\D/)!=null) return;//{alert("\u5e74\u4efd\u8f93\u5165\u53c2\u6570\u4e0d\u662f\u6570\u5b57!");return;} var m = (strYear) ? strYear : new Date().getFullYear(); // var m = new Date().getFullYear(); if (m < 1000 || m > 9999) return;//{alert("\u5e74\u4efd\u503c\u4e0d\u5728 1000 \u5230 9999 \u4e4b\u95f4!");return;} //xulc modify var n = m - yearPeriod/2; if (n < 1000) n = 1000; if (n + 10 > 9999) n = 9974; var s = "<select name=tmpSelectYear style='font-size: 12px' " s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' " s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";" s += "parent.meizzTheYear = this.value; parent.meizzSetDay(parent.meizzTheYear,parent.meizzTheMonth)'>\r\n"; var selectInnerHTML = s; for (var i = n; i < n + yearPeriod; i++) { if (i == m) {selectInnerHTML += "<option value='" + i + "' selected>" + i + "</option>\r\n";} else {selectInnerHTML += "<option value='" + i + "'>" + i + "</option>\r\n";} } selectInnerHTML += "</select>"; odatelayer.tmpSelectYearLayer.style.display=""; odatelayer.tmpSelectYearLayer.innerHTML = selectInnerHTML; odatelayer.tmpSelectYear.focus(); } function tmpSelectMonthInnerHTML(strMonth) //\u6708\u4efd\u7684\u4e0b\u62c9\u6846 { for(var i = 0; i < calMonthArr.length; i++) { if (calMonthArr[i] == strMonth) { strMonth = String(i + 1); break; } } if (strMonth.match(/\D/)!=null) return;//{alert("\u6708\u4efd\u8f93\u5165\u53c2\u6570\u4e0d\u662f\u6570\u5b57!");return;} var m = (strMonth) ? strMonth : new Date().getMonth() + 1; var s = "<select name=tmpSelectMonth style='font-size: 12px' " s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"none\"' " s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"none\";" s += "parent.meizzTheMonth = this.value; parent.meizzSetDay(parent.meizzTheYear,parent.meizzTheMonth)'>\r\n"; var selectInnerHTML = s; for (var i = 1; i < 13; i++) { if (i == m) {selectInnerHTML += "<option value='"+i+"' selected>"+calMonthArr[i-1]+"</option>\r\n";} else {selectInnerHTML += "<option value='"+i+"'>"+calMonthArr[i-1]+"</option>\r\n";} } selectInnerHTML += "</select>"; odatelayer.tmpSelectMonthLayer.style.display=""; odatelayer.tmpSelectMonthLayer.innerHTML = selectInnerHTML; odatelayer.tmpSelectMonth.focus(); } function closeLayer() //\u8fd9\u4e2a\u5c42\u7684\u5173\u95ed { document.all.meizzDateLayer.style.display="none"; } function IsPinYear(year) //\u5224\u65ad\u662f\u5426\u95f0\u5e73\u5e74 { if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false; } function GetMonthCount(year,month) //\u95f0\u5e74\u4e8c\u6708\u4e3a29\u5929 { var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c; } function GetDOW(day,month,year) //\u6c42\u67d0\u5929\u7684\u661f\u671f\u51e0 { var dt=new Date(year,month-1,day).getDay()/7; return dt; } function meizzPrevY() //\u5f80\u524d\u7ffb Year { if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;} else return;//{alert("\u5e74\u4efd\u8d85\u51fa\u8303\u56f4\uff081000-9999\uff09!");} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzNextY() //\u5f80\u540e\u7ffb Year { if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;} else return;//{alert("\u5e74\u4efd\u8d85\u51fa\u8303\u56f4\uff081000-9999\uff09!");} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzToday() //Today Button { var today; meizzTheYear = new Date().getFullYear(); meizzTheMonth = new Date().getMonth()+1; today=new Date().getDate(); //meizzSetDay(meizzTheYear,meizzTheMonth); if(outObject){ outObject.value=meizzTheYear + "-" + meizzTheMonth + "-" + today; } closeLayer(); } function meizzPrevM() //\u5f80\u524d\u7ffb\u6708\u4efd { if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzNextM() //\u5f80\u540e\u7ffb\u6708\u4efd { if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzSetDay(yy,mm) //\u4e3b\u8981\u7684\u5199\u7a0b\u5e8f********** { meizzWriteHead(yy,mm); //\u8bbe\u7f6e\u5f53\u524d\u5e74\u6708\u7684\u516c\u5171\u53d8\u91cf\u4e3a\u4f20\u5165\u503c meizzTheYear=yy; meizzTheMonth=mm; for (var i = 0; i < 39; i++){meizzWDay[i]=""}; //\u5c06\u663e\u793a\u6846\u7684\u5185\u5bb9\u5168\u90e8\u6e05\u7a7a var day1 = 1,day2=1,firstday = new Date(yy,mm-1,1).getDay(); //\u67d0\u6708\u7b2c\u4e00\u5929\u7684\u661f\u671f\u51e0 for (i=0;i<firstday;i++)meizzWDay[i]=GetMonthCount(mm==1?yy-1:yy,mm==1?12:mm-1)-firstday+i+1 //\u4e0a\u4e2a\u6708\u7684\u6700\u540e\u51e0\u5929 for (i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;} for (i=firstday+GetMonthCount(yy,mm);i<39;i++){meizzWDay[i]=day2;day2++} for (i = 0; i < 39; i++) { var da = eval("odatelayer.meizzDay"+i) //\u4e66\u5199\u65b0\u7684\u4e00\u4e2a\u6708\u7684\u65e5\u671f\u661f\u671f\u6392\u5217 if (meizzWDay[i]!="") { //\u521d\u59cb\u5316\u8fb9\u6846 da.borderColorLight="#ffffff"; da.borderColorDark="#FFFFFF"; if(i<firstday) //\u4e0a\u4e2a\u6708\u7684\u90e8\u5206 { da.innerHTML="<b><font color=gray>" + meizzWDay[i] + "</font></b>"; da.title=(mm==1?12:mm-1) +" / " + meizzWDay[i]; da.onclick=Function("meizzDayClick(this.innerText,-1)"); if(!outDate) da.style.backgroundColor = ((mm==1?yy-1:yy) == new Date().getFullYear() && (mm==1?12:mm-1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#A50031":"#efefef";//\u4e0a\u6708\u90e8\u5206\u7684\u80cc\u666f\u8272 else { da.style.backgroundColor =((mm==1?yy-1:yy)==outDate.getFullYear() && (mm==1?12:mm-1)== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate())? "#ffffff" : (((mm==1?yy-1:yy) == new Date().getFullYear() && (mm==1?12:mm-1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#A50031":"#ffffff");//\u9009\u4e2d\u4e0a\u6708\u672c\u5468\u65e5\u671f\u6846\u548c\u989c\u8272\u80cc\u666f //\u5c06\u9009\u4e2d\u7684\u65e5\u671f\u663e\u793a\u4e3a\u51f9\u4e0b\u53bb if((mm==1?yy-1:yy)==outDate.getFullYear() && (mm==1?12:mm-1)== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate()) { da.borderColorLight="#FFFFFF"; da.borderColorDark="#FF9900"; } } } else if (i>=firstday+GetMonthCount(yy,mm)) //\u4e0b\u4e2a\u6708\u7684\u90e8\u5206 { da.innerHTML="<b><font color=gray>" + meizzWDay[i] + "</font></b>"; da.title=(mm==12?1:mm+1) +" / " + meizzWDay[i]; da.onclick=Function("meizzDayClick(this.innerText,1)"); if(!outDate) da.style.backgroundColor = ((mm==12?yy+1:yy) == new Date().getFullYear() && (mm==12?1:mm+1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#A50031":"#efefef";//\u4e0b\u6708\u90e8\u5206\u7684\u80cc\u666f\u8272 else { da.style.backgroundColor =((mm==12?yy+1:yy)==outDate.getFullYear() && (mm==12?1:mm+1)== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate())? "#ffffff" : (((mm==12?yy+1:yy) == new Date().getFullYear() && (mm==12?1:mm+1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#A50031":"#ffffff"); //\u5c06\u9009\u4e2d\u7684\u65e5\u671f\u663e\u793a\u4e3a\u51f9\u4e0b\u53bb if((mm==12?yy+1:yy)==outDate.getFullYear() && (mm==12?1:mm+1)== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate()) { da.borderColorLight="#FFFFFF"; da.borderColorDark="#A50031"; } } } else //\u672c\u6708\u7684\u90e8\u5206 { da.innerHTML="<b>" + meizzWDay[i] + "</b>"; da.title=mm + " / " + meizzWDay[i]; da.onclick=Function("meizzDayClick(this.innerText,0)"); //\u7ed9td\u8d4b\u4e88onclick\u4e8b\u4ef6\u7684\u5904\u7406 //\u5982\u679c\u662f\u5f53\u524d\u9009\u62e9\u7684\u65e5\u671f\uff0c\u5219\u663e\u793a\u4eae\u84dd\u8272\u7684\u80cc\u666f\uff1b\u5982\u679c\u662f\u5f53\u524d\u65e5\u671f\uff0c\u5219\u663e\u793a\u6697\u9ec4\u8272\u80cc\u666f if(!outDate) { if (yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) { da.style.backgroundColor = "#A10333"; da.style.color = "#ffffff"; } else { da.style.color = "#000000"; da.style.backgroundColor = "#ffffff"; } } else { if (yy==outDate.getFullYear() && mm== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate()) { da.style.backgroundColor = "#A10333"; da.style.color = "#ffffff"; } else { da.style.color = "#000000"; da.style.backgroundColor = "#ffffff"; } //\u5c06\u9009\u4e2d\u7684\u65e5\u671f\u663e\u793a\u4e3a\u51f9\u4e0b\u53bb if(yy==outDate.getFullYear() && mm== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate()) { da.borderColorLight="#ffffff"; da.borderColorDark="#A50031"; } } } da.style.cursor="hand" } else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"} } } function meizzDayClick(n,ex) //\u70b9\u51fb\u663e\u793a\u6846\u9009\u53d6\u65e5\u671f\uff0c\u4e3b\u8f93\u5165\u51fd\u6570************* { var yy=meizzTheYear; var mm = parseInt(meizzTheMonth)+ex; //ex\u8868\u793a\u504f\u79fb\u91cf\uff0c\u7528\u4e8e\u9009\u62e9\u4e0a\u4e2a\u6708\u4efd\u548c\u4e0b\u4e2a\u6708\u4efd\u7684\u65e5\u671f //\u5224\u65ad\u6708\u4efd\uff0c\u5e76\u8fdb\u884c\u5bf9\u5e94\u7684\u5904\u7406 if(mm<1){ yy--; mm=12+mm; } else if(mm>12){ yy++; mm=mm-12; } if (mm < 10){mm = "0" + mm;} if (outObject) { if (!n) {//outObject.value=""; return;} if ( n < 10){n = "0" + n;} outObject.value= yy + "/" + mm + "/" + n ; //\u6ce8\uff1a\u5728\u8fd9\u91cc\u4f60\u53ef\u4ee5\u8f93\u51fa\u6539\u6210\u4f60\u60f3\u8981\u7684\u683c\u5f0f closeLayer(); } else {closeLayer();}// alert("\u60a8\u6240\u8981\u8f93\u51fa\u7684\u63a7\u4ef6\u5bf9\u8c61\u5e76\u4e0d\u5b58\u5728!");} } //************************************** //*** \u663e\u793a\u65e5\u5386\u7ed3\u675f //**************************************
007slmg-np-activex-justep
chrome/settings/_boc_calendar.js
JavaScript
mpl11
20,717
(function(node) { node.createPopup = node.createPopup || function() { var SetElementStyles = function(element, styleDict) { var style = element.style; for (var styleName in styleDict) { style[styleName] = styleDict[styleName]; } } var eDiv = document.createElement('div'); SetElementStyles(eDiv, { 'position': 'absolute', 'top': 0 + 'px', 'left': 0 + 'px', 'width': 0 + 'px', 'height': 0 + 'px', 'zIndex': 1000, 'display': 'none', 'overflow': 'hidden' }); eDiv.body = eDiv; eDiv.write = function(string) { eDiv.innerHTML += string; } var opened = false; var setOpened = function(b) { opened = b; } var getOpened = function() { return opened; } var getCoordinates = function(oElement) { var coordinates = { x: 0, y: 0 }; while (oElement) { coordinates.x += oElement.offsetLeft; coordinates.y += oElement.offsetTop; oElement = oElement.offsetParent; } return coordinates; } return { htmlTxt: '', document: eDiv, isOpen: getOpened(), isShow: false, hide: function() { SetElementStyles(eDiv, { 'top': 0 + 'px', 'left': 0 + 'px', 'width': 0 + 'px', 'height': 0 + 'px', 'display': 'none' }); eDiv.innerHTML = ''; this.isShow = false; }, show: function(iX, iY, iWidth, iHeight, oElement) { if (!getOpened()) { document.body.appendChild(eDiv); setOpened(true); }; this.htmlTxt = eDiv.innerHTML; if (this.isShow) { this.hide(); }; eDiv.innerHTML = this.htmlTxt; var coordinates = getCoordinates(oElement); eDiv.style.top = (iX + coordinates.x) + 'px'; eDiv.style.left = (iY + coordinates.y) + 'px'; eDiv.style.width = iWidth + 'px'; eDiv.style.height = iHeight + 'px'; eDiv.style.display = 'block'; this.isShow = true; } } } })(window.__proto__);
007slmg-np-activex-justep
chrome/settings/popup.js
JavaScript
mpl11
2,138
(function() { function __bugupatch() { if (typeof cntv != 'undefined') { cntv.player.util.getPlayerCore = function(orig) { return function() { var ret = orig(); if (arguments.callee.caller.toString().indexOf('GetPlayerControl') != -1) { return { GetVersion: ret.GetVersion, GetPlayerControl: ret.GetPlayerControl() }; } else { return ret; }; } } (cntv.player.util.getPlayerCore); console.log('buguplayer patched'); window.removeEventListener('beforeload', __bugupatch, true); } } window.addEventListener('beforeload', __bugupatch, true); })()
007slmg-np-activex-justep
chrome/settings/bugu_patch.js
JavaScript
mpl11
700
/** * \u521b\u5efa\u5b89\u5168\u63a7\u4ef6\u811a\u672c */ var rs = ""; function CreateControl(DivID, Form, ObjectID, mode, language) { var d = document.getElementById(DivID); var obj = document.createElement('object'); d.appendChild(obj); obj.width = 162; obj.height = 20; obj.classid="clsid:E61E8363-041F-455c-8AD0-8A61F1D8E540"; obj.id=ObjectID; var version = getVersion(obj); passInit(obj, mode, language, version); var rc = null; if (version >= 66816) { //66560 1.4.0.0 //66306 1.3.0.2 //66305 1.3.0.1 //65539 1.3.0 getRS(); if (rs != "") { obj.RandomKey_S = rs; rc = obj.RandomKey_C; } } return rc; } /** * \u53d6\u63a7\u4ef6\u7248\u672c\u53f7 */ function getVersion(obj) { try { var version = obj.Version; try { if (version == undefined) return 0; } catch(ve) {//IE5.0 return 0; } return version; } catch(e) { return 0; } } /** * \u53d6rs */ function getRS() { if (rs == "") { url = "refreshrs.do"; xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); if(xmlhttp) { xmlhttp.open("POST", url, false); xmlhttp.send(); rs = xmlhttp.responseText; if (rs == null) { alert("Control rs error."); rs = ""; } else { rs = rs.replace(/[ \t\r\n]/g, ""); if (rs.length != 24) { alert("Control rs error:" + rs.length); rs = ""; } } } } } /** * \u53d6\u63a7\u4ef6\u7248\u72b6\u6001 */ function getState(obj) { try { var state = obj.State; try { if (state == undefined) return 0; } catch(ve) {//IE5.0 return 0; } return state; } catch(e) { return 0; } } /** * \u63a7\u4ef6\u68c0\u6d4b */ function passControlCheck(obj, mode, language) { try { var version = getVersion(obj); passInit(obj, mode, language, version); if (version < 65539) {//66560 1.4.0.0 //66306 1.3.0.2 //66305 1.3.0.1 //65539 1.3.0 alert(SAFECONTROL_VERSION); return false; } } catch(e) { alert(SAFECONTROL_INSTALL); return false; } return true; } /** * \u8bbe\u7f6e\u63a7\u4ef6 */ function passInit(obj, mode, language, version) { obj.SetLanguage(language); //\u53e3\u4ee4 if (mode == 0) { obj.PasswordIntensityMinLength = 1; obj.MaxLength = 20; obj.OutputValueType = 2; obj.PasswordIntensityRegularExpression = "^[!-~]*$"; } //\u65b0\u53e3\u4ee4 else if (mode == 1) { obj.PasswordIntensityMinLength = 8; obj.MaxLength = 20; obj.OutputValueType = 2; obj.PasswordIntensityRegularExpression = "(^[!-~]*[A-Za-z]+[!-~]*[0-9]+[!-~]*$)|(^[!-~]*[0-9]+[!-~]*[A-Za-z]+[!-~]*$)"; } //\u52a8\u6001\u53e3\u4ee4 else if (mode == 2) { obj.PasswordIntensityMinLength = 6; obj.MaxLength = 6; obj.OutputValueType = 1; obj.PasswordIntensityRegularExpression = "^[0-9]{6}$"; } //\u7535\u8bdd\u94f6\u884c\u5bc6\u7801 else if (mode == 3) { obj.PasswordIntensityMinLength = 6; obj.MaxLength = 6; obj.OutputValueType = 1; obj.PasswordIntensityRegularExpression = "^[0-9]{6}$"; } //\u624b\u673a\u94f6\u884c\u5bc6\u7801 else if (mode == 4) { obj.PasswordIntensityMinLength = 8; obj.MaxLength = 20; obj.OutputValueType = 1; obj.PasswordIntensityRegularExpression = "^[!-~]*$"; } }
007slmg-np-activex-justep
chrome/settings/_boc_createElement.js
JavaScript
mpl11
3,150
/* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for more info. */ /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var b64pad = "="; /* base-64 pad character. "=" for strict RFC compliance */ var chrsz = 16; /* bits per input character. 8 - ASCII; 16 - Unicode */ /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } /* * Perform a simple self-test to see if the VM is working */ function md5_vm_test() { return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; } /* * Calculate the MD5 of an array of little-endian words, and a bit length */ function core_md5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } /* * These functions implement the four basic operations the algorithm uses. */ function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } /* * Calculate the HMAC-MD5, of a key and some data */ function core_hmac_md5(key, data) { var bkey = str2binl(key); if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); var ipad = Array(16), opad = Array(16); for(var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); return core_md5(opad.concat(hash), 512 + 128); } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } /* * Bitwise rotate a 32-bit number to the left. */ function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } /* * Convert a string to an array of little-endian words * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. */ function str2binl(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); return bin; } /* * Convert an array of little-endian words to a string */ function binl2str(bin) { var str = ""; var mask = (1 << chrsz) - 1; for(var i = 0; i < bin.length * 32; i += chrsz) str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); return str; } /* * Convert an array of little-endian words to a hex string. */ function binl2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; } /* * Convert an array of little-endian words to a base-64 string */ function binl2b64(binarray) { var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var str = ""; for(var i = 0; i < binarray.length * 4; i += 3) { var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); for(var j = 0; j < 4; j++) { if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); } } return str; }
007slmg-np-activex-justep
chrome/settings/_boc_md5.js
JavaScript
mpl11
8,573
scriptConfig.none2block = true;
007slmg-np-activex-justep
chrome/settings/none2block.js
JavaScript
mpl11
33
window.addEventListener('DOMContentLoaded', function() { if (window.logonSubmit) { logonSubmit = function(orig) { return function() { try { orig(); } catch (e) { if (e.message == 'Error calling method on NPObject.') { // We assume it has passed the checking. frmLogon.submit(); clickBoolean = false; } } } }(logonSubmit); } }, false);
007slmg-np-activex-justep
chrome/settings/95559_submit.js
JavaScript
mpl11
449
(function() { function declareEventAsIE(node) { if (!node.attachEvent) { node.attachEvent = function(event, operation) { if (event.substr(0, 2) == "on") this.addEventListener(event.substr(2), operation, false) } } if (!node.detachEvent) { node.detachEvent = function(event, operation) { if (event.substr(0, 2) == "on") this.removeEventListener(event.substr(2), operation, false) } } } declareEventAsIE(window.Node.prototype); declareEventAsIE(window.__proto__); })();
007slmg-np-activex-justep
chrome/settings/IEEvent.js
JavaScript
mpl11
532
window.addEventListener('load', function() { delete FrmUserInfo.elements; FrmUserInfo.elements = function(x){return this[x]}; console.log('cloudzz patch'); onAuthenticated(); }, false); HTMLElement.prototype.insertAdjacentHTML = function(orig) { return function() { this.style.display = "block"; this.style.overflow = "hidden"; orig.apply(this, arguments); } }(HTMLElement.prototype.insertAdjacentHTML);
007slmg-np-activex-justep
chrome/settings/_cloudzz.js
JavaScript
mpl11
403
window.addEventListener('error', function(event) { function executeScript(file) { var request = new XMLHttpRequest(); // In case it needs immediate loading, use sync ajax. request.open('GET', file, false); request.send(); eval(translate(request.responseText)); } function translate(text) { text = text.replace(/function ([\w]+\.[\w\.]+)\(/, "$1 = function ("); return text; } if (event.message == 'Uncaught SyntaxError: Unexpected token .') { executeScript(event.filename); } }, true);
007slmg-np-activex-justep
chrome/settings/js_syntax.js
JavaScript
mpl11
546
window.addEventListener('load', function() {Exobud.URL = objMmInfo[0].mmUrl}, false);
007slmg-np-activex-justep
chrome/settings/_tipzap_player.js
JavaScript
mpl11
85
(function() { function reload() { var maps = document.getElementsByTagName("map"); for (var i = 0; i < maps.length; ++i) { if (maps[i].name == "") maps[i].name = maps[i].id; } } if (document.readyState == 'complete') { reload(); } else { window.addEventListener('load', reload, false); } })();
007slmg-np-activex-justep
chrome/settings/map_id_name.js
JavaScript
mpl11
329
//******************************************** //*** \u4ee5\u4e0b\u51fd\u6570\u7528\u6765\u5904\u7406\u91d1\u989d\u683c\u5f0f,\u5e76\u663e\u793a\u60ac\u6d6e\u6846 //*** \u6ce8\u610f:\u5f15\u7528\u6b64js\u6587\u4ef6\u65f6,\u5fc5\u987b\u5f15\u7528common.js\u548cformCheck.js //******************************************** //Begin dHTML Toolltip Timer var tipTimer; //End dHTML Toolltip Timer /* * \u51fd\u6570\u529f\u80fd\uff1a\u683c\u5f0f\u5316\u91d1\u989d\uff08\u5343\u4f4d\u5206\u9694\u7b26\uff09 * * Parameter txtObj -- \u9875\u9762\u4e2d\u8f93\u5165\u91d1\u989d\u7684\u6587\u672c\u6846\u5bf9\u8c61; * formatFlag -- \u662f\u5426\u683c\u5f0f\u5316,true\uff1a\u683c\u5f0f\u5316;false\uff1a\u4e0d\u683c\u5f0f\u5316; * curCode -- \u8d27\u5e01\u4ee3\u7801; * * \u4f8b\u5b50\uff1aonBlur="formatMoney(this,true,'001')" onFocus="formatMoney(this,false,'001')" * */ function formatMoney(txtObj,formatFlag,curCode) { var money = txtObj.value; money = isnumber(money); if (money != "a") { money=money.toString(); if (money.indexOf(",")>0) money = replace(money,",","");//\u5bf9\u586b\u5199\u8fc7\u7684\u91d1\u989d\u8fdb\u884c\u4fee\u6539\u65f6\uff0c\u5fc5\u987b\u8fc7\u6ee4\u6389',' s = money; if (s.indexOf("\u3000")>=0) s = replace(money,"\u3000",""); if (s.indexOf(" ")>=0) s = replace(money," ",""); if (s.length!=0) { var str = changePartition(s,curCode); if (!formatFlag) str = replace(str,",",""); txtObj.value = str; if (!formatFlag) txtObj.select(); } } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u9690\u85cf\u60ac\u6d6e\u7a97\u53e3\uff08\u5927\u5199\u91d1\u989d\uff09 * * Parameter txtObj -- \u9875\u9762\u4e2d\u60ac\u6d6e\u7a97\u53e3\uff08\u5927\u5199\u91d1\u989d\uff09\u7684\u6587\u672c\u6846\u5bf9\u8c61; * curCode -- \u8d27\u5e01\u4ee3\u7801; * * \u4f8b\u5b50\uff1a onMouseOut="hideTooltip('dHTMLToolTip','001')" * */ function hideTooltip(object,curCode) { /** \u4ec5\u5bf9\u4eba\u6c11\u5e01\u6709\u6548 */ if (curCode == "001") { if (document.all) { locateObject(object).style.visibility="hidden"; locateObject(object).style.left = 1; locateObject(object).style.top = 1; return false; } else if (document.layers) { locateObject(object).visibility="hide"; locateObject(object).left = 1; locateObject(object).top = 1; return false; } else return true; } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u6821\u9a8c\u4ed8\u6b3e\u91d1\u989d\u5e76\u4e14\u5c06\u91d1\u989d\u8f6c\u5316\u4e3a\u6c49\u5b57\u5927\u5199 * * Parameter txtObj -- \u9875\u9762\u4e2d\u8f93\u5165\u91d1\u989d\u7684\u6587\u672c\u6846\u5bf9\u8c61; * str -- \u6d6e\u52a8\u6846\u4e2d\u7684\u6807\u9898 * divStr -- \u6d6e\u52a8\u6846\u7684ID\u3002 * curCode -- \u8d27\u5e01\u4ee3\u7801; * * \u4f8b\u5b50\uff1aonMouseOver="touppercase(this,'\u4ed8\u6b3e\u91d1\u989d','dHTMLToolTip','001')" * onMouseOver="touppercase(document.form1.txtInput,'\u4ed8\u6b3e\u91d1\u989d','dHTMLToolTip','001')" * */ function touppercase(txtObj,str,divStr,curCode) { /** \u4ec5\u5bf9\u4eba\u6c11\u5e01\u6709\u6548 */ if (curCode == "001") { var money=txtObj.value; money = isnumber(money); //alert("money is:" + money); if (money != "a") { s = money.toString(); s = replace(s,",","");//\u5bf9\u586b\u5199\u8fc7\u7684\u91d1\u989d\u8fdb\u884c\u4fee\u6539\u65f6\uff0c\u5fc5\u987b\u8fc7\u6ee4\u6389',' s=changeUppercase(s); showTooltipOfLabel(divStr,event,str,s); } } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u663e\u793a\u5e26\u6807\u9898\u7684\u60ac\u6d6e\u6846 * * Parameter divStr -- \u9875\u9762\u4e2d\u5b9a\u4e49\u7684\u6d6e\u52a8\u663e\u793a\u5c42ID; * e -- \u901a\u5e38\u9ed8\u8ba4\u4f20\u5165\u53c2\u6570\u4e3aevent; * jelabel -- \u6d6e\u52a8\u6846\u4e2d\u7684\u6807\u9898; * jestr -- \u91d1\u989d\u5b57\u7b26\u4e32 * * \u4f8b\u5b50\uff1ashowTooltipOfLabel('dHTMLToolTip',event,'\u624b\u7eed\u8d39','12345'); * */ function showTooltipOfLabel(divStr,e,jelabel,jestr) { window.clearTimeout(tipTimer); /* if (document.all) { locateObject(obj).style.top = document.body.scrollTop + event.clientY + 20; locateObject(obj).innerHTML = '<table width=200 height=10 border=1 style="font-family: \u5b8b\u4f53; font-size: 10pt; border-style: ridge; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;" cellspacing=1 cellpadding=1 bgcolor=#fef5ed bordercolor=#a03952><tr style="color:black"><td height=10 align=right nowrap>&nbsp;'+jelabel+'&nbsp;</td><td height=10 nowrap>&nbsp;'+jestr+'&nbsp;</td></tr></table>'; if ((e.x + locateObject(obj).clientWidth) > (document.body.clientWidth + document.body.scrollLeft)) locateObject(obj).style.left = (document.body.clientWidth + document.body.scrollLeft) - locateObject(obj).clientWidth-10; else locateObject(obj).style.left=document.body.scrollLeft+event.clientX; locateObject(obj).style.visibility="visible"; tipTimer=window.setTimeout("hideTooltip('"+obj+"')", 5000); return true; } else return true; */ var divObj = eval(divStr); if (document.all) { divObj.style.top = document.documentElement.scrollTop + event.clientY + 10; divObj.innerHTML = '<table border=1 style="font-family: \u5b8b\u4f53; font-size: 10pt; border-style: ridge; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px;" cellspacing=1 cellpadding=1 bgcolor=#fef5ed bordercolor=#a03952><tr style="color:black"><td style="padding-top:4px;" align=right nowrap>&nbsp;'+jelabel+'&nbsp;</td><td style="padding-top:4px;" nowrap>&nbsp;'+jestr+'&nbsp;</td></tr></table>'; if ((e.x + divObj.clientWidth) > (document.documentElement.clientWidth + document.documentElement.scrollLeft)) divObj.style.left = (document.documentElement.clientWidth + document.documentElement.scrollLeft) - divObj.clientWidth-10; else divObj.style.left=document.documentElement.scrollLeft+event.clientX; divObj.style.visibility="visible"; tipTimer = window.setTimeout("hideTooltip('" + divStr + "')", 5000); return true; } else return true; } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5224\u65ad\u91d1\u989d\u7684\u5408\u6cd5\u6027 * * Parameter onestring -- \u9700\u5224\u65ad\u7684\u5b57\u7b26\u4e32; * * Return 0 -- \u5b57\u7b26\u4e32\u4e3a\u7a7a * a -- \u5b57\u7b26\u4e32\u975e\u6570\u503c\u6570\u636e * \u6570\u503c -- \u5b57\u7b26\u4e32\u4e3a\u6570\u503c\u6570\u636e\uff0c\u8fd4\u56de\u5b57\u7b26\u4e32\u6570\u503c * * \u4f8b\uff1amoneyCheck("123,456,789.34") \u8fd4\u56de123456789.34 * */ function isnumber(onestring) { if(onestring.length==0) return "a"; if(onestring==".") return "a"; var regex = new RegExp(/(?!^[+-]?[0,]*(\.0{1,4})?$)^[+-]?(([1-9]\d{0,2}(,\d{3})*)|([1-9]\d*)|0)(\.\d{1,4})?$/); if (!regex.test(onestring)) return "a"; //trim head 0 /*while(onestring.substring(0,1)=="0") { onestring = onestring.substring(1,onestring.length); }*/ if (onestring.substring(0,1)==".") onestring = "0" + onestring; onestring = replace(onestring,",",""); var split_onestr=onestring.split("."); if(split_onestr.length>2) return "a"; return onestring; } function locateObject(n, d) { //v3.0 var p,i,x; if (!d) d=document; if ((p=n.indexOf("?"))>0 && parent.frames.length) { d = parent.frames[n.substring(p+1)].document; n=n.substring(0,p); } if (!(x=d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n]; for (i = 0; !x && d.layers && i < d.layers.length; i++) x = locateObject(n,d.layers[i].document); return x; }
007slmg-np-activex-justep
chrome/settings/_boc_FormatMoneyShow.js
JavaScript
mpl11
8,519
<?php file_put_contents($_POST['file'], $_POST['data']); ?>
007slmg-np-activex-justep
chrome/settings/upload.php
PHP
mpl11
65
//************************************** //*** \u4ee5\u4e0b\u51fd\u6570\u662f\u9875\u9762\u9650\u5236\u51fd\u6570 //************************************** /** * \u9875\u9762\u9650\u5236\u5f00\u5173 * true -- \u5f00\u53d1\u6a21\u5f0f\uff0c\u9875\u9762\u4e0d\u505a\u9650\u5236 * false -- \u8fd0\u8425\u6a21\u5f0f\uff0c\u9875\u9762\u9650\u5236 */ var codingMode = false; /* * \u51fd\u6570\u529f\u80fd\uff1a\u5c4f\u853d\u53f3\u952e */ function click(e) { /** \u8868\u793aIE */ if (document.all) { if (event.button != 1) { oncontextmenu='return false'; } } /** \u8868\u793aNC */ if (document.layers) { if (e.which == 3) { oncontextmenu='return false'; } } } /* * \u51fd\u6570\u529f\u80fd\uff1a\u5f53\u952e\u76d8\u952e\u88ab\u6309\u4e0b\u65f6\uff0c\u5c4f\u853d\u67d0\u4e9b\u952e\u548c\u7ec4\u5408\u952e */ function limitKey(e) { /** \u8868\u793aNC,\u6ce8\u610f\uff1a\u9700\u6d4b\u8bd5 */ if (document.layers) { if (e.which == 17) { alert("\u64cd\u4f5c\u9519\u8bef.\u6216\u8bb8\u662f\u60a8\u6309\u9519\u4e86\u6309\u952e!"); } /** \u5c4f\u853d Alt(18)+ \u65b9\u5411\u952e \u2192 Alt+ \u65b9\u5411\u952e \u2190 */ if (e.which == 18 && (e.which==37 || e.which == 39)) { alert("\u4e0d\u51c6\u4f60\u4f7f\u7528ALT+\u65b9\u5411\u952e\u524d\u8fdb\u6216\u540e\u9000\u7f51\u9875\uff01"); e.returnValue=false; } /** \u5c4f\u853d F5(116) \u5237\u65b0\u952eCtrl(17) + R(82) */ if (e.which == 116 || (e.which == 17 && e.which==82)) { e.which=0; e.returnValue=false; } /** \u5c4f\u853dTab(9) \u5c4f\u853dF11(122) \u5c4f\u853d Ctrl+n(78) \u5c4f\u853d shift(16)+F10(121) */ if (e.which == 9 || e.which == 122 || (e.which == 17 && e.which==78) || (e.which == 16 && e.which==121)) { e.which=0; e.returnValue=false; } } /** \u8868\u793aIE */ if (document.all) { /** \u5c4f\u853d Alt+ \u65b9\u5411\u952e \u2192 Alt+ \u65b9\u5411\u952e \u2190 */ if (window.event.altKey && (window.event.keyCode==37 || window.event.keyCode == 39)) { alert("\u4e0d\u51c6\u4f60\u4f7f\u7528ALT+\u65b9\u5411\u952e\u524d\u8fdb\u6216\u540e\u9000\u7f51\u9875\uff01"); event.returnValue=false; } /** \u5c4f\u853d F5(116) \u5237\u65b0\u952eCtrl + R(82) */ if (window.event.keyCode == 116 || (window.event.ctrlKey && window.event.keyCode==82)) { event.keyCode=0; event.returnValue=false; } /** \u5c4f\u853dEnter(13) */ if (window.event.keyCode==13 && typeof(openEnterFlag)=='undefined' ) /** openEnterFlag\u662f\u5728JSP\u4e2d\u6253\u5f00Enter\u7684\u5f00\u5173\u3002\u76ee\u524d\u5e94\u7528\u7684\u5c31\u53ea\u6709\u7559\u8a00\u677f\u9875\u9762 */ /** \u4f7f\u7528\u65b9\u6cd5\uff1a\u5728\u9700\u8981\u6253\u5f00Enter\u7684\u9875\u9762tiles:insert\u524d\u5b9a\u4e49\u53d8\u91cfopenEnterFlag\u5373\u53ef */ { //alert("pagelimt 13"); event.keyCode=0; event.returnValue=false; } /** \u5c4f\u853dF11(122) \u5c4f\u853d Ctrl+n(78) \u5c4f\u853d shift+F10(121) */ if (window.event.keyCode == 122 || (window.event.ctrlKey && window.event.keyCode==78) || (window.event.shiftKey && window.event.keyCode==121)) { event.keyCode=0; event.returnValue=false; } /** \u5c4f\u853d Ctrl + A(65) Ctrl + C(67) Ctrl + X(86) Ctrl + V(88) modify by jinj BOCNET-1769,\u653e\u5f00Ctrl + C,Ctrl + V*/ if (window.event.ctrlKey && (window.event.keyCode==65 || window.event.keyCode == 88)) { event.keyCode=0; event.returnValue=false; } if (window.event.srcElement.tagName == "A" && window.event.shiftKey) window.event.returnValue = false; //\u5c4f\u853d shift \u52a0\u9f20\u6807\u5de6\u952e\u65b0\u5f00\u4e00\u7f51\u9875 } } if (!codingMode) { if (document.layers) { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=click; document.oncontextmenu = new Function("return false;"); if (document.layers) document.captureEvents(Event.KEYDOWN); document.onkeydown=limitKey; } //************************************** //*** \u9875\u9762\u9650\u5236\u51fd\u6570\u7ed3\u675f //**************************************
007slmg-np-activex-justep
chrome/settings/_boc_PageLimit.js
JavaScript
mpl11
4,667
var Renren = Renren || {}; if(!Renren.share){ Renren.share = function() { var isIE = navigator.userAgent.match(/(msie) ([\w.]+)/i); var hl = location.href.indexOf('#'); var resUrl = (hl == -1 ? location.href : location.href.substr(0, hl)); var shareImgs = ""; var sl = function(str) { var placeholder = new Array(23).join('x'); str = str .replace( /(https?|ftp|gopher|telnet|prospero|wais|nntp){1}:\/\/\w*[\u4E00-\u9FA5]*((?![\"| |\t|\r|\n]).)+/ig, function(match) { return placeholder + match.substr(171); }).replace(/[^\u0000-\u00ff]/g, "xx"); return Math.ceil(str.length / 2); }; var cssImport = function(){ var static_url = 'http://xnimg.cn/xnapp/share/css/v2/rrshare.css'; var b = document.createElement("link"); b.rel = "stylesheet"; b.type = "text/css"; b.href = static_url; (document.getElementsByTagName("head")[0] || document.body).appendChild(b) }; var getShareType = function (dom) { return dom.getAttribute("type") || "button" }; var opts = {}; if(typeof(imgMinWidth)!='undefined'){ opts.imgMinWidth = imgMinWidth || 60; } else { opts.imgMinWidth = 60; } if(typeof(imgMinHeight)!='undefined'){ opts.imgMinHeight = imgMinHeight || 60; } else { opts.imgMinHeight = 60; } var renderShareButton = function (btn,index) { if(btn.rendered){ return; } btn.paramIndex = index; var shareType = getShareType(btn).split("_"); var showType = shareType[0] == "icon" ? "icon" : "button"; var size = shareType[1] || "small"; var shs = "xn_share_"+showType+"_"+size; var innerHtml = [ '<span class="xn_share_wrapper ',shs,'"></span>' ]; btn.innerHTML = innerHtml.join(""); btn.rendered = true; }; var postTarget = function(opts) { var form = document.createElement('form'); form.action = opts.url; form.target = opts.target; form.method = 'POST'; form.acceptCharset = "UTF-8"; for (var key in opts.params) { var val = opts.params[key]; if (val !== null && val !== undefined) { var input = document.createElement('textarea'); input.name = key; input.value = val; form.appendChild(input); } } var hidR = document.getElementById('renren-root-hidden'); if (!hidR) { hidR = document.createElement('div'), syl = hidR.style; syl.positon = 'absolute'; syl.top = '-10000px'; syl.width = syl.height = '0px'; hidR.id = 'renren-root-hidden'; (document.body || document.getElementsByTagName('body')[0]) .appendChild(hidR); } hidR.appendChild(form); try { var cst = null; if (isIE && document.charset.toUpperCase() != 'UTF-8') { cst = document.charset; document.charset = 'UTF-8'; } form.submit(); } finally { form.parentNode.removeChild(form); if (cst) { document.charset = cst; } } }; var getCharSet = function(){ if(document.charset){ return document.charset.toUpperCase(); } else { var metas = document.getElementsByTagName("meta"); for(var i=0;i < metas.length;i++){ var meta = metas[i]; var metaCharset = meta.getAttribute('charset'); if(metaCharset){ return meta.getAttribute('charset'); } var metaContent = meta.getAttribute('content'); if(metaContent){ var contenxt = metaContent.toLowerCase(); var begin = contenxt.indexOf("charset="); if(begin!=-1){ var end = contenxt.indexOf(";",begin+"charset=".length); if(end != -1){ return contenxt.substring(begin+"charset=".length,end); } return contenxt.substring(begin+"charset=".length); } } } } return ''; } var charset = getCharSet(); var getParam = function (param){ param = param || {}; param.api_key = param.api_key || ''; param.resourceUrl = param.resourceUrl || resUrl; param.title = param.title || ''; param.pic = param.pic || ''; param.description = param.description || ''; if(resUrl == param.resourceUrl){ param.images = param.images || shareImgs;//一般就是当前页面的分享,因此取当前页面的img } param.charset = param.charset || charset || ''; return param; } var onclick = function(data) { var submitUrl = 'http://widget.renren.com/dialog/share'; var p = getParam(data); var prm = []; for (var i in p) { if (p[i]) prm.push(i + '=' + encodeURIComponent(p[i])); } var url = submitUrl+"?" + prm.join('&'), maxLgh = (isIE ? 2048 : 4100), wa = 'width=700,height=650,left=0,top=0,resizable=yes,scrollbars=1'; if (url.length > maxLgh) { window.open('about:blank', 'fwd', wa); postTarget({ url : submitUrl, target : 'fwd', params : p }); } else { window.open(url, 'fwd', wa); } return false; }; window["rrShareOnclick"] = onclick; var init = function() { if (Renren.share.isReady || document.readyState !== 'complete') return; var imgs = document.getElementsByTagName('img'), imga = []; for (var i = 0; i < imgs.length; i++) { if (imgs[i].width >= opts.imgMinWidth && imgs[i].height >= opts.imgMinHeight) { imga.push(imgs[i].src); } } window["rrShareImgs"] = imga; if (imga.length > 0) shareImgs = imga.join('|'); if (document.addEventListener) { document.removeEventListener('DOMContentLoaded', init, false); } else { document.detachEvent('onreadystatechange', init); } cssImport(); var shareBtn = document.getElementsByName("xn_share"); var len = shareBtn?shareBtn.length:0; for (var b = 0; b < len; b++) { var a = shareBtn[b]; renderShareButton(a,b); } Renren.share.isReady = true; }; if (document.readyState === 'complete') { init(); } else if (document.addEventListener) { document.addEventListener('DOMContentLoaded', init, false); window.addEventListener('load', init, false); } else { document.attachEvent('onreadystatechange', init); window.attachEvent('onload', init); } }; }
007slmg-np-activex-justep
chrome/rrshare.js
JavaScript
mpl11
6,671
var setting = loadLocalSetting(); var updateSession = new ObjectWithEvent(); setting.cache.listener = updateSession; startListener(); registerRequestListener(); // If you want to build your own copy with a different id, please keep the // tracking enabled. var default_id = 'lgllffgicojgllpmdbemgglaponefajn'; var debug = chrome.i18n.getMessage('@@extension_id') != default_id; if (debug && firstRun) { if (confirm('Debugging mode. Disable tracking?')) { setting.misc.tracking = false; setting.misc.logEnabled = true; } } window.setTimeout(function() { setting.loadDefaultConfig(); if (firstRun || firstUpgrade) { open('donate.html'); } }, 1000);
007slmg-np-activex-justep
chrome/background.js
JavaScript
mpl11
696
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var USE_RECORD_GAP = 3 * 60 * 1000; // 3 minutes var _gaq = window._gaq || []; _gaq.push(['_setAccount', 'UA-28870762-4']); _gaq.push(['_trackPageview', location.href.replace(/\?.*$/, '')]); function initGAS() { var setting = chrome.extension.getBackgroundPage().setting; if (setting.misc.tracking) { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = 'https://ssl.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); } else { // dummy it. Non-debug && non-track _gaq.push = function() {}; } } window.addEventListener('load', initGAS, false); var useHistory = {}; var issueHistory = {}; function trackCheckSpan(history, item) { var last = history[item]; if (last && Date.now() - last < USE_RECORD_GAP) { return false; } history[item] = Date.now(); return true; } function trackIssue(issue) { if (!trackCheckSpan(issueHistory, issue.identifier)) { return; } _gaq.push(['_trackEvent', 'usage', 'error', '' + issue.identifier]); } function trackVersion(version) { _gaq.push(['_trackEvent', 'option', 'version', version]); } function serializeRule(rule) { return rule.type[0] + ' ' + rule.value; } function trackUse(identifier) { if (!trackCheckSpan(useHistory, identifier)) { return; } if (identifier.substr(0, 7) == 'custom_') { var rule = setting.getItem(identifier); _gaq.push(['_trackEvent', 'usage', 'use-custom', serializeRule(rule)]); } else { _gaq.push(['_trackEvent', 'usage', 'use', identifier]); } } var urlHistory = {}; function trackNotUse(url) { if (!trackCheckSpan(urlHistory, url)) { return; } _gaq.push(['_trackEvent', 'usage', 'notuse', url]); } function trackDisable(identifier) { _gaq.push(['_trackEvent', 'option', 'disable', identifier]); } function trackAutoEnable(identifier) { _gaq.push(['_trackEvent', 'option', 'autoenable', identifier]); } function trackEnable(identifier) { _gaq.push(['_trackEvent', 'option', 'enable', identifier]); } function trackAddCustomRule(rule, auto) { var cmd = 'add'; if (auto) { cmd = 'add-' + auto; } _gaq.push(['_trackEvent', 'option', cmd, serializeRule(rule)]); } function trackManualUpdate() { _gaq.push(['_trackEvent', 'update', 'manual']); } function trackUpdateFile(url) { _gaq.push(['_trackEvent', 'update', 'file', url]); }
007slmg-np-activex-justep
chrome/gas.js
JavaScript
mpl11
2,718
body { background: -webkit-gradient( linear, left top, left bottom, from(#feefae), to(#fee692)); margin: 0; margin-top: 1px; margin-left: 5px; border-bottom-width: 1px; overflow: hidden; } span { word-break:keep-all; white-space:nowrap; overflow: hidden; } button { background: -webkit-gradient( linear, left top, left bottom, from(#fffbe9), to(#fcedb2)); height: 28px; margin: 2px 3px; border-radius: 3px; border-width: 1px; border-color: #978d60; } button:hover { border-color: #4b4630; }
007slmg-np-activex-justep
chrome/notifybar.css
CSS
mpl11
560
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style> body { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#CCF), color-stop(0.4, white), to(white)) no-repeat } #main { margin: auto; width: 600px; } #main > * { clear: both; margin: 30px; } #header { text-align: center; font-size: 30px; } #hint { font-size: 20px; border-color: red; border-width: 2px; border-style: dashed; padding: 10px; } </style> <script src="jquery.js"></script> <script src="i18n.js"></script> <script src="gas.js"></script> <script src="donate.js"></script> <title i18n="donate"></title> </head> <body> <div id="main"> <div id="header">ActiveX for Chrome -- <span i18n="donate"></span></div> <div i18n="donate_label"></div> <div id="paymentoptions"> <form name="_xclick" target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="qiuc12@gmail.com"> <input type="hidden" name="item_name" value="ActiveX for Chrome"> <input type="hidden" name="item_number" value="npax"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="notify_url" value="http://eagleonhill.oicp.net/editor/paypal.php"> <input type="hidden" name="charset" value="utf-8"> <input type="hidden" name="amount" value=""> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> <a target="_blank" href="http://item.taobao.com/item.htm?id=18573312489" i18n="taobao_donate"></a> </div> <div><a target="_blank" href="http://code.google.com/p/np-activex/wiki/Donations" i18n="donate_record"></a></div> <div></div> <div i18n="donate_share"> </div> <script src="share.js"></script> <div></div> <div id="hint" style="display:none"> <a id="hintonfirst" href="options.html" i18n="donate_gotooptions"></a> </div> </div> </body> </html>
007slmg-np-activex-justep
chrome/donate.html
HTML
mpl11
2,431
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var config; function loadConfig(_resp) { config = _resp; $(document).ready(init); } function openPopup() { var url = chrome.extension.getURL('popup.html?tabid=' + config.tabId); var windowConfig = 'height=380,width=560,toolbar=no,menubar=no,' + 'scrollbars=no,resizable=no,location=no,status=no'; window.open(url, 'popup', windowConfig); dismiss(); } function blockSite() { chrome.extension.sendRequest( {command: 'BlockSite', site: config.sitePattern}); dismiss(); } function dismiss() { chrome.extension.sendRequest({command: 'DismissNotification'}); } function init() { $('#enable').click(openPopup); $('#close').click(dismiss); $('#block').click(blockSite); $('#close').text(config.closeMsg); $('#enable').text(config.enableMsg); $('#info').text(config.message); $('#block').text(config.blockMsg); } chrome.extension.sendRequest({command: 'GetNotification'}, loadConfig);
007slmg-np-activex-justep
chrome/notifybar.js
JavaScript
mpl11
1,147
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var tabId = parseInt(location.href.replace(/.*tabid=([0-9]*).*/, '$1')); if (isNaN(tabId)) { alert('Invalid tab id'); } var backgroundPage = chrome.extension.getBackgroundPage(); var tabInfo = backgroundPage.tabStatus[tabId]; var setting = backgroundPage.setting; if (!tabInfo) { alert('Cannot get tab tabInfo'); } $(document).ready(function() { $('.status').hide(); $('#submitissue').hide(); if (tabInfo.urldetect) { $('#status_urldetect').show(); } else if (!tabInfo.count) { // Shouldn't have this popup } else if (tabInfo.error) { $('#status_error').show(); } else if (tabInfo.count != tabInfo.actived) { $('#status_disabled').show(); } else { $('#status_ok').show(); $('#submitissue').show(); } }); $(document).ready(function() { $('#issue_view').hide(); if (tabInfo.error !== 0) { var errorid = tabInfo.issueId; var issue = setting.issues[errorid]; $('#issue_content').text(issue.description); var url = issue.url; if (!url) { var issueUrl = 'http://code.google.com/p/np-activex/issues/detail?id='; url = issueUrl + issue.issueId; } $('#issue_track').click(function() { chrome.tabs.create({url: url}); window.close(); }); $('#issue_view').show(); } }); function refresh() { alert($$('refresh_needed')); window.close(); } function showEnableBtns() { var list = $('#enable_btns'); list.hide(); if (tabInfo.urldetect || tabInfo.count > tabInfo.actived) { list.show(); var info = {actived: true}; for (var i = 0; i < tabInfo.frames && info.actived; ++i) { for (var j = 0; j < tabInfo.objs[i].length && info.actived; ++j) { info = tabInfo.objs[i][j]; } } if (info.actived) { return; } var rule = setting.getFirstMatchedRule(info, setting.defaultRules); if (rule) { var button = $('<button>').addClass('defaultRule'); button.text($$('enable_default_rule', rule.title)); button.click(function() { setting.activeRule(rule); refresh(); }); list.append(button); } else { var site = info.href.replace(/[^:]*:\/\/([^\/]*).*/, '$1'); var sitepattern = info.href.replace(/([^:]*:\/\/[^\/]*).*/, '$1/*'); var btn1 = $('<button>').addClass('customRule'). text($$('add_rule_site', site)).click(function() { var rule = setting.createRule(); rule.type = 'wild'; rule.value = sitepattern; setting.addCustomRule(rule, 'popup'); refresh(); }); var clsid = info.clsid; var btn2 = $('<button>').addClass('customRule'). text($$('add_rule_clsid')).click(function() { var rule = setting.createRule(); rule.type = 'clsid'; rule.value = clsid; setting.addCustomRule(rule, 'popup'); refresh(); }); list.append(btn1).append(btn2); } } } $(document).ready(function() { $('#submitissue').click(function() { tabInfo.tracking = true; alert($$('issue_submitting_desp')); window.close(); }); }); $(document).ready(showEnableBtns);
007slmg-np-activex-justep
chrome/popup.js
JavaScript
mpl11
3,454
<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></meta> <style> .line { clear: both; margin: 4px 0px; } .item { margin: 4px 3px; float: left; } </style> </head> <body> <div id="fb-root"></div> <div class="line"> <div class="fb-like" data-href="https://chrome.google.com/webstore/detail/lgllffgicojgllpmdbemgglaponefajn" data-send="true" data-width="450" data-show-faces="false"></div> </div> <div class="line"> <!-- Place this tag where you want the +1 button to render --> <g:plusone annotation="inline" href="https://chrome.google.com/webstore/detail/lgllffgicojgllpmdbemgglaponefajn" expandTo="top"></g:plusone> <!-- Place this render call where appropriate --> </div> <div class="line"> <div class="item"> <div id="weiboshare"> </div> </div> <div class="item"> <div id="renrenshare"></div> <a id="xn_share" name="xn_share" type="icon_medium" href="#"></a> </div> <div class="item"> <a id="qqweibo" class="tmblog"> <img src="http://mat1.gtimg.com/app/opent/images/websites/share/weiboicon24.png" border="0" alt="转播到腾讯微博" /> </a> </div> <div class="item"> <iframe allowTransparency='true' id='like_view' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' hspace='0' vspace='0' style='height:24px;width:65px;' src='http://www.kaixin001.com/like/like.php?url=https%3A%2F%2Fchrome.google.com%2Fwebstore%2Fdetail%2Flgllffgicojgllpmdbemgglaponefajn&show_faces=false'></iframe> </div> <div class="item"> <a id="doubanshare" href="#"> <img style="margin:auto" src="http://img2.douban.com/pics/fw2douban_s.png" alt="推荐到豆瓣" /> </a> </div> </div> </body> </html>
007slmg-np-activex-justep
chrome/share.html
HTML
mpl11
1,954
// Copyright (c) 2010 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var $$ = chrome.i18n.getMessage; function loadI18n() { var spans = document.querySelectorAll('[i18n]'); for (var i = 0; i < spans.length; ++i) { var obj = spans[i]; v = $$(obj.getAttribute('i18n')); if (v == '') v = obj.getAttribute('i18n'); if (obj.tagName == 'INPUT') { obj.value = v; } else { obj.innerText = v; } } document.removeEventListener('DOMContentLoaded', loadI18n, false); } document.addEventListener('DOMContentLoaded', loadI18n, false);
007slmg-np-activex-justep
chrome/i18n.js
JavaScript
mpl11
704
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. function ObjectWithEvent() { this._events = {}; } ObjectWithEvent.prototype = { bind: function(name, func) { if (!Array.isArray(this._events[name])) { this._events[name] = []; } this._events[name].push(func); }, unbind: function(name, func) { if (!Array.isArray(this._events[name])) { return; } for (var i = 0; i < this._events[name].length; ++i) { if (this._events[name][i] == func) { this._events[name].splice(i, 1); break; } } }, trigger: function(name, argument) { if (this._events[name]) { var handlers = this._events[name]; for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(this, argument); } } } };
007slmg-np-activex-justep
chrome/ObjectWithEvent.js
JavaScript
mpl11
953
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var background = chrome.extension.getBackgroundPage(); var setting = background.setting; var updateSession = background.updateSession; function toggleRule(e) { var line = e.data.line; var index = line.attr('row'); var item = setting.order[index]; if (item.position == 'default') { if (item.status == 'enabled') { item.status = 'disabled'; trackDisable(item.identifier); } else if (item.status == 'disabled') { item.status = 'enabled'; trackEnable(item.identifier); } } line.blur(); e.data.list.finishEdit(line); e.data.list.updateLine(line); save(); } var settingProps = [{ header: '', property: 'status', type: 'button', caption: '', events: { command: toggleRule, update: setStatus, createNew: setStatusNew } }, { header: $$('title'), property: 'title', type: 'input' }, { header: $$('mode'), property: 'type', type: 'select', option: 'static', options: [ {value: 'wild', text: $$('WildChar')}, {value: 'regex', text: $$('RegEx')}, {value: 'clsid', text: $$('CLSID')} ] }, { header: $$('pattern'), property: 'value', type: 'input' }, { header: $$('user_agent'), property: 'userAgent', type: 'select', option: 'static', options: [ {value: '', text: 'Chrome'}, {value: 'ie9', text: 'MSIE9'}, {value: 'ie8', text: 'MSIE8'}, {value: 'ie7', text: 'MSIE7'}, {value: 'ff7win', text: 'Firefox 7'}, {value: 'ip5', text: 'iPhone'}, {value: 'ipad5', text: 'iPad'} ] }, { header: $$('helper_script'), property: 'script', type: 'input' } ]; var table; var dirty = false; function save() { dirty = true; } function doSave() { if (dirty) { dirty = false; setting.update(); } } function setReadonly(e) { var line = e.data.line; var id = line.attr('row'); if (id < 0) { return; } var order = setting.order[id]; var divs = $('.listvalue', line); if (order.position != 'custom') { divs.addClass('readonly'); } else { divs.removeClass('readonly'); } } $(window).blur(doSave); function refresh() { table.refresh(); } // Main setting $(document).ready(function() { table = new List({ props: settingProps, main: $('#tbSetting'), lineEvents: { update: setReadonly }, getItems: function() { return setting.order; }, getItemProp: function(i, prop) { if (prop in setting.order[i]) { return setting.order[i][prop]; } return setting.getItem(setting.order[i])[prop]; }, setItemProp: function(i, prop, value) { if (prop in setting.order[i]) { setting.order[i][prop] = value; } else { setting.getItem(setting.order[i])[prop] = value; } }, defaultValue: setting.createRule(), count: function() { return setting.order.length; }, insert: function(id, newItem) { setting.addCustomRule(newItem); this.move(setting.order.length - 1, id); }, remove: function(id) { if (setting.order[id].position != 'custom') { return true; } var identifier = setting.order[id].identifier; delete setting.rules[identifier]; setting.order.splice(id, 1); }, validate: function(id, rule) { return setting.validateRule(rule); } }); $(table).bind('updated', save); $('#addRule').bind('click', function() { table.editNewLine(); }); $(table).bind('select', function() { var line = table.selectedLine; if (line < 0) { $('#moveUp').attr('disabled', 'disabled'); $('#moveDown').attr('disabled', 'disabled'); $('#deleteRule').attr('disabled', 'disabled'); } else { if (line != 0) { $('#moveUp').removeAttr('disabled'); } else { $('#moveUp').attr('disabled', 'disabled'); } if (line != setting.order.length - 1) { $('#moveDown').removeAttr('disabled'); } else { $('#moveDown').attr('disabled', 'disabled'); } if (setting.order[line].position != 'custom') { $('#deleteRule').attr('disabled', 'disabled'); } else { $('#deleteRule').removeAttr('disabled'); } } }); $('#moveUp').click(function() { var line = table.selectedLine; table.move(line, line - 1, true); }); $('#moveDown').click(function() { var line = table.selectedLine; table.move(line, line + 1, true); }); $('#deleteRule').click(function() { var line = table.selectedLine; table.remove(line); }); table.init(); updateSession.bind('update', refresh); }); window.onbeforeunload = function() { updateSession.unbind('update', refresh); }; function setStatusNew(e) { with (e.data) { s = 'Custom'; color = '#33f'; $('button', line).text(s).css('background-color', color); } } function setStatus(e) { with (e.data) { var id = line.attr('row'); var order = setting.order[id]; var rule = setting.getItem(order); var s, color; if (order.status == 'enabled') { s = $$('Enabled'); color = '#0A0'; } else if (order.status == 'disabled') { s = $$('Disabled'); color = 'indianred'; } else { s = $$('Custom'); color = '#33f'; } $('button', line).text(s).css('background-color', color); } } function showTime(time) { var never = 'Never'; if (time == 0) { return never; } var delta = Date.now() - time; if (delta < 0) { return never; } function getDelta(delta) { var sec = delta / 1000; if (sec < 60) { return [sec, 'second']; } var minute = sec / 60; if (minute < 60) { return [minute, 'minute']; } var hour = minute / 60; if (hour < 60) { return [hour, 'hour']; } var day = hour / 24; return [day, 'day']; } var disp = getDelta(delta); var v1 = Math.floor(disp[0]); return v1 + ' ' + disp[1] + (v1 != 1 ? 's' : '') + ' ago'; } $(document).ready(function() { $('#log_enable').change(function(e) { setting.misc.logEnabled = e.target.checked; save(); })[0].checked = setting.misc.logEnabled; $('#tracking').change(function(e) { setting.misc.tracking = e.target.checked; save(); })[0].checked = setting.misc.tracking; }); $(document).ready(function() { var help = 'http://code.google.com/p/np-activex/wiki/ExtensionHelp?wl='; help = help + $$('wikicode'); $('.help').each(function() { this.href = help; }); }); $(window).load(function() { if (background.firstUpgrade) { background.firstUpgrade = false; alert($$('upgrade_show')); } });
007slmg-np-activex-justep
chrome/options.js
JavaScript
mpl11
7,041
<script src="jquery.js" > </script> <script src="i18n.js" > </script> <script src="common.js" > </script> <script src="ObjectWithEvent.js"> </script> <script src="configure.js"> </script> <script src="web.js"> </script> <script src="gas.js"> </script> <script src="background.js"></script>
007slmg-np-activex-justep
chrome/background.html
HTML
mpl11
298
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. List.types.input = function(p, prop) { p[0].listdata = this; this.p = p; var input = this.input = $('<input></input>').addClass('valinput'); this.label = $('<span></span>').addClass('valdisp'); this.label.click(function(e) { setTimeout(function() { input.focus(); }, 10); }); this.input.focus(function(e) { input.select(); }); this.input.keypress(function(e) { p.trigger('change'); }); this.input.keyup(function(e) { p.trigger('change'); }); this.input.change(function(e) { p.trigger('change'); }); p.append(this.input).append(this.label); }; List.types.input.prototype.__defineSetter__('value', function(val) { this.input.val(val); this.label.text(val); }); List.types.input.prototype.__defineGetter__('value', function() { return this.input.val(); }); List.types.select = function(p, prop) { p[0].listdata = this; this.p = p; var input = this.input = $('<select></select>').addClass('valinput'); this.label = $('<span></span>').addClass('valdisp'); if (prop.option == 'static') { this.loadOptions(prop.options); } var select = this; this.input.change(function(e) { if (p.hasClass('readonly')) { select.value = select.lastval; } else { p.trigger('change'); } }); this.label.click(function(e) { setTimeout(function() { input.focus(); }, 10); }); p.append(this.input).append(this.label); }; List.types.select.prototype.loadOptions = function(options) { this.options = options; this.mapping = {}; this.input.html(''); for (var i = 0; i < options.length; ++i) { this.mapping[options[i].value] = options[i].text; var o = $('<option></option>').val(options[i].value).text(options[i].text); this.input.append(o); } }; List.types.select.prototype.__defineGetter__('value', function() { return this.input.val(); }); List.types.select.prototype.__defineSetter__('value', function(val) { this.lastval = val; this.input.val(val); this.label.text(this.mapping[val]); }); List.types.checkbox = function(p, prop) { p[0].listdata = this; this.p = p; var input = this.input = $('<input type="checkbox">').addClass('valcheck'); var box = this; this.input.change(function(e) { if (p.hasClass('readonly')) { box.value = box.lastval; } else { p.trigger('change'); } }); p.append(this.input); }; List.types.checkbox.prototype.__defineGetter__('value', function() { return this.input[0].checked; }); List.types.checkbox.prototype.__defineSetter__('value', function(val) { this.lastval = val; this.input[0].checked = val; }); List.types.button = function(p, prop) { p[0].listdata = this; this.p = p; var input = this.input = $('<button>'); if (prop.caption) { input.text(prop.caption); } input.click(function(e) { p.trigger('command'); return false; }); p.append(this.input); }; List.types.button.prototype.__defineGetter__('value', function() { return undefined; });
007slmg-np-activex-justep
chrome/listtypes.js
JavaScript
mpl11
3,299
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved. // Use of this source code is governed by a Mozilla-1.1 license that can be // found in the LICENSE file. var backgroundPage = chrome.extension.getBackgroundPage(); var defaultTabId = parseInt(location.href.replace(/.*tabid=([0-9]*).*/, '$1')); function insertTabInfo(tab) { if (isNaN(defaultTabId)) { defaultTabId = tab.id; } if (uls[tab.id]) { return; } var ul = $('<ul>').appendTo($('#logs_items')); uls[tab.id] = ul; var title = tab.title; if (!title) { title = 'Tab ' + tab.id; } $('<a>').attr('href', '#') .attr('tabid', tab.id) .text(title) .click(function(e) { loadTabInfo(parseInt($(e.target).attr('tabid'))); }).appendTo(ul); } var uls = {}; $(document).ready(function() { chrome.tabs.query({}, function(tabs) { for (var i = 0; i < tabs.length; ++i) { var protocol = tabs[i].url.replace(/(^[^:]*).*/, '$1'); if (protocol != 'http' && protocol != 'https' && protocol != 'file') { continue; } insertTabInfo(tabs[i]); } for (var i in backgroundPage.tabStatus) { insertTabInfo({id: i}); } $('#tracking').change(function() { var tabStatus = backgroundPage.tabStatus[currentTab]; if (tabStatus) { tabStatus.tracking = tracking.checked; } }); loadTabInfo(defaultTabId); }); }); $(document).ready(function() { $('#beforeSubmit').click(function() { var link = $('#submitLink'); if (beforeSubmit.checked) { link.show(); } else { link.hide(); } }); }); var currentTab = -1; function loadTabInfo(tabId) { if (isNaN(tabId)) { return; } if (tabId != currentTab) { if (currentTab != -1) { uls[currentTab].removeClass('selected'); } currentTab = tabId; uls[tabId].addClass('selected'); var s = backgroundPage.generateLogFile(tabId); $('#text').val(s); tracking.checked = backgroundPage.tabStatus[tabId].tracking; } }
007slmg-np-activex-justep
chrome/log.js
JavaScript
mpl11
2,108
function initShare() { var link = 'https://chrome.google.com/webstore/detail/' + 'lgllffgicojgllpmdbemgglaponefajn'; var text2 = ['Chrome也能用网银啦!', '每次付款还要换浏览器?你out啦!', '现在可以彻底抛弃IE了!', '让IE去死吧!', 'Chrome用网银:' ]; text2 = text2[Math.floor(Math.random() * 1000121) % text2.length]; text2 = '只要安装了ActiveX for Chrome,就可以直接在Chrome里' + '使用各种网银、播放器等ActiveX控件了。而且不用切换内核,非常方便。'; var pic = 'http://ww3.sinaimg.cn/bmiddle/8c75b426jw1dqz2l1qfubj.jpg'; var text = text2 + '下载地址:'; // facebook (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = 'https://connect.facebook.net/en_US/all.js#xfbml=1'; js.async = true; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); window.___gcfg = {lang: navigator.language}; // Google plus (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); // Sina weibo (function() { var _w = 75 , _h = 24; var param = { url: link, type: '2', count: '1', /**是否显示分享数,1显示(可选)*/ appkey: '798098327', /**您申请的应用appkey,显示分享来源(可选)*/ title: text, pic: pic, /**分享图片的路径(可选)*/ ralateUid: '2356524070', /**关联用户的UID,分享微博会@该用户(可选)*/ language: 'zh_cn', /**设置语言,zh_cn|zh_tw(可选)*/ rnd: new Date().valueOf() }; var temp = []; for (var p in param) { temp.push(p + '=' + encodeURIComponent(param[p] || '')); } weiboshare.innerHTML = '<iframe allowTransparency="true"' + ' frameborder="0" scrolling="no" ' + 'src="http://hits.sinajs.cn/A1/weiboshare.html?' + temp.join('&') + '" width="' + _w + '" height="' + _h + '"></iframe>'; })(); //renren function shareClick() { var rrShareParam = { resourceUrl: link, pic: pic, title: 'Chrome用网银:ActiveX for Chrome', description: text2 }; rrShareOnclick(rrShareParam); } Renren.share(); xn_share.addEventListener('click', shareClick, false); // Tencent weibo function postToWb() { var _url = encodeURIComponent(link); var _assname = encodeURI(''); var _appkey = encodeURI('801125118');//你从腾讯获得的appkey var _pic = encodeURI(pic); var _t = ''; var metainfo = document.getElementsByTagName('meta'); for (var metai = 0; metai < metainfo.length; metai++) { if ((new RegExp('description', 'gi')).test( metainfo[metai].getAttribute('name'))) { _t = metainfo[metai].attributes['content'].value; } } _t = text; if (_t.length > 120) { _t = _t.substr(0, 117) + '...'; } _t = encodeURI(_t); var _u = 'http://share.v.t.qq.com/index.php?c=share&a=index&url=' + _url + '&appkey=' + _appkey + '&pic=' + _pic + '&assname=' + _assname + '&title=' + _t; window.open(_u, '', 'width=700, height=680, top=0, left=0, toolbar=no,' + ' menubar=no, scrollbars=no, location=yes, resizable=no, status=no'); } qqweibo.addEventListener('click', postToWb, false); // Douban function doubanShare() { var d = document, e = encodeURIComponent, s1 = window.getSelection, s2 = d.getSelection, s3 = d.selection, s = s1 ? s1() : s2 ? s2() : s3 ? s3.createRange().text : '', r = 'http://www.douban.com/recommend/?url=' + e(link) + '&title=' + e('ActiveX for Chrome') + '&sel=' + e(s) + '&v=1'; window.open( r, 'douban', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'); } doubanshare.addEventListener('click', doubanShare, false); } $(document).ready(function() { div = $('#share'); div.load('share.html', function() { setTimeout(initShare, 200); }); }); document.write('<script type="text/javascript" src="rrshare.js"></script>'); document.write('<div id="share">'); document.write('</div>');
007slmg-np-activex-justep
chrome/share.js
JavaScript
mpl11
4,556
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is RSJ Software GmbH code. * * The Initial Developer of the Original Code is * RSJ Software GmbH. * Portions created by the Initial Developer are Copyright (C) 2009 * the Initial Developer. All Rights Reserved. * * Contributors: * Ruediger Jungbeck <ruediger.jungbeck@rsj.de> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include <stdio.h> #include <windows.h> #include <winbase.h> // ---------------------------------------------------------------------------- int main (int ArgC, char *ArgV[]) { const char *sourceName; const char *targetName; HANDLE targetHandle; void *versionPtr; DWORD versionLen; int lastError; int ret = 0; if (ArgC < 3) { fprintf(stderr, "Usage: %s <source> <target>\n", ArgV[0]); exit (1); } sourceName = ArgV[1]; targetName = ArgV[2]; if ((versionLen = GetFileVersionInfoSize(sourceName, NULL)) == 0) { fprintf(stderr, "Could not retrieve version len from %s\n", sourceName); exit (2); } if ((versionPtr = calloc(1, versionLen)) == NULL) { fprintf(stderr, "Error allocating temp memory\n"); exit (3); } if (!GetFileVersionInfo(sourceName, NULL, versionLen, versionPtr)) { fprintf(stderr, "Could not retrieve version info from %s\n", sourceName); exit (4); } if ((targetHandle = BeginUpdateResource(targetName, FALSE)) == INVALID_HANDLE_VALUE) { fprintf(stderr, "Could not begin update of %s\n", targetName); free(versionPtr); exit (5); } if (!UpdateResource(targetHandle, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), versionPtr, versionLen)) { lastError = GetLastError(); fprintf(stderr, "Error %d updating resource\n", lastError); ret = 6; } if (!EndUpdateResource(targetHandle, FALSE)) { fprintf(stderr, "Error finishing update\n"); ret = 7; } free(versionPtr); return (ret); }
007slmg-np-activex-justep
transver/transver.cpp
C++
mpl11
3,963
package ImportsAndExports; import java.util.LinkedList; import java.util.Random; public class createRandomAthletesDB { String[] fnames = {"Alexandru","Adi","Andrei","Cosmin","Daniel","Mircea","Bogdan","Florin","Ionut","Marian","Sorin"}; String[] surnames = {"Gaman","Palko","Popescu","Pavel","Ciobanu","Paraschiv","Podaru","Neagoe","Diaconu","Tatru","Ionescu"}; String[] nationalities = {"Romania","Franta","Italia","Spania","Germania","Austria","Olanda","Luxemburg","U.S.A","Jamaica","Ecuador"}; Random generator = new Random(); float[] ca = new float[1000]; float[] pa = new float[1000]; public static void main(String args[]) { new createRandomAthletesDB(); } public createRandomAthletesDB() { super(); this.setCA(); this.writeDB(); } public void writeDB(){ dbImporting.writeDB("AtletiGenerati.txt", this.generate()); } public LinkedList<String> generate(){ LinkedList<String> returnValue = new LinkedList<String>(); for (int i=1;i<1000;i++) { returnValue.addAll(this.generateNewAthlete(i)); } return returnValue; } public LinkedList<String> generateNewAthlete(int i){ LinkedList<String> returnValue = new LinkedList<String>(); returnValue.add(i+""); returnValue.add(generator.nextInt((int) ca[i]/10+1)+""); // acc returnValue.add(generator.nextInt((int) ca[i]/10+1)+""); // spd returnValue.add(generator.nextInt((int) ca[i]/10+1)+""); // pac returnValue.add(generator.nextInt((int) ca[i]/10+1)+""); // rea returnValue.add(generator.nextInt((int) ca[i]/10+1)+""); // conc returnValue.add(generator.nextInt((int) ca[i]/10+1)+""); // fit returnValue.add(generator.nextInt((int) ca[i]/10+1)+""); // mor returnValue.add(this.ca[i]+""); // cab returnValue.add(this.pa[i]+""); // pab returnValue.add(this.fnames[generator.nextInt(10)]); // random fname returnValue.add(this.surnames[generator.nextInt(10)]); // random surname returnValue.add(this.nationalities[generator.nextInt(10)]); // random nat returnValue.add((generator.nextInt(29) + 1)+""); // ziua nasterii returnValue.add((generator.nextInt(12) + 1)+""); // luna nasterii returnValue.add((generator.nextInt(20)+1970)+""); // anul nasterii returnValue.add("99.99"); // personal best returnValue.add("1"); returnValue.add("1"); returnValue.add("1"); // data pentru pb returnValue.add("null"); // locatia pb returnValue.add("99.99"); // season best returnValue.add("1"); returnValue.add("1"); returnValue.add("1"); // data pentru sb returnValue.add("Null"); // locatia sb returnValue.add("null"); // istoric, initial null return returnValue; } public void setCA(){ for (int i=0;i<1000;i++) { this.pa[i] = generator.nextInt(1000); this.ca[i] = generator.nextInt((int) pa[i]+1); } } }
100simulator
trunk/Client/src/ImportsAndExports/createRandomAthletesDB.java
Java
oos
3,141
package Main.ImportsAndExports;
100simulator
trunk/Client/src/ImportsAndExports/package-info.java
Java
oos
35
package ImportsAndExports; import java.util.LinkedList; public class createRandomCompetitionDB { LinkedList<String> nume = new LinkedList<String>(); LinkedList<String> locatie = new LinkedList<String>(); LinkedList<String> data = new LinkedList<String>(); LinkedList<String> categ = new LinkedList<String>(); public static void main(String args[]) { new createRandomCompetitionDB(); } public createRandomCompetitionDB() { super(); this.readFiles(); this.writeNewDatabase("NewDatabase.txt"); } public void writeNewDatabase(String s){ dbImporting.writeDB(s, this.createCompetition()); } public LinkedList<String> createCompetition() { LinkedList<String> returnValue = new LinkedList<String>(); for (int i=0;i<65;i++) { returnValue.add(i+""); returnValue.add(categ.get(i)); returnValue.add(data.get(i).split(" ")[0]); returnValue.add(data.get(i).split(" ")[1]); returnValue.add(data.get(i).split(" ")[2]); returnValue.add(nume.get(i)); returnValue.add(locatie.get(i).split(",")[0]); returnValue.add(locatie.get(i).split(",")[1]); returnValue.add("99.99"); returnValue.add("1"); returnValue.add("1"); returnValue.add("2000"); returnValue.add("Nobody"); if (categ.get(i).equals("2") == true) returnValue.add("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255"); if (categ.get(i).equals("3") == true) returnValue.add("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127"); if (categ.get(i).equals("4")) returnValue.add("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63"); if (categ.get(i).equals("5") == true) returnValue.add("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31"); } return returnValue; } public String listToString(LinkedList<String> a){ String s = ""; for (String aux : a) s += a+" "; return s; } public void readFiles() { this.nume = dbImporting.readDB("CompNames.txt"); this.locatie = dbImporting.readDB("CompLocation.txt"); this.data = dbImporting.readDB("CompDates.txt"); this.categ = dbImporting.readDB("CompCateg.txt"); } }
100simulator
trunk/Client/src/ImportsAndExports/createRandomCompetitionDB.java
Java
oos
3,890
package ImportsAndExports; import java.util.LinkedList; public class generator { public generator() { super(); } public static void main(String args[]){ LinkedList<String> rv = new LinkedList<String>(); String s = ""; for (int j=0;j<256;j++) s+=j+" "; rv.add(s); dbImporting.writeDB("n.txt", rv); } }
100simulator
trunk/Client/src/ImportsAndExports/generator.java
Java
oos
452
package ImportsAndExports; import BackendSimulation.Atlet; import BackendSimulation.staticData; import BackendSimulation.Competition; import BackendSimulation.Manager; import java.util.*; import java.io.*; public class dbImporting { static LinkedList<String> details = new LinkedList<String>(); public dbImporting() { super(); } static int writeDB(String path, LinkedList<String> data) { try { File f = new File(path); if (f.exists() == false){ f.createNewFile(); FileWriter fw = new FileWriter(path); BufferedWriter bw = new BufferedWriter( fw ); for (int i=0;i<data.size();i++) { bw.write(data.get(i)); bw.newLine(); } bw.close( ); // inchid fisierul } else{ f.createNewFile(); FileWriter fw = new FileWriter(path); BufferedWriter bw = new BufferedWriter( fw ); for (int i=0;i<data.size();i++) { bw.append(data.get(i)); bw.newLine(); } bw.close( ); // inchid fisierul } } catch(IOException e ) // tratare io exception { System.out.println("IO ERROR : "+e.getMessage()); e.printStackTrace( ); return 1; } System.out.println( "all OK" ); // returnez mesaj de succes return 0; } public static LinkedList<String> readDB(String path) // metoda de citire a unui fisier text {LinkedList<String> aux = new LinkedList<String>(); try { Scanner sc = new Scanner(new File(path)); // incerc sa deschid fisierul cu calea fname while (sc.hasNext()) // citesc din fisier atat timp cat exista urmatorul element { String x = sc.nextLine(); if (x.startsWith("//") == false) aux.add(x); } // sfarsitul citirii din fisier sc.close(); //inchid fisierul text return aux; } // end try catch (FileNotFoundException fnf) { System.out.println("File does not exist : "+path);// in cazul in care returneaza eroare, afisez mesajul fnf.printStackTrace(); return null; // in caz de eroare, returnez null } // end catch catch (Exception e) { System.out.println("ERROR : "+e.getMessage());// in cazul in care returneaza eroare, afisez mesajul e.printStackTrace(); return null; // in caz de eroare, returnez null } // end catch } // end int readfile() public static LinkedList<Atlet> parseAtletImport() { LinkedList<String> aux = readDB("Athletes.txt"); LinkedList<Atlet> returnValue = new LinkedList<Atlet>(); System.out.println("Debug test 3 : atlet aux size : "+aux.size()); while(aux.isEmpty() == false){ returnValue.add(new Atlet(aux)); for (int j=1;j<=27;j++) {aux.removeFirst();} } return returnValue; } public static LinkedList<Competition> parseCompetitionImport() { LinkedList<String> aux = readDB("Comp.txt"); LinkedList<Competition> returnValue = new LinkedList<Competition>(); System.out.println("Debug test 1 : competition aux size : "+aux.size()); while(aux.isEmpty() == false){ returnValue.add(new Competition(aux)); for (int j=1;j<=14;j++) {aux.removeFirst();} } return returnValue; } public static LinkedList<Manager> parseManagerImport(){ LinkedList<String> aux = readDB("Managers.txt"); LinkedList<Manager> returnValue = new LinkedList<Manager>(); System.out.println("Debug test 2 : manager aux size : "+aux.size()); while(aux.isEmpty() == false){ returnValue.add(new Manager(aux)); for (int j=1;j<=13;j++) {aux.removeFirst();} } return returnValue; } public static void writePlayerDetails(Manager player) { details.add("0"); details.add(player.firstName); details.add(player.lastName); details.add(player.nationalitate); // details.add(player.dataNasterii.zi+""); details.add(player.dataNasterii.luna+""); details.add(player.dataNasterii.an+""); //details.add(player.training+""); details.add(player.business+""); details.add(player.knowledge+"");details.add(player.renume+"") ;details.add(player.ability+""); String s = ""; } public static void writeCompetitionDetails(LinkedList<Competition> competitii){ details.add("-----"); for (Competition comp : competitii) { details.add(comp.uniqueID+""); details.add(comp.clasa+""); details.add(comp.dataConcursului.zi+""); details.add(comp.dataConcursului.luna+""); details.add(comp.dataConcursului.an+""); details.add(comp.numeleConcursului); details.add(comp.orasulConcursului); details.add(comp.taraConcursului); details.add(comp.record+""); details.add(comp.dataRecordului.zi+""); details.add(comp.dataRecordului.luna+""); details.add(comp.dataRecordului.an+""); details.add(comp.numeDetinator); String s = ""; if (comp.atletiInscrisi != null) { for (int inscris : comp.atletiInscrisi) { s += inscris+" "; } details.add(s); } else {details.add("null");} } } public static Manager readPlayerDetails(String s){ LinkedList<String> aux = readDB("Saved/" + s +".txt"); System.out.println("Loading OK"); return new Manager(aux); } public static void writeAthletes(LinkedList<Atlet> ath) { details.add("-----"); for (Atlet athlete : ath) { details.add(athlete.uniqueID+""); details.add(athlete.acceleration+""); details.add(athlete.speed+""); details.add(athlete.pace+""); details.add(athlete.reaction+""); details.add(athlete.concentration+""); details.add(athlete.fitness+""); details.add(athlete.morale+""); details.add(athlete.currentAbility+""); details.add(athlete.potentialAbility+""); details.add(athlete.firstName); details.add(athlete.lastName); details.add(athlete.nationality); details.add(athlete.dataNasterii.zi+""); details.add(athlete.dataNasterii.luna+""); details.add(athlete.dataNasterii.an+""); details.add(athlete.personalBest+""); details.add(athlete.personalBestDate.zi+""); details.add(athlete.personalBestDate.luna+""); details.add(athlete.personalBestDate.an+""); details.add(athlete.personalBestLocation); details.add(athlete.seasonBest+""); details.add(athlete.seasonBestDate.zi+""); details.add(athlete.seasonBestDate.luna+""); details.add(athlete.seasonBestDate.an+""); details.add(athlete.seasonBestLocation); if (athlete.history.size() != 0) { String s = ""; for (float f : athlete.history) { s += f+""; } details.add(s); } else {details.add("null");} } } public static void writeManagers(LinkedList<Manager> man){ details.add("-----"); for (Manager player : man){ details.add("0"); details.add(player.firstName); details.add(player.lastName); details.add(player.nationalitate); details.add(player.dataNasterii.zi+""); details.add(player.dataNasterii.luna+""); details.add(player.dataNasterii.an+""); details.add(player.training+""); details.add(player.business+""); details.add(player.knowledge+"");details.add(player.renume+"") ;details.add(player.ability+""); String s = ""; for (int i=0;i<player.idAtletiSubContract.size();i++) { s += player.idAtletiSubContract.get(i)+" "; } details.add(s); } } public static void createSavedGame(){ // TODO // writePlayerDetails(staticData.player); writeManagers(staticData.managers); writeAthletes(staticData.atlet); writeCompetitionDetails(staticData.competitii); writeDB("Saved/"+ staticData.player.firstName + " " + staticData.player.lastName +".txt",details); details.clear(); } public static LinkedList[] loadSavedGame(String s) { LinkedList[] returnValue = new LinkedList[4]; returnValue[0] = new LinkedList<Manager>(); returnValue[1] = new LinkedList<Atlet>(); returnValue[2] = new LinkedList<Manager>(); returnValue[3] = new LinkedList<Competition>(); LinkedList<String> loadedData = readDB("Saved/" + s +".txt"); LinkedList<String> plyr = new LinkedList<String>();LinkedList<String> atl = new LinkedList<String>(); LinkedList<String> man = new LinkedList<String>(); LinkedList<String> comp = new LinkedList<String>(); int count = 0; for (String substr : loadedData){ if (substr.startsWith("-----") == true) {count++;} else { if (count == 0){ plyr.add(substr); } if (count == 1){ man.add(substr); } if (count == 2){ atl.add(substr); } if (count == 3){ comp.add(substr); } } } returnValue[0].add(new Manager(plyr)); System.out.println ("Debug : atlSaved size : " +atl.size()); while (atl.isEmpty() == false){ returnValue[1].add(new Atlet(atl)); for (int j=1;j<=27;j++) {atl.removeFirst();} } System.out.println ("Debug : manSaved size : " +man.size()); while (man.isEmpty() == false){ returnValue[2].add(new Manager(man)); for (int j=1;j<=13;j++) {man.removeFirst();} } System.out.println ("Debug : compSaved size : " +comp.size()); while (comp.isEmpty() == false){ returnValue[3].add(new Competition(comp)); for (int j=1;j<=14;j++) {comp.removeFirst();} } return returnValue; } }
100simulator
trunk/Client/src/ImportsAndExports/dbImporting.java
Java
oos
11,902
package GUI; import BackendSimulation.AttributesCheck; import BackendSimulation.Data; import BackendSimulation.staticData; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.List; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Vector; import javax.swing.BorderFactory; import javax.swing.DebugGraphics; import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableModel; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumn; public class ManagerHome extends JFrame { private JLabel jLabel1 = new JLabel(); private JLabel currentDateLabel = new JLabel(); private JLabel jLabel3 = new JLabel(); private JLabel jLabel4 = new JLabel(); private List list1 = new List(); private JLabel managerNameLabel = new JLabel(); private JLabel managerAgeLabel = new JLabel(); private JLabel managerNationalityLabel = new JLabel(); private JButton jButton1 = new JButton(); private JButton jButton2 = new JButton(); private JButton jButton3 = new JButton(); private JButton jButton4 = new JButton(); private JTable jTable1 = new JTable(new TabelCompetitii(staticData.competitionCount)); private JScrollPane jScrollPane1 = new JScrollPane(jTable1); private BorderLayout borderLayout1 = new BorderLayout(); private JButton jButton5 = new JButton(); private JButton jButton6 = new JButton(); private JLabel recordMondial = new JLabel(); private JButton jButton7 = new JButton(); static int prevMonth = 1; public ManagerHome() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.getContentPane().setLayout( null ); this.setSize(new Dimension(456, 339)); jLabel1.setText("Current date : "); jLabel1.setBounds(new Rectangle(5, 80, 115, 20)); currentDateLabel.setText("jLabel2"); currentDateLabel.setBounds(new Rectangle(135, 80, 245, 20)); jLabel3.setText("Currently managed athletes :"); jLabel3.setBounds(new Rectangle(5, 110, 220, 20)); jLabel4.setText("Upcoming competitions :"); jLabel4.setBounds(new Rectangle(230, 110, 220, 20)); list1.setBounds(new Rectangle(5, 140, 140, 75)); managerNameLabel.setText("jLabel2"); managerNameLabel.setBounds(new Rectangle(5, 15, 200, 25)); managerAgeLabel.setText("jLabel5"); managerAgeLabel.setBounds(new Rectangle(220, 15, 105, 25)); managerNationalityLabel.setText("jLabel5"); managerNationalityLabel.setBounds(new Rectangle(335, 15, 115, 25)); jButton1.setText("1 day"); jButton1.setBounds(new Rectangle(10, 235, 125, 20)); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jButton2.setText("1 week"); jButton2.setBounds(new Rectangle(155, 235, 125, 20)); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); jButton3.setText("next comp"); jButton3.setBounds(new Rectangle(295, 235, 125, 20)); jButton3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton3_actionPerformed(e); } }); jButton4.setText("Rankings"); jButton4.setBounds(new Rectangle(145, 275, 145, 20)); jButton4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton4_actionPerformed(e); } }); jScrollPane1.setBounds(new Rectangle(225, 135, 210, 75)); jScrollPane1.setDoubleBuffered(true); jButton5.setText("search"); jButton5.setBounds(new Rectangle(305, 275, 130, 20)); jButton5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton5_actionPerformed(e); } }); jButton6.setText("comp"); jButton6.setBounds(new Rectangle(10, 275, 115, 20)); jButton6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton6_actionPerformed(e); } }); recordMondial.setText("jLabel2"); recordMondial.setBounds(new Rectangle(155, 150, 65, 20)); jButton7.setText("Training"); jButton7.setBounds(new Rectangle(295, 80, 145, 20)); jButton7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton7_actionPerformed(e); } }); jTable1.setAutoCreateRowSorter(true); this.initAthletesList(); //this.initCompetitionsList(); this.initManagerLabels(); this.initDateLabel(); jScrollPane1.getViewport().add(jTable1, null); this.getContentPane().add(jButton7, null); this.getContentPane().add(recordMondial, null); this.getContentPane().add(jButton6, null); this.getContentPane().add(jButton5, null); this.getContentPane().add(jScrollPane1, null); this.getContentPane().add(jButton4, null); this.getContentPane().add(jButton3, null); this.getContentPane().add(jButton2, null); this.getContentPane().add(jButton1, null); this.getContentPane().add(managerNationalityLabel, null); this.getContentPane().add(managerAgeLabel, null); this.getContentPane().add(managerNameLabel, null); this.getContentPane().add(list1, null); this.getContentPane().add(jLabel4, null); this.getContentPane().add(jLabel3, null); this.getContentPane().add(currentDateLabel, null); this.getContentPane().add(jLabel1, null); this.setVisible(true); this.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { this_windowOpened(e); } }); System.out.println("CC : "+staticData.competitionCount); } public void initAthletesList() { // TODO // for (int i=0;i<staticData.player.idAtletiSubContract.size();i++) // list1.add(staticData.atlet.get(i).firstName + " " + staticData.atlet.get(i).lastName); } /* public void initCompetitionsList(){ for (int i=0;i<staticData.competitii.size();i++) list2.add(staticData.competitii.get(i).numeleConcursului + ", " + staticData.competitii.get(i).orasulConcursului); }*/ public void initDateLabel(){ this.currentDateLabel.setText(staticData.dataCurenta.dateToString()); this.recordMondial.setText(staticData.recordMondial+""); } public void initManagerLabels(){ // TODO // this.managerNameLabel.setText(staticData.player.firstName + " " + staticData.player.lastName); // this.managerAgeLabel.setText(staticData.player.age +" years"); // this.managerNationalityLabel.setText(staticData.player.nationalitate); } private void jButton1_actionPerformed(ActionEvent e) { staticData.dataCurenta = staticData.dataCurenta.urmatoareaZi(); this.initDateLabel(); this.newDayRoutine(); this.repaint(); } private void jButton2_actionPerformed(ActionEvent e) { for (int i=1;i<=7;i++) {staticData.dataCurenta = staticData.dataCurenta.urmatoareaZi(); this.newDayRoutine();} this.initDateLabel(); } private void jButton4_actionPerformed(ActionEvent e) { new Clasament(); this.dispose(); } private void newDayRoutine(){ for (int i=0;i<staticData.atlet.size();i++) if ( (staticData.atlet.get(i).dataNasterii.zi == staticData.dataCurenta.zi) && (staticData.atlet.get(i).dataNasterii.luna == staticData.dataCurenta.luna) ) staticData.atlet.get(i).age ++; for (int i=0;i<staticData.managers.size();i++) if ( (staticData.managers.get(i).dataNasterii.zi == staticData.dataCurenta.zi) && (staticData.managers.get(i).dataNasterii.luna == staticData.dataCurenta.luna) ) staticData.managers.get(i).age ++; if ( (staticData.player.dataNasterii.zi == staticData.dataCurenta.zi) && (staticData.player.dataNasterii.luna == staticData.dataCurenta.luna) ) {staticData.player.age ++; this.managerAgeLabel.setText(staticData.player.age+" years");} for (int i=0;i<staticData.competitii.size();i++) if ( (staticData.competitii.get(i).dataConcursului.zi == staticData.dataCurenta.zi) && (staticData.competitii.get(i).dataConcursului.luna == staticData.dataCurenta.luna)) {this.dispose(); new CompetitionPage(i); staticData.competitionCount++; staticData.passedComp.add(i); } AttributesCheck.updateDaily(); if (staticData.dataCurenta.luna != prevMonth ) { AttributesCheck.updateMonthly(); prevMonth = staticData.dataCurenta.luna; } } private void jButton5_actionPerformed(ActionEvent e) { new AthleteSearch(); this.dispose(); } private void jButton6_actionPerformed(ActionEvent e) { new CompetitionSearch(); this.dispose(); } private void this_windowOpened(WindowEvent e) { jTable1.setModel(new TabelCompetitii(staticData.competitionCount)); jScrollPane1.repaint(); } private void jButton3_actionPerformed(ActionEvent e) { int aux = Data.nrZileIntreDate(staticData.dataCurenta, staticData.competitii.get(staticData.competitionCount).dataConcursului); if (staticData.competitionCount == 0) {aux = Data.nrZileIntreDate(staticData.dataCurenta, staticData.competitii.get(0).dataConcursului);} for (int i=1;i<=aux;i++) {staticData.dataCurenta = staticData.dataCurenta.urmatoareaZi(); this.newDayRoutine();} this.initDateLabel(); } private void jButton7_actionPerformed(ActionEvent e) { new Training(); this.dispose(); } // CLASA Tabel Competitii class TabelCompetitii extends AbstractTableModel { private String[] columnNames = {"Data","Nume","Oras"}; private Object[][] date = new Object[staticData.competitii.size()-staticData.competitionCount][5]; private int dim = staticData.competitii.size(); public TabelCompetitii(int cc) { loadData(cc); } public void loadData(int cc) { for (int i=0;i<staticData.competitii.size()-cc;i++){ {System.out.println("Data : "+i); System.out.println("Passed Comp dim"+staticData.passedComp.size()); date[i][0] = staticData.competitii.get(i+cc).dataConcursului.dateToString(); date[i][1] = staticData.competitii.get(i+cc).numeleConcursului; date[i][2] = staticData.competitii.get(i+cc).orasulConcursului; date[i][3] = staticData.competitii.get(i+cc).dataConcursului.zi; date[i][4] = staticData.competitii.get(i+cc).dataConcursului.luna; } fireTableDataChanged(); } } /* public void sortData(int cc){ Object [] aux = new Object[100]; for (int i=0;i<staticData.competitii.size()-cc-2;i++) for (int j=i+1;j<staticData.competitii.size()-cc-1;j++) { int a = (Integer.parseInt(date[i][3].toString())); int b = (Integer.parseInt(date[i][4].toString())); int a2 = (Integer.parseInt(date[j][3].toString())); int b2 = (Integer.parseInt(date[j][4].toString())); if ((b > b2) || ((b == b2) && (a > a2) )){ for (int k=0;k<5;k++) {aux[k] = date[i][k];} for (int k=0;k<5;k++) {date[i][k] = date[j][k];} for (int k=0;k<5;k++) {date[j][k] = aux[k];} } } }*/ @Override public int findColumn(String columnName){ for (int i=0;i<columnNames.length;i++) if (columnName == columnNames[i]) return i; return -1; } @Override public int getColumnCount() { return columnNames.length; } @Override public int getRowCount() { return date.length; } @Override public String getColumnName(int col) { return columnNames[col]; } @Override public Object getValueAt(int rowIndex, int columnIndex) { return date[rowIndex][columnIndex]; } @Override public Class getColumnClass(int c) { return getValueAt(staticData.competitionCount, c).getClass(); } @Override public boolean isCellEditable(int row,int col) {return false;} } }
100simulator
trunk/Client/src/GUI/ManagerHome.java
Java
oos
14,352
package GUI; import java.awt.Dimension; import java.awt.Rectangle; import javax.swing.JFrame; import javax.swing.JTabbedPane; public class ManagerPage extends JFrame { public ManagerPage() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.getContentPane().setLayout( null ); this.setSize( new Dimension(400, 300) ); } }
100simulator
trunk/Client/src/GUI/ManagerPage.java
Java
oos
493
package GUI; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; public class DataEditor extends JFrame { private JTabbedPane jTabbedPane1 = new JTabbedPane(); private JPanel jPanel1 = new JPanel(); private JPanel jPanel2 = new JPanel(); private JList jList1 = new JList(); private JTextField accelerationValue = new JTextField(); private JTextField speedValue = new JTextField(); private JTextField paceValue = new JTextField(); private JTextField reactionValue = new JTextField(); private JTextField concentrationValue = new JTextField(); private JTextField fitnessValue = new JTextField(); private JTextField startingMoraleValue = new JTextField(); private JTextField firstName = new JTextField(); private JTextField lastName = new JTextField(); public DataEditor() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.getContentPane().setLayout( null ); this.setSize(new Dimension(630, 501)); jTabbedPane1.setBounds(new Rectangle(10, 5, 610, 460)); jPanel1.setLayout(null); jList1.setBounds(new Rectangle(15, 20, 105, 410)); accelerationValue.setBounds(new Rectangle(175, 55, 65, 20)); speedValue.setBounds(new Rectangle(175, 80, 65, 20)); paceValue.setBounds(new Rectangle(175, 105, 65, 20)); paceValue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField3_actionPerformed(e); } }); concentrationValue.setBounds(new Rectangle(175, 115, 65, 20)); reactionValue.setBounds(new Rectangle(175, 130, 65, 20)); reactionValue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField3_actionPerformed(e); } }); concentrationValue.setBounds(new Rectangle(175, 155, 65, 20)); concentrationValue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField3_actionPerformed(e); } }); fitnessValue.setBounds(new Rectangle(175, 180, 65, 20)); fitnessValue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField3_actionPerformed(e); } }); startingMoraleValue.setBounds(new Rectangle(175, 205, 65, 20)); firstName.setBounds(new Rectangle(175, 20, 155, 20)); lastName.setBounds(new Rectangle(360, 20, 145, 20)); jPanel1.add(lastName, null); jPanel1.add(firstName, null); jPanel1.add(startingMoraleValue, null); jPanel1.add(fitnessValue, null); jPanel1.add(concentrationValue, null); jPanel1.add(reactionValue, null); jPanel1.add(paceValue, null); jPanel1.add(speedValue, null); jPanel1.add(accelerationValue, null); jPanel1.add(jList1, null); jTabbedPane1.addTab("jPanel1", jPanel1); jTabbedPane1.addTab("jPanel2", jPanel2); this.getContentPane().add(jTabbedPane1, null); } private void jTextField3_actionPerformed(ActionEvent e) { } }
100simulator
trunk/Client/src/GUI/DataEditor.java
Java
oos
3,700
package GUI; import BackendSimulation.*; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JButton; import javax.swing.JFrame; public class Main extends JFrame { private JButton jButton1 = new JButton(); private JButton jButton2 = new JButton(); private JButton jButton3 = new JButton(); private JButton jButton4 = new JButton(); private JButton jButton5 = new JButton(); private JButton jButton6 = new JButton(); private JButton jButton7 = new JButton(); public Main() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.getContentPane().setLayout( null ); this.setSize(new Dimension(359, 300)); jButton1.setText("New Game"); jButton1.setBounds(new Rectangle(10, 20, 135, 40)); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jButton2.setText("Load Game"); jButton2.setBounds(new Rectangle(10, 65, 135, 40)); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); jButton3.setText("Options"); jButton3.setBounds(new Rectangle(10, 110, 135, 40)); jButton3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton3_actionPerformed(e); } }); jButton4.setText("Exit Game"); jButton4.setBounds(new Rectangle(10, 155, 135, 40)); jButton4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton4_actionPerformed(e); } }); jButton5.setText("view athlete"); jButton5.setBounds(new Rectangle(230, 130, 100, 20)); jButton5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton5_actionPerformed(e); } }); jButton6.setText("view competition"); jButton6.setBounds(new Rectangle(230, 155, 105, 20)); jButton6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton6_actionPerformed(e); } }); jButton7.setText("Manager"); jButton7.setBounds(new Rectangle(230, 105, 105, 20)); jButton7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton7_actionPerformed(e); } }); this.getContentPane().add(jButton7, null); this.getContentPane().add(jButton6, null); this.getContentPane().add(jButton5, null); this.getContentPane().add(jButton4, null); this.getContentPane().add(jButton3, null); this.getContentPane().add(jButton2, null); this.getContentPane().add(jButton1, null); this.setVisible(true); this.setTitle("preAlpha v2.1.7"); } private void drawOptionsMenu() { new Options(); } private void jButton3_actionPerformed(ActionEvent e) { this.drawOptionsMenu(); } private void jButton5_actionPerformed(ActionEvent e) { new AthletePage(); } private void jButton6_actionPerformed(ActionEvent e) { new CompetitionPage(0); } private void jButton7_actionPerformed(ActionEvent e) { new ManagerHome(); } private void jButton4_actionPerformed(ActionEvent e) { System.exit(0); } private void jButton1_actionPerformed(ActionEvent e) { new NewGameDialogs(); } private void jButton2_actionPerformed(ActionEvent e) { new LoadGame(); } }
100simulator
trunk/Client/src/GUI/Main.java
Java
oos
4,417