-
Notifications
You must be signed in to change notification settings - Fork 8
/
HtmlLocation.cpp
80 lines (69 loc) · 1.67 KB
/
HtmlLocation.cpp
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
#include "stdafx.h"
#include "HtmlLocation.h"
#include "JSVMInterface.h"
IMPLEMENT_CUSTOM_CLASS(HtmlLocation, CustomClassBase)
HtmlLocation::HtmlLocation()
{
}
HtmlLocation::~HtmlLocation()
{
}
bool HtmlLocation::InitClass(const HandleContext&context)
{
return InitClass_s(context, "Location", HandleObject());
}
bool HtmlLocation::OnGetProperty(GetPropertyArgs&args)
{
const char*name = args.GetName();
if (!PROPCMP(name, "href"))
{
args.SetRetValue(LocalValue(args.GetContext()).SetString(args.GetContext(),JSVM::GetInstance()->m_szUrl.c_str()));
return true;
}
else if (!PROPCMP(name, "search"))
{
std::string str = JSVM::GetInstance()->m_szUrl;
int i = str.find('?');
if (i != str.npos)
{
str = str.substr(i);
}
else str = "";
args.SetRetValue(LocalValue(args.GetContext()).SetString(args.GetContext(), str.c_str()));
return true;
}
return CustomClassBase::OnGetProperty(args);
}
bool HtmlLocation::OnSetProperty(SetPropertyArgs&args)
{
CustomClassAutoThisObj cc(this, args);
const char*name = args.GetName();
if (!PROPCMP(name, "href"))
{
JSVM::GetInstance()->GetSystemInterface()->OpenUrl(args.GetValue().GetString(args.GetContext()).c_str());
}
return CustomClassBase::OnSetProperty(args);
}
void HtmlLocation::OnFinalize(FinalizeArgs&args)
{
return CustomClassBase::OnFinalize(args);
}
bool HtmlLocation::OnConstructor(IFunctionCallbackArgs&args)
{
return CustomClassBase::OnConstructor(args);
}
bool HtmlLocation::reload(IFunctionCallbackArgs&args)
{
assert(0);
return true;
}
bool HtmlLocation::assign(IFunctionCallbackArgs&args)
{
assert(0);
return true;
}
bool HtmlLocation::replace(IFunctionCallbackArgs&args)
{
assert(0);
return true;
}