1/* -- 21.0.3:20220321:add sendMessageToContact and openContactChat 31.0.4:20220322ï¼remove sendMessageToContact 41.0.5:20220607 :edit openContactRoom return promis 51.0.6~1.0.8: ï¼edit getOpener return data, add getRoomStatus 61.0.9 : The sendMessage method adds the type parameter to support text and template 71.0.10 : suport iframe 81.0.11 :add getAiffItem 91.0.12: add scanCode å getCurrentPostionçæ¹æ³ 101.0.13: add shareMessage and sendCmd and openWindow 111.0.14: add getClientType 12*/ 13var AiffJS = { 14 version: "1.0.14", 15 onCloseWindow: function (cancelFun) { 16 cancelFun(false); 17 }, 18 onAiffEvent: function (args) { 19 }, 20 aileAPI: null, 21 _initSuccessed: false, 22 _iniData: {}, 23 // init IPC Event 24 _initEvent: function () { 25 if (window.parent != window.top) { 26 // in iframe 27 return; 28 } 29 if (window["AileAPI"]) { 30 window["AileAPI"].removeAllListen(); 31 window["AileAPI"].listen("closeAiff", (c, d) => { 32 AiffJS.onCloseWindow(AiffJS._closeEvent); 33 }); 34 window["AileAPI"].listen("aiffEvent", (c, d) => { 35 AiffJS.onAiffEvent(d); 36 }); 37 } 38 }, 39 _closeEvent: function (cancel) { 40 if (!cancel) { 41 window["AileAPI"].closeAiff(); 42 } 43 }, 44 openDev: function () { 45 if (window.parent != window.top) { 46 // in iframe 47 return; 48 } 49 if (window["AileAPI"]) { 50 window["AileAPI"].openDevTools(); 51 } 52 }, 53 init: function (aiffId) { 54 return new Promise((res, rej) => { 55 if (window.parent != window.top) { 56 // in iframe 57 return; 58 } 59 if (window["AileAPI"]) { 60 AiffJS.aileAPI = window["AileAPI"]; 61 window["AileAPI"].listenonce("initLApp", (c, d) => { 62 AiffJS._iniData = d; 63 if (AiffJS._iniData.code == "Aiff.OK") { 64 AiffJS._initSuccessed = true; 65 res(true); 66 } 67 else { 68 res(false); 69 } 70 }) 71 AiffJS.aileAPI.init(aiffId); 72 } else { 73 res(false); 74 } 75 }) 76 }, 77 getNative: function () { 78 return new Promise((res, rej) => { 79 if (AiffJS._initSuccessed) { 80 window["AileAPI"].listenonce("getNative", (c, d) => { 81 res(d); 82 }); 83 AiffJS.aileAPI.getNative(); 84 } 85 else { 86 res({ 'code': "Aiff.NotInit" }); 87 } 88 }) 89 }, 90 getAuthToken: function () { 91 if (AiffJS._initSuccessed) { 92 return AiffJS._iniData.data.authToken; 93 } 94 else { 95 return null; 96 } 97 }, 98 getAiffConfig: function () { 99 if (AiffJS._initSuccessed) { 100 return AiffJS._iniData.aiffItem; 101 } 102 else { 103 return null; 104 } 105 }, 106 getOpener: function () { 107 if (AiffJS._initSuccessed) { 108 return AiffJS._iniData.info; 109 } 110 else { 111 return null; 112 } 113 }, 114 115 // Send a message in the current chat room 116 sendMessage: function (msgObj, type) { 117 if (AiffJS._initSuccessed) { 118 if (window.parent != window.top) { 119 // in iframe 120 return null; 121 } 122 return AiffJS.aileAPI.sendMessage(msgObj, type); 123 } 124 else { 125 return null; 126 } 127 }, 128 selectMessage: function (msgObj) { 129 if (AiffJS._initSuccessed) { 130 if (window.parent != window.top) { 131 // in iframe 132 return null; 133 } 134 return AiffJS.aileAPI.selectMessage(msgObj); 135 } 136 else { 137 return null; 138 } 139 }, 140 sendAiffState: function (ibState) { 141 if (AiffJS._initSuccessed) { 142 143 return AiffJS.aileAPI.sendState(ibState); 144 } 145 else { 146 return null; 147 } 148 }, 149 sendAiffStateNumber: function (iNumber) { 150 if (AiffJS._initSuccessed) { 151 return AiffJS.aileAPI.sendNumber(iNumber); 152 } 153 else { 154 return null; 155 } 156 }, 157 getClientType: function () { 158 if (window.parent != window.top) { 159 // in iframe 160 return "iframe"; 161 } 162 163 if (AiffJS._initSuccessed) { 164 return AiffJS._iniData.data.clientType; 165 } 166 else { 167 if (window["AileAPI"]) { 168 return "client"; 169 } 170 else { 171 return "other"; 172 } 173 } 174 175 }, 176 177 getProfile: function () { 178 if (AiffJS._initSuccessed) { 179 return AiffJS._iniData.data; 180 } 181 else { 182 return null; 183 } 184 }, 185 getRoomStatus: function (roomId = "") { 186 return new Promise((res, rej) => { 187 if (AiffJS._initSuccessed) { 188 window["AileAPI"].listenonce("getRoomStatus" + roomId, (c, d) => { 189 res(d); 190 }); 191 AiffJS.aileAPI.getRoomStatus(roomId); 192 } 193 else { 194 res({ 'code': "Aiff.NotInit" }); 195 } 196 }) 197 }, 198 199 getAvatar: function (openId, type = "") { 200 return new Promise((res, rej) => { 201 if (AiffJS._initSuccessed) { 202 window["AileAPI"].listenonce("getAvatar" + openId + type, (c, d) => { 203 res(d); 204 }); 205 AiffJS.aileAPI.getAvatar(openId, type); 206 } 207 else { 208 res({ 'code': "Aiff.NotInit" }); 209 } 210 }) 211 }, 212 getUser: function (openId, type = "") { 213 return new Promise((res, rej) => { 214 if (AiffJS._initSuccessed) { 215 window["AileAPI"].listenonce("getUser" + openId + type, (c, d) => { 216 res(d); 217 }); 218 AiffJS.aileAPI.getUser(openId, type); 219 } 220 else { 221 res({ 'code': "Aiff.NotInit" }); 222 } 223 }) 224 225 }, 226 getAiffItem: function (aiffKey) { 227 return new Promise((res, rej) => { 228 if (AiffJS._initSuccessed) { 229 let key = Math.floor(Math.random() * 16777216).toString(); 230 231 window["AileAPI"].listenonce("getAiffItem" + key, (c, d) => { 232 res(d); 233 });
234 AiffJS.aileAPI.getAiffItem(aiffKey, key); 235 } 236 else { 237 res({ 'code': "Aiff.NotInit" }); 238 } 239 }) 240 241 }, 242 scanCode: function () { 243 return new Promise((res, rej) => { 244 if (AiffJS._initSuccessed) { 245 let key = Math.floor(Math.random() * 16777216).toString(); 246 window["AileAPI"].listenonce("scanCode" + key, (c, d) => { 247 res(d); 248 }); 249 AiffJS.aileAPI.scanCode(key); 250 } 251 else { 252 res({ 'code': "Aiff.NotInit" }); 253 } 254 }) 255 }, 256 getCurrentPosition: function () { 257 return new Promise((res, rej) => { 258 if (AiffJS._initSuccessed) { 259 let key = Math.floor(Math.random() * 16777216).toString(); 260 261 window["AileAPI"].listenonce("getCurrentPosition" + key, (c, d) => { 262 res(d); 263 }); 264 AiffJS.aileAPI.getCurrentPosition(key); 265 } 266 else { 267 res({ 'code': "Aiff.NotInit" }); 268 } 269 }) 270 271 }, 272 273 shareMessage: function (message) { 274 return new Promise((res, rej) => { 275 if (AiffJS._initSuccessed) { 276 let key = Math.floor(Math.random() * 16777216).toString(); 277 window["AileAPI"].listenonce("shareMessage" + key, (c, d) => { 278 res(d); 279 }); 280 AiffJS.aileAPI.shareMessage(message, key); 281 } 282 else { 283 res({ 'code': "Aiff.NotInit" }); 284 } 285 }) 286 }, 287 288 sendCmd: function (cmd) { 289 return new Promise((res, rej) => { 290 if (AiffJS._initSuccessed) { 291 let key = Math.floor(Math.random() * 16777216).toString(); 292 window["AileAPI"].listenonce("sendCmd" + key, (c, d) => { 293 res(d); 294 }); 295 AiffJS.aileAPI.sendCmd(cmd, key); 296 } 297 else { 298 res({ 'code': "Aiff.NotInit" }); 299 } 300 }) 301 }, 302 303 openWindow: function (args) { 304 if (AiffJS._initSuccessed) { 305 return AiffJS.aileAPI.openWindow(args); 306 } 307 else { 308 return null; 309 } 310 }, 311 312 313 closeWindow: function () { 314 if (AiffJS._initSuccessed) { 315 AiffJS.aileAPI.closeAiff(); 316 return true; 317 } 318 else { 319 return null; 320 } 321 }, 322 getAllRooms: function () { 323 return new Promise((res, rej) => { 324 if (AiffJS._initSuccessed) { 325 let key = Math.floor(Math.random() * 16777216).toString(); 326 window["AileAPI"].listenonce("getAllRooms" + key, (c, d) => { 327 res(d); 328 }); 329 AiffJS.aileAPI.getAllRooms(key); 330 } 331 else { 332 res(null); 333 } 334 }) 335 }, 336 openChat: function (roomId) { 337 return new Promise((res, rej) => { 338 if (AiffJS._initSuccessed) { 339 let key = Math.floor(Math.random() * 16777216).toString(); 340 window["AileAPI"].listenonce("openRoom" + key, (c, d) => { 341 res(d); 342 }); 343 AiffJS.aileAPI.openRoom(roomId, key); 344 } 345 else { 346 res(null); 347 } 348 }) 349 350 }, 351 // Open an employee chat room 352 openUserChat: function (openId) { 353 return new Promise((res, rej) => { 354 if (AiffJS._initSuccessed) { 355 let key = Math.floor(Math.random() * 16777216).toString(); 356 window["AileAPI"].listenonce("openUserRoom" + key, (c, d) => { 357 res(d); 358 }); 359 AiffJS.aileAPI.openUserRoom(openId, key); 360 } 361 else { 362 res(null); 363 } 364 }) 365 }, 366 367 // get an employee chat rooms 368 getUserRooms: function (openId) { 369 return new Promise((res, rej) => { 370 if (AiffJS._initSuccessed) { 371 let key = Math.floor(Math.random() * 16777216).toString(); 372 window["AileAPI"].listenonce("getUserRooms" + key, (c, d) => { 373 res(d); 374 }); 375 AiffJS.aileAPI.getUserRooms(openId, key); 376 } 377 else { 378 res(null); 379 } 380 }) 381 }, 382 navigateToTab: function (mainAiffId, args = null) { 383 if (AiffJS._initSuccessed) { 384 AiffJS.aileAPI.navigateToTab(mainAiffId, args); 385 } 386 else { 387 res(null); 388 } 389 }, 390 391 // open the customer chat room 392 openContactChat: function (serviceNumberId, openId) { 393 return new Promise((res, rej) => { 394 if (AiffJS._initSuccessed) { 395 AiffJS.aileAPI.openContactChat(serviceNumberId, openId); 396 res({ "code": "Aiff.OK" }) 397 } 398 else { 399 res(null); 400 } 401 }) 402 }, 403 openBossContactChat: function (openId) { 404 return new Promise((res, rej) => { 405 if (AiffJS._initSuccessed) { 406 AiffJS.aileAPI.openContactChat(openId); 407 res({ "code": "Aiff.OK" }) 408 } 409 else { 410 res(null); 411 } 412 }) 413 },
414 shareTargetPicker: function (templateObj, type) { 415 return new Promise((res, rej) => { 416 if (AiffJS._initSuccessed) { 417 let key = Math.floor(Math.random() * 16777216).toString(); 418 window["AileAPI"].listenonce("shareTargetPicker" + key, (c, d) => { 419 res(d); 420 }); 421 AiffJS.aileAPI.shareTargetPicker(templateObj, type, key); 422 } 423 else { 424 res({ 'code': "Aiff.NotInit" }); 425 } 426 }); 427 } 428} 429 430AiffJS._initEvent();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.